Free hosting using Heroku

Free hosting using Heroku

ยท

3 min read

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 can't 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 that 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 the GitHub repo.
    1. Make sure the 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 to 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 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 ๐ŸŽ‰ ๐Ÿ”ฝ!!

ย