【问题标题】:Discord.js Make your bot wait for replyDiscord.js 让你的机器人等待回复
【发布时间】:2020-05-24 10:10:00
【问题描述】:

我正在制作一个机器人,当您执行 !train 时,它会在公告中说一些内容,还会向作者发送消息,并告诉他在完成训练后输入完成,然后编辑表示训练正在进行的消息或发送通知中的新消息。

case 'train':
  if (message.member.roles.has('649756129240547348')) {
    const user60 = message.author.username;
    bot.channels.get("649756880314302464").send('<@&673125623463673857>');
    bot.channels.get("649756880314302464").send('Subway Security Trainings!! \n Are you still awaiting tryout? Then come along to this training.\n (Slock in 10-15 minutes)\n https://www.roblox.com/games/4582202027/Subway-Security-Tryout-Centre\n https://discord.gg/bvYgmDe');
    bot.channels.get("649756880314302464").send('Training underway, hosted by ' + user60);
    message.author.send('Tell me when you have finished(say Finished)');
    const collector = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, {
      time: 100000
    });
    collector.on('collect', message => {
      if (message.content == 'Finished') {
        bot.channels.get("649756880314302464").send('Training has finished. Hosted by ' + user60);
        message.channel.sendMessage('Thanks!')
      } else if (message.content == 'finished') {
        bot.channels.get("649756880314302464").send('Training has finished. Hosted by ' + user60);
        message.channel.sendMessage('Thanks!')
      }
    })
  } else {
    message.channel.sendMessage('You do not have the permission to do this command')
  }
  break;

【问题讨论】:

  • 不,它没有,所以如果有人知道如何请帮助。一切正常,直到等待回复
  • 请更具体地提出您的问题,现在还不清楚您到底想要什么以及在哪个地方。

标签: javascript visual-studio discord discord.js


【解决方案1】:

我会推荐使用async/await

【讨论】:

    猜你喜欢
    • 2020-11-07
    • 2021-04-19
    • 1970-01-01
    • 2021-08-18
    • 2017-10-31
    • 2021-06-26
    • 2020-09-16
    • 1970-01-01
    • 2018-02-19
    相关资源
    最近更新 更多