Over the past few months, I have been experimenting on the best way to host my discord bot I have tested a few websites and Will explain why I like/dislike these hosting websites.
Heroku- This website I would not recommend to anyone starting out I was confused by the website and in the end I didn’t even manage to get my bot to run
Glitch- This website is good for beginners the only downside is the bot goes offline every 24 hours and requires you to go to the repository and refresh for the bot to come back online I would recommend this for anyone who is starting out. I used this bot for the first few months but then I got annoyed by it shutting off every 24 hours so I decided to learn how to host my bot on my pi
Hosting bot on Pi
When you have your pi turned on the first thing you will need to do is make sure that your bot files are copied onto your pi
Open up a terminal and type the following
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - This will download the files required for you to download node
sudo apt-get install -y nodejs This will install nodejs
sudo npm install pm2 -g This will install process manager 2 this is the program that will run your bot
When all these programs have been installed you will need to open the terminal in your bots directory you can do this by typing
Then you will need to install all the node modules if you have set up your package.json correctly all you will need to type is
npm install this will install all the modules that are listed in your package.json file
Your next step is to type
pm2 start index.js --name bot
Replace index.js with whatever the main file is such as bot.js then your bot will run!
Any issues with this guide feel free to PM me on discord Bencey_#8587