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

messageReactionAdd event is called twice when the bot adds reactions to its own message #1285

Closed
CorpulentBrony opened this issue Mar 17, 2017 · 5 comments

Comments

@CorpulentBrony
Copy link

I'm experiencing some more strange message reaction event behavior. I'm on master now.

It's a bit convoluted, but I have gotten the behavior to repeat reliably. Here's what I do:

  1. The bot creates a new embedded message
  2. The bot adds a reaction to the message it just sent
    The first oddity occurs here, in that the messageReactionAdd event is called twice. This only occurs when the bot adds its own reactions to the message. Next:
  3. A user adds a reaction to the message (either a new one or an "upvote")
    A single messageReactionAdd event is fired, as expected
  4. The bot edits the message embed in response to the above fired messageReactionAdd event
  5. A user removes the reaction they added to the message (either the new one or the "upvote")
    At this point, the second oddity occurs in that the messageReactionRemove event is not called at all. If the message is not edited and another reaction is removed, the event will be called. But the first one after the edit is ignored.
@bdistin
Copy link
Contributor

bdistin commented Mar 17, 2017

Message editing breaking reaction remove should be fixed in pr #1236. I am not sure about bot reacting calling messageReactionAdd 2x though, I will see if I can replicate that.

You can test my pr by running npm i bdistin/discord.js, and see if that does indeed fix your issues.

@bdistin
Copy link
Contributor

bdistin commented Mar 17, 2017

So, double messageReactionAdd happens in both master, and in my pr. I am not sure where it is coming from, as the data packet handler is actually being run 2x (as if there are 2 data packets). That particular bug seems like it will be out of scope of my pr.

However the messageReactionRemove event not getting broken with message edits is fixed in my pr.

@iCrawl iCrawl changed the title messageReactionRemove ignored after message is edited messageReactionAdd event is called twice when the bot adds reactions to its own message Apr 5, 2017
@iCrawl
Copy link
Member

iCrawl commented Apr 5, 2017

Fixed in 6ce2439

@iCrawl iCrawl closed this as completed Apr 5, 2017
@AClmbr
Copy link

AClmbr commented Jun 19, 2020

Hi all 👋

I just used the messageReactionAdd observation and I faced the same problem explained here: the event was called twice per reaction (only when the bot reacted, then everything is fine).

Do you have an idea why?

@Rigelrain
Copy link

I came to this problem when I was having the same issue with ReactionCollector. Every time the bot reacts to it's own (in my case at least, an embedded) message, the filter function is called twice and if it passes the filter, then of course the 'collect'-event is also called twice. Does not happen when a user reacts to the message.

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

6 participants