Skip to content

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.

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) or requirements.txt (Python) for dependencies
  • Appropriate gateway intents enabled in Discord Developer Portal
  1. Customer selects a Discord bot hosting plan from your store.
  2. After payment, Mamba Panel automatically provisions the container.
  3. Customer receives:
    • Portal access credentials
    • SFTP connection details
    • Initial console access

Provisioning typically completes in under 2 minutes.

  1. Connect using SFTP credentials from the portal (typically port 2022).
  2. Upload bot files to /home/container.
  3. Do not upload node_modules or .venv — install dependencies on the server.
  1. Open the file manager in the customer portal.
  2. Drag and drop files or upload a ZIP archive.
  3. Extract archives using the built-in extraction tool.
  • Keep the entry file (index.js, bot.py, main.py) at the container root.
  • Use .gitignore patterns to exclude build artifacts locally.
  • Version control source code in Git before uploading.

From the console panel:

Terminal window
npm install

Or with a lockfile:

Terminal window
npm ci

For pnpm users:

Terminal window
pnpm install
Terminal window
pip install -r requirements.txt

For Poetry projects, export first:

Terminal window
poetry export -f requirements.txt > requirements.txt
pip install -r requirements.txt

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
  1. Navigate to Startup → Variables in the portal.
  2. Add required variables:
VariableExamplePurpose
DISCORD_TOKENMTIz...Bot authentication
APPLICATION_ID123456789For slash commands
PREFIX!Command prefix (if used)
DATABASE_URLmysql://...Database connection
  1. Mark sensitive values as hidden to prevent accidental exposure in logs.

Node.js:

const token = process.env.DISCORD_TOKEN;

Python:

import os
token = os.getenv("DISCORD_TOKEN")
  1. Go to Startup in the portal.
  2. Verify or adjust the start command:

Node.js:

Terminal window
node index.js

or

Terminal window
node dist/index.js

Python:

Terminal window
python bot.py

or

Terminal window
python -m mybot
  1. Click Start in the portal.

  2. Watch the console for:

    • Dependency loading
    • Discord gateway connection
    • “Ready” or login confirmation message
  3. Test the bot in Discord:

    • Verify it appears online
    • Test a basic command
    • Check slash command registration

Configure the watchdog to handle crashes:

  1. Go to Settings → Auto-Restart.
  2. Enable restart on crash.
  3. Set restart delay (recommended: 5-10 seconds).
  4. Configure maximum restart attempts before alerting.

Set up recurring tasks:

  1. Navigate to Schedules in the portal.
  2. 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

Automate deployments from your repository:

name: Deploy Bot
on:
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.

SQLite works out of the box. Store the .db file in the container:

const db = new Database('./data/bot.db');
  1. Request MySQL access from support or enable in plan features.
  2. Add connection string to environment variables.
  3. 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 aiomysql
pool = await aiomysql.create_pool(host='...', user='...', password='...', db='...')
IssueSolution
”Cannot find module”Run npm install or check file paths
”ModuleNotFoundError”Run pip install -r requirements.txt
Token invalidRegenerate token in Discord Developer Portal
Intents errorEnable required intents in Developer Portal
Port already in useDiscord bots don’t need ports; check startup command
SFTP connection refusedVerify credentials and port (usually 2022)