This guide starts from zero: you create the bot in Discord, write a small bot with a !ping command and start it on your RHQ Python server.
-
Create the application in Discord
Go to the Discord Developer Portal, click New Application, give it a name and confirm.
-
Get the bot token
Open the Bot tab and click Reset Token. Copy the token and keep it to yourself.
On the same page, under Privileged Gateway Intents, turn on Message Content Intent. Prefix commands need it.
-
Invite the bot to your Discord server
Open OAuth2 → URL Generator, tick the
botscope and the Send Messages and Read Message History permissions. Open the generated link and pick your server. -
Prepare the project
On your computer, create a folder with three files.
requirements.txt discord.py>=2.4 python-dotenv>=1.0main.py import os import discord from discord.ext import commands from dotenv import load_dotenv load_dotenv() 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.reply("Pong!") bot.run(os.environ["DISCORD_TOKEN"]).env DISCORD_TOKEN=paste_your_token_here -
Upload the files to the panel
In the RHQ panel open the Files tab and upload
requirements.txt,main.pyand.env. -
Set the main file and start
In the Startup tab set the main file to
main.py, then click Start. Libraries install on the first start. When Console showsLogged in as ..., type!pingin Discord.
Troubleshooting
The bot is online but does not answer !ping
Check that Message Content Intent is on in the Developer Portal and that the code has intents.message_content = True.
The console shows "ModuleNotFoundError: No module named 'discord'"
requirements.txt is missing or has a different name. Upload it to the main folder and restart the server so the libraries install.