If you don’t have a dedicated linux server or machine, yet you still want to run your Discord bots 24/7 for free. Heroku to the rescue. It’s a free cloud platform for developers and enterprise users.
If you intend to develop/modify bots then it’s way easier to get a super cheap cloud server at DigitalOcean, Vultr or some other provider. If you only wish to run these bots for free then Heroku will do just fine.
In this tutorial I will give an easy step-by-step tutorial on how to run my Discord speech recognition bots on Heroku.
- You need a (temporary) linux machine with sudo access, this can be a virtualbox (preferably Ubuntu 18).
- You need to install heroku CLI (tutorial).
- You need to install Docker (tutorial for Ubuntu 18)
- Sign up for a free account on https://www.heroku.com/
- On your linux machine make sure you are logged in to Heroku:
heroku login -i
3. Create a new app on your dashboard panel:
4. Give your app a unique name and set your region, finally click “create app”.
5. Clone the git repository of your choice and enter it:
git clone https://github.com/healzer/DiscordSpeechBot.git
6. Rename the file “settings-sample.json” to “settings.json”, then provide your API credentials and save the file.
7. Now we need to build a docker image from the Dockerfile:
sudo docker build -t dockerspeechbot .
8. Use the following command to check if our “dockerspeechbot” is listed:
sudo docker images
9. (Optional) you can try running the docker image as a test:
sudo docker run -it dockerspeechbot
10. Push the docker image to heroku, this may take several minutes:
heroku container:push dockerspeechbot -a mediumherokudemo
11. Set the image to “release” state:
heroku container:release dockerspeechbot -a mediumherokudemo
12. On your Heroku dashboard click “resources” and your dyno will be there:
Note: it may take a minute or two before your dyno appears.
13. Click the “edit” icon of the “dockerspeechbot” dyno and enable the slider:
14. Finally click “confirm”.
15. On the top right go to “more” — > “view logs”:
Now you should see similar logs appear, where it says that “node index.js” is launching (this may take a minute to appear).
16. Now you can go to your Discord server and try it out:
You’ve reached the end :)
You can now repeat this process for all the other bots to create your own.