简体   繁体   中英

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>) .

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");
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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