Skip to content

fix(interactions): stop double-executing slash commands and components#112

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-c6cf
Draft

fix(interactions): stop double-executing slash commands and components#112
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-c6cf

Conversation

@cursor

@cursor cursor Bot commented Jun 6, 2026

Copy link
Copy Markdown

Bug and impact

After c430893 restored per-module event registration in src/handlers/events.js, every slash command and context menu command ran twice — once from Guild/interactionCreate.js and again from the validations/* chain.

Concrete trigger: A user runs /deposit 100. The Guild handler deposits $100 and replies; chatInputCommandValidator then 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.js did not await handlers before validators ran.

Root cause

c430893 correctly fixed broken event names (e.g. listening on "Guild" instead of "interactionCreate"), but re-enabled Guild/interactionCreate.js calling command.run() while validations/* validators already call commandObject.run() for the same interactions. Guild listeners register before validations (alphabetical folder order), so both paths always executed.

Fix

  • Guild interactionCreate: keep feature toggles only; return early for chat input and context menu commands (validators own execution).
  • Validators: add interaction.replied || interaction.deferred guards; move developer/staff/nsfw/cooldown gates from the Guild handler into chatInputCommandValidator and devCommandValidator.
  • Shared cooldown: extract applicationCommandCooldown.js utility.
  • Guild components: await component.run() so validators see completed replies.
  • Tests: guild-interaction-routing.test.js and interaction-duplicate-guard.test.js.

Validation

  • npm test — 40/40 passing
Open in Web View Automation 

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant