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

fix(MessageReaction): Prevent event double fire from uncached messages #6818

Merged
merged 9 commits into from Oct 16, 2021

Conversation

Jiralite
Copy link
Member

@Jiralite Jiralite commented Oct 11, 2021

Please describe the changes this PR makes and why it should be merged:
This should resolve #5063.

The problem was that the manual call to the handler was running side-by-side with the payload received from Discord, resulting in the event firing twice (and the cache check being redundant). In this case, I added a new parameter called fromStructure to the handler (which is called only from the structure) and removed the existing cache check! This should return the object instead of firing the event when called from the structure and will allow the object to be received without firing the event, which in turn will let the event be fired only from a payload received from Discord.

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating

Copy link
Member

@SpaceEEC SpaceEEC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the message is not partial and the request goes through before the gateway event comes in, the reaction add event will not be emitted at all.

I don't really have a good solution for this at hand though. 😅

src/structures/Message.js Show resolved Hide resolved
Copy link
Member

@vladfrangu vladfrangu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine, however isn't this an issue?

src/structures/Message.js Show resolved Hide resolved
@iCrawl iCrawl merged commit 267a4b3 into discordjs:main Oct 16, 2021
@Jiralite Jiralite deleted the reaction-twice-fix branch October 16, 2021 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue #4284 [Reaction add event firing twice] is still reproducible.
4 participants