Articles on: Community Tutorials

Startup Configuration (Node.js)

This tutorial is made by Fyrlex#2740

Startup Configuration

When you complete your order of a Discord Bot and go through installations. In your configuration, use Node 12, it is required for the latest version of Discord.js. You do not need to use any startup paramaters yet.

Go to your console, click Start to start your server. This will turn your server on and allow you to run commands through the console.

.env - Secrets File

Create a file in your main directory called .env. This is where you can store tokens or information you don't want the public to see, such as your Discord Bot Token.

An example of how to use .env files can be found here.

Your .env contents will look similar to this

Now you can use procces.env.DISCORD_TOKEN to get your token.


This is your main file that will start your bot.
// use dotenv package to access .env screts

// get the discord.js library
const Discord = require("discord.js");

// create a new Discord Client that you will use accross your files
const bot = new Discord.Client();

// all other code here

// login using your Discord token from the .env file

The file will not work until you install the packages below.
*Tip: You can use bot to a variable like const or let. But you will be able to use this in all files you run bot. Examples:*
bot.votelink = "https://vote.mybot"
bot.array = []
bot.object = {}
bot.collection = new Discord.Collection()

Package Installation

Packages from NPM are installed using this method through the console. Packages are software made by developers for other developers to use in their project. Discord.js is a package.

Then install the latest version of Discord.js using the following command.
npm install discord.js

A .env file is used to store private information such as your bot token. Install dotenv to use proccess.env.
npm install dotenv

In your .env file, create a key and assign it to your application token. Example:

Updated on: 13/12/2020

Was this article helpful?

Share your feedback


Thank you!