不和谐机器人消息不收集反应



我正试图在收到对我的机器人消息的反应后删除对该消息的反应,但由于某种原因,我的行为似乎无法找到原因。

我希望能够看到用户何时对回复消息做出反应,但我只看到机器人何时对自己的消息做出反应以及用户何时对用户消息做出反应。我运行了我的代码(如下(,并向频道发送了"消息",在收到机器人的回复后,我点击了我的消息和机器人消息上的反应。以下是日志:

bot is ready
reaction by:  Lyon bot  on  reply
reaction by:  Lyon bot  on  reply
reaction by:  Lyon bot  on  reply
reaction by:  Lyon bot  on  reply
reaction by:  Virt  on  message
reaction by:  Virt  on  message

我希望能够看到reaction by: Virt on reply,但我从来没有看到。

const Discord = require('discord.js');
const bot = new Discord.Client();
const token = '*******';
bot.on('ready', () => {
console.log('bot is ready');
});
bot.on('message', message => {
if (message.content === 'message') {
message.channel.send('reply');
}
message.react('👍').then(() => message.react('👎'));
const filter = (reaction, user) => {
return ['👍', '👎'].includes(reaction.emoji.name) && user.id === message.author.id;
};
const collector = message.createReactionCollector(filter, {});
collector.on('collect', r => {
console.log('reaction by: ', r.message.author.username, ' on ', r.message.content);
});
});
bot.login(token);

您的过滤器似乎不正确,请将其替换为:const filter = (reaction, user) => reaction.emoji.name === '👍' || reaction.emoji.name === '👎' && user.id === message.author.id;

最新更新