How to Host a Python (discord.py) Bot

This guide shows you how to upload a Python bot built with discord.py to your GuavaHost panel, install its libraries from requirements.txt, and start it so it stays online around the clock.

This guide shows you how to upload a Python bot built with discord.py to your GuavaHost panel, install its libraries from requirements.txt, and start it so it stays online around the clock.

What you need

  • Your bot code with a main file such as bot.py.
  • A requirements.txt file listing your libraries, one per line, for example discord.py.
  • Your token from the Discord Developer Portal.

To create requirements.txt on your computer, run pip freeze > requirements.txt in your project folder, or simply make a text file with discord.py on the first line. Pinning a version, for example discord.py==2.4.0, keeps installs predictable.

Step 1: Upload your files

  • Open the panel from guavahost.com/account.
  • Go to the Files tab.
  • Upload bot.py, requirements.txt and any other files your bot needs. Drag them in, or connect over SFTP using the host, port and username on the Settings tab (SFTP is a secure way to move files between your computer and your server, and FileZilla works well).

Do not upload a local virtual environment folder such as venv; the panel builds its own.

Step 2: Set your main file

On the Startup tab, set the Python file variable to your entry file, for example bot.py. That is the file the panel runs with python.

Step 3: Keep your token out of the code

Paste your token into the token variable on the Startup tab, not into bot.py. Read it from the environment in your code:

import os

bot.run(os.environ["DISCORDTOKEN"])`

This way your token stays in the panel and never ends up in a file you might share.

Step 4: Start it

Press Start. On startup the panel reads your requirements.txt and installs your libraries with pip, then runs your bot with python bot.py. The first launch is slower while packages download.

Open the Console and watch. discord.py prints a login line and any errors here. When you see your onready` message, check Discord; your bot should be online.

Common issues

  • ModuleNotFoundError: No module named 'discord': discord.py is missing from requirements.txt. Add it, re-upload, and restart so pip runs again.
  • PrivilegedIntentsRequired: turn on the Gateway Intents your bot uses (for example Message Content or Server Members) in the Discord Developer Portal, then restart.
  • LoginFailure: Improper token has been passed: recheck the token variable for extra spaces, or regenerate the token and paste the new value.
  • IndentationError or a traceback on start: the Console shows the file and line number so you can find it.

discord.py version note

Older tutorials use commands that were removed in discord.py 2.x, and code written for the old 1.x will crash on a modern install. Match your code and your pinned version. If you inherited old code, pinning the version it was written for in requirements.txt is the quickest fix.

Updating later

Change your code locally, re-upload the changed files on the Files tab, then press Restart. New lines in requirements.txt install automatically on the next start. Take a Backups snapshot before big changes so you can roll back.

Still stuck? Jump into our Discord at discord.gg/GuavaHost and the team will help you out.