Skip to content

fix(interactions): prevent duplicate slash and component execution#111

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

fix(interactions): prevent duplicate slash and component execution#111
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-c508

Conversation

@cursor

@cursor cursor Bot commented Jun 5, 2026

Copy link
Copy Markdown

Bug and impact

Every slash command and component interaction could run twice because multiple interactionCreate listeners were registered and Discord.js invokes them concurrently (without awaiting each other).

  • Slash commands (/rob, /deposit, etc.): chatInputCommandValidator / devCommandValidator and Guild/interactionCreate.js both called run(), causing duplicate balance updates, double replies, and cooldown races.
  • Buttons/selects/modals: Guild/components.js ran handlers without validator permission checks, then validators ran again—e.g. ticket-close could schedule duplicate channel deletes and transcript generation.

Root cause

After the Prisma migration, events.js registered separate client.on("interactionCreate") listeners for validations, components.js, and interactionCreate.js. The interaction.replied guard only works within a single listener chain, not across parallel listeners.

Fix

  • Consolidate all interactionCreate handlers into one sequential listener (validators first, then Guild/interactionCreate.js).
  • Remove duplicate Guild/components.js handler (validators already execute buttons/selects/modals with permission checks).
  • Make slash/context/dev validators validation-only (no run()); execution stays in Guild/interactionCreate.js.

Validation

  • npm test (39 tests, all passing)
  • Regression tests updated in tests/events-handler-shape.test.js
Open in Web View Automation 

Multiple interactionCreate listeners ran concurrently: validators and
Guild handlers each called command/component run(), and components.js
bypassed validator permission checks. Consolidate validators and Guild
interactionCreate into one sequential listener; remove components.js;
make slash/context validators validation-only.

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