vvv
vvv

Reputation: 43

messagereactionadd dont get triggered

I have a problem with the messageReactionAdd event, it only works after a message is sent inside the discord. I also tried to put a console.log at the beginning of the event but not even that is triggered.

This is my code:

    module.exports = async (client, reaction, user) => {
    if(reaction.message.partial) await reaction.message.fetch();
    if(reaction.partial) await reaction.fetch();
    if(user.bot) return;

    if(reaction.message.channel.id === '837981337658589204') {
        reaction.users.remove(user);
        if(reaction.emoji.name === '🐬') {
            //code...
        }
    }

partials:

const client = new discord.Client({ partials: ['MESSAGE', 'REACTION']});

i have tried all the methods found on this site but it still doesn't work.

Edit: The solution to all of this was to activate Privileged Gateway Intents on the bot page, like that. Thanks to @Toasty

Upvotes: 1

Views: 127

Answers (1)

Toasty
Toasty

Reputation: 1880

I think you don't need to check if the message is partial, but if the reactionis partial. Try this:

try {
   if(reaction.partial) await reaction.fetch();
   if(user.partial) await user.fetch();
} catch(err) {
   console.log('Error: ' + err);
}

In the official guide it is checked if the message is partial, but this example is not about the messageReactionAdd event


Edit / Update:

After looking through the guide again, I remembered one thing:

Try enabling Privileged Intents in the Discord Developer Portal under "Privileged Gateway Intents" in the "Bot" section.

If you don't know what I mean, look at this screenshot. Just enable these and it may work now.

Upvotes: 1

Related Questions