Skip to content

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

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

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

Conversation

@cursor

@cursor cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

Bug and impact

After c430893 restored per-module event registration in src/handlers/events.js, slash commands and component interactions were handled twice on every invocation:

  1. src/events/Guild/interactionCreate.js (or components.js) ran command.run / component.run
  2. The src/events/validations/* chain ran the same handler again

Concrete scenario: A user runs /deposit 100 with $200 in their wallet. The Guild handler deposits $100, then chatInputCommandValidator runs 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.js registers separate interactionCreate listeners for the Guild folder and the validations folder. Both paths invoked command execution after the handler restore, with no replied/deferred guard on validators and no early return in the Guild slash handler.

Fix

  • Route slash and context menu execution only through src/events/validations/*
  • Guild interactionCreate now only applies feature toggles and returns for chat/context commands
  • Add interaction.replied || interaction.deferred guards to all validators
  • await async component.run in Guild components.js so validators see completed replies
  • Move cooldown logic to shared src/utils/applicationCommandCooldown.js used by validators

Validation

  • npm test — 40/40 passing (includes new guild-interaction-routing.test.js and interaction-duplicate-guard.test.js)
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