fix: stop double-executing interactions and /rank info crash#109
Draft
cursor[bot] wants to merge 2 commits into
Draft
fix: stop double-executing interactions and /rank info crash#109cursor[bot] wants to merge 2 commits into
cursor[bot] wants to merge 2 commits into
Conversation
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>
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.
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
c430893restored per-moduleinteractionCreateregistration insrc/handlers/events.js, but validators (chatInputCommandValidator,devCommandValidator,buttonValidator, etc.) still called.run()after validation. Discord.js invokes separateinteractionCreatelisteners concurrently, so both paths executed.Fix:
.run()for slash/components)interactionCreatemodules batched into one sequential listenercomponents.jsawaitscomponent.run()Bug 2:
/rank infoalways crashesImpact:
/rank infothrowsTypeError: a.build is not a functionon every invocation.Root cause:
AttachmentBuilderin 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 tofiles.Validation
npm test— 41/41 passingtests/interaction-routing.test.js,tests/rank-attachment.test.jstests/events-handler-shape.test.js