fix: stop duplicate interaction execution and ticket category bug#117
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix: stop duplicate interaction execution and ticket category bug#117cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
- Guild interactionCreate/components were running alongside validators, causing every slash command and component to execute twice (economy corruption, InteractionAlreadyReplied crashes). - Route execution solely through src/events/validations/ with config toggles and replied/deferred guards. - ticket-modal: use Ticket.Category (not Channel) as channel parent. - deposit/withdraw: remove Math.abs that minted money from negative balances. Add regression tests for all three issues. 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
Found and fixed three critical correctness bugs introduced/exposed by recent event-handler changes.
1. Duplicate interaction execution (critical)
Impact: Every slash command, dev command, button, select menu, and modal ran twice — once via Guild handlers and once via the validator chain. This caused economy corruption (concurrent read-modify-write),
InteractionAlreadyRepliedcrashes, and double side effects (e.g./evalrunning twice).Root cause: Commit
c430893restored per-module Guild event registration (interactionCreate.js,components.js) while keeping the separate validator chain — both registeredclient.on("interactionCreate")and both calledrun().Fix: Guild handlers are now no-ops; execution flows solely through
src/events/validations/. Added config toggles andreplied/deferredguards to validators.2. Ticket creation used wrong DB field (high)
Impact: Ticket channels were created with
parent: data.Channel(panel text channel) instead ofdata.Category, causing ticket creation to fail or land under the wrong parent.Fix: Use
data.Categorywith a null guard when setup is incomplete.3. Math.abs money minting (high, race-dependent)
Impact:
deposit/withdrawusedMath.abson balances after subtraction. Combined with concurrent updates (from bug #1), negative wallet/bank values became positive — minting money.Fix: Remove
Math.abs; balances are already validated before subtraction.Validation
npm test— 42/42 passinginteraction-handler-dedup.test.js,ticket-modal-category.test.js,economy-balance-guard.test.js