Special Offer: Save Upto 10% on Game Servers & Bot Hosting
Bot Hosting4 min read

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
  /cogs

requirements.txt:

discord.py>=2.3.0
python-dotenv

bot.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

  1. 1Upload the folder to your bot's panel
  2. 2Open Startup β†’ Python Version β†’ pick 3.11
  3. 3Set the startup command:
   python3 bot.py
  1. 1Add DISCORD_TOKEN to Environment Variables
  2. 2Click Start

Console should print Logged in as YourBot#1234.

Install Extra Packages

  • Edit requirements.txt to add the package
  • Click Reinstall Dependencies in the panel, or run pip install -r requirements.txt in 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.

Still need help?

Our team is on Discord around the clock. Real humans, real answers.