【发布时间】:2020-11-20 15:27:19
【问题描述】:
我正在为我的 Discord 机器人制定战斗命令,人们可以在其中互相战斗。
这是我当前的代码:
//rng battl command (my whole life has lead up to this and bela cant stop me)
if(message.content.startsWith(`k!battle`)) {
var opponent = message.content.split(' ').slice(1).join(' ')
if(!opponent) return message.reply('Wait, who were you going to battle again?\nProper command useage: **k!battle <@username>**')
message.channel.send('Mentioned user, you have been challenged to a battle! Do you accept?')
message.channel.send(opponent)
//battle accept/deny
message.react('????').then(() => message.react('????'));
const filter = (reaction, user) => {
return reaction.emoji.name === '????' && user.id === message.author.id;
};
message.awaitReactions(filter, { max: 3, time: 30000, errors: ['time'] })
.then(collected => message.channel.send('Let the battle commence! :KirbyPopcorn:'))
.catch(collected => {
message.channel.send(`Battle Expired.`);
});
}
当两个用户对消息做出反应时,什么都没有发生,但 30 秒后,Battle Expired 文本会显示出来。
如果您发现我的错误,请告诉我!
【问题讨论】:
-
我认为您的错误与过滤器有关,您只检查发送战斗请求的人的拇指,但从不检查
opponent的ID
标签: javascript node.js discord discord.js