Running Your Discord.js Bot 24/7 With Heroku for Free

Опубликовано: 04 Октябрь 2024
на канале: FiNS Flexin
1,929
35

If you have any questions about anything! Feel free to ask down below, any question is good: (It could be anything from 24/7 discord bots to discord.js coding).

Twitter:   / finsflexin  

TIMESTAMPS:

0:00 Introduction -- (Why might want to run your bot 24/7)
0:31 Downloading tools -- (Github Desktop: https://desktop.github.com/)
0:37 Creating a repository -- (You should have an account, later on, you will use this repository you just made to put all your code into it... also make sure to click "set up on desktop" if you are using Github Desktop, your Github should be set to private)
1:00 Moving files to Repository -- (Move files from your code folder to the Github desktop file that came from installing Github Desktop)
1:09 Committing files to repository -- (This means tracking changes and updating them on your Github profile)
1:35 Creating an app on Heroku -- (Name can be anything, only you really need to look at it, keep anything else the same)
2:06 Adding code for Heroku -- (Make a file named "Procfile" with text in it that says "worker: node index.js")
2:52 Things you need to do when updating code -- (Committing file on Github Desktop and publishing it to Heroku to deploy it)
3:12 Flipping on the switch to your bot -- (One should be on... if its confusing check the logs, Heroku - bot page - more (top right) - view logs)


COMMON MISTAKES:
3:43 Not installing software -- (Github desktop... also you can try installing Heroku CLI and Git for additional features regarding your terminal)
4:22 Coding errors -- (You could always test if your code work through the terminal itself instead of going through Heroku for every problem... also look over your package.json and Heroku files)
6:05 Github Desktop errors -- (I don't know if you can really have an error here, just want to be safe)
6:42 Heroku mistakes -- (A ton of stuff bad can happen here, mainly the dependencies you installed, always try to search it up before asking people, also Dyno is difficult to understand, if its confusing check the logs, Heroku - bot page - more (top right) - view logs)
7:46 Alternative ways of doing this process -- (Heroku CLI and Git are required to install... HEROKU CLI: https://devcenter.heroku.com/articles..., GIT: https://git-scm.com/download/win (this is a bit tedious))
8:36 Bot sleeps after 1 hour -- (Heroku does this so people don't overwhelm their servers with things that are currently not doing anything, try installing a cron and updating it repeatedly with that, https://www.npmjs.com/package/cron)