Guide
CommandKit Setup

CommandKit Setup

This is a simple overview of how to set up CommandKit with all the available options. You’d usually set this up in your entry file (e.g. index.js) where you have access to your Discord.js client object.

index.js
const { Client, GatewayIntentBits } = require('discord.js');
const { CommandKit } = require('commandkit');
const path = require('path');
 
const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.MessageContent,
    ],
});
 
new CommandKit({
    client,
    commandsPath: path.join(__dirname, 'commands'),
    eventsPath: path.join(__dirname, 'events'),
    validationsPath: path.join(__dirname, 'validations'),
    devGuildIds: ['DEV_SERVER_ID_1', 'DEV_SERVER_ID_2'],
    devUserIds: ['DEV_USER_ID_1', 'DEV_USER_ID_2'],
    devRoleIds: ['DEV_ROLE_ID_1', 'DEV_ROLE_ID_2'],
    skipBuiltInValidations: true,
    bulkRegister: true,
});
 
client.login('YOUR_TOKEN_HERE');
 
⚠️

Some Discord.js properties are only accessible using the correct intents.

CommandKit options

client

This is your Discord.js client object. This is required to register and handle application commands and events.

commandsPath (optional)

  • Type: string

This is the path to your commands directory. It's used to fetch, register, and listen for application commands.

eventsPath (optional)

  • Type: string

This is the path to your events directory. It's used to fetch and set event listeners based on the folder names inside of it.

validationsPath (optional)

  • Type: string

This is the path to your validations directory. It's used to fetch and call validation functions before running application commands.

devGuildIds (optional)

  • Type: string[]

This is a list of development server IDs. It's used to restrict commands marked with devOnly to specific servers.

If there is at least 1 guild ID provided, CommandKit will register any commands marked as devOnly inside the listed servers.

devUserIds (optional)

  • Type: string[]

This is a list of developer user IDs. It's used to restrict commands marked with devOnly to specific users.

Trying to execute a command when this is set to at-least 1 user ID will call a built-in validation function everytime to validate that the user running the command belongs to the provided devUserIds array.

devRoleIds (optional)

  • Type: string[]

This is a list of developer role IDs. It's used to restrict commands marked with devOnly to specific roles.

Trying to execute a command when this is set to at-least 1 role ID will call a built-in validation function everytime to validate that the user running the command has at least one of the provided roles.

skipBuiltInValidations (optional)

  • Type: boolean
  • Default: false

This is used to disable CommandKit's built-in validation functions. Setting this to true will ignore the default behaviour of validating who is running commands marked with devOnly.

bulkRegister (optional)

  • Type: boolean
  • Default: false

This is used to change the behaviour of how CommandKit loads application commands. By default it's one-by-one while comparing changes. Setting this option to true will load application commands all at once on every restart, and when reloadCommands() is called.