Class: Command<PreParseReturn, Options>
Extends
AliasPiece
<Options
,"commands"
>
Type Parameters
Type Parameter | Default type |
---|---|
PreParseReturn | Args |
Options extends Options | Options |
Constructors
new Command()
new Command<
PreParseReturn
,Options
>(context
:LoaderContext
,options
:Options
):Command
<PreParseReturn
,Options
>
Parameters
Parameter | Type | Description |
---|---|---|
context | LoaderContext | The context. |
options | Options | Optional Command settings. |
Returns
Command
<PreParseReturn
, Options
>
Since
1.0.0
Overrides
AliasPiece<Options, 'commands'>.constructor
Defined in
projects/framework/src/lib/structures/Command.ts:107
Properties
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:93
description
description:
string
A basic summary about the command
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:49
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:61
fullCategory
readonly
fullCategory: readonlystring
[]
The full category for the command, can be overridden by setting the Command.Options.fullCategory option.
If Command.Options.fullCategory is not set, then:
- If the command is loaded from the file system, then this is the command's location in file system relative to
the commands folder. For example, if you have a command located at
commands/General/Information/info.ts
then this property will be['General', 'Info']
. - If the command is virtual, then this will be
[]
.
Since
2.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:74
preconditions
preconditions:
PreconditionContainerArray
The preconditions to be run.
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:55
rawName
rawName:
string
The raw name of the command as provided through file name or constructor options.
This is exactly what is set by the developer, completely unmodified internally by the framework.
Unlike the name
which gets lowercased for storing it uniquely in the CommandStore.
Defined in
projects/framework/src/lib/structures/Command.ts:43
strategy
strategy:
IUnorderedStrategy
The strategy to use for the lexer.
Since
1.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:80
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:87
Accessors
category
Get Signature
get category():
null
|string
The main category for the command, if any.
This getter retrieves the first value of Command.fullCategory, if it has at least one item, otherwise it
returns null
.
Note
You can set Command.Options.fullCategory to override the built-in category resolution.
Returns
null
| string
Defined in
projects/framework/src/lib/structures/Command.ts:167
parentCategory
Get Signature
get parentCategory():
null
|string
The parent category for the command.
This getter retrieves the last value of Command.fullCategory, if it has at least one item, otherwise it
returns null
.
Note
You can set Command.Options.fullCategory to override the built-in category resolution.
Returns
null
| string
Defined in
projects/framework/src/lib/structures/Command.ts:191
subCategory
Get Signature
get subCategory():
null
|string
The sub-category for the command, if any.
This getter retrieves the second value of Command.fullCategory, if it has at least two items, otherwise
it returns null
.
Note
You can set Command.Options.fullCategory to override the built-in category resolution.
Returns
null
| string
Defined in
projects/framework/src/lib/structures/Command.ts:179
Methods
autocompleteRun()?
optional
autocompleteRun(interaction
:AutocompleteInteraction
<CacheType
>):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
Parameter | Type | Description |
---|---|---|
interaction | AutocompleteInteraction <CacheType > | The interaction that triggered the autocomplete. |
Returns
unknown
Defined in
projects/framework/src/lib/structures/Command.ts:229
chatInputRun()?
optional
chatInputRun(interaction
:ChatInputCommandInteraction
<CacheType
>,context
:ChatInputCommandContext
):unknown
Executes the application command's logic.
Parameters
Parameter | 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:208
contextMenuRun()?
optional
contextMenuRun(interaction
:ContextMenuCommandInteraction
<CacheType
>,context
:ContextMenuCommandContext
):unknown
Executes the context menu's logic.
Parameters
Parameter | 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:215
messagePreParse()
messagePreParse(
message
:Message
<boolean
>,parameters
:string
,context
:MessageCommandContext
):Awaitable
<PreParseReturn
>
The message pre-parse method. This method can be overridden by plugins to define their own argument parser.
Parameters
Parameter | 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:153
messageRun()?
optional
messageRun(message
:Message
<boolean
>,args
:PreParseReturn
,context
:MessageCommandContext
):unknown
Executes the message command's logic.
Parameters
Parameter | Type | Description |
---|---|---|
message | Message <boolean > | The message that triggered the command. |
args | PreParseReturn | The value returned by Command.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:201
parseConstructorPreConditions()
protected
parseConstructorPreConditions(options
:CommandOptions
):void
Parses the command's options and processes them, calling Command#parseConstructorPreConditionsRunIn, Command#parseConstructorPreConditionsNsfw, Command#parseConstructorPreConditionsRequiredClientPermissions, and Command#parseConstructorPreConditionsCooldown.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Since
2.0.0
Defined in
projects/framework/src/lib/structures/Command.ts:360
parseConstructorPreConditionsCooldown()
protected
parseConstructorPreConditionsCooldown(options
:CommandOptions
):void
Appends the Cooldown
precondition when Command.Options.cooldownLimit and
Command.Options.cooldownDelay are both non-zero.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:408
parseConstructorPreConditionsNsfw()
protected
parseConstructorPreConditionsNsfw(options
:CommandOptions
):void
Appends the NSFW
precondition if Command.Options.nsfw is set to true.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:372
parseConstructorPreConditionsRequiredClientPermissions()
protected
parseConstructorPreConditionsRequiredClientPermissions(options
:CommandOptions
):void
Appends the ClientPermissions
precondition when Command.Options.requiredClientPermissions resolves to a
non-zero bitfield.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:390
parseConstructorPreConditionsRequiredUserPermissions()
protected
parseConstructorPreConditionsRequiredUserPermissions(options
:CommandOptions
):void
Appends the UserPermissions
precondition when Command.Options.requiredUserPermissions resolves to a
non-zero bitfield.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:399
parseConstructorPreConditionsRunIn()
protected
parseConstructorPreConditionsRunIn(options
:CommandOptions
):void
Appends the RunIn
precondition based on the values passed, defaulting to null
, which doesn't add a
precondition.
Parameters
Parameter | Type | Description |
---|---|---|
options | CommandOptions | The command options given from the constructor. |
Returns
void
Defined in
projects/framework/src/lib/structures/Command.ts:381
registerApplicationCommands()?
optional
registerApplicationCommands(registry
:ApplicationCommandRegistry
):Awaitable
<void
>
Registers the application commands that should be handled by this command.
Parameters
Parameter | Type | Description |
---|---|---|
registry | ApplicationCommandRegistry | This command's registry |
Returns
Awaitable
<void
>
Defined in
projects/framework/src/lib/structures/Command.ts:247
reload()
reload():
Promise
<void
>
Reloads the piece by loading the same path in the store.
Returns
Promise
<void
>
Overrides
AliasPiece.reload
Defined in
projects/framework/src/lib/structures/Command.ts:277
resolveConstructorPreConditionsRunType()
protected
resolveConstructorPreConditionsRunType(types
:CommandRunInUnion
):null
| readonlyChannelType
[]
Resolves the Command.Options.runIn option into a Command.RunInTypes array.
Parameters
Parameter | Type | Description |
---|---|---|
types | CommandRunInUnion | The types to resolve. |
Returns
null
| readonly ChannelType
[]
The resolved types, or null
if no types were resolved.
Defined in
projects/framework/src/lib/structures/Command.ts:424
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:273
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:259
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:266
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:252
toJSON()
toJSON():
CommandJSON
Defines the JSON.stringify behavior of the command.
Returns
Overrides
AliasPiece.toJSON
Defined in
projects/framework/src/lib/structures/Command.ts:234
runInTypeIsSpecificsObject()
static
runInTypeIsSpecificsObject(types
:CommandRunInUnion
|CommandSpecificRunIn
):types is CommandSpecificRunIn
Parameters
Parameter | Type |
---|---|
types | CommandRunInUnion | CommandSpecificRunIn |
Returns
types is CommandSpecificRunIn