Discord.JS | Zach's Starter
This repository contains the starting code for my discord bots based on a tutorial I followed here. There are random comments sprinkled throught to help me recall the functionalities of sections
Please note that this is not the best starter code for making a discord bot with Discord.JS, but it's good enough for me at the moment.
- Install relevant packages with
npm install
- Setup
.env
with relevant info
TOKEN = 123
GUILD_ID = 123
CLIENT_ID = 123
- Setup
config.json
with relevant info
{
"testServer": "123",
"clientId": "123",
"devs": [
"123",
"456"
]
}
- Run
nodemon
in the terminal in project root directory
Example commands are given in the starter code in /src/commands
Steps
- Go to the
src/commands
folder and add your command file into an appropriate nested folder OR make your own nested folder and put your command file into it - Follow the same formatting as provided in the examples
ping.js
andban.js
- run
nodemon
in the terminal - Good Luck 😎
Example code for src/commands/misc/helloworld.js
module.exports = {
name: 'helloworld',
description: 'Classic Hello world',
devOnly: false,
callback: (client, interaction) => {
interaction.reply({
content: `Hello World! User: ${interaction.user.globalName}`,
ephemeral: true,
})
},
};
Handle different events. Example events are given in the starter code in /src/events