How do I host a Python bot?
Prepare requirements.txt, choose the main file and install the dependencies.
The Python environment uses a dependency file and an explicit launch command. Avoid storing the token directly in code.
Step-by-step procedure
-
Prepare requirements.txt
List the necessary libraries with compatible versions.
-
Choose the Python environment
Order a bot and select the Python environment offered in the catalog.
-
Import the code
Upload requirements.txt, the source folder and the main file.
-
Configure secrets
Create the DISCORD_TOKEN variable, then read it with os.environ.
-
Start
Install the dependencies then run python bot.py or the file defined in Startup.