fix(events): prevent duplicate slash command and button execution#127
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(events): prevent duplicate slash command and button execution#127cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Consolidate all interactionCreate handlers (validators, command router, components) into one sequential listener. Validators now gate only; Guild handlers own execution. Fixes economy corruption from double /beg, /deposit, etc. and double button side effects. Also guard null getMember() in /ban and /kick before bannable/kickable checks to avoid crashes when targeting non-members. 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
Duplicate interaction execution — After the events-handler regression fix (c430893), slash commands and buttons were handled by two independent
interactionCreatelisteners that ran in parallel:src/events/validations/*validators (callingcommand.run()/button.run())src/events/Guild/interactionCreate.jsandcomponents.js(also callingrun())Because Discord.js does not await async listeners, both paths executed concurrently before
interaction.repliedwas set. This caused:/beg,/deposit,/withdrawapplied balance changes twice/afk setcould create two records/eval— arbitrary code executed twice for authorized developersModeration crash —
/banand/kickdereferencedmember.bannable/member.kickablewhengetMember()returnednull(user not in guild), causing an uncaughtTypeError.Root cause
Validators were left as full executors while Guild handlers were restored as separate per-module listeners. Three
interactionCreatelisteners fired in parallel for every interaction.Fix
interactionCreatehandlers into one sequential listener insrc/handlers/events.js(validators first, then command router, then components)await *.run()calls; Guild handlers own executioncomponents.jsasyncandawaitcomponent handlers/banand/kick(matching/timeout)Validation
npm test— 40/40 passingtests/events-handler-shape.test.js— single consolidated listener + validators don't executetests/moderation-member-null-guard.test.js— ban/kick null guard ordering