A UI-driven Discord bot that creates private prediction markets where friends can bet on each other with mock currency.
- UI-First Design: All interactions use Discord's native components — buttons, dropdowns, and modals
- Private Markets: Markets are sent via DM; targets don't see markets about themselves until resolved
- Mock Currency: Users start with 1000 Bucks and bet on outcomes
- AMM Pricing: Automated Market Maker with dynamic pricing based on liquidity
- Public Feed: Resolved markets are announced in a dedicated feed channel with full bet breakdown and updated leaderboard
- Leaderboards: Track top performers by total profit
/housebets new @target— Pick a target from the member picker, then fill in the market details- Context Menu: Right-click a user → Apps → "Create Market About"
Markets are sent via DM with interactive buttons:
- Buy [Outcome] — Click to enter a bet amount
- View Position — Check your current holdings
/housebets resolve— Select a market you created, then pick the winning outcome from a dropdown- ⚖️ Resolve Market button — Available on the market card in your DM
/housebets balance— View your balance and total profit/housebets leaderboard— See top players/housebets my_markets— View markets you've created
- Go to the Discord Developer Portal
- Create a New Application → go to the Bot tab
- Click Reset Token and copy your bot token
- Enable all three Privileged Gateway Intents:
- Presence Intent
- Server Members Intent
- Message Content Intent
Use this URL (replace YOUR_CLIENT_ID with your app's ID):
https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot+applications.commands&permissions=268528656
Required permissions: Send Messages, Embed Links, Read Message History, Manage Channels, Use Application Commands.
Create a .env file in the project root:
BOT_TOKEN=your_discord_bot_token_here
INITIAL_BALANCE=1000
CURRENCY_NAME=Bucks
FEED_CHANNEL_NAME=housebets-feed# Start the bot (builds automatically on first run)
docker compose up -d
# View live logs
docker compose logs -f
# Stop the bot
docker compose down
# Deploy an update
git pull && docker compose up -d --buildThe SQLite database is stored in a named Docker volume and persists across restarts and rebuilds.
Method 1: Slash Command
- Type
/housebets newand select a target member from the@-mention picker - Fill in the modal: question, outcomes (comma-separated), close time (
1d,2h,30m,1w) - Submit — eligible server members get a DM with the market card
Method 2: Context Menu
- Right-click a user → Apps → "Create Market About"
- Fill in the modal (target is pre-filled)
- Open the market card in your DMs
- Click a Buy button for your chosen outcome
- Enter the amount to spend
- Prices adjust automatically based on the AMM
/housebets resolve(or click ⚖️ Resolve Market in your DM)- Select your market from the dropdown
- Select the winning outcome from the dropdown
- Payouts are distributed automatically; a full breakdown and updated leaderboard post to the feed channel
housebets/
├── main.py # Bot entry point
├── config.py # Configuration
├── requirements.txt # Dependencies
├── Dockerfile
├── docker-compose.yml
├── .env # Environment variables (not committed)
├── reset_db.py # Database reset utility
├── database/
│ └── db.py # Database operations
├── cogs/
│ ├── commands.py # All /housebets slash commands
│ └── betting.py # Bet placement logic
├── ui/
│ ├── modals.py # Modal forms
│ ├── embeds.py # Embed builders
│ └── buttons.py # Button/view handlers
└── utils/
├── pricing.py # AMM pricing logic
└── helpers.py # Utility functions
- Creator runs
/housebets new @targetand fills in the modal - Bot creates the market and DMs all eligible guild members (excluding the target)
- Creator receives the market card with buy buttons and a resolve button
- User clicks a Buy button on the market card in their DM
- Modal opens for the amount to spend
- Bot calculates shares using AMM pricing and records the bet
- Market card updates with new prices and balance
- Creator selects a market and picks the winning outcome via dropdown
- Bot calculates payouts (1 Buck per winning share)
- Balances and profit/loss updated for all bettors
- Resolution embed (with full bet breakdown) + updated leaderboard posted to the feed channel
- Winners receive a DM notification
Uses a simplified constant-product formula:
- Each outcome has its own liquidity pool
- Price = liquidity[outcome] / total_liquidity
- Buying shares reduces liquidity, increasing the price naturally
| Variable | Default | Description |
|---|---|---|
BOT_TOKEN |
— | Your Discord bot token |
INITIAL_BALANCE |
1000 |
Starting balance for new users |
CURRENCY_NAME |
Bucks |
Name of the mock currency |
FEED_CHANNEL_NAME |
housebets-feed |
Channel for resolved market announcements |
INITIAL_LIQUIDITY |
100 |
AMM liquidity parameter |
# Wipe all data, keep schema
python reset_db.py
# Delete the database file entirely and recreate
python reset_db.py --hardBot not responding to commands — Verify the bot token in .env and check Docker logs with docker compose logs -f.
DMs not being sent — Check per-server privacy settings: right-click the server → Privacy Settings → enable Direct Messages. Also ensure the Server Members Intent is enabled in the Developer Portal.
0 members cached at startup — Server Members Intent is not enabled in the Developer Portal. See Setup step 1.
Feed channel not created — Bot needs the Manage Channels permission. You can also create #housebets-feed manually.
- Markets are distributed via DM — other users can't see what markets exist
- Target users are excluded from markets about themselves until resolution
- No real money involved — mock currency only
- All data stored locally in SQLite via a Docker volume
MIT License — feel free to modify and use for your server!
