how a flip works
Anyone can post a wager with !coinflip 500; anyone else can accept it. On accept, the bot spins up a private channel visible only to the two players and itself, builds the suspense with a five-second gif of a dog doing a backflip (load-bearing), flips, pays the winner 96% of the pot, and deletes the channel ten seconds later. The 4% house fee is disclosed right in the embed footer — "to cover transaction costs." A background task rebuilds the #leaderboards channel every sixty seconds: top balances, largest flips ever.
the escrow is real
The part i'd defend in a design review: money is never in limbo. Creating a flip debits you immediately. Cancelling refunds you. And the flip itself runs inside a try/except that refunds both players if anything throws mid-flip, with a finally that deletes the private channel no matter what. When people's balances are on the line, "the bot crashed" can't be allowed to mean "someone's gems vanished."
Deposits and withdrawals happened outside the bot, through discord tickets — the owner-only !add_gems and !set_gems commands were the mint.
lessons, visible in the code
pingsNearly every message the bot sends has mentions disabled. That's the kind of thorough you only get after a bot pings the wrong people once..envThe commit log includes ".env added to .gitnore" [sic] mid-week — the token near-miss every dev gets exactly one of.min wagerA bug that's still in there: the check rejects wagers under 10, the error message says the minimum is 15. The code and the copy disagree, and nobody ever complained, which tells you something about how people read error messages.architecturebot.py and owner_commands.py import each other. It works because of import-order luck. Classic first-bot architecture, preserved honestly.
stack
- bot
- Python, discord.py, ~430 lines. Embeds configured from JSON; owner commands gated by is_owner.
- data
- SQLite — player stats (gems, wins, losses, total wagered, largest win) and a coinflip lifecycle table (open → pending → completed/cancelled).
- status
- Dormant since november 2024. Repo's private, so no source link — this page is the tour.
On connect it prints "connected to Discord, hell yeah!" — which remains the correct emotion for a bot coming online.