How do I set up a VPS for Discord Bots?

This is a great question! It is actually a lot simpler than you would think. First, you need to get yourself a VPS. If you do not know what that is, this tutorial isn’t for you. Check out other tutorials that go over what that is and why you could have one for your Discord Bot(s).

Anyway, assuming you do know what that is, you need to purchase one for your Discord Bots. I recommend going with Vultr, Digital Ocean, Linode or Hostinger. I’m using Hostinger personally but I have used the others I have suggested and they work fantastic.

Once you have your VPS you want to use one of these Operating systems:

Ubuntu 20.04 (LTS) x64 or 18.04 (LTS) x64 CentOS 8.3 x64 Debian 9 x64 or 10 x64 If your hosting provider allows it, create a NodeJS 12.18.0 server on Ubuntu 20.04. This is something Digital Ocean provides, for example.

Once you have your VPS set up with one of those operating systems, you will want to login to your SSH. You can do this by using either Command Prompt, PowerShell, or PuTTY for Windows. For Mac, you can use the Terminal or PuTTY for Mac OS X.

Once you login via SSH you will want to install npm, node, nodemon, your discord handler (discord.js or, as well as pm2 (I recommend pm2 over nodemon as I’ve had issues with nodemon not stopping unless I reboot my entire server/computer).

The way you install npm & node is by running the following:

sudo apt-get install npm node

Once this runs you will want to run npm -v and node -v to make sure that npm version 12.20.1 and node version 7.5.4 are installed. If not, you will want to uninstall them by running sudo npm uninstall npm -g or (if that failes) sudo make uninstall and then reinstall them by following the tutorial on npm docs’ website. Now that you have node installed, you will want to install your discord handler. I use discord.js so I will go over that. If you use you can find tutorials on how to install that on their documentation website. To install discord.js you will want to run:

npm install discord.js@latest

Now that you have that installed you will want to install PM2. To do that you will run: npm install pm2@latest There you go. To run your bot with pm2 you will use pm2 start index.js If you need to restart your bot (on code changes) you can run pm2 restart index.js and to stop your bot it would be pm2 stop index.js or if you have several bots, you can use pm2 stop all or pm2 restart all or pm2 start all. There you go, you have your VPS set up for your bots. To edit the files, you need to use an FTP editor. I have a tutorial on those here. If you have any questions, either post them below or use the Subreddit or Discord Server. Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.