Discord Bot Deployment
This guide helps your customers deploy Discord bots on your Mamba Panel-powered hosting platform. Share this documentation with customers or adapt it for your knowledge base.
Prerequisites
Section titled “Prerequisites”Before deploying, customers need:
- Discord bot application with token from https://discord.com/developers/applications
- Bot source code (Node.js or Python)
package.json(Node.js) orrequirements.txt(Python) for dependencies- Appropriate gateway intents enabled in Discord Developer Portal
Step 1: Purchase and Provision
Section titled “Step 1: Purchase and Provision”- Customer selects a Discord bot hosting plan from your store.
- After payment, Mamba Panel automatically provisions the container.
- Customer receives:
- Portal access credentials
- SFTP connection details
- Initial console access
Provisioning typically completes in under 2 minutes.
Step 2: Upload Bot Code
Section titled “Step 2: Upload Bot Code”Via SFTP (Recommended)
Section titled “Via SFTP (Recommended)”- Connect using SFTP credentials from the portal (typically port 2022).
- Upload bot files to
/home/container. - Do not upload
node_modulesor.venv— install dependencies on the server.
Via Web File Manager
Section titled “Via Web File Manager”- Open the file manager in the customer portal.
- Drag and drop files or upload a ZIP archive.
- Extract archives using the built-in extraction tool.
Best Practices
Section titled “Best Practices”- Keep the entry file (
index.js,bot.py,main.py) at the container root. - Use
.gitignorepatterns to exclude build artifacts locally. - Version control source code in Git before uploading.
Step 3: Install Dependencies
Section titled “Step 3: Install Dependencies”Node.js Bots
Section titled “Node.js Bots”From the console panel:
npm installOr with a lockfile:
npm ciFor pnpm users:
pnpm installPython Bots
Section titled “Python Bots”pip install -r requirements.txtFor Poetry projects, export first:
poetry export -f requirements.txt > requirements.txtpip install -r requirements.txtNative Dependencies
Section titled “Native Dependencies”If the bot requires system packages (FFmpeg for music bots, etc.):
- Check if pre-installed on the node
- Contact support to request additional packages
- Consider pre-building native modules locally
Step 4: Configure Environment Variables
Section titled “Step 4: Configure Environment Variables”- Navigate to Startup → Variables in the portal.
- Add required variables:
| Variable | Example | Purpose |
|---|---|---|
DISCORD_TOKEN | MTIz... | Bot authentication |
APPLICATION_ID | 123456789 | For slash commands |
PREFIX | ! | Command prefix (if used) |
DATABASE_URL | mysql://... | Database connection |
- Mark sensitive values as hidden to prevent accidental exposure in logs.
Accessing Variables in Code
Section titled “Accessing Variables in Code”Node.js:
const token = process.env.DISCORD_TOKEN;Python:
import ostoken = os.getenv("DISCORD_TOKEN")Step 5: Configure Startup Command
Section titled “Step 5: Configure Startup Command”- Go to Startup in the portal.
- Verify or adjust the start command:
Node.js:
node index.jsor
node dist/index.jsPython:
python bot.pyor
python -m mybotStep 6: Start and Verify
Section titled “Step 6: Start and Verify”-
Click Start in the portal.
-
Watch the console for:
- Dependency loading
- Discord gateway connection
- “Ready” or login confirmation message
-
Test the bot in Discord:
- Verify it appears online
- Test a basic command
- Check slash command registration
Step 7: Enable Auto-Restart
Section titled “Step 7: Enable Auto-Restart”Configure the watchdog to handle crashes:
- Go to Settings → Auto-Restart.
- Enable restart on crash.
- Set restart delay (recommended: 5-10 seconds).
- Configure maximum restart attempts before alerting.
Step 8: Schedule Maintenance Tasks
Section titled “Step 8: Schedule Maintenance Tasks”Set up recurring tasks:
- Navigate to Schedules in the portal.
- Create tasks for:
- Daily restart (clears memory leaks)
- Weekly dependency updates
- Backup exports
Example schedule:
- Daily restart: 4:00 AM (low traffic time)
- Weekly update check: Sundays at 3:00 AM
CI/CD Integration
Section titled “CI/CD Integration”GitHub Actions Example
Section titled “GitHub Actions Example”Automate deployments from your repository:
name: Deploy Boton: push: branches: [main]
jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- uses: actions/setup-node@v4 with: node-version: 20
- run: npm ci - run: npm test
- name: Deploy via SFTP uses: wlixcc/SFTP-Deploy-Action@v1.2 with: server: ${{ secrets.SFTP_HOST }} username: ${{ secrets.SFTP_USER }} password: ${{ secrets.SFTP_PASS }} port: 2022 local-path: "./" remote-path: "/home/container" exclude: "node_modules,.git"
- name: Restart Bot run: | curl -X POST "${{ secrets.PANEL_URL }}/api/client/servers/${{ secrets.SERVER_ID }}/power" \ -H "Authorization: Bearer ${{ secrets.PANEL_API_KEY }}" \ -H "Content-Type: application/json" \ -d '{"signal":"restart"}'Store secrets in GitHub repository settings.
Database Setup (Optional)
Section titled “Database Setup (Optional)”SQLite (Default)
Section titled “SQLite (Default)”SQLite works out of the box. Store the .db file in the container:
const db = new Database('./data/bot.db');MySQL (Add-On)
Section titled “MySQL (Add-On)”- Request MySQL access from support or enable in plan features.
- Add connection string to environment variables.
- Configure ORM or driver:
Node.js (mysql2):
const mysql = require('mysql2/promise');const connection = await mysql.createConnection(process.env.DATABASE_URL);Python (asyncpg/aiomysql):
import aiomysqlpool = await aiomysql.create_pool(host='...', user='...', password='...', db='...')Troubleshooting Deployment
Section titled “Troubleshooting Deployment”| Issue | Solution |
|---|---|
| ”Cannot find module” | Run npm install or check file paths |
| ”ModuleNotFoundError” | Run pip install -r requirements.txt |
| Token invalid | Regenerate token in Discord Developer Portal |
| Intents error | Enable required intents in Developer Portal |
| Port already in use | Discord bots don’t need ports; check startup command |
| SFTP connection refused | Verify credentials and port (usually 2022) |
Next Steps
Section titled “Next Steps”- Operations Guide — Monitoring, scaling, backups
- Troubleshooting — Common errors and fixes
- Discord Bot Overview — Feature summary