Dynamic Command Handling
Get started with our easy-to-use command handler
Starting Up
First, create a folder called "cmds". This will be your commands folder. Then, make a subfolder for each command module. For example, misc, music, economy. In each folder make a module.js file.
module.exports = {
key: "misc", // Module Key (LOWERCASE!)
name: "Miscelaneous", // Module Name
desc: "Misc commands" // Module Description
}
For each command, make a file in the folder. for example, ping.js
module.exports = {
name: "ping", // Command Name
module: "misc", // Must be a valid key to a module.
execute: (client, message, args) => {
// Your code here
message.channel.send(`Pong! ${client.ws.ping}ms`)
}
}
So on so forward.
Incorporating it to our code
// Imports
const { Client, commandHandler } = require("djsplus")
// Client
let client = new Client()
// Config
client.config.prefix = "?" // Command Prefix
// Command Handler
commandHandler(client, __dirname)
// Login
client.login("Your bot token")
Last updated
Was this helpful?