How to Install a Python Discord Bot
Deploy a Python Discord bot like discord.py on your XGamingServer bot hosting server.
This guide covers how to deploy a Python Discord bot (such as one built with discord.py) on your XGamingServer.
📝 Note: You need a Discord bot token before proceeding. If you have not created one yet, follow our Create a Bot Token guide first.
Check your Startup page to see which server type you have. If you see App py File, Git Repo Address, and User Uploaded Files variables, follow the Standalone Python Server instructions. If you only see a Startup Command variable, follow the Discord Bot Server instructions.
Standalone Python Server
If your Startup page has App py File, Git Repo Address, User Uploaded Files, and Additional Python Packages variables, you have the standalone Python egg. Dependencies install automatically from requirements.txt on each start.
Option A: Upload Files
Enable User Uploads
Go to Startup and set User Uploaded Files to 1. This skips the Git clone step on startup.
Upload Your Bot Files
Log in to the XGamingServer panel and go to the Files page. Upload your bot files including:
- Your main bot file (e.g.,
bot.py,main.py) requirements.txtwith your Python dependencies listed- Any other files your bot needs (cogs folder, config files, etc.)
Set the App py File
Go to Startup and set App py File to your bot's main file:
bot.pyReplace bot.py with your actual main file name. The default is app.py.
Configure Your Bot Token
Go to Files and create a .env file with your bot token:
TOKEN=your_bot_token_hereUse whatever variable name your bot's code expects. See our Manage Bot Token guide for more details.
Start Your Server
Go to the Console page and click Start. The server will automatically install packages from requirements.txt and then run your bot.
Option B: Deploy from GitHub
Set the Git Repository
Go to Startup and fill in:
- Git Repo Address — Your repository URL (e.g.,
https://github.com/username/my-bot) - Git Branch — The branch to clone (leave blank for the repo default)
- User Uploaded Files — Set to
0(so the server clones from Git)
Set the App py File
Set App py File to your bot's main file (e.g., bot.py).
Enable Auto Update (Optional)
Set Auto Update to 1 if you want the server to pull the latest code from GitHub on each restart.
Start Your Server
Go to Console and click Start. The server will clone the repo, install dependencies, and run your bot.
Configure Your Bot Token
After the first start, go to Files and create a .env file with your bot token. The repository is cloned to the server's file directory. Restart for the token to take effect.
Installing Additional Packages
If you need packages beyond what is in requirements.txt, add them to the Additional Python Packages field on the Startup page (space-separated):
aiohttp pillowThese packages are installed automatically alongside your requirements.txt dependencies on each start.
Custom Requirements File
If your project uses a different filename for requirements (e.g., requirements-bot.txt), set the Requirements File variable on the Startup page to match.
Using a Private GitHub Repository
On the Startup page, fill in the Git Username and Git Access Token fields. Create a personal access token with repo scope and use it as the access token.
Discord Bot Server
If your Startup page only has a Startup Command variable, you have the multi-language Discord Bot server.
📝 Note: Make sure your server is using a Python Docker image. If your server was set up for Node.js, contact support or join our Discord to switch to a Python image.
Upload Your Bot Files
Log in to the XGamingServer panel and go to the Files page. Upload your bot files including:
- Your main bot file (e.g.,
bot.py,main.py) requirements.txtwith your Python dependencies listed- Any other files your bot needs (cogs folder, config files, etc.)
Install Dependencies
Go to Startup and set the Startup Command to:
/bin/bashStart the server. In the Console, type:
pip3 install -r requirements.txtWait for all dependencies to install.
Configure Your Bot Token
Go to Files and create a .env file with your bot token:
TOKEN=your_bot_token_hereUse whatever variable name your bot's code expects. See our Manage Bot Token guide for more details.
Set the Startup Command
Go to Startup and change the Startup Command to run your bot:
python3 bot.pyReplace bot.py with your bot's main file name.
Start Your Server
Go to the Console page and click Restart. Your bot should come online and connect to Discord.
Installing Additional Packages
If you need to add more pip packages later:
Switch to Bash
Set the Startup Command to /bin/bash and restart.
Troubleshooting
- Bot starts but immediately crashes — Check the
Consolefor error messages. Common issues include a missing or invalid bot token. - "ModuleNotFoundError" errors — Dependencies are missing. On the Discord Bot server, set startup to
/bin/bash, runpip3 install -r requirements.txt, then switch back. On the standalone Python server, check that yourrequirements.txtlists all required packages. - Server stuck on "Starting" — The panel may not detect startup output. Join our Discord for help.
- Wrong Python version — Contact support to switch the Docker image. Available versions: Python 2.7, 3.7, 3.8, 3.9, 3.10.
- "SyntaxError" on startup — You may be running code written for a newer Python version than what is installed.
How is this guide?