Python Discord bot comprises codes to cater to your server’s visitors. You can quickly create a bot for your server on Discord with a few steps. But if you have already created one using the codes, know that the bots you create using the scripts run only when your computer is switched on. And to keep it online all the time, you need to host your Bot 24/7 using the software. We will use the Heroku hosting service to keep your Python Discord bot online even if your device is switched off.
Steps To Host Python Discord bot On Your Device
To host the Python bot on your computer, setting up the account on Heruko is the first step. Here’s how you can do it.
1. Visit the Heroku.com sign-up page and create an account.
2. Once it’s done, head to create new app options to make the application.
3. Navigate to the setting at the top below your profile icon. You will see different sections on the screen. Scroll down and click the “Add Buildpack” button on the right-bottom side to run the Discord Python bot.
4. Enter the “Buildpack URL” or select from the “officially supported Buildpacks” below. Click on the save changes, and you are ready to deploy your bot to Heruko.
Before running the bot, you need to create some necessary files and Git Repository. You can make it before or after setting up your Heroku account.
Create Necessary Files To Host Python Discord bot.
To run your bot effectively on Discord, creating these two files in the same directory is crucial as our Python script. Carefully follow the following guide to create both files.
1. Head to the bots directory and run the cmd.
2. Run the command: echo>profile.
3. Open the profile using Notepad, replace the content with the worker: Python, and save it to your computer.
4. Create a new text file in the same directory as Python and give it a name to save, i.e., requirement.
Create A Git Repository And Run The Bot
Now that you have created the necessary files, it’s time to make a Git Repository to run the Discord Python bot. You have to see whether your cmd is in the correct directory.
- Heroku login information
- Name of the app on Heruko
- Git add
- Git commit- anything in here
- Git push heroku master
Finally, connect your Discord application with the GitHub repo to run your Python bot. Follow these steps:
1. Navigate to Heroku.com and search for your repository to connect.
2. Choose the main option from the dropdown as a branch to deploy and click the deploy branch button next to it.
3. Now head to the resources section at the top and press the toggle button to turn on the worker dyno. Keep your Github repo updated to avoid any issues running the bot.
The mentioned steps will help you know how to host a Python Discord bot for free. Since Heroku is a free hosting service, you may see issues or command delays while working on it. So don’t worry, and do not forget to make the necessary files in the same depository, as it can also create problems running the bot. If you want to maintain a bot for your NSFW servers, there’s no need for codes. You can look through multiple different NSFW bots available online for free.