Setup Commands Path

To setup commands, you must provide the commandsPath property when creating a new instance of CommandHandler.

index.js
const { Client, IntentsBitField } = require('discord.js');
const { CommandHandler } = require('djs-commander');
const path = require('path');

const client = new Client({
  intents: [IntentsBitField.Flags.Guilds], // Your bot's intents
});

new CommandHandler({
  client, // Discord.js client object | Required by default
  commandsPath: path.join(__dirname, 'commands'), // Your commands directory
});

client.login('YOUR_TOKEN_HERE');

Different Command Folders

Of course, your commandsPath can lead to a folder with any name anywhere. For example, if I have my commands saved inside a folder called bot-commands, I would define commandsPath like this.

commandsPath: path.join(__dirname, 'bot-commands')

Last updated