【发布时间】:2020-12-13 20:11:03
【问题描述】:
我试图让机器人等待用户的反应,但我不知道如何设置它。我已经尝试过了,我也将const filter 放在了第一部分,但是当它以 1️⃣ 对消息做出反应时,机器人会说回复。
message.channel.send(`the current number is: ${number}`).then(message => {
message.react('1️⃣')
message.react('2️⃣')
message.react('3️⃣')
});
const filter = (reaction, user) => {
return ['1️⃣', '2️⃣','3️⃣'].includes(reaction.emoji.name)
&& user.id === message.author.id;
}
message.awaitReactions(filter, { max: 1, time: 20000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.name === '1️⃣') {
message.reply('you reacted with 1');
} else if (reaction.emoji.name === '2️⃣') {
message.reply('you reacted with 2');
} else {
message.reply('you reacted with 3');
}
})
.catch(collected => {
message.reply('game has ended');
});
【问题讨论】:
标签: javascript node.js discord.js