// Under the Hood
// Stack
// Code Structure
commands/ → test.js (player) · tester.js (tester) · setup.js (admin roles) · announce.js (scheduling)
// Data Flow
1. Player runs /test request → database.js:addToQueue()
2. queue.js:processQueue() runs every 30s → finds match
3. queue.js:sendConflictCheck() → DMs tester with Accept/Recuse
4. interactions.js:handleButton('conflict_no_*') → starts session
5. interactions.js:handleModal('result_modal_*') → saves result
6. database.js:setTier(), updatePairHistory(), setCooldown()
7. Player DMed result → can appeal within 24h via /test appeal
8. Appeal sent to panel channel → uphold/deny → probation check
All writes go through the Stmt class which wraps sql.js prepared statements. After every .run() call, the entire SQLite database is exported to disk as a binary blob. This ensures data survives bot restarts even without native file locking (sql.js operates entirely in memory and serializes to disk).
// Database
16 SQLite tables power the entire tier system. All stored in data/tiers.db — a single file, auto-created on first run.
// Internals
Tiers are stored as an ordered array where index increases with skill:
Index: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Tier: LT5 MT5 HT5 LT4 MT4 HT4 LT3 MT3 HT3 LT2 MT2 HT2 LT1 MT1 HT1
───────────── lowest ──────────────→────── middle ────────→────── highest ────────────