Now that we have created a discord bot it would be useful to know how and where we can host it for free. This tutorial will show you how to host your discord bot for free using heroku.
Hosting a Bot
Right now our bot is only online when we are running the python script on our computer. To allow our bot to stay online at all time we will need to host it on some kind of server. We will be using heroku, a completely free hosting service to accomplish this.
The first step is to setup an account on heroku.com.
Next we will create a new application and name it something that we can remember (we will need this name later).
After creating the app we will need to add a new python build-path. Navigate to Settings > Add Build path > Python.
Now we are ready to deploy our bot to heroku.
Downloading the Heroku CLI
To be able to execute some of the commands seen later we need to download the heroku CLI.
DOWNLOAD HERE
Uploading our Bot
Now that we have setup things on heroku it’s time to deploy our code there. To do this we need to follow a few steps.
Navigate to our bots directory
Create a Procfile
Create a requirements.txt file
Initialize a git repository
Commit to the repository
Sign into heroku from command line
Push git to heroku
Turn our bot on from heroku dashboard.
Creating the Necessary Files
For our bot to run we need to create two files within the same directory as our python script.
First navigate to your bots directory and run the command prompt. Make sure cmd is in the correct directory
Now run the following command: echo>Profile
Open the Profile using Notepad++ or Notepad and replace the contents with worker: python YOURSCRIPTNAME.py
Now inside the current directory create a new text file called requirements
Edit the requirements file to contain the following: (pandas is optional)
git+https://github.com/Rapptz/discord.py@rewritednspython==1.16.0PyNaCl==1.3.0async-timeout==3.0.1
SAVE both files
Creating a Git Repository
Now that we have created the necessary files we need to create a git repository that contains them and upload it to heroku. To do this we need to type a series on commands into cmd.
Again make sure that cmd is in the correct directory.
heroku login
heroku git:clone -a NAME_OF_APP_ON_HEROKU
git add .
git commit -am “make it better”
git push heroku master
Your output should look something like this:
Running the App
The last thing we need to do is turn our bot on from heroku.com. To do this we need to navigate to the Resources Tab and hit Edit. The simply click the slider so it turns on and hit Confirm.
And now after waiting for a minute or two we should see our discord bot online!
FAQs
To do this we need to follow a few steps.
- Navigate to our bots directory.
- Create a Procfile.
- Create a requirements.txt file.
- Initialize a git repository.
- Commit to the repository.
- Sign into heroku from command line.
- Push git to heroku.
- Turn our bot on from heroku dashboard.
How to host a Python bot for free? ›
PythonAnywhere is a free hosting service that allows you to host your Python scripts on a server. The service offers a free plan that provides 100 seconds of CPU usage per day, which resets every 24 hours. While there are some limitations to the free plan, it's more than enough to host a simple bot.
How to host a Discord py bot? ›
Once you have logged in, navigate to your server and hit the “Startup” button on the left navigation menu. Next, Head into the "File Manager" and upload all of your Bot files. Once you uploaded all of your discord bot files, head into the console and click "Start".
Can you code a Discord bot for free? ›
Build simple or complex Discord bots to bring your server to new heights. BotDisco allows you to create automatic triggers and tasks to automate virtually any task in Discord. Build for free!
Is Discord bot API free? ›
DiscordBot offers all of its endpoints for free, but the price for other APIs in the Discord collection can vary.
How do I permanently host a Discord bot? ›
Here is the recap:
- Create a Discord account and application in the developer portal.
- Set the bot permissions and invite it to your Discord server.
- Choose a programming language and IDE.
- Write your Discord bot code.
- Purchase a Discord bot hosting service, like Hostinger's VPS.
How to host Python code free? ›
- 5 Top Free Hosting Platforms for Python Apps 2024 — Best Heroku Alternatives. Alisdair Broshar. ...
- Koyeb. Website: https://www.koyeb.com/ ...
- pythonanywhere.com. Free Tier: One web application. ...
- Render. Website: https://render.com/ ...
- Fly.io. Free Tier: $5 sign-up credit. ...
- DigitalOcean App Platform. ...
- Heroku.
How do you make a discord bot easy in Python? ›
The bot presented in this tutorial is intended to add roles within a Discord server.
- Step 1: install discord.py. ...
- Step 2: create Python document. ...
- Step 3: connect to Discord. ...
- Step 4: Verify that the connection was successfully established. ...
- Step 5: add functionalities to your bot.
Is creating a bot free? ›
But you can also try using one of the chatbot development platforms powered by AI technology. Tidio is one of the most popular solutions that offers tools for building chatbots that recognize user intent for free. It also allows you to train your chatbots by uploading a list of conversations and text messages.
How do I host a custom Discord bot? ›
How to host a discord bot
- Step 1: Turn on developer mode.
- Step 2: Choose applications.
- Step 3: Name and create.
- Step 4: Add bot.
- Step 5: Programme your bot.
- Step 6: Set the details.
- Step 7: Set bot permissions.
- Step 8: Authentication link.
If you've been searching around and looking at some other Discord bot creation guides, you've likely noticed that nearly all of them are written in… JavaScript. Using JavaScript (with node.
Do you need to host a Discord bot? ›
Since Discord bots execute code and can do very complex interactions with Discord servers, they have to be hosted on a server. Even though you can get paid services which will host your Discord bot on the internet, it's really easy to host one yourself, as this tutorial will show.
Is Discord.py hard? ›
discord.py is a modern, easy to use, feature-rich, and async ready API wrapper for Discord.
Is coding a Discord bot hard? ›
If you're familiar with the Discord development environment and have some coding skills, even beginners can find making Discord bots relatively simple.
Is Discord JS hard? ›
We do, however expect you to have a basic understanding of JavaScript before attempting to write bots. Discord. js (and other discord libraries) require some median-to-advanced concepts that might be hard to grasp for anyone that doesn't have a good footing with the language.
Does a Discord bot need a host? ›
Since Discord bots execute code and can do very complex interactions with Discord servers, they have to be hosted on a server. Even though you can get paid services which will host your Discord bot on the internet, it's really easy to host one yourself, as this tutorial will show.
Can you host a Discord server for free? ›
Discord servers are free and can be set up easily by anyone that has a Discord account. If you want to use premium features, such as an optimized sound quality for all chat members, you can also use the paid Discord Nitro service.
Is bot hosting.net free? ›
Our services are trusted by thousands of users.
We know hosting can be confusing, which is why we've tried to simplify the process with extensive guides in our docs. We hope we can help you too, why not give it a try ~ it's free!
How do I add bots to my Discord server for free? ›
Select a Discord bot from a website offering a Discord bot list (e.g. “top.gg”). Click on “Invite” on the bot website. Select your server and grant the bot the permissions it needs. The bot will then be added to your Discord server.