Economy bots are among the most engaging Discord features. Users earn and spend virtual currency, compete on leaderboards, and interact with shops. Here is how to build one that scales.
Database Choice
An economy system needs persistent storage. Your options:
- SQLite - Simple, file-based, perfect for small-medium bots. No separate server needed.
- PostgreSQL - Better for large bots with thousands of active users. Handles concurrent writes well.
- MongoDB - Flexible schema, good for complex item systems.
For most Discord bots, SQLite is the right starting point. You can migrate later if needed.
Core Schema
Your economy needs at least two tables:
CREATE TABLE users (
user_id TEXT PRIMARY KEY,
balance INTEGER DEFAULT 0,
bank INTEGER DEFAULT 0,
last_daily TIMESTAMP,
last_work TIMESTAMP
);
CREATE TABLE transactions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT,
amount INTEGER,
type TEXT,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Tracking transactions separately from balances gives you audit capabilities and makes debugging easier.
Essential Commands
Every economy bot needs these core commands:
Balance Check
Show the user their wallet and bank balance. Include a net worth calculation if you have items.
Daily Rewards
Give users a fixed amount once per 24 hours. Add streak bonuses for consecutive daily claims - this drives daily engagement.
Work Command
A cooldown-based earning command. Randomize the payout within a range to keep it interesting. Common cooldown: 30-60 minutes.
Transfer
Let users send currency to each other. Always validate that the sender has enough balance and that amounts are positive integers.
Leaderboard
Show the top 10-25 users by balance. Cache this query - it can be expensive on large datasets. Refresh every 5-10 minutes.
Item Shop
Adding a shop creates a proper economy loop:
CREATE TABLE items (
id INTEGER PRIMARY KEY,
name TEXT,
description TEXT,
price INTEGER,
type TEXT
);
CREATE TABLE inventory (
user_id TEXT,
item_id INTEGER,
quantity INTEGER DEFAULT 1,
PRIMARY KEY (user_id, item_id)
);
Items can be cosmetic (custom roles, badges) or functional (experience boosters, cooldown reducers).
Anti-Abuse Measures
Economy systems attract exploitation attempts:
- Rate limiting - Cap how many economy commands a user can run per minute
- Transaction validation - Always check balances server-side, never trust client state
- Alt detection - Watch for new accounts farming daily rewards
- Maximum balances - Set reasonable caps to prevent inflation
Hosting Considerations
Economy bots with active databases need consistent uptime and fast disk I/O. NVMe SSD hosting is important here - SQLite performance depends heavily on disk speed.
A 1GB RAM plan handles most economy bots. If you have thousands of concurrent users, consider 2GB+ for the database cache.
Scaling Tips
- Use database connection pooling for PostgreSQL
- Cache frequently accessed data (leaderboards, shop items) in memory
- Run database maintenance (VACUUM for SQLite) on a schedule
- Back up your database regularly - losing user economy data kills engagement
The key to a successful economy bot is balance: earning should feel rewarding but not too easy, and spending should offer meaningful choices.
