#
Command
implements ICommand
Creates a slash command.
Properties
Methods
name description options permissions
permCheck noPerm run
#
Import
import { Command } from 'discordkit';
const { Command } = require('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
#
.name
The name of the command.
Type:
string
#
.description
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
#
.permCheck(bot
, interaction
)
Optional
bot
, interaction
)If it returns true the user can use the command, but if it returns false the command will not be executed.
Returns: Promise<boolean> | boolean
Example
new Command({
...
permCheck: (bot, interaction) => {
// only 451444721089380373 can use this command
return interaction.user.id === '451444721089380373';
}
});
#
.noPerm(bot
, interaction
)
Optional
bot
, interaction
)This function is called if the user is not authorized to use the command.
Returns: Promise<any> | any
Example
new Command({
...
noPerm: async (bot, interaction) => {
await interaction.reply({
content: 'u\'re not authorized.'
});
}
});
#
.run(bot
, interaction
)
bot
, interaction
)Executed when the command is used.
Returns: Promise<any> | any
Example
new Command({
...
run: async (bot, interaction) => {
await interaction.reply({
content: 'pong, my ping is ' + bot.ws.ping + 'ms.'
});
}
});