-
-
Notifications
You must be signed in to change notification settings - Fork 4k
fix(Poll): ensure this.answers
is set before we reference it
#10809
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the if (data.answers)
block up too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an intermittent bug where this.answers was sometimes undefined when referenced in the Poll structure.
- Moves the initialization of this.answers to the constructor to guarantee its definition.
- Removes duplicate initialization of this.answers within the _patch method.
Comments suppressed due to low confidence (2)
packages/discord.js/src/structures/Poll.js:50
- Initializing this.answers in the constructor ensures it is defined before it is referenced in _patch, preventing the potential TypeError.
this.answers = new Collection();
packages/discord.js/src/structures/Poll.js:111
- The duplicate initialization of this.answers in _patch has been removed as it is no longer necessary and could lead to unintended side effects.
this.answers ??= new Collection();
Please describe the changes this PR makes and why it should be merged:
I use polls but I don't subscribe to the
messageUpdate
event, but I've been occassionally seeing this pop up. It doesn't seem to happen for every poll so I'm not 100% sure on reproduce steps. I think it's a minor bug that stems from the overhaul #10328Status and versioning classification:
Patch