Skip to content

Modernize A-Bot: tooling, CI, bug fixes, tests, and docs#20

Open
rramboer wants to merge 1 commit into
masterfrom
modernize
Open

Modernize A-Bot: tooling, CI, bug fixes, tests, and docs#20
rramboer wants to merge 1 commit into
masterfrom
modernize

Conversation

@rramboer

@rramboer rramboer commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Full modernization pass to bring the repo up to current professional standards. Runtime behavior is preserved except where noted.

Tooling & infrastructure

  • ESLint 10 flat config with typescript-eslint strict + stylistic type-checked rules; Prettier config, whole repo formatted
  • GitHub Actions CI: install (immutable), lint, format check, typecheck, test, build on pushes to master and PRs (Node from .nvmrc, Yarn 4 via corepack)
  • Dependabot (weekly npm + actions), .editorconfig, .nvmrc, MIT LICENSE, CONTRIBUTING.md
  • Stricter tsconfig (noUncheckedIndexedAccess, exactOptionalPropertyTypes, verbatimModuleSyntax), separate tsconfig.build.json for emit

Bug fixes

  • Dev mode (yarn dev via tsx) loaded zero commands — the loader only matched .js; it now accepts .ts/.js
  • Race condition: bets were validated at command time but debited at button-settlement time, allowing negative balances across concurrent games — new atomic settleBet transaction re-checks funds
  • Reaction roles broke on cache eviction — added message/reaction/user partials and partial fetching
  • Slash-command registration via raw REST silently dropped camelCase fields (channelTypes, minValue) — now uses application.commands.set()
  • Button handlers hardened against malformed customId JSON

Code quality

  • Env-driven config (src/config.ts) — previous hard-coded server IDs kept as defaults so behavior is unchanged without a .env change
  • Shared logic extracted to src/lib/ (bet validation, game outcomes, duration formatting, message-link parsing); dead code removed; typed option getters replace stringly-typed args
  • Graceful shutdown, unhandledRejection handler, correct error replies for deferred interactions

Tests & docs

  • 50 tests (was 13): new test/lib.test.ts covering game-outcome matrices and validation; expanded db tests including the negative-balance race
  • README rewritten with accurate command list, env-var table, setup instructions, and CI badge

Deliberate behavior change (flagging for your review)

  • The soon.ts easter egg's second branch (crude "CS major" reply) was removed as part of professionalization. The main "Soon:tm:" auto-reply is preserved (and its trigger matching was verified against master's behavior, including plurals). Easy to restore if you want it back.

Verification

  • yarn lint, yarn format:check, yarn typecheck, yarn test (50/50), yarn build — all green
  • Smoke-ran both tsx dev mode and the compiled build with a fake token: both load all 19 commands
  • Multi-agent adversarial review of the full diff vs master; all confirmed findings fixed (trigger-regex regression, presence-version regression, docs/gating mismatch)

Tooling and infrastructure:
- Add ESLint 10 flat config (typescript-eslint strict + stylistic type-checked)
- Add Prettier config and format the repo
- Add GitHub Actions CI (install, lint, format check, typecheck, test, build)
- Add Dependabot, .editorconfig, .nvmrc, MIT LICENSE, CONTRIBUTING.md
- Tighten tsconfig (noUncheckedIndexedAccess, exactOptionalPropertyTypes,
  verbatimModuleSyntax) with a separate tsconfig.build.json for emit

Bug fixes:
- Command/event loader only matched .js, so dev mode (tsx) loaded zero
  commands; now accepts .ts and .js
- Atomic settleBet transaction closes a race that could drive balances
  negative across concurrent casino games
- Add message/reaction/user partials so reaction roles survive cache eviction
- Register slash commands via application.commands.set(), fixing silently
  dropped fields (channelTypes, minValue)
- Harden button handlers against malformed customId payloads

Code quality:
- Extract env-driven config (src/config.ts) with previous IDs as defaults
- Extract shared logic into src/lib (bets, game outcomes, duration,
  message-link parsing); remove dead code and stringly-typed options
- Graceful shutdown, unhandledRejection handler, proper error replies

Tests and docs:
- New test/lib.test.ts and expanded db tests (50 tests total)
- README rewritten: accurate command list, env-var table, setup, CI badge
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