#Command

implements ICommand

Creates a slash command.


#Import

import { Command } from 'discordkit';

#Constructor

new Command({ name: string, description: string, options?: ICommandOptions[], permissions?: bigint[], permCheck?: (bot: Bot, interaction: CommandInteraction) => Promise<boolean> | boolean, noPerm?: (bot: Bot, interaction: CommandInteraction) => Promise<any> | any, run: (bot: Bot, interaction: CommandInteraction) => Promise<any> | any });

#Properties

The name of the command.
Type: string


The description of the command.
Type: string


#.options Optional

The options of the command.
Type: ICommandOptions[]


#.permissions Optional

The permissions required to use the command.
Type: bigint[]


#Methods

If it returns true the user can use the command, but if it returns false the command will not be executed.

ParameterTypeDescription
botBotExtended Discord.js client.
interactionCommandInteraction Slash command interaction.

Returns: Promise<boolean> | boolean

Example
new Command({ ... permCheck: (bot, interaction) => { // only 451444721089380373 can use this command return interaction.user.id === '451444721089380373'; } });

This function is called if the user is not authorized to use the command.

ParameterTypeDescription
botBotExtended Discord.js client.
interactionCommandInteraction Slash command interaction.

Returns: Promise<any> | any

Example
new Command({ ... noPerm: async (bot, interaction) => { await interaction.reply({ content: 'u\'re not authorized.' }); } });

Executed when the command is used.

ParameterTypeDescription
botBotExtended Discord.js client.
interactionCommandInteraction Slash command interaction.

Returns: Promise<any> | any

Example
new Command({ ... run: async (bot, interaction) => { await interaction.reply({ content: 'pong, my ping is ' + bot.ws.ping + 'ms.' }); } });