Chapter 2
Economy & Trust
A Discord casino is only interesting if the ledger is honest. Balances split into buckets, every movement leaves an immutable transaction, and ATM deposits/withdrawals require human approval, especially important for RP servers that map virtual cash to in-game currency.

Balance model
Users are scoped per guild. Funds are not a single number. Buckets keep bonuses, withdrawable cash, and open exposure separable.
balance- withdrawable cash. ATM withdrawals only touch this bucket.bonusBalance- non-withdrawable rewards from daily bonus, quests, and admin grants; consumed first on casino bets.lockedBalance- reserved while a bet or multi-bet session is open; released on settle, refund, or recovery workers.
Immutable transaction log
Every meaningful money move appends a Transaction document: type (deposit, withdraw, bet, win, refund, bonus, vip, transfer, …), source (command, manual, web, system, casino), optional betId / session references, and enough metadata for PnL and staff review.
- Casino bets use
reserveCasinoBet/settleCasinoWinningsinside MongoDB multi-document transactions. - Duplicate betId settlement is rejected so spam-clicks cannot double-pay.
- Bonus balance is consumed before cash; locked balance tracks open exposure until settle or refund.
- Dashboard transactions table: type/source/date filters, search, cash-flow and game PnL summary panels.
- Staff actions from the web are audited separately from raw ledger rows (who changed what, when).
- Session bet reference ids keep multi-hand / multi-bet rounds correlatable in the ledger.
Gated ATM
Deposits and withdrawals are request-based. Players open an ATM request in Discord; moderators approve or deny in Discord or via the admin ATM queue. The bot never silently mints or burns “real” in-game-mapped currency.
RP safety
Register, deposit, withdraw, bonus grant, and balance reset are explicit staff actions. That audit trail matters when virtual balances map to GTA RP (or similar) economies.
- AtmRequest documents track pending approvals.
- Dashboard ATM queue for managers who prefer tables over channel embeds.
- Channel bindings for ATM actions/logs in guild configuration.
Player pay
/pay moves cash between registered users with guild-configurable fee percent, min/max amounts, and optional daily transfer caps (timezone-aware). Fees are burned from the sender so peer transfers stay economically controlled.
- Shared pay settings defaults + dashboard Pay settings form.
- Gross debit / net credit split keeps fee accounting explicit in the ledger.
- Hard floor remains enforced even when minAmount is configured as uncapped.
Locks & reconciliation
Interactive games (blackjack, baccarat, mines, hilo, slots, roulette) can leave money locked if a player walks away mid-session. Workers exist specifically for that failure mode, not as an afterthought.
- lockedBalanceReconciliation - finds stuck locks and restores consistency.
- casinoInFlightRecovery - recovers interrupted in-flight casino sessions.
- Per-game idle close / nudge / auto-resolve jobs for abandoned interactive UIs.
- Ban flows can sync Discord roles while preserving ledger integrity.