Docs · Discord bots

Host a discord.py bot (Python)

Run a discord.py, Pycord or nextcord bot 24/7. Packages from requirements.txt install on every start, and the token stays in a .env file.

Startup → Docker Image → Python 3.13. Then upload these files.

The files

requirements.txt lists your packages, one per line:

discord.py>=2.4
python-dotenv

bot.py is the bot:

import os

import discord
from dotenv import load_dotenv

load_dotenv()
intents = discord.Intents.default()
client = discord.Client(intents=intents)


@client.event
async def on_ready():
    print(f"Logged in as {client.user}")


client.run(os.environ["DISCORD_TOKEN"])

.env holds the token: DISCORD_TOKEN=your-token-here.

Don’t upload a venv folder. On start we install everything in requirements.txt (or your pyproject.toml), then run the first of main.py, bot.py, app.py, run.py that exists. Another name? Type it in Main file.

Good to know

  • Message content: set intents.message_content = True, and switch on Message Content Intent in the Developer Portal → your app → Bot.
  • Pycord or nextcord: put py-cord or nextcord in requirements.txt instead of discord.py. Never install two of them together: they share the name discord and break each other.
  • Print shows up late? It doesn’t here: output goes to the console right away.
  • Voice and music: add PyNaCl to requirements.txt. ffmpeg is already installed.
  • A library needs an older Python: pick Python 3.12 in Docker Image.
  • Stop sends Ctrl+C, which discord.py handles: the bot logs out cleanly.

More help: Run your Discord bot 24/7.

Still stuck?

Open a ticket with your service name and the console error, and a real person helps you.