Skip to content

fix: stop duplicate interaction execution and ticket category bug#117

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

fix: stop duplicate interaction execution and ticket category bug#117
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-05e9

Conversation

@cursor

@cursor cursor Bot commented Jun 10, 2026

Copy link
Copy Markdown

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), InteractionAlreadyReplied crashes, and double side effects (e.g. /eval running twice).

Root cause: Commit c430893 restored per-module Guild event registration (interactionCreate.js, components.js) while keeping the separate validator chain — both registered client.on("interactionCreate") and both called run().

Fix: Guild handlers are now no-ops; execution flows solely through src/events/validations/. Added config toggles and replied/deferred guards to validators.

2. Ticket creation used wrong DB field (high)

Impact: Ticket channels were created with parent: data.Channel (panel text channel) instead of data.Category, causing ticket creation to fail or land under the wrong parent.

Fix: Use data.Category with a null guard when setup is incomplete.

3. Math.abs money minting (high, race-dependent)

Impact: deposit/withdraw used Math.abs on 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 passing
  • Added regression tests: interaction-handler-dedup.test.js, ticket-modal-category.test.js, economy-balance-guard.test.js
Open in Web View Automation 

- 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>
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