Discord.js让您的机器人等待回复

时间:2020-02-08 14:08:47

标签: javascript visual-studio discord discord.js

我是一个制作机器人,当您进行培训时,它会在公告中说出一些内容,并发消息给作者,并告诉他在完成培训后键入完成,然后在编辑中说培训正在进行中,或发送一条消息。向公告发布新消息。

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;

1 个答案:

答案 0 :(得分:0)

我建议使用async/await