fix(interactions): prevent duplicate slash and component execution#111
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(interactions): prevent duplicate slash and component execution#111cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Multiple interactionCreate listeners ran concurrently: validators and Guild handlers each called command/component run(), and components.js bypassed validator permission checks. Consolidate validators and Guild interactionCreate into one sequential listener; remove components.js; make slash/context validators validation-only. Co-authored-by: zVapor_ <contact@zvapor.xyz>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug and impact
Every slash command and component interaction could run twice because multiple
interactionCreatelisteners were registered and Discord.js invokes them concurrently (without awaiting each other)./rob,/deposit, etc.):chatInputCommandValidator/devCommandValidatorandGuild/interactionCreate.jsboth calledrun(), causing duplicate balance updates, double replies, and cooldown races.Guild/components.jsran handlers without validator permission checks, then validators ran again—e.g.ticket-closecould schedule duplicate channel deletes and transcript generation.Root cause
After the Prisma migration,
events.jsregistered separateclient.on("interactionCreate")listeners for validations,components.js, andinteractionCreate.js. Theinteraction.repliedguard only works within a single listener chain, not across parallel listeners.Fix
interactionCreatehandlers into one sequential listener (validators first, thenGuild/interactionCreate.js).Guild/components.jshandler (validators already execute buttons/selects/modals with permission checks).run()); execution stays inGuild/interactionCreate.js.Validation
npm test(39 tests, all passing)tests/events-handler-shape.test.js