Skip to content

Discord Bot Deployment

Deploy your Discord bot from local development to production. This guide covers code upload, dependency installation, secret management, and CI/CD automation.


Before deploying, ensure you have:

  • Discord bot application with a valid token from Discord Developer Portal
  • Source code for Node.js (Discord.js, Eris, etc.) or Python (discord.py, Nextcord, etc.)
  • package.json or requirements.txt for dependency installation
  • Optional: Git repository with automated tests

  1. Sign in to panel.mambahost.com

  2. Click Create ServerDiscord Bot Hosting

  3. Choose your plan (Starter/Pro/Premium) and region

  4. Confirm the runtime (node 20+ or Python 3.11+) under Startup

  5. Adjust start command if your entry file differs (e.g., node dist/index.js)

  6. Enable backups in Settings → Backups


  1. Get SFTP credentials from your panel

  2. Connect using an SFTP client (FileZilla, WinSCP, etc.) on port 2022

  3. Upload your repository to /home/container

  4. Exclude build artifacts (node_modules, .venv, etc.)

  • Drag-and-drop single files
  • Upload a ZIP and extract in the panel
  • Best for small updates
  • Build and test in GitHub Actions
  • Sync artifacts via SFTP or panel API
  • See CI/CD section below

Terminal window
npm install
# or
pnpm install

Use lockfiles (package-lock.json, pnpm-lock.yaml) for reproducible builds.

Terminal window
pip install -r requirements.txt
# or for Poetry
pip install .

Music bots often need FFmpeg and libsodium. Request these through support if not already installed.


  1. Navigate to Startup → Variables

  2. Add your secrets:

    • DISCORD_TOKEN
    • APPLICATION_ID
    • API keys (OpenAI, Stripe, etc.)
    • Database credentials
    • Webhook URLs
  3. Mark sensitive values as hidden to prevent logging

  4. Access in code:

    Node.js
    const token = process.env.DISCORD_TOKEN;
    # Python
    import os
    token = os.getenv("DISCORD_TOKEN")

  1. Click Start — the watchdog restarts automatically on crashes

  2. Watch the console for gateway login confirmation

  3. Test slash commands in your Discord server

  4. Configure scheduled restarts (daily/weekly) for stability

  5. Subscribe to incidents at status.mambahost.com


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: Upload 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 "https://panel.mambahost.com/api/client/servers/${{ secrets.SERVER_ID }}/power" \
-H "Authorization: Bearer ${{ secrets.PANEL_API_KEY }}" \
-H "Content-Type: application/json" \
-d '{"signal":"restart"}'
  1. Keep a staging container synced with production

  2. Deploy to staging first and run smoke tests

  3. Register slash commands against the staging bot

  4. Promote to production by switching tokens/env vars

  • Store the last good build in /backups or object storage
  • Use panel backups to revert files and env vars
  • Restore database dumps before re-running migrations

const { ShardingManager } = require('discord.js');
const manager = new ShardingManager('./bot.js', {
totalShards: 'auto',
token: process.env.DISCORD_TOKEN
});
manager.spawn();
  • Disnake: AutoShardedBot
  • Hikari: Built-in sharding support
  • Run multiple containers, each handling a portion of shards
  • Coordinate via Redis or REST for shared state
  • Allocate additional CPU (Premium) for voice-heavy bots

  1. Enable daily backups for the container filesystem

  2. Verify restore points weekly

  3. Schedule database exports (mysqldump or SQLite copies) to /backups

  4. Document recovery steps — token rotation, slash-command re-registration