You are expected to know the basic fundamentals of JavaScript, TypeScript, Node.js. It would also be useful if you know basic usage of your device's operating system.
- You are required to have 'Node.js'
v16.9
(~v7.21.1 npm) or above! - Discord.js v14.2.0.
- Setting up dotenv files.
- Remove
.example
from theproduction.env.example
,development.env.example
, and.env.example
files.
- Remove
- Obtain a bot token and bot Id.
- You'll need to create a new bot in your Discord Developer Portal application dashboard.
- At the end you should have a Bot Token.
- You'll need to create a new bot in your Discord Developer Portal application dashboard.
- Modify the dotenv files.
- Open the
production.env
file. - Insert your bot token as the value of
DISCORD_TOKEN
. - Insert your bot Id as the value of
CLIENT_ID
. - Do the same steps for
development.env
. - Inside the
.env
file, either use "development" or "production" for theNODE_ENV
key. The key production will use theproduction.env
file, and development will use thedevelopment.env
file.
- Open the
- Install the needed dependencies.
- Navigate into the installed source files and type
npm install
.
- Navigate into the installed source files and type
- Register commands.
- In order to use application commands, they first have to be registered.
- Type
npm run deploy-commands
to register the bot's application commands globally.- Run this script any time you change a command name, structure, or add/remove commands, etc.
- This is so Discord knows what your commands look like.
- Command deployments should be almost instant whether it is being deployed in a guild or globally.
Disclaimer We also have .replit and start.bat files you can use, along with a Procfile for Heroku but you must change the scripts yourselves if you do not want the one that is currently set.
Docker will be in the works, no ETA is set for this.
- Normal Mode
- Type
npm run start:bot
. - This starts a single instance of the bot.
- Type
- Sharding Mode
- Type
npm start
. - Starts the bot with sharding.
- Type
- PM2 Mode
- Note: You may have to run this as an
Administrator
in order to use this or you may get aPermission Denied
error. This may apply to other scripts insidepackage.json
and should be handled accordingly. - Inside process.json you will see this object:
env: { "NODE_ENV": "development" }
, you are free to change it as it acts as the.env
'sNODE_ENV
key. Change it either to production or keep it as development. - Type
npm run start:pm2
. - This is similar to Sharding Mode but it also uses PM2 to manage processes.
- Note: You may have to run this as an