PANDAUDIT Discord Bot
A comprehensive Discord bot for the PANDAUDIT community featuring moderation tools, community engagement features, and automated blog post notifications.
🌟 Features
🛡️ Moderation Commands
!kick @user [reason]- Kick a user from the server!ban @user [reason]- Ban a user from the server!mute @user [duration] [reason]- Temporarily mute a user (e.g., 10m, 1h, 1d)!unmute @user- Unmute a user!clear [number]- Delete multiple messages (default 10, max 100)!warn @user [reason]- Issue a warning to a user!warnings @user- View all warnings for a user
💬 General Commands
!help [command]- Show all commands or help for a specific command!about- Learn about PANDAUDIT and its mission!latest- Get a link to the latest blog post!ping- Check bot status and latency!invite- Get the pandaudit.com website link!stats- Show server statistics
🎉 Community Features
- Welcome Messages - Automatically greets new members with helpful information
- Auto-Reactions - Adds reactions (👍 💬 🔖) to posts in #blog-updates
- Rich Embeds - Beautiful, informative message formatting
- Comprehensive Logging - Tracks all moderation actions
- Error Handling - User-friendly error messages
🚀 Quick Start
Prerequisites
- Python 3.8 or higher
- A Discord bot application (see Setup Guide below)
- Discord server with appropriate permissions
Installation
- Clone or navigate to the repository:
cd discord_bot - Install dependencies:
pip install -r requirements.txt - Configure environment variables:
cp .env.example .env # Edit .env and add your DISCORD_BOT_TOKEN - Run the bot:
python bot.py
🔧 Setup Guide
Step 1: Create Discord Bot Application
- Go to Discord Developer Portal
- Click New Application
- Name it “PANDAUDIT Bot” and click Create
- Navigate to the Bot tab (left sidebar)
- Click Add Bot → Yes, do it!
- Important: Under “Privileged Gateway Intents”, enable:
- ✅ Server Members Intent
- ✅ Message Content Intent
- Click Reset Token and copy your bot token
- Save this token securely - you’ll need it for the
.envfile
Step 2: Configure Bot Permissions
Your bot needs these permissions:
- Read Messages/View Channels
- Send Messages
- Manage Messages
- Embed Links
- Attach Files
- Read Message History
- Add Reactions
- Kick Members (for moderation)
- Ban Members (for moderation)
- Manage Roles (for muting)
Permission Integer: 1099511689222
Step 3: Invite Bot to Your Server
- In Discord Developer Portal, go to OAuth2 → URL Generator
- Select scopes:
- ✅
bot - ✅
applications.commands(for future slash commands)
- ✅
- Select permissions (or use integer
1099511689222) - Copy the generated URL and open it in your browser
- Select your server and click Authorize
Step 4: Configure and Run
- Create
.envfile:cp .env.example .env nano .env # or use your preferred editor - Add your bot token:
DISCORD_BOT_TOKEN=MTQ1OTIxNTk1ODg3ODA2MDYzNQ.GHa50Q.9Ryxa4qyhiF9bmhQCJts7i5Rryv6jLSwtghBGM - Run the bot:
python bot.py - Verify it’s working:
- Check the console for “Bot is ready!” message
- In Discord, type
!ping- the bot should respond - Try
!helpto see all commands
☁️ Hosting Options
Option 1: Replit (Easiest - Free)
- Create account at Replit
- Create new Python Repl
- Upload bot files
- Add
DISCORD_BOT_TOKENto Secrets (lock icon) - Click “Run”
- Use UptimeRobot to keep it online 24/7
Pros: Free, easy setup, no credit card Cons: Bot may sleep after inactivity
Option 2: Railway (Recommended - Free with limits)
- Sign up at Railway.app
- Create new project → Deploy from GitHub
- Add environment variable:
DISCORD_BOT_TOKEN - Deploy automatically from your repo
- Free $5 credit per month
Pros: Always online, auto-deploys, professional Cons: May need to add credit card after free tier
Option 3: Heroku (Popular)
- Create account at Heroku
- Install Heroku CLI
- Create
Procfile:worker: python bot.py - Create
runtime.txt:python-3.11.0 - Deploy:
heroku create pandaudit-bot heroku config:set DISCORD_BOT_TOKEN=your_token git push heroku main heroku ps:scale worker=1
Pros: Reliable, popular, good documentation Cons: Requires credit card, free tier limited
Option 4: VPS (Most Control)
Use any VPS provider (DigitalOcean, Linode, AWS, etc.):
- Setup server:
apt update && apt upgrade -y apt install python3 python3-pip git -y - Clone and setup:
git clone https://github.com/nev1111/nev1111.github.io.git cd nev1111.github.io/discord_bot pip3 install -r requirements.txt - Create systemd service (
/etc/systemd/system/pandaudit-bot.service):[Unit] Description=PANDAUDIT Discord Bot After=network.target [Service] Type=simple User=ubuntu WorkingDirectory=/home/ubuntu/nev1111.github.io/discord_bot Environment="DISCORD_BOT_TOKEN=your_token_here" ExecStart=/usr/bin/python3 bot.py Restart=always RestartSec=10 [Install] WantedBy=multi-user.target - Start service:
systemctl daemon-reload systemctl enable pandaudit-bot systemctl start pandaudit-bot systemctl status pandaudit-bot
Pros: Full control, always online, can host other services Cons: Costs $5-10/month, requires maintenance
Option 5: Local Machine (Testing Only)
For development/testing only - not recommended for production:
python bot.py
# Keep terminal open
Pros: Free, immediate testing Cons: Bot offline when computer is off
📝 Configuration
Environment Variables
Edit .env file:
# Required
DISCORD_BOT_TOKEN=your_bot_token_here
# Optional
BOT_PREFIX=!
BOT_STATUS=pandaudit.com | !help
LOG_LEVEL=INFO
Custom Configuration
Edit config.py to customize:
- Channel names
- Colors
- Moderation settings
- Auto-reaction settings
- Website URLs
🔐 Security Best Practices
- Never commit
.envfile - It’s already in.gitignore - Keep bot token secret - Regenerate if exposed
- Use environment variables - Never hardcode tokens
- Regular updates - Keep
discord.pyupdated - Limit permissions - Only grant necessary permissions
- Monitor logs - Check
bot.logregularly
🐛 Troubleshooting
Bot doesn’t start
Check 1: Token is correct
cat .env # Verify token is set correctly
Check 2: Dependencies installed
pip install -r requirements.txt --upgrade
Check 3: Intents enabled
- Discord Developer Portal → Bot → Privileged Gateway Intents
- Enable “Server Members Intent” and “Message Content Intent”
Bot is online but doesn’t respond
Check 1: Permissions
- Right-click bot in member list → Verify it has proper roles
- Check channel permissions
Check 2: Message Content Intent
- Bot needs this to read command messages
- Enable in Discord Developer Portal
Check 3: Prefix is correct
- Default is
! - Try
!pingto test
Commands don’t work
Check error messages:
tail -f bot.log # View real-time logs
Common issues:
- Missing permissions: Bot needs “Manage Messages”, “Kick Members”, etc.
- Invalid arguments: Use
!help <command>for correct usage - Rate limiting: Wait a few seconds between commands
Moderation commands fail
Check bot role hierarchy:
- Discord Server Settings → Roles
- Drag bot role ABOVE roles you want to moderate
- Bot cannot moderate users with higher/equal roles
Bot goes offline
If hosting locally:
- Use a VPS or cloud hosting service instead
If on Replit:
- Use UptimeRobot to ping your bot every 5 minutes
If on Railway/Heroku:
- Check logs in dashboard
- Verify dyno/service is running
📊 Monitoring
View Logs
# Real-time logs
tail -f bot.log
# Last 50 lines
tail -n 50 bot.log
# Search for errors
grep ERROR bot.log
Bot Status
In Discord:
!ping- Check if bot is responding!stats- View server statistics
System Monitoring (VPS)
# Check if bot is running
systemctl status pandaudit-bot
# View service logs
journalctl -u pandaudit-bot -f
# Restart bot
systemctl restart pandaudit-bot
🔄 Updates
Update Bot Code
cd /path/to/discord_bot
git pull origin master
pip install -r requirements.txt --upgrade
python bot.py # or restart service
Update discord.py
pip install discord.py --upgrade
📚 Resources
Official Documentation
Community Resources
Helpful Tools
- Discord Permissions Calculator
- Discord Embed Visualizer
- Uptime Robot - Keep bot online
🆘 Support
Need Help?
- Check the logs:
bot.logcontains detailed information - Read the docs: Most issues are covered in documentation
- GitHub Issues: Create an issue
- Discord Community: Ask in your PANDAUDIT Discord server
Common Questions
Q: Can I customize the welcome message?
A: Yes! Edit the on_member_join function in bot.py
Q: How do I add new commands?
A: Add a new function decorated with @bot.command() in bot.py
Q: Can I use slash commands instead of ! prefix?
A: Yes! discord.py supports application commands. Check the documentation
Q: How do I persist warnings across restarts?
A: Use a database (SQLite, PostgreSQL, etc.). See commented code in bot.py for database setup hints.
Q: Can the bot create forum threads automatically? A: Yes! You’ll need to implement thread creation logic. See Thread documentation
📄 License
This bot is part of the PANDAUDIT project. Feel free to modify and adapt it for your community!
🙏 Credits
Built with:
- discord.py - Discord API wrapper
- Python 3.8+
- Love for data analytics and automation ❤️
Happy botting! 🤖
For more information, visit pandaudit.com