繁体   English   中英

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

[英]Discord.js Make your bot wait for reply

我正在制作一个机器人,当你做 !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;

我建议使用async/await

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM