Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messageReactionRemove event does not trigger #2922

Closed
strigefleur opened this issue Nov 1, 2018 · 8 comments
Closed

messageReactionRemove event does not trigger #2922

strigefleur opened this issue Nov 1, 2018 · 8 comments

Comments

@strigefleur
Copy link

strigefleur commented Nov 1, 2018

Please describe the problem you are having in as much detail as possible:
If you put reaction on a message and then log in with the bot, the messageReactionRemove event not gonna happen when you remove your reaction from this message even if you cache this message.
While trying 'raw' event I found out that message.reactions is empty after fetching message from there and thus event emitter sends undefined reaction in this case.
However if you add reaction with the bot online it all works as expected.

Include a reproducible code sample here, if possible:

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('messageReactionRemove', (reaction, user) => {
    console.log(`${user.username} removed their "${reaction.emoji.name}" reaction.`);
});

client.on('ready', async () => {
    console.log('Ready!');

    let channel = client.channels.get('channel-with-message-id');
    let msgId = 'message-with-pre-added-reaction-id';

    await channel.fetchMessage(msgId);
    if (channel.messages.has(msgId)) {
        console.log('Cached!');
    }
});

client.login(token);

Further details:

  • discord.js version: 11.4.2
  • Node.js version: 10.4.1
  • Operating system: Windows 10 x64
  • Priority this issue should have – please be realistic and elaborate if possible: low.
@Ayplow
Copy link
Contributor

Ayplow commented Nov 4, 2018

Though this is being addressed in #1376, discord.js currently only emits the messageReaction events on cached messages, meaning they need to be sent while the client is online, or manually cached. (For now,) This is working as intended

@strigefleur
Copy link
Author

You are wrong. Just take a look at the code sample: I cache the message manually in order to show it's not working as intended.

@amishshah
Copy link
Member

This has been addressed in #3070, please try out the PR and tell me how it works for you!

@amishshah
Copy link
Member

Closing due to inactivity

@Rult
Copy link

Rult commented Aug 24, 2019

@amishshah
messageReactionRemove still doesn't trigger on fetched messages if you put reactions on them before bot restarting

@pimhakkert
Copy link

@amishshah
messageReactionRemove still doesn't trigger on fetched messages if you put reactions on them before bot restarting

You can fix this by manually listening for the raw events and then emitting messageReactionAdd and messageReactionRemove events.

I used the template code at this link and it works perfectly.

@skeddles
Copy link

skeddles commented Feb 25, 2020

Seems like this should be reopened because it still happens. Even if you cache the message manually, it doesn't emit the event unless you unreact, react, and unreact again.

Even in the example of looking at raw packets that @pimhakkert posted, it says "// There's no need to emit if the message is cached, because the event will fire anyway for that", yet clearly it wont. I have confirmed that the code in that works, but you MUST remove that line that checks if it's cached, otherwise it will skip "cached" messages, and not emit the event, just like it does without this script.

@StrategFirst

This comment has been minimized.

@discordjs discordjs locked as resolved and limited conversation to collaborators Sep 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants