PANDAUDIT Discord Bot Setup & Deployment Guide
Complete guide to setting up, configuring, and hosting the PANDAUDIT Discord bot.
Table of Contents
- Overview
- Prerequisites
- Initial Setup
- Configuration
- Hosting Options
- Deployment Guide
- Testing
- Maintenance
- Troubleshooting
Overview
The PANDAUDIT Discord bot is a comprehensive community management tool featuring:
Features
- Moderation: Kick, ban, mute, warn users, and manage messages
- Community: Welcome messages, auto-reactions, engagement tools
- Information: Bot status, server stats, help commands
- Integration: Connects with pandaudit.com ecosystem
Technical Stack
- Language: Python 3.8+
- Framework: discord.py 2.3.2+
- Dependencies: See
discord_bot/requirements.txt - Storage: In-memory (warnings/mutes) - can be extended with database
Prerequisites
System Requirements
- Python: 3.8 or higher
- Memory: 128MB minimum (512MB recommended)
- Storage: 50MB for bot + dependencies
- Network: Internet connection with access to Discord API
Accounts Needed
- Discord Account - To create bot application
- Hosting Account - Choose from:
- Replit (free)
- Railway (free tier)
- Heroku (requires credit card)
- VPS (DigitalOcean, Linode, AWS, etc.)
Skills Required
- Basic command line/terminal knowledge
- Understanding of environment variables
- Basic Git knowledge (for VPS deployment)
Initial Setup
Step 1: Create Discord Bot Application
- Go to Discord Developer Portal
- Visit: https://discord.com/developers/applications
- Log in with your Discord account
- Create New Application
- Click “New Application” (top right)
- Name:
PANDAUDIT Bot - Click “Create”
- Configure General Information
- Add description: “Community bot for PANDAUDIT - Data Analytics & Automation”
- Upload bot icon (optional): Use PANDAUDIT logo
- Add tags:
analytics,community,moderation
- Create Bot User
- Navigate to “Bot” tab (left sidebar)
- Click “Add Bot”
- Click “Yes, do it!” to confirm
- Configure Bot Settings
- Username:
PANDAUDIT(or your preference) - Icon: Upload PANDAUDIT logo
- Public Bot: Toggle OFF (private to your server only)
- Requires OAuth2 Code Grant: Toggle OFF
- Username:
-
Enable Privileged Gateway Intents
CRITICAL: These must be enabled or bot won’t work!
Scroll down to “Privileged Gateway Intents”:
- Server Members Intent - Toggle ON
- Presence Intent - Toggle OFF (not needed)
- Message Content Intent - Toggle ON
Click “Save Changes”
- Get Your Bot Token
- Click “Reset Token” (if first time) or “View Token”
- Click “Copy”
- SAVE THIS TOKEN SECURELY - You’ll need it later
- NEVER share this token publicly!
Step 2: Set Up Bot Permissions
- Navigate to OAuth2 → URL Generator
- Go to “OAuth2” tab (left sidebar)
- Click “URL Generator”
- Select Scopes
botapplications.commands(for future slash commands)
-
Select Bot Permissions
General Permissions:
- Read Messages/View Channels
- Send Messages
- Send Messages in Threads
- Embed Links
- Attach Files
- Read Message History
- Add Reactions
Moderation Permissions:
- Manage Messages (for !clear command)
- Kick Members (for !kick command)
- Ban Members (for !ban command)
- Manage Roles (for !mute command)
- Manage Channels (to set muted role permissions)
Permission Integer:
1099511689222Tip: You can paste this integer directly instead of clicking checkboxes
- Copy Generated URL
- Scroll down
- Copy the generated URL
- Save it - you’ll use this to invite the bot
Step 3: Invite Bot to Your Server
- Open Invite URL
- Paste the URL from Step 2 into your browser
- Or use:
https://discord.com/api/oauth2/authorize?client_id=YOUR_CLIENT_ID&permissions=1099511689222&scope=bot%20applications.commands- Replace
YOUR_CLIENT_IDwith your Application ID (found in General Information)
- Replace
- Select Server
- Choose your PANDAUDIT Discord server from dropdown
- Click “Continue”
- Authorize Permissions
- Review the permissions list
- Click “Authorize”
- Complete CAPTCHA if prompted
- Verify Bot Joined
- Go to your Discord server
- Bot should appear in member list (offline until you run it)
- You should see a system message: “PANDAUDIT Bot joined the server”
Step 4: Configure Bot Role Position
IMPORTANT: Bot can only moderate users with roles BELOW its own role!
- Go to Server Settings → Roles
- Right-click server name → “Server Settings”
- Click “Roles” (left sidebar)
- Position Bot Role
- Drag “PANDAUDIT Bot” role ABOVE roles you want to moderate
- Example hierarchy:
[Admin] <- Can't be moderated by bot [PANDAUDIT Bot] <- Bot role [Moderator] <- Can be moderated by bot [Member] <- Can be moderated by bot [everyone] <- Can be moderated by bot
- Save Changes
Configuration
Step 1: Download Bot Files
Option A: Clone from GitHub
git clone https://github.com/nev1111/nev1111.github.io.git
cd nev1111.github.io/discord_bot
Option B: Download ZIP
- Go to: https://github.com/nev1111/nev1111.github.io
- Click “Code” → “Download ZIP”
- Extract and navigate to
discord_bot/folder
Step 2: Install Dependencies
# Make sure you're in the discord_bot directory
cd discord_bot
# Install required packages
pip install -r requirements.txt
# Or with pip3 (if pip defaults to Python 2)
pip3 install -r requirements.txt
Expected output:
Collecting discord.py>=2.3.2
Downloading discord.py-2.3.2-py3-none-any.whl
Collecting python-dotenv>=1.0.0
Downloading python_dotenv-1.0.0-py3-none-any.whl
...
Successfully installed discord.py-2.3.2 python-dotenv-1.0.0 ...
Step 3: Configure Environment Variables
- Create
.envfilecp .env.example .env - Edit
.envfilenano .env # or use your preferred text editor - Add your bot token
# Required: Your Discord Bot Token DISCORD_BOT_TOKEN=MTQ1OTIxNTk1ODg3ODA2MDYzNQ.GHa50Q.9Ryxa4qyhiF9bmhQCJts7i5Rryv6jLSwtghBGM # Optional: Customize bot behavior BOT_PREFIX=! BOT_STATUS=pandaudit.com | !help LOG_LEVEL=INFO - Save and exit
- Nano:
Ctrl+X,Y,Enter - Vim:
Esc,:wq,Enter
- Nano:
Step 4: Test Bot Locally
python bot.py
# Or: python3 bot.py
Expected output:
2025-01-09 12:00:00 - pandaudit_bot - INFO - Starting PANDAUDIT Discord Bot...
2025-01-09 12:00:01 - pandaudit_bot - INFO - Bot logged in as PANDAUDIT Bot (ID: 1459215958878060635)
2025-01-09 12:00:01 - pandaudit_bot - INFO - Connected to 1 guild(s)
2025-01-09 12:00:01 - pandaudit_bot - INFO - Bot is ready!
Verify in Discord:
- Bot should show as online (green circle)
- Type
!ping- bot should respond with latency - Type
!help- bot should show command list
If successful: Bot is working! You can now proceed to hosting.
If errors: See Troubleshooting section below.
Hosting Options
Comparison of hosting platforms:
| Platform | Cost | Difficulty | Uptime | Best For |
|---|---|---|---|---|
| Replit | Free | Easy | 80% | Quick testing |
| Railway | Free tier | Medium | 99.9% | Recommended |
| Heroku | $7/mo | Medium | 99.9% | Professional |
| VPS | $5-10/mo | Hard | 99.9% | Full control |
| Local | Free | Easy | 50% | Development only |
Recommendation: Railway - Best balance of ease, reliability, and cost.
Deployment Guide
Option 1: Railway (Recommended)
Why Railway?
- Free $5 credit per month (enough for small bot)
- Always online (24/7 uptime)
- Automatic deployments from GitHub
- Easy environment variable management
- Simple setup, no credit card required initially
Step-by-Step:
- Sign Up for Railway
- Go to: https://railway.app
- Click “Start a New Project”
- Sign up with GitHub (recommended) or email
- Create New Project
- Click “New Project”
- Select “Deploy from GitHub repo”
- Authorize Railway to access your GitHub
- Select repository:
nev1111/nev1111.github.io
- Configure Deployment
- Railway will detect Python app automatically
- Set Root Directory:
discord_bot - Set Start Command:
python bot.py
- Add Environment Variables
- Click on your project
- Go to “Variables” tab
- Click ”+ New Variable”
- Add:
- Name:
DISCORD_BOT_TOKEN - Value: Your bot token
- Name:
- Click “Add”
- Deploy
- Click “Deploy”
- Wait for deployment (1-2 minutes)
- Check logs for “Bot is ready!” message
- Verify
- Go to Discord server
- Bot should be online
- Test with
!ping
Auto-Deployment:
- Every time you push to GitHub, Railway automatically redeploys
- No manual intervention needed!
Monitoring:
- View logs: Railway dashboard → Deployments → Logs
- Check metrics: Railway dashboard → Metrics
Option 2: Replit (Easiest)
Best for: Quick setup, testing, learning
Step-by-Step:
- Create Replit Account
- Go to: https://replit.com
- Sign up (free)
- Create New Repl
- Click ”+ Create Repl”
- Template: “Python”
- Title:
PANDAUDIT-Discord-Bot - Click “Create Repl”
- Upload Bot Files
- Click “Upload file” (in Files panel)
- Upload all files from
discord_bot/directory:bot.pyconfig.pyrequirements.txt.env.example
- Configure Secrets
- Click “Secrets” (lock icon in left sidebar)
- Click “New secret”
- Key:
DISCORD_BOT_TOKEN - Value: Your bot token
- Click “Add new secret”
- Install Dependencies
- In Shell (bottom panel), run:
pip install -r requirements.txt
- In Shell (bottom panel), run:
- Run Bot
- Click “Run” (big green button at top)
- Bot should start and show “Bot is ready!” in console
- Keep Bot Online 24/7 (Optional)
- Replit bots sleep after 1 hour of inactivity
- Use UptimeRobot to keep it awake:
- Create UptimeRobot account
- Add new monitor (HTTP(s))
- Use your Repl URL
- Set interval: 5 minutes
- UptimeRobot will “ping” your bot every 5 minutes
Note: Replit has usage limits. For production, use Railway or VPS.
Option 3: Heroku
Best for: Professional deployment with scaling
Step-by-Step:
- Sign Up for Heroku
- Go to: https://heroku.com
- Create account (requires credit card, but won’t charge for small bot)
-
Install Heroku CLI
MacOS:
brew install heroku/brew/herokuWindows:
- Download from: https://devcenter.heroku.com/articles/heroku-cli
Linux:
curl https://cli-assets.heroku.com/install.sh | sh - Login to Heroku
heroku login # Opens browser for authentication -
Prepare Bot for Heroku
Create
Procfileindiscord_bot/directory:echo "worker: python bot.py" > ProcfileCreate
runtime.txtto specify Python version:echo "python-3.11.0" > runtime.txt - Create Heroku App
cd discord_bot heroku create pandaudit-discord-bot - Set Environment Variables
heroku config:set DISCORD_BOT_TOKEN="your_token_here" - Deploy
git init # If not already a git repo git add . git commit -m "Initial bot deployment" git push heroku main - Scale Worker
heroku ps:scale worker=1 - View Logs
heroku logs --tail - Verify
- Check logs for “Bot is ready!”
- Test in Discord with
!ping
Costs:
- Eco Dynos: $5/month (1000 hours)
- Basic Dynos: $7/month (always on)
Option 4: VPS (DigitalOcean, Linode, AWS, etc.)
Best for: Maximum control, hosting multiple services
Prerequisites:
- Basic Linux knowledge
- SSH access to server
- Server with Ubuntu 20.04+ or Debian 11+
Step-by-Step:
- Create Server
- Provider: DigitalOcean, Linode, Vultr, AWS EC2, etc.
- OS: Ubuntu 22.04 LTS
- Size: Basic ($5/month is sufficient)
- Create and note IP address
- Connect to Server
ssh root@your_server_ip - Update System
apt update && apt upgrade -y - Install Python and Dependencies
apt install python3 python3-pip git -y - Create Bot User (security best practice)
adduser --disabled-password --gecos "" pandaudit su - pandaudit - Clone Repository
git clone https://github.com/nev1111/nev1111.github.io.git cd nev1111.github.io/discord_bot - Install Python Dependencies
pip3 install -r requirements.txt - Create
.envFilecp .env.example .env nano .env # Add your DISCORD_BOT_TOKEN # Save: Ctrl+X, Y, Enter - Test Bot
python3 bot.py # Should see "Bot is ready!" # Press Ctrl+C to stop -
Create Systemd Service (for auto-start)
Exit to root user:
exit # Back to rootCreate service file:
nano /etc/systemd/system/pandaudit-bot.servicePaste this configuration:
[Unit] Description=PANDAUDIT Discord Bot After=network.target [Service] Type=simple User=pandaudit WorkingDirectory=/home/pandaudit/nev1111.github.io/discord_bot Environment="DISCORD_BOT_TOKEN=YOUR_TOKEN_HERE" ExecStart=/usr/bin/python3 /home/pandaudit/nev1111.github.io/discord_bot/bot.py Restart=always RestartSec=10 StandardOutput=append:/home/pandaudit/bot.log StandardError=append:/home/pandaudit/bot_error.log [Install] WantedBy=multi-user.targetReplace
YOUR_TOKEN_HEREwith your actual bot tokenSave:
Ctrl+X,Y,Enter - Enable and Start Service
systemctl daemon-reload systemctl enable pandaudit-bot systemctl start pandaudit-bot - Check Status
systemctl status pandaudit-botShould show: active (running)
- View Logs
# Service logs journalctl -u pandaudit-bot -f # Or bot logs tail -f /home/pandaudit/bot.log - Useful Commands
# Stop bot systemctl stop pandaudit-bot # Restart bot systemctl restart pandaudit-bot # View status systemctl status pandaudit-bot # Disable auto-start systemctl disable pandaudit-bot
Security Hardening:
# Set up firewall
ufw allow 22/tcp # SSH
ufw enable
# Disable root login
sed -i 's/PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
systemctl restart sshd
# Set up automatic security updates
apt install unattended-upgrades -y
dpkg-reconfigure -plow unattended-upgrades
Updating Bot:
su - pandaudit
cd nev1111.github.io
git pull origin master
cd discord_bot
pip3 install -r requirements.txt --upgrade
exit
systemctl restart pandaudit-bot
Testing
Basic Tests
- Bot Online Test
- Check bot shows as online in Discord
- Green circle next to bot name
- Ping Test
!pingExpected: Bot responds with latency
- Help Test
!helpExpected: Bot shows command list
- About Test
!aboutExpected: Bot shows PANDAUDIT information
Moderation Tests
Create a test user or use an alternate account
- Clear Test
!clear 5Expected: Deletes 5 messages
- Warn Test
!warn @testuser Testing warning systemExpected: User receives warning
- Mute Test
!mute @testuser 1m Test muteExpected: User muted for 1 minute
- Unmute Test
!unmute @testuserExpected: User unmuted
Community Feature Tests
- Welcome Message Test
- Have someone join the server
- Expected: Bot sends welcome message
- Auto-Reaction Test
- Post a message in #blog-updates channel
- Expected: Bot adds reactions ( )
- Stats Test
!statsExpected: Bot shows server statistics
Load Testing
# Send multiple commands quickly
!ping
!ping
!ping
!help
!about
Expected: Bot responds to all commands without crashing
Maintenance
Regular Tasks
Daily:
- Monitor bot uptime
- Check for error messages in logs
Weekly:
- Review moderation logs
- Check disk space (VPS only)
- Verify bot is responding correctly
Monthly:
- Update dependencies
- Review and backup warning data
- Check hosting costs/usage
Quarterly:
- Update discord.py to latest version
- Review bot permissions
- Audit moderation logs
Updating Bot
Railway/Heroku: Automatic from GitHub pushes
VPS:
cd /home/pandaudit/nev1111.github.io
git pull origin master
cd discord_bot
pip3 install -r requirements.txt --upgrade
sudo systemctl restart pandaudit-bot
Replit: Re-upload files or sync with GitHub
Backup
Configuration:
# Backup .env file
cp .env .env.backup
# Or for VPS
scp root@your_server:/home/pandaudit/nev1111.github.io/discord_bot/.env ./env_backup
Logs:
# VPS
scp root@your_server:/home/pandaudit/bot.log ./bot_log_backup
# Railway/Heroku: Download from dashboard
Monitoring
Discord Status:
- Use
!pingperiodically - Monitor bot’s online status
Logs:
# Railway: Dashboard → Logs
# Heroku: heroku logs --tail
# VPS: journalctl -u pandaudit-bot -f
Uptime Monitoring (Recommended):
- Use UptimeRobot or Uptime.com
- Set up HTTP monitor (if bot has web endpoint)
- Or use Discord webhook to send periodic heartbeat
- Get alerts when bot goes down
Troubleshooting
Bot Won’t Start
Error: discord.errors.LoginFailure: Improper token has been passed.
Solution:
- Verify token in
.envfile is correct - No extra spaces or quotes
- Token should be exactly as copied from Discord Developer Portal
- Regenerate token if needed
Error: discord.errors.PrivilegedIntentsRequired
Solution:
- Go to Discord Developer Portal
- Your Application → Bot tab
- Enable “Server Members Intent” and “Message Content Intent”
- Save changes
- Restart bot
Error: ModuleNotFoundError: No module named 'discord'
Solution:
pip install discord.py
# Or: pip3 install discord.py
Bot Online But Doesn’t Respond
Issue: Bot shows online but doesn’t respond to commands
Checks:
- Message Content Intent
- Developer Portal → Bot → Enable “Message Content Intent”
- Permissions
- Right-click bot → Check role permissions
- Bot needs “Read Messages” and “Send Messages”
- Channel Permissions
- Check channel-specific permissions
- Bot may be denied in specific channels
- Prefix
- Make sure you’re using correct prefix (default:
!) - Try:
!helpnot/help
- Make sure you’re using correct prefix (default:
- Check Logs
tail -f bot.log # Look for errors
Moderation Commands Fail
Error: Forbidden: Missing Permissions
Solution:
- Check Bot Role Position
- Server Settings → Roles
- Bot role must be ABOVE roles it moderates
- Check Permissions
- Bot needs:
- Kick Members (for !kick)
- Ban Members (for !ban)
- Manage Roles (for !mute)
- Manage Messages (for !clear)
- Bot needs:
- Bot Can’t Moderate Admins
- Bot can’t moderate users with roles above its own
- Bot can’t moderate server owner
Mute Command Not Working
Issue: !mute command completes but user can still send messages
Solution:
- Check “Muted” role permissions in each channel:
- Right-click channel → Edit Channel → Permissions
- Add “Muted” role
- Deny “Send Messages” and “Speak” (voice)
- Or let bot auto-create role:
- Bot will create “Muted” role automatically
- Bot will set permissions for all channels
- Ensure bot has “Manage Channels” permission
Bot Goes Offline Randomly
Railway/Heroku: Check logs for errors
railway logs
# Or: heroku logs --tail
VPS:
systemctl status pandaudit-bot
journalctl -u pandaudit-bot -n 50
Common causes:
- Network issues
- Rate limiting by Discord
- Uncaught exceptions
- Memory issues
Solution: Enable auto-restart
- VPS: Already configured in systemd service
- Railway/Heroku: Should auto-restart
- Replit: Use UptimeRobot
High Memory Usage
Issue: Bot using too much RAM
Checks:
# Linux
ps aux | grep python
top -p $(pgrep -f bot.py)
Solutions:
- Implement database for warnings/mutes instead of in-memory storage
- Clear logs periodically
- Upgrade hosting plan
Rate Limiting
Error: discord.errors.HTTPException: 429 Too Many Requests
Solution:
- Bot is sending too many requests to Discord
- Add delays between bulk operations
- Don’t spam commands
- Implement command cooldowns
Can’t Find Logs
Railway: Dashboard → Deployments → Logs
Heroku:
heroku logs --tail -a pandaudit-discord-bot
VPS:
# Service logs
journalctl -u pandaudit-bot -f
# Bot logs
tail -f /home/pandaudit/bot.log
# Error logs
tail -f /home/pandaudit/bot_error.log
Replit: Console panel at bottom of editor
Additional Resources
Documentation
Community
Tools
- Discord Permissions Calculator
- Discord Embed Visualizer
- UptimeRobot - Keep bot online
Tutorials
Support
Need help?
- Check Documentation: Most issues covered in this guide
- Review Logs: Errors usually point to the problem
- Discord Community: Ask in your PANDAUDIT server
- GitHub Issues: https://github.com/nev1111/nev1111.github.io/issues
- discord.py Support: https://discord.gg/dpy
Success Checklist
Before considering your bot deployment complete:
- Bot application created in Discord Developer Portal
- Bot token generated and saved securely
- Privileged intents enabled (Server Members, Message Content)
- Bot invited to server with correct permissions
- Bot role positioned above moderated roles
- Dependencies installed (
pip install -r requirements.txt) .envfile created withDISCORD_BOT_TOKEN- Bot tested locally and responds to
!ping - Hosting platform chosen and configured
- Bot deployed and running 24/7
- Welcome messages working
- Auto-reactions working in #blog-updates
- Moderation commands tested
- Logs accessible and monitoring set up
- Backup of configuration files created
- Team members trained on bot commands
** Congratulations!** Your PANDAUDIT Discord bot is now live and ready to engage your community.
For ongoing support and updates, visit pandaudit.com or check the GitHub repository.
Happy community building!