fix(interactions): stop double-executing slash commands and components#112
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(interactions): stop double-executing slash commands and components#112cursor[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, every slash command and context menu command ran twice — once fromGuild/interactionCreate.jsand again from thevalidations/*chain.Concrete trigger: A user runs
/deposit 100. The Guild handler deposits $100 and replies;chatInputCommandValidatorthen runs the same command again, depositing another $100. The same pattern affects/beg,/rob,/eval, and other economy/dev commands — causing balance corruption, duplicate side effects, and duplicate reply errors.Component interactions (buttons/selects/modals) could also double-fire because
Guild/components.jsdid notawaithandlers before validators ran.Root cause
c430893correctly fixed broken event names (e.g. listening on"Guild"instead of"interactionCreate"), but re-enabledGuild/interactionCreate.jscallingcommand.run()whilevalidations/*validators already callcommandObject.run()for the same interactions. Guild listeners register before validations (alphabetical folder order), so both paths always executed.Fix
interactionCreate: keep feature toggles only; return early for chat input and context menu commands (validators own execution).interaction.replied || interaction.deferredguards; move developer/staff/nsfw/cooldown gates from the Guild handler intochatInputCommandValidatoranddevCommandValidator.applicationCommandCooldown.jsutility.components:await component.run()so validators see completed replies.guild-interaction-routing.test.jsandinteraction-duplicate-guard.test.js.Validation
npm test— 40/40 passing