How do I set up a discord bot?

May 24, 2017 18.6k views
Ubuntu Node.js

I recently bought a $5 droplet hoping to host my Discord bot. It’s coded in JavaScript but I just have NO idea how to set this up such as how to add my .js file, or my node_modules, etc.

Any help would be really appreciated.

2 Answers


Upfront, this is a bit lengthy :-).

A VPS is essentially a barebones environment from which you’ll build your stack – in this case, that’d consist of at least NodeJS – and is comparable to a Dedicated Server; you are in full control (i.e. you have root access).

This means that you need to be ready and willing to learn how to manage your own server, as well as secure it while maintaining your application(s).

To get started, you’ll need a way to connect to your Droplet (VPS). If you’re on MacOS (or OS X), you can use Terminal. If you’re on Windows, you’d use PuTTy.

For PuTTy, see the link below. From under Package Files, download putty-64bit-0.69-installer.msi.

If you’re using Terminal, you’ll start the app and run:

ssh root@DROPLET_IP

DROPLET_IP should be replaced with the actual IP address of your Droplet.

You’ll be prompted for a password – that’ll be the password that was e-mailed to you once set up of your Droplet completed. If you don’t see the e-mail, check spam/junk just in case it was flagged.

If you’re on Windows and using PuTTy, you’ll double-click the application icon to launch. From there, you’ll enter the Droplet IP Address in the “Host Name (or IP Address)” box and click on “Open.”

You’ll be prompted for a password – you’ll use the same password that was e-mailed to you, as noted above.

When you login for the first time, you’ll be asked to reset your password to something else. You’ll first enter the same password you just used to login, then enter a new password, and finally confirm the new password.

That new password is what you’ll use to login from here on – so make sure you remember it (but don’t use something basic, it should be a secure password – generally 16-32 characters and as random as you can make it).

Once logged in to SSH, you’ll want to update (sync) your repositories and upgrade any packages in need up upgrading. On Ubuntu, you can do that by running each of the following commands:

apt-get update
apt-get -y dist-upgrade

That will at least ensure that everything is up-2-date and provide a solid base from which to build on.

I’d recommend taking a good look at this guide for a few more basics:

I recommend the above as you really shouldn’t stay logged in as root, though you need to pay very close attention to the guide as it is relatively easy to lock yourself out of the VPS if you are not careful.

From here on, it’s all a matter of setting up your stack. For NodeJS, you need to figure out the version you need to run. Right now, that’d be 4.x, 5.x, 6.x, or 7.x. In most cases, 5.x or 6.x is what is supported by most applications.

To install NodeJS, I recommend the NodeSource repositories:

To install any version, 4.x through 7.x, you’d simply run:

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

You’d replace 6.x in the command above with the version you want to install – you only need to change the 6 to a 4, 5, or 7 – the .x should stay as-is.

Once NodeJS is installed, you’ll have access to run node myapp.js ect – as well as access to npm.

As for uploading files, you can use scp or SFTP. If you’re on Windows, SFTP would be the main and preferred option and nothing more needs to be installed to use it.

You’d want to download FileZilla:

… and then install it. From there, you’ll connect much in the same way that you did with PuTTy.

File => Site Manager => New Site
Host        =>  Droplet IP
Port        =>  22
Protocol    =>  SFTP - SSH File Transfer Protocol
Logon Type  =>  Normal
User        =>  root
Password    =>  The new root password you setup.

From there, you’ll need to choose where you want to upload your files. Generally, you’ll use either:


or you’ll create a sub-directory within /home, such as:



mkdir -p /home/mynewapp

or by creating a directory through FileZilla.

Keep in mind, these are really just the basics. With a VPS or Dedicated Server, you’re going to be using the CLI a lot, so you need to become familiar with it and learn to love it :-).

Hopefully that’ll help to get you started. If you have any questions along the way, feel free to reply and I’ll do my best to help!

by Mitchell Anicas
When you start a new server, there are a few steps that you should take every time to add some basic security and give you a solid foundation. In this guide, we'll walk you through the basic steps necessary to hit the ground running with Ubuntu 16.04.
Have another answer? Share your knowledge.