Discord机器人的消息不收集反应。

问题描述 投票:0回答:1

我正试图删除对我的机器人消息的反应,一旦反应来了,但由于某些原因,我得到的行为,我似乎不能跟踪的原因。

我希望能够看到用户对回复消息的反应,但我只看到机器人对自己的消息和用户对用户消息的反应。我运行了我的代码(如下图),并向该频道发送了'消息',在机器人回复消息后,我点击了我的消息和机器人的消息的反应。下面是日志。

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);
javascript node.js botframework discord discord.js
1个回答
0
投票

你的过滤器好像不对,换成这个吧。const filter = (reaction, user) => reaction.emoji.name === '👍' || reaction.emoji.name === '👎' && user.id === message.author.id;

© www.soinside.com 2019 - 2024. All rights reserved.