An abstract interaction based command class. Extend this class to define your command's functionality. This class serves as a base for interaction based commands (slash commands).

Hierarchy

Constructors

Properties

aliases: string[]

Aliases for this command.

Memberof

Command

Default Value

[]

The client that this command will be used by.

Memberof

Command

dataBuilder: Partial<SlashCommandBuilder>

The data builder for this slash command. You do not need to set its name or description, the constructor will automatically set these based on the command info.

Memberof

SlashCommand

description: string

The description of this command.

Memberof

Command

emoji: string

The emoji of this command. This is used by the default HelpSlashCommand.

Memberof

Command

Default Value

🤖

group: null | CommandGroup

The group that this command is registered to.

Remarks

This gets initialized on command registration.

Memberof

Command

groupID: string

The ID of the group that this command is registered to.

Memberof

Command

guildOnly: boolean

Whether this command may only be used in a guild.

Memberof

Command

Default Value

false

name: string

The name of this command.

Memberof

Command

nsfw: boolean

Whether this command may only be used in a NSFW channel.

Memberof

Command

Default Value

false

ownerOnly: boolean

Whether this command may only be used by the bot's owner.

Memberof

Command

Default Value

false

ownerOverride: boolean

Whether the bot's owner can execute this command even if they don't have the required permissions.

Memberof

Command

Default Value

true

userPermissions: null | PermissionResolvable

The permissions resolvable that defines the permissions that a user requires to execute this command.

Memberof

Command

Default Value

null

Methods

  • Get all the data builders associated to this command. This includes a copy of the original dataBuilder for each command alias.

    Returns Partial<SlashCommandBuilder>[]

    An array of this command's data builders.

  • Get this command's data builder.

    Returns Partial<SlashCommandBuilder>

    This command's data builder.

  • Check whether the interaction author can execute this command.

    Parameters

    • interaction: ChatInputCommandInteraction<CacheType>

      The interaction that triggered this command.

    Returns string | boolean

    true if the user has enough permissions, or a string with the reason why they cannot execute this command.

  • Handle command error.

    Parameters

    • error: unknown

      The error that was thrown inside the command's run method.

    • interaction: ChatInputCommandInteraction<CacheType>

      The interaction that triggered this command.

    Returns Promise<void>

    Emits

    client#commandError

  • Abstract method. You need to implement this method in order for the command to work. This defines the execution behavior of the command.

    Parameters

    • interaction: ChatInputCommandInteraction<CacheType>

      The interaction that triggered this command.

    Returns Promise<void>

Generated using TypeDoc