Skip to content

fix: stop double-executing interactions and /rank info crash#109

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-correctness-bugs-74e2
Draft

fix: stop double-executing interactions and /rank info crash#109
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-correctness-bugs-74e2

Conversation

@cursor

@cursor cursor Bot commented Jun 3, 2026

Copy link
Copy Markdown

Summary

Fixes two critical correctness bugs introduced in recent event-handler and rank changes.

Bug 1: Double execution of slash commands and components

Impact: Every slash command and button/select/modal interaction ran twice — once in the validation chain and again in Guild handlers. This caused duplicate economy transactions, duplicate DB writes, duplicate replies (Discord API errors), and broken cooldown semantics.

Root cause: Commit c430893 restored per-module interactionCreate registration in src/handlers/events.js, but validators (chatInputCommandValidator, devCommandValidator, buttonValidator, etc.) still called .run() after validation. Discord.js invokes separate interactionCreate listeners concurrently, so both paths executed.

Fix:

  • Validators now gate only (no .run() for slash/components)
  • Guild interactionCreate modules batched into one sequential listener
  • Validations folder registers before Guild handlers
  • components.js awaits component.run()

Bug 2: /rank info always crashes

Impact: /rank info throws TypeError: a.build is not a function on every invocation.

Root cause: AttachmentBuilder in discord.js v14 is not a builder — it has no .build() method. The rank card reply incorrectly called .build() on the attachment instance.

Fix: Pass new AttachmentBuilder(data, { name: "rank.png" }) directly to files.

Validation

  • npm test — 41/41 passing
  • Added regression tests: tests/interaction-routing.test.js, tests/rank-attachment.test.js
  • Updated tests/events-handler-shape.test.js
Open in Web View Automation 

cursoragent and others added 2 commits June 3, 2026 11:06
Restoring Guild interactionCreate registration (c430893) caused every slash
command and component to run twice: once in validators and again in Guild
handlers, because Discord.js invokes separate listeners concurrently.

Register validations before Guild, batch Guild interactionCreate modules into
one sequential listener, validate-only in slash/component validators, and
await component.run in components.js.

Co-authored-by: zVapor_ <contact@zvapor.xyz>
discord.js v14 AttachmentBuilder has no .build() method; calling it throws
TypeError and breaks every /rank info invocation.

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