Carbon
Core/Classes

Command

Represents a standard command that the user creates

Extends

Constructors

Constructor

new Command(): Command

Returns

Command

Inherited from

BaseCommand.constructor

Properties

PropertyModifierTypeDefault valueDescriptionOverridesInherited from
components?publicBaseMessageInteractiveComponent[]undefinedThe components that this command uses. These will be registered with the client when the command is initialized.-BaseCommand.components
contextspublicInteractionContextType[]undefinedThe contexts this command can be used in-BaseCommand.contexts
deferpublicbooleanfalseWhether the command response should be automatically deferred-BaseCommand.defer
description?publicstringundefinedA description of the command-BaseCommand.description
descriptionLocalizations?publicRecord<string, string>undefinedThe localized description of the command See https://discord.com/developers/docs/interactions/application-commands#localization-BaseCommand.descriptionLocalizations
ephemeralpublicbooleanfalseWhether the command response should be ephemeral-BaseCommand.ephemeral
guildIds?publicstring[]undefinedThe guild IDs this command should be deployed to (guild-specific deployment). If not set, the command is deployed globally.-BaseCommand.guildIds
integrationTypespublicApplicationIntegrationType[]undefinedThe places this command can be used in-BaseCommand.integrationTypes
nameabstractstringundefinedThe name of the command (e.g. "ping" for /ping)-BaseCommand.name
nameLocalizations?publicRecord<string, string>undefinedThe localized name of the command See https://discord.com/developers/docs/interactions/application-commands#localization-BaseCommand.nameLocalizations
options?publicCommandOptionsundefinedThe options that the user passes along with the command in Discord--
permission?publicArrayOrSingle<bigint>undefinedThe default permission that a user needs to have to use this command. This can be overridden by server admins.-BaseCommand.permission
typepublicApplicationCommandTypeApplicationCommandType.ChatInputThe type of command, either ChatInput, User, or Message. User and Message are context menu commands. Default ChatInputBaseCommand.type-

Methods

autocomplete()

autocomplete(interaction): Promise<void>

The function that is called when the command's autocomplete is triggered.

Parameters

ParameterTypeDescription
interactionAutocompleteInteractionThe interaction that triggered the autocomplete

Returns

Promise<void>

Remarks

You are expected to override this function to provide your own autocomplete functionality.


preCheck()

preCheck(interaction): Promise<unknown>

The function that is called before the command is ran. You can use this to run things such as cooldown checks, extra permission checks, etc. If this returns anything other than true, the command will not run.

Parameters

ParameterTypeDescription
interactionCommandInteractionThe interaction that triggered the command

Returns

Promise<unknown>

Whether the command should continue to run


run()

abstract run(interaction): unknown

The function that is called when the command is ran

Parameters

ParameterTypeDescription
interactionCommandInteractionThe interaction that triggered the command

Returns

unknown


serialize()

serialize(): RESTPostAPIChatInputApplicationCommandsJSONBody | RESTPostAPIContextMenuApplicationCommandsJSONBody

Internal

Serializes the command into a JSON object that can be sent to Discord

Returns

RESTPostAPIChatInputApplicationCommandsJSONBody | RESTPostAPIContextMenuApplicationCommandsJSONBody

Inherited from

BaseCommand.serialize


serializeOptions()

serializeOptions(): undefined | APIApplicationCommandBasicOption[]

Internal

Returns

undefined | APIApplicationCommandBasicOption[]

Overrides

BaseCommand.serializeOptions

On this page