【问题标题】:Make JDA Discord Bot write a message with a delay让 JDA Discord Bot 延迟写入消息
【发布时间】:2020-05-11 19:03:54
【问题描述】:

我目前正在尝试让我的 JDA 机器人在离开语音频道时写一条消息。然后在消息发送 3 秒后,它应该跟随另一条消息。

我已经尝试使用 RestAction 来实现,但我只能弄清楚如何延迟删除消息。

代码看起来像这样:

channel.sendMessage("You told me to leave, so I left"); //I shortened the message command here

//Then with a delay of 3 seconds it should do this
channel.sendMessage("That was mean");

我希望有人能在这里帮助我。非常感谢任何帮助!

【问题讨论】:

    标签: bots delay discord discord-jda


    【解决方案1】:

    每个 RestAction 都有一个 queueAfter(long, TimeUnit) 可以用来延迟它:

    channel.sendMessage("Hello").queueAfter(10, TimeUnit.SECONDS);
    

    【讨论】:

      猜你喜欢
      • 2021-07-06
      • 2023-01-12
      • 2022-11-23
      • 2017-06-10
      • 2022-01-05
      • 2019-07-26
      • 2021-09-10
      • 2022-11-16
      • 2019-06-26
      相关资源
      最近更新 更多