How to Use Python for Your Discord Bot on Endercloud
Set up a discord.py bot from scratch, the right Python version, the right libs.
Introduction
Python is a great choice for Discord bots, readable, batteries-included, huge community. Endercloud supports Python 3.10, 3.11, and 3.12.
Pick Your Library
- discord.py, the original, well-maintained, slash commands supported
- Pycord, fork of discord.py with focus on slash commands
- Hikari, newer, async-first, less battery-included
Most guides assume discord.py, that's what we'll use.
Project Setup
/my-bot
bot.py
requirements.txt
.gitignore
/cogsrequirements.txt:
discord.py>=2.3.0
python-dotenvbot.py:
import os
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
@bot.command()
async def ping(ctx):
await ctx.send("Pong!")
bot.run(os.environ["DISCORD_TOKEN"])Deploy to Endercloud
- 1Upload the folder to your bot's panel
- 2Open Startup β Python Version β pick 3.11
- 3Set the startup command:
python3 bot.py- 1Add
DISCORD_TOKENto Environment Variables - 2Click Start
Console should print Logged in as YourBot#1234.
Install Extra Packages
- Edit
requirements.txtto add the package - Click Reinstall Dependencies in the panel, or run
pip install -r requirements.txtin console - Restart the bot
Warning: Don't use pip install for individual packages from the console, they vanish after panel updates. Always pin to `requirements.txt`.
Need More Help?
Discord intents tripping you up? Drop the error in Discord, that one's common.
Was this helpful?
Your feedback helps us write better guides.
Related Articles
More from Bot Hosting.
How to Upload and Run Your Discord Bot
From local code to a live bot on Endercloud in five minutes.
How to Keep Your Bot Online 24/7
Auto-restart on crash, auto-start on reboot, the only two settings you need.
How to Set Environment Variables for Your Bot
Keep tokens, API keys, and secrets out of your code with env vars.
Still need help?
Our team is on Discord around the clock. Real humans, real answers.