Basic Setup

Here's a basic Discord.js bot that makes use of all the djs-commander options.

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'), // The commands directory
  eventsPath: path.join(__dirname, 'events'), // The events directory
  validationsPath: path.join(__dirname, 'validations'), // Only works if commandsPath is provided
  testServer: 'TEST_SERVER_ID', // To register guild-based commands (if it's not provided commands will be registered globally)
});

client.login('YOUR_TOKEN_HERE');

Last updated