Skip to content

NeelFrostrain/Advanced-Discord-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– Advanced Discord Bot

A complete, production-ready Discord bot with 70+ commands, analytics, economy, leveling, RPG systems, and MongoDB/JSON database.

TypeScript Discord.js Node.js License


✨ Features

πŸ’° Economy System

  • 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

⭐ Advanced Leveling

  • 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

βš”οΈ Battle & RPG

  • 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

πŸ“Š Analytics System

  • 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 Tracker

  • 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

πŸ›‘οΈ Moderation

  • Ban/Kick - Remove problematic users
  • Timeout - Temporarily mute users
  • Message Clear - Bulk delete messages
  • Slowmode - Rate limit channels
  • Channel Lockdown - Lock/unlock channels

πŸ‘‘ Admin Tools

  • 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

πŸ€– AI Best Friend (NEW in v2.1.5)

  • 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!

πŸ“¦ Utility

  • 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

πŸš€ Quick Start

Prerequisites

  • Node.js 18 or higher
  • MongoDB (optional - JSON fallback available)
  • Discord Bot Token

Installation

# 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 start

Environment Variables

Create 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=3000

πŸ—„οΈ Database System

Dual Database Architecture

MongoDB (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

Key Features

  • βœ… Auto-Sync - MongoDB ↔ JSON every 5 minutes
  • βœ… Auto-Fallback - Seamlessly switches to JSON if MongoDB fails
  • βœ… Manual Sync - /syncdb command for manual synchronization
  • βœ… Zero Downtime - Bot never crashes due to database issues

Admin Commands

/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

πŸ“Š Command Categories

Economy Commands (17)

/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

Leveling Commands (13)

/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)

Battle & RPG Commands (6)

/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

Analytics Commands (4)

/useractivity [user]     # User activity stats
/topactive [period]      # Most active members
/channelstats            # Channel statistics
/serverstats [period]    # Server statistics

Invite Commands (5)

/invites [user]          # View invite stats
/whoinvited <user>       # Check who invited
/inviteleaderboard       # Top inviters
/fakeinvites             # View suspicious joins
/addinvites <user> <amt> # Add bonus invites (Admin)

Moderation Commands (6)

/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

Admin Commands (6)

/giveaway                # Create giveaway
/announce                # Send announcement
/autorole                # Configure auto-roles
/welcome                 # Configure welcome messages
/syncdb                  # Sync databases
/backup                  # Backup database

Utility Commands (9)

/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

🎯 Key Highlights

Version 1.2 Updates

βœ… 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.

Production Features

  • βœ… 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

πŸ“ Project Structure

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

πŸ”§ Configuration

Bot Settings (config.json)

{
  "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
  }
}

Leveling System

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

πŸš€ Deployment

Development

npm run dev

Production

npm run build
npm start

Using PM2 (Recommended)

npm install -g pm2
pm2 start dist/index.js --name discord-bot
pm2 save
pm2 startup

Using Docker

docker-compose up -d

πŸ” Troubleshooting

Leaderboard Shows "No Data"

Solution: Restart bot or run /syncdb direction:JSON β†’ MongoDB

Rank Shows "Unranked"

Solution: Same as above - the bot will auto-read from JSON after restart

MongoDB Connection Failed

Solution: Bot automatically uses JSON fallback - no action needed

Commands Not Registering

Solution:

npm run build
npm start

Wait 1-2 minutes for Discord to update commands globally.


πŸ“š Documentation


🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ“„ License

This project is licensed under the MIT License.


πŸ”— Resources


πŸ’‘ Support

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages