How to set up a Discord Python 3 Bot
How to Configure
In this guide, we're going to show you how to configure a Discord bot running Python code.
Out of the box, your server will not start - That's because we need to provide it with some python code that will run your bot!
There are a couple of ways to get your code onto the server. We'll go over those options below.
Option 1 - Startup Parameters & Git Repository
-
Go to your server on the Straya Panel (opens in a new tab)
-
Go to Configuration -> Startup Parameters
- Provide a git repository address that contains python code.
You can use your own, or use our repository that provides some basic code to get you started -
https://github.com/Straya-Hosting/DiscordPythonBot
- Specify the git branch
By default, this is usually either
main
ormaster
. Check your git repository to be sure. In the case of our sample code, it's on themain
branch
- Specify the bot python file
This is the main code that starts your bot. Typically it's called
bot.py
- but it might be called something else in your case. Update as necessary. In our case with our sample code, it's calledbot.py
so that's what we'll use.
- Finally, update any of the other parameters if you need to or proceed to restart your server. After your server has restarted, check your file manager to see if the code from the git repository was pulled into your server. If not, or if you run into any issues, proceed to either option 2 or option 3.
Option 2 - Manually Clone a Git Repository
- Go to the file manager
- Click the three dots in the top right and click
git Clone
- Enter the repository URL (Make sure it ends with .git) and the branch name
Option 3 - Manually Create the python files
-
Go to the file manager
-
Select the option to upload a file
- Upload all the files you need, then make sure to go into the
Startup Parameters
section in the menu and set the python bot file that your server can use to start the bot.