Discord.js: MessageReactionAdd/Remove events not fired on uncached messages when opted into BOTH Intents AND Partials

Created on 27 May 2020  路  2Comments  路  Source: discordjs/discord.js

Hello, as requested from @almostSouji from the Discord.JS server, I've opened this issue. Basically I was testing out Gateway Intents with Partials, and I've noticed a couple of things:

  • In order for Guild Messages to have been received, I needed to be opted in to the GUILDS intent along with the GUILD_MESSAGES intent (not sure if this is intentional or mandatory, but just thought I'd mention it in case if it was a side effect).
  • When opted in to the message reaction intents AND reaction & message partials, I was not receiving any events for un-cached messages, but for cached messages I was.

I made a video about this, you don't have to watch the whole thing, just skip to 8:40 and see what happens when I restart the bot, react to an un-cached message - it does not trigger the message reaction add event. When I do send a message and react to it, the event is then triggered.

Skip to 8:40 https://youtu.be/RMP5FuIBgWA?t=520

I also just tested this now with all the events in 1 file and the same issue occurs, reactions only work on cached messages, but not on un-cached messages.

const { Client } = require('discord.js');
const client = new Client({
  ws: {
    intents: ['GUILD_MESSAGES', 'GUILDS', 'GUILD_MESSAGE_REACTIONS']
  },
  partials: ['REACTION', 'MESSAGE']
});

client.on('ready', () => {
  console.log('logged in')
})
client.on('message', msg => {
  console.log(msg);
});

client.on('messageReactionAdd', (reaction, user) => {
  console.log(`${reaction.emoji.name} was added.`)
});

client.login('token');
unverified bug

Most helpful comment

Thank you for making this issue, I unfortunately totally lost track of it (despite that being precisely the reason why I asked you to put it on the GH in the first place)

pretty sure you need the User intent

The relevant intent is called "GUILD_PRESENCES", there is no user intent, maybe you mean the "USER" partial, as that too can help to solve this issue.

Solutions:

  1. You either need the "GUILD_PRESENCES" intent (privileged)
  2. or the "USER" partial type

the relevant code reference preventing the event to emit is: https://github.com/discordjs/discord.js/blob/d827544fbd12e827fb4b6ff99d8894ecd79ede02/src/client/actions/MessageReactionAdd.js#L18-L19

Relevant comment in another issue https://github.com/discordjs/discord.js/issues/4310#issuecomment-645954864


EDIT: I have applied a tip for this on the guide with https://github.com/discordjs/guide/commit/5e11b51c9cddd8b024bb89456dee25e3a6edb3bf

All 2 comments

pretty sure you need the User intent for uncached messages sent by a user who wasn't cached yet, or the GuildPresences intent to actually be able to cache online members/users on GuildCreate events

when you have the GuildPresences intent disabled, discord only sends you the bot and people in voice channels as guild members iirc, so no one else in the guild is cached until they send a message or are fetched

so you need the User partial to receive events for their uncached messages from their uncached selves

Thank you for making this issue, I unfortunately totally lost track of it (despite that being precisely the reason why I asked you to put it on the GH in the first place)

pretty sure you need the User intent

The relevant intent is called "GUILD_PRESENCES", there is no user intent, maybe you mean the "USER" partial, as that too can help to solve this issue.

Solutions:

  1. You either need the "GUILD_PRESENCES" intent (privileged)
  2. or the "USER" partial type

the relevant code reference preventing the event to emit is: https://github.com/discordjs/discord.js/blob/d827544fbd12e827fb4b6ff99d8894ecd79ede02/src/client/actions/MessageReactionAdd.js#L18-L19

Relevant comment in another issue https://github.com/discordjs/discord.js/issues/4310#issuecomment-645954864


EDIT: I have applied a tip for this on the guide with https://github.com/discordjs/guide/commit/5e11b51c9cddd8b024bb89456dee25e3a6edb3bf

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iCrawl picture iCrawl  路  3Comments

tiritto picture tiritto  路  3Comments

Acaretia picture Acaretia  路  3Comments

Brawaru picture Brawaru  路  3Comments

BrandonCookeDev picture BrandonCookeDev  路  3Comments