fix(interactions): stop double-executing slash commands and components#119
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(interactions): stop double-executing slash commands and components#119cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
Guild interactionCreate and validations/* each called command.run after per-module event registration was restored in c430893, so economy commands like /deposit and /beg applied balance changes twice per invocation. Route slash and context menu execution only through validators, move cooldown/developer/staff/nsfw gates into chatInputCommandValidator, and add replied/deferred guards plus awaited component handlers so Guild component listeners cannot race the validation chain. 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
After
c430893restored per-module event registration insrc/handlers/events.js, slash commands and component interactions were handled twice on every invocation:src/events/Guild/interactionCreate.js(orcomponents.js) rancommand.run/component.runsrc/events/validations/*chain ran the same handler againConcrete scenario: A user runs
/deposit 100with $200 in their wallet. The Guild handler deposits $100, thenchatInputCommandValidatorruns the command again and deposits another $100 — corrupting balances without any error surfaced to the user.The same pattern affected
/beg,/withdraw, moderation commands, and button/select/modal components.Root cause
events.jsregisters separateinteractionCreatelisteners for the Guild folder and the validations folder. Both paths invoked command execution after the handler restore, with noreplied/deferredguard on validators and no early return in the Guild slash handler.Fix
src/events/validations/*interactionCreatenow only applies feature toggles and returns for chat/context commandsinteraction.replied || interaction.deferredguards to all validatorsawaitasynccomponent.runin Guildcomponents.jsso validators see completed repliessrc/utils/applicationCommandCooldown.jsused by validatorsValidation
npm test— 40/40 passing (includes newguild-interaction-routing.test.jsandinteraction-duplicate-guard.test.js)