DEV Community

Cover image for Free hosting using Heroku
Shreyas Pahune
Shreyas Pahune

Posted on

Free hosting using Heroku

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 .

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
  2. Create a new app :
    1. second
    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
    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
    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
  6. Then go the settings tab:

    1. Click on Reveal Config Vars
    2. 👇🏻 seven
    3. Inside the config vars enter your key and value pair of your API KEY and Discord Bot's Token. 👇🏻
    4. eight
  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
    3. Then click on Node.JS 👇🏻 as our bot is made using JS and Node Modules.
    4. add
  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
  11. Go to the resource tab:

    1. Refresh the page once.
    2. You can see 2 Dynos 👇🏻
    3. dyno 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

Latest comments (5)

Collapse
 
kashiwalharsh profile image
Harsh Kashiwal

Is it really available now
Maybe they closed the free hosting feature

Collapse
 
blackr1234 profile image
blackr1234 • Edited

Heroku is really easy to register, setup and get the results. It is extremely easy that I don't even need a user manual. It can automatically deploy my server when commits are pushed to my Git repo.

Collapse
 
shreyazz profile image
Shreyas Pahune

Yup Heroku makes deployment so easy!!

Collapse
 
hrushikesh41 profile image
Hrushikesh Kokardekar

Very Informative 👍👍

Collapse
 
shreyazz profile image
Shreyas Pahune

Thanks bro