Command
Represents a standard command that the user creates
Extends
Constructors
Constructor
new Command():
Command
Returns
Command
Inherited from
Properties
Property | Modifier | Type | Default value | Description | Overrides | Inherited from |
---|---|---|---|---|---|---|
components? | public | BaseMessageInteractiveComponent [] | undefined | The components that this command uses. These will be registered with the client when the command is initialized. | - | BaseCommand .components |
contexts | public | InteractionContextType [] | undefined | The contexts this command can be used in | - | BaseCommand .contexts |
defer | public | boolean | false | Whether the command response should be automatically deferred | - | BaseCommand .defer |
description? | public | string | undefined | A description of the command | - | BaseCommand .description |
descriptionLocalizations? | public | Record <string , string > | undefined | The localized description of the command See https://discord.com/developers/docs/interactions/application-commands#localization | - | BaseCommand .descriptionLocalizations |
ephemeral | public | boolean | false | Whether the command response should be ephemeral | - | BaseCommand .ephemeral |
guildIds? | public | string [] | undefined | The guild IDs this command should be deployed to (guild-specific deployment). If not set, the command is deployed globally. | - | BaseCommand .guildIds |
integrationTypes | public | ApplicationIntegrationType [] | undefined | The places this command can be used in | - | BaseCommand .integrationTypes |
name | abstract | string | undefined | The name of the command (e.g. "ping" for /ping) | - | BaseCommand .name |
nameLocalizations? | public | Record <string , string > | undefined | The localized name of the command See https://discord.com/developers/docs/interactions/application-commands#localization | - | BaseCommand .nameLocalizations |
options? | public | CommandOptions | undefined | The options that the user passes along with the command in Discord | - | - |
permission? | public | ArrayOrSingle <bigint > | undefined | The default permission that a user needs to have to use this command. This can be overridden by server admins. | - | BaseCommand .permission |
type | public | ApplicationCommandType | ApplicationCommandType.ChatInput | The type of command, either ChatInput, User, or Message. User and Message are context menu commands. Default ChatInput | BaseCommand .type | - |
Methods
autocomplete()
autocomplete(
interaction
):Promise
<void
>
The function that is called when the command's autocomplete is triggered.
Parameters
Parameter | Type | Description |
---|---|---|
interaction | AutocompleteInteraction | The 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
Parameter | Type | Description |
---|---|---|
interaction | CommandInteraction | The 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
Parameter | Type | Description |
---|---|---|
interaction | CommandInteraction | The 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
serializeOptions()
serializeOptions():
undefined
|APIApplicationCommandBasicOption
[]
Internal
Returns
undefined
| APIApplicationCommandBasicOption
[]