How to setup your Node.js / JavaScript based Discord Bot
Preparation
To get started with your Node.js / JavaScript based bot, you'll want to make sure you have all of the files that you need for your bot ready first. Primarily, you will need the following:
package.json
— This file tells our panel about any requirements/dependencies your bot requires. As long as this file contains the list of packages that your bot uses, our panel will automatically install said packages when your bot is next started. Alternatively, you can install any needed packages manually via theNode Package Manager
link on the left sidebar of your panel.package-lock.json
— This file is optional, however it generally is a companion topackage.json
. If you do not have one, that will not be an issue, however if you do have one, we recommend uploading it as well.index.js
— Your bot's main starting point. While the name of this file is not important, we will useindex.js
as the example for this guide. This file can be named whatever you would like, so long as you remember to mentally replaceindex.js
with whichever file name you go with while reading this guide.
Both of these files should be saved somewhere on your computer, along with any other files that your bot requires to run.
Uploading your bot's files
For the next step, we'll go ahead and get our bot's files uploaded to our bot hosting service.
To do so, first head over to the File Manager
link on your panel's left sidebar, like so:
From here, you will most likely see that there are already some files here, that comes pre-installed on a NodeJS bot hosting plan. Although these files will not cause any sort of issues (in fact, uploading a file with the same name will just simply overwrite it), we'll go ahead and delete some of these files just to ensure we have a fresh start. In this case, delete package.json
, package-lock.json
, and bot.js
.
Now that some of those default files have been removed, lets go ahead and actually upload our bot's files. There are a couple of ways to do this:
- Simply drag and drop your bot's files onto the File Manager window
- Or, click
Upload
->File
and choose your bot's files in the file picker window that pops up - Alternatively, you can also deploy your bot's files via FTP, which is useful for deploying from say a build service. You can grab the FTP details for your bot hosting plan via the
FTP Client Details
link on the left sidebar of the File Manager.
In this example, my bot only has three files that need to be uploaded, an index.js
file, a package.json
file, and a package-lock.json
file — depending on how your bot is constructed, it will most likely have more files, you'll want to ensure you upload these as well.
node_modules
folder, as our panel will automatically generate this for you, so long as your bot's package.json
file contains its necessary packages in this file. Some node packages may contain various files for different types of operating systems, so it is best to let us generate this folder for you to avoid any issues. In addition, it will most likely trim off some time from your upload as well!Final steps
Now that our bot's files are uploaded, it's just about time to go ahead and start our bot for the first time! Head back over to the main page of your panel using the Back
button on the left sidebar from the File Manager.
The last step in our checklist is to ensure that the Start File
section on the panel is correct. By default, the panel will automatically use the file defined as main
in your package.json
file if one is present. Earlier we mentioned that we would be utilizing index.js
as our bot's main file, however if your bot uses a different file name, you will need to make sure this is entered in the Start File
textbox. Don't forget to click save after updating this!
Next head over to the Console
link on the left sidebar of your panel, this will allow us to see any output from our bot, whether said output is an error, or just informational output.
From the console page, click the Start
button at the top right of the page, and your bot should now start up!
And with that, your bot should now be up and running!
In our example of course, our bot only prints one line and then stops, however yours will continue running in the background. Feel free to leave the console page once you're all set. If you run into any issues getting your bot started, please feel free to reach out to our support team so that we may provide assistance with this. You can reach our support team by either opening a ticket on our website or our Discord.
Updated on: 05/06/2021
Thank you!