【问题标题】:About Discord Bot Event关于 Discord Bot 活动
【发布时间】:2019-04-17 09:00:44
【问题描述】:
if (messageSent.equalsIgnoreCase("is {0} my father")){
            event.getChannel().sendMessage("No! I am your father!").queue();

我想在这个“if”方法中为随机单词设置那个 {0} 条目,因为它不起作用。例如,如果有人发送“is doe my Father”或其他任何字词,它会回答“No. I am your dad!”。有什么解决办法吗?

下面是“HelloEvent.java”类的代码图像:

Image here...

提前致谢! ????

【问题讨论】:

  • 请直接粘贴代码,不要链接图片。

标签: java bots discord


【解决方案1】:

使用MessageFormat 替换{0}。示例:

int planet = 7;
String event = "a disturbance in the Force";

String result = MessageFormat.format(
 "At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.",
 planet, new Date(), event);

【讨论】:

    猜你喜欢
    • 2020-10-25
    • 2021-03-27
    • 2021-11-04
    • 2020-07-28
    • 2021-01-30
    • 2021-10-23
    • 2018-12-03
    • 2020-07-16
    • 1970-01-01
    相关资源
    最近更新 更多