Class: Command<PreParseReturn, O>
The piece to be stored in AliasStore instances.
Type parameters
Name | Type |
---|---|
PreParseReturn | Args |
O | extends Options = Options |
Hierarchy
AliasPiece
<O
>↳
Command
Constructors
constructor
• new Command<PreParseReturn
, O
>(context
, options?
)
Since
1.0.0
Type parameters
Name | Type |
---|---|
PreParseReturn | Args |
O | extends CommandOptions <O > = CommandOptions |
Parameters
Name | Type | Description |
---|---|---|
context | PieceContext | The context. |
options | O | Optional Command settings. |
Overrides
Defined in
projects/framework/src/lib/structures/Command.ts:88
Properties
aliases
• aliases: readonly string
[]
The aliases for the piece.
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:687
applicationCommandRegistry
• Readonly
applicationCommandRegistry: ApplicationCommandRegistry
The application command registry associated with this command.
Since
3.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:74
description
• description: string
A basic summary about the command
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:33
detailedDescription
• detailedDescription: DetailedDescriptionCommand
Longer version of command's summary and how to use it
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:45
enabled
• enabled: boolean
Whether or not the piece is enabled.
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:450
fullCategory
• Readonly
fullCategory: readonly string
[]
The full category for the command. Either an array of strings that denote every (sub)folder the command is in,
or null
if it could not be resolved automatically.
If this is null
with how you set up your code then you can overwrite how the fullCategory
is resolved by
extending this class and overwriting the assignment in the constructor.
Since
2.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:55
lexer
• Private
lexer: Lexer
The lexer to be used for command parsing
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:81
location
• Readonly
location: PieceLocation
The location metadata for the piece's file.
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:442
name
• Readonly
name: string
The name of the piece.
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:446
options
• Readonly
options: O
The raw options passed to this Piece
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:454
preconditions
• preconditions: PreconditionContainerArray
The preconditions to be run.
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:39
store
• store: CommandStore
The CommandStore that contains this Command.
Overrides
Defined in
projects/framework/src/lib/structures/Command.ts:27
strategy
• strategy: IUnorderedStrategy
The strategy to use for the lexer.
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:61
typing
• typing: boolean
If SapphireClient.typing is true, it can be overridden for a specific command using this property, set via its options. Otherwise, this property will be ignored.
Default
true
Defined in
projects/framework/src/lib/structures/Command.ts:68
Accessors
category
• get
category(): null
| string
The main category for the command, if any.
This getter retrieves the first value of fullCategory, if it has at least one item, otherwise it
returns null
.
Note
You can set fullCategory to override the built-in category resolution.
Returns
null
| string
Defined in
projects/framework/src/lib/structures/Command.ts:145
container
• get
container(): Container
A reference to the Container object for ease of use.
See
container
Returns
Container
Inherited from
AliasPiece.container
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:460
parentCategory
• get
parentCategory(): null
| string
The parent category for the command.
This getter retrieves the last value of fullCategory, if it has at least one item, otherwise it
returns null
.
Note
You can set fullCategory to override the built-in category resolution.
Returns
null
| string
Defined in
projects/framework/src/lib/structures/Command.ts:169
subCategory
• get
subCategory(): null
| string
The sub-category for the command, if any.
This getter retrieves the second value of fullCategory, if it has at least two items, otherwise
it returns null
.
Note
You can set fullCategory to override the built-in category resolution.
Returns
null
| string
Defined in
projects/framework/src/lib/structures/Command.ts:157
Methods
autocompleteRun
▸ Optional
autocompleteRun(interaction
): unknown
Executes the autocomplete logic.
You may use this, or alternatively create an interaction handler to handle autocomplete interactions. Keep in mind that commands take precedence over interaction handlers.
Parameters
Name | Type | Description |
---|---|---|
interaction | AutocompleteInteraction <CacheType > | The interaction that triggered the autocomplete. |
Returns
unknown
Defined in
projects/framework/src/lib/structures/Command.ts:207
chatInputRun
▸ Optional
chatInputRun(interaction
, context
): unknown
Executes the application command's logic.
Parameters
Name | Type | Description |
---|---|---|
interaction | ChatInputCommandInteraction <CacheType > | The interaction that triggered the command. |
context | ChatInputCommandContext | The chat input command run context. |
Returns
unknown
Defined in
projects/framework/src/lib/structures/Command.ts:186
contextMenuRun
▸ Optional
contextMenuRun(interaction
, context
): unknown
Executes the context menu's logic.
Parameters
Name | Type | Description |
---|---|---|
interaction | ContextMenuCommandInteraction <CacheType > | The interaction that triggered the command. |
context | ContextMenuCommandContext | The context menu command run context. |
Returns
unknown
Defined in
projects/framework/src/lib/structures/Command.ts:193
messagePreParse
▸ messagePreParse(message
, parameters
, context
): Awaitable
<PreParseReturn
>
The message pre-parse method. This method can be overridden by plugins to define their own argument parser.
Parameters
Name | Type | Description |
---|---|---|
message | Message <boolean > | The message that triggered the command. |
parameters | string | The raw parameters as a single string. |
context | MessageCommandContext | The command-context used in this execution. |
Returns
Awaitable
<PreParseReturn
>
Defined in
projects/framework/src/lib/structures/Command.ts:131
messageRun
▸ Optional
messageRun(message
, args
, context
): unknown
Executes the message command's logic.
Parameters
Name | Type | Description |
---|---|---|
message | Message <boolean > | The message that triggered the command. |
args | PreParseReturn | The value returned by messagePreParse, by default an instance of Args. |
context | MessageCommandContext | The context in which the command was executed. |
Returns
unknown
Defined in
projects/framework/src/lib/structures/Command.ts:179
onLoad
▸ onLoad(): unknown
Per-piece listener that is called when the piece is loaded into the store. Useful to set-up asynchronous initialization tasks.
Returns
unknown
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:465
onUnload
▸ onUnload(): unknown
Per-piece listener that is called when the piece is unloaded from the store. Useful to set-up clean-up tasks.
Returns
unknown
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:470
parseConstructorPreConditions
▸ Protected
parseConstructorPreConditions(options
): void
Parses the command's options and processes them, calling parseConstructorPreConditionsRunIn, parseConstructorPreConditionsNsfw, parseConstructorPreConditionsRequiredClientPermissions, and parseConstructorPreConditionsCooldown.
Since
2.0.0
Parameters
Name | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:338
parseConstructorPreConditionsCooldown
▸ Protected
parseConstructorPreConditionsCooldown(options
): void
Appends the Cooldown
precondition when cooldownLimit and
cooldownDelay are both non-zero.
Parameters
Name | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:394
parseConstructorPreConditionsNsfw
▸ Protected
parseConstructorPreConditionsNsfw(options
): void
Appends the NSFW
precondition if nsfw is set to true.
Parameters
Name | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:350
parseConstructorPreConditionsRequiredClientPermissions
▸ Protected
parseConstructorPreConditionsRequiredClientPermissions(options
): void
Appends the ClientPermissions
precondition when requiredClientPermissions resolves to a
non-zero bitfield.
Parameters
Name | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:370
parseConstructorPreConditionsRequiredUserPermissions
▸ Protected
parseConstructorPreConditionsRequiredUserPermissions(options
): void
Appends the UserPermissions
precondition when requiredUserPermissions resolves to a
non-zero bitfield.
Parameters
Name | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:382
parseConstructorPreConditionsRunIn
▸ Protected
parseConstructorPreConditionsRunIn(options
): void
Appends the DMOnly
, GuildOnly
, NewsOnly
, and TextOnly
preconditions based on the values passed in
runIn, optimizing in specific cases (NewsOnly
+ TextOnly
= GuildOnly
; DMOnly
+
GuildOnly
= null
), defaulting to null
, which doesn't add a precondition.
Parameters
Name | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:360
registerApplicationCommands
▸ Optional
registerApplicationCommands(registry
): Awaitable
<void
>
Registers the application commands that should be handled by this command.
Parameters
Name | Type | Description |
---|---|---|
registry | ApplicationCommandRegistry | This command's registry |
Returns
Awaitable
<void
>
Defined in
projects/framework/src/lib/structures/Command.ts:225
reload
▸ reload(): Promise
<void
>
Reloads the piece by loading the same path in the store.
Returns
Promise
<void
>
Overrides
Defined in
projects/framework/src/lib/structures/Command.ts:255
resolveConstructorPreConditionsRunType
▸ Private
resolveConstructorPreConditionsRunType(runIn
): null
| PreconditionContainerArray
| CommandPreConditions
Parameters
Name | Type |
---|---|
runIn | undefined | null | CommandOptionsRunType | CommandOptionsRunTypeEnum | readonly (CommandOptionsRunType | CommandOptionsRunTypeEnum )[] |
Returns
null
| PreconditionContainerArray
| CommandPreConditions
Defined in
projects/framework/src/lib/structures/Command.ts:414
supportsAutocompleteInteractions
▸ supportsAutocompleteInteractions(): this is AutocompleteCommand
Type-guard that ensures the command supports handling autocomplete interactions by checking if the handler for it is present
Returns
this is AutocompleteCommand
Defined in
projects/framework/src/lib/structures/Command.ts:251
supportsChatInputCommands
▸ supportsChatInputCommands(): this is ChatInputCommand
Type-guard that ensures the command supports chat input commands by checking if the handler for it is present
Returns
this is ChatInputCommand
Defined in
projects/framework/src/lib/structures/Command.ts:237
supportsContextMenuCommands
▸ supportsContextMenuCommands(): this is ContextMenuCommand
Type-guard that ensures the command supports context menu commands by checking if the handler for it is present
Returns
this is ContextMenuCommand
Defined in
projects/framework/src/lib/structures/Command.ts:244
supportsMessageCommands
▸ supportsMessageCommands(): this is MessageCommand
Type-guard that ensures the command supports message commands by checking if the handler for it is present
Returns
this is MessageCommand
Defined in
projects/framework/src/lib/structures/Command.ts:230
toJSON
▸ toJSON(): CommandJSON
Defines the JSON.stringify behavior of the command.
Returns
Overrides
Defined in
projects/framework/src/lib/structures/Command.ts:212
unload
▸ unload(): Promise
<void
>
Unloads and disables the piece.
Returns
Promise
<void
>
Inherited from
Defined in
node_modules/@sapphire/pieces/dist/index.d.ts:474