Free hosting using Heroku
Tags: heroku, watercooler, javascript, node
Published: 2021-07-14 19:21:00

Hey readers 👋🏻,
I hope you all are doing fine, in this blog we are going to discuss about hosting and how to host our own discord bot, which we made in my [previous blog](https://dev.to/shreyazz/make-a-discord-bot-in-just-30-lines-of-code-44el) .

We are going to use **Heroku** to host our bot. 

### What do I mean when I say 'HOST' a discord bot?

So basically you cant run the program which you made for 24x7 and 365 days, so we need a server to do that.

The hosting platform has a lot of servers which will serve our discord bot for 24x7 and 365 days, so you and your friends can anytime use it anytime!!

#### Let's host it now 🤖 :


1. __Sign-up or Log-in to Heroku :__
   1. ![login](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uyql0ssmkmuo0210ii1u.PNG)
2. **Create a new app :**
   1. ![second](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nrt9su6x0viar8zlndnh.PNG)
   2. Click on the new button on the `top-right corner`.
   3. Click on Create New App
3. **Name your project and select a region:**
   1. ![third](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/efxt00tk9z7rqr2dsstt.PNG)
   2. Click on Create App
4. Now you have to push the source code on GitHub repo.
   1. Make sure source code does not contain your discord bot TOKEN or any other API key.
5. Now you will have this screen:
   1. ![connect](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/teajlym42ngt3g66uv01.PNG)
   2. Click on the `Connect to GitHub` button.
   3. Then select the repository which you created.
   4. Once the repo is connected, just press on `Enable Automatic Deploys`, which will help us to deploy the new version of our bot automatically whenever the repo is updated.
   5.  Refer to this image 👇🏻![six](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bo686ov9x1m7a56fe1gd.PNG)
6. **Then go the settings tab:**
   1. Click on `Reveal Config Vars`
   2. 👇🏻 ![seven](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzmhw8inm98fo6v56o1o.PNG)
   3. Inside the config vars enter your key and value pair of your API KEY and Discord Bot's Token. 👇🏻 

   4. ![eight](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/czzp1vx5rznfizn5x80g.PNG)
7. **Add a BuildPack:**
   1. BuildPack are scripts that are run when your bot will be deployed. They are used to install dependencies for your bot and configure your environment.
   2. Click on  add BuildPack 👇🏻 ![buildpack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dnwltj1yy5h4wfiaiblb.PNG)
   3. Then click on Node.JS 👇🏻 as our bot is made using JS and Node Modules. 
   4. ![add](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qwn3j784kudilbrwvo8e.PNG)
8. **After these steps, go to the home directory of your project and make a new File with the name of `Procfile`**
   1. The `Procfile` should contain `worker node <Source-folder-Name>/<file-which-has-bot's-code>` in this case, it will be `worker node src/bot.js`  .
   2. `Procfile` will help the Heroku's server to run our bot.
9. **Now push the new change to the repository.**
10. **Go to the deploy tab:**
    1. Now click on the `Deploy Branch` button.
    2. You will see a green check mark which will ensure you that there are no errors while deploying 👇🏻.
    3. ![check](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z5i73dwjv7fe8ac8f809.PNG)

11. **Go to the resource tab:**
    1. Refresh the page once.
    2. You can see 2 Dynos 👇🏻
    3. ![dyno](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/03ld4n7s45gnk8w8m26l.PNG)
 Click on the pen icon and switch off the `Web` and Switch on the `Worker`.
12. **Click on more and then click on view logs.**
13. **That's it you have successfully hosted your discord bot, and now you and your friends can use the bot anytime you want 🎉!!**

------

Thank you so much for reading the whole blog and if you liked it, do share it with your developer friends 💻!!

------

In case you want to learn how to make a discord bot(my previous bog's topic)and how to host it on Heroku, do check out my talk 🎉!

[Make a Discord Bot using Discord.js and host it online on Heroku](https://www.youtube.com/watch?v=FAbGyOPxw-U)