简体   繁体   English

Discord.js 表情收集器

[英]Discord.js Emoji Collector

i have litle problem when i using collector i tried test with logging actions.我在使用收集器时遇到了一点问题,我尝试使用日志记录操作进行测试。 Then where is problem when i remove/delete reaction from message its doesnt react i must add reaction first time and that removing/deleting reaction detect works after setting first time reaction but previously reaction doesnt works.那么当我从消息中删除/删除反应时问题出在哪里,它没有反应我必须第一次添加反应,并且删除/删除反应检测在设置第一次反应后起作用,但以前的反应不起作用。

const collector = msg.createReactionCollector({ dispose: true });
collector.on('collect', (reaction, user) => {
   console.log("Collect");
});
collector.on('remove', (reaction, user) => {
   console.log("remove");
});

If I understood your question correctly, what's happening here is that the message in which the reactions are being added/removed is not cached by the bot on boot, and it is only cached after the first reaction gets added or removed from it, this is why the second action is detected but the first one isn't.如果我正确理解了您的问题,这里发生的情况是,机器人在启动时不会缓存添加/删除反应的消息,并且仅在添加或删除第一个反应后才缓存,这是为什么检测到第二个动作但没有检测到第一个动作。

One away to solve this would be to cache the message on startup by fetching it using <TextChannel>.messages.fetch(<MESSAGE_ID>) .解决此问题的一种方法是在启动时通过使用<TextChannel>.messages.fetch(<MESSAGE_ID>)获取消息来缓存消息。

I find way how fix this我想办法解决这个问题

msg.createReactionCollector({ dispose: true });

client.on('messageReactionAdd', (reaction, user) =>
{
    console.log("ReactionAdded");
});

client.on('messageReactionRemove', (reaction, user) =>
{
    console.log("ReactionAdded");
});

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

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