Skip to content

How to run the DiscordBot.js

AtomixDem edited this page Jun 24, 2021 · 5 revisions

Once we have created the file and inserted all the code to be executed by our bot, we must start it to make it work on our server.In this Wiki I will use the Visual Studio Code program to start the bot but these actions can also be done from the terminal!
To start it you must first install libraries:

The first thing to do is to install Node.js on our computer. You can download it for free from here! Once downloaded, open it and perform the steps you see until it is successfully installed.
Once this is done open Visual Studio Code (or the terminal, depending on how you want to host it) and open the terminal window by clicking on View > Terminal.

If you are not located in the folder where you have the .js file move with the terminal commands to get there; you can see a simple guide here!


Now we are ready to execute the few commands to start the bot. First of all let’s initialize the Node.js package we installed earlier with this command:

$ npm init

Immediately after we should click a few times on the enter key until a message appears where it will ask us if we would like to initialize everything, write “Yes” and send.
Once you have finished this step you will have created a file called “package.json” where you can change some things. Now you can choose two ways, you can create a file called index.js and paste all the code in there, or in the package.json file rename to main with your file name. In addition, you can also set the name of the bot (attention, it will not be what you will see on Discord), a description, the development version and the author.

Clone this wiki locally