A complete, production-ready Discord bot with 70+ commands, analytics, economy, leveling, RPG systems, and MongoDB/JSON database.
- Balance Management - Wallet & bank system
- Daily/Weekly Rewards - Claim coins regularly
- Work System - Earn coins by working
- Shop & Inventory - Buy and manage items
- Trading - Trade coins with other users
- Gambling Games - Coinflip, Blackjack, Slots, Roulette
- XP & Levels - Gain XP from chatting
- Custom Rank Cards - Personalized rank displays
- Leaderboards - Server-wide rankings (levels & economy)
- Role Rewards - Auto-assign roles at specific levels
- XP Multipliers - Role-based XP boosts
- Rank Comparison - Compare stats with others
- Monster Hunting - Hunt for coins and XP
- PvP Battles - Challenge other users
- Pet System - Summon and collect pets
- Equipment - Weapons and armor
- Battle Stats - Track your combat power
- Member Activity - Track messages, voice, reactions
- Channel Statistics - Most active channels
- Server Health - Growth rate, engagement metrics
- Activity Scores - Measure user engagement
- Leaderboards - Top active members
- Invite Tracking - Track who invited whom
- Fake Detection - Auto-detect suspicious accounts
- Quality Scoring - Rate invite quality
- Invite Leaderboard - Top inviters
- Auto-Kick - Remove fake accounts automatically
- Ban/Kick - Remove problematic users
- Timeout - Temporarily mute users
- Message Clear - Bulk delete messages
- Slowmode - Rate limit channels
- Channel Lockdown - Lock/unlock channels
- Giveaways - Create and manage giveaways
- Announcements - Send formatted announcements
- Auto-Roles - Assign roles on join
- Welcome Messages - Greet new members
- Database Management - Sync, backup, debug tools
- Chat with AI - Natural conversations with AI
- Mention Detection - Tag bot to chat
- Reply Detection - Reply to bot messages
- Conversation Memory - Remembers context
- Emotion Detection - Responds to your mood
- Free Google Gemini API - No cost!
- User Info - View user details
- Server Info - View server statistics
- Avatar - Display user avatars
- Polls - Create polls with reactions
- Reminders - Set reminders
- AFK System - Auto-respond when AFK
- Node.js 18 or higher
- MongoDB (optional - JSON fallback available)
- Discord Bot Token
# Clone the repository
git clone <your-repo-url>
cd discord-bot
# Install dependencies
npm install
# Configure environment
cp .env.example .env
# Edit .env with your bot token and settings
# Build TypeScript
npm run build
# Start the bot
npm startCreate a .env file:
# Required
TOKEN=your_discord_bot_token
CLIENT_ID=your_bot_client_id
PREFIX=!
# Optional - MongoDB (will use JSON if not provided)
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/
# Optional - Dashboard
CLIENT_SECRET=your_client_secret
DASHBOARD_PORT=3000MongoDB (Primary)
- Cloud-based scalable database
- Automatic backups every 5 minutes
- Best for production use
JSON (Fallback)
- Local file-based storage
- Zero configuration needed
- Automatic fallback if MongoDB fails
- β Auto-Sync - MongoDB β JSON every 5 minutes
- β Auto-Fallback - Seamlessly switches to JSON if MongoDB fails
- β
Manual Sync -
/syncdbcommand for manual synchronization - β Zero Downtime - Bot never crashes due to database issues
/syncdb direction:JSON β MongoDB # Sync JSON to MongoDB
/syncdb direction:MongoDB β JSON # Sync MongoDB to JSON
/backup # Force immediate backup
/testdb # Test database access
/debuglevels # Debug database structure
/balance [user] # Check balance
/daily # Claim daily reward
/weekly # Claim weekly reward
/work # Work for coins
/shop # View shop items
/buy <item> # Buy an item
/inventory [user] # View inventory
/trade <user> <amount> # Trade coins
/coinflip <bet> # Flip a coin
/blackjack <bet> # Play blackjack
/slots <bet> # Play slots
/roulette <bet> # Play roulette
/rank [user] # View rank card
/rankstats [user] # Detailed rank statistics
/rankcompare <user> # Compare ranks
/leaderboard [type] # Server leaderboard
/toprank [limit] # Top ranked users
/rankrewards # View rank rewards
/rankconfig # Configure leveling (Admin)
/rankroles # Manage rank roles (Admin)
/givexp <user> <amount> # Give XP (Admin)
/removexp <user> <amount> # Remove XP (Admin)
/setxp <user> <amount> # Set XP (Admin)
/rankreset <user> # Reset rank (Admin)
/hunt # Hunt monsters
/battle <user> [wager] # PvP battle
/stats [user] # View battle stats
/pet view # View your pets
/pet summon # Summon a pet
/equip <item> # Equip weapon/armor
/useractivity [user] # User activity stats
/topactive [period] # Most active members
/channelstats # Channel statistics
/serverstats [period] # Server statistics
/invites [user] # View invite stats
/whoinvited <user> # Check who invited
/inviteleaderboard # Top inviters
/fakeinvites # View suspicious joins
/addinvites <user> <amt> # Add bonus invites (Admin)
/ban <user> [reason] # Ban a user
/kick <user> [reason] # Kick a user
/timeout <user> <time> # Timeout a user
/clear <amount> [user] # Clear messages
/slowmode <seconds> # Set slowmode
/lockdown [lock] # Lock/unlock channel
/giveaway # Create giveaway
/announce # Send announcement
/autorole # Configure auto-roles
/welcome # Configure welcome messages
/syncdb # Sync databases
/backup # Backup database
/userinfo [user] # User information
/serverinfo # Server information
/avatar [user] # User avatar
/poll <question> # Create a poll
/remind <time> <msg> # Set a reminder
/afk [reason] # Set AFK status
/ping # Check bot latency
/help [command] # Help menu
β
User Mention System - Proper Discord notifications (19 commands fixed)
β
Leaderboard Fix - Accurate rankings and data retrieval
β
Database Sync - MongoDB β JSON automatic backup system
β
Level-Up Notifications - Enhanced with proper formatting
β
Rank Calculation - Unified XP formula across all systems
β
Admin Tools - 4 new database management commands
β
Auto-Fallback - Seamless JSON fallback if MongoDB fails
See CHANGELOG.md for complete details.
- β 70+ Commands across 9 categories
- β TypeScript with full type safety
- β Dual Database - MongoDB + JSON fallback
- β Never Crashes - Comprehensive error handling
- β Auto-Backup - Every 5 minutes
- β Slash Commands - Modern Discord interactions
- β Prefix Support - Legacy command support
discord-bot/
βββ src/
β βββ commands/ # All bot commands
β β βββ admin/ # Admin commands
β β βββ analytics/ # Analytics commands
β β βββ battle/ # Battle/RPG commands
β β βββ economy/ # Economy commands
β β βββ invites/ # Invite tracking
β β βββ leveling/ # Leveling commands
β β βββ moderation/ # Moderation commands
β β βββ utility/ # Utility commands
β βββ events/ # Discord event handlers
β βββ database/ # Database adapters
β β βββ MongoDBAdapter.ts
β β βββ JsonAdapter.ts
β β βββ index.ts
β βββ utils/ # Utility functions
β β βββ leveling.ts # XP & level calculations
β β βββ embeds.ts # Embed factory
β β βββ analytics.ts # Analytics tracking
β β βββ inviteTracker.ts
β βββ types/ # TypeScript types
β βββ index.ts # Main entry point
βββ database/
β βββ json/
β βββ data.json # JSON database
βββ config.json # Bot configuration
βββ .env # Environment variables
βββ package.json # Dependencies
βββ tsconfig.json # TypeScript config
βββ CHANGELOG.md # Version 1.2 changes
βββ README.md # This file
{
"economy": {
"dailyAmount": 1000,
"weeklyAmount": 5000,
"workMin": 100,
"workMax": 500,
"dailyCooldown": 86400000,
"workCooldown": 3600000
},
"leveling": {
"xpPerMessage": 15,
"xpCooldown": 60000,
"levelUpChannel": null
},
"battle": {
"huntCooldown": 30000,
"critChance": 0.15
}
}XP Formula:
level = floor(sqrt(totalXP / 100))
XP Requirements:
- Level 1: 0-99 XP
- Level 2: 100-399 XP
- Level 3: 400-899 XP
- Level 5: 1,600-2,499 XP
- Level 10: 10,000 XP
- Level 20: 40,000 XP
npm run devnpm run build
npm startnpm install -g pm2
pm2 start dist/index.js --name discord-bot
pm2 save
pm2 startupdocker-compose up -dSolution: Restart bot or run /syncdb direction:JSON β MongoDB
Solution: Same as above - the bot will auto-read from JSON after restart
Solution: Bot automatically uses JSON fallback - no action needed
Solution:
npm run build
npm startWait 1-2 minutes for Discord to update commands globally.
- CHANGELOG.md - Version 1.2 complete changes
- Setup Guide - Installation instructions
- Commands - All available commands
- Database - Database architecture
- Configuration - Bot settings
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For issues, questions, or suggestions:
- Open an issue on GitHub
- Check CHANGELOG.md for recent updates
- Review troubleshooting section above
Built with β€οΈ using TypeScript & Discord.js v14
Version 1.2 - Complete overhaul with enhanced user mentions, fixed leaderboards, MongoDB/JSON sync system, and 4 new admin commands.