Command
Represents a standard command that the user creates
Extends
Constructors
new Command()
new Command():
Command
Returns
Inherited from
Properties
Property | Modifier | Type | Default value | Description | Overrides | Inherited from |
---|---|---|---|---|---|---|
components | public | () => BaseComponent [] | [] | The components that the command is able to use. You pass these here so the handler can listen for them.. | - | BaseCommand .components |
contexts | public | InteractionContextType [] | undefined | Beta The contexts this command can be used in API types are not finalized | - | BaseCommand .contexts |
defer | public | boolean | false | Whether the command response should be automatically deferred | - | BaseCommand .defer |
description | abstract | string | undefined | A description of the command | - | BaseCommand .description |
ephemeral | public | boolean | false | Whether the command response should be ephemeral | - | BaseCommand .ephemeral |
integrationTypes | public | ApplicationIntegrationType [] | undefined | Beta The places this command can be used in API types are not finalized | - | BaseCommand .integrationTypes |
modals | public | () => Modal [] | [] | All the modals that the command is able to use. You pass these here so the handler can listen for them. | - | BaseCommand .modals |
name | abstract | string | undefined | The name of the command (e.g. "ping" for /ping) | - | BaseCommand .name |
options? | public | CommandOptions | undefined | The options that the user passes along with the command in Discord | - | - |
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.
run()
abstract
run(interaction
):Promise
<void
>
The function that is called when the command is ran
Parameters
Parameter | Type | Description |
---|---|---|
interaction | CommandInteraction | The interaction that triggered the command |
Returns
Promise
<void
>
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
|CommandOptions
Internal
Returns
undefined
| CommandOptions