Class: Command<PreParseReturn, Options>
Defined in: projects/framework/src/lib/structures/Command.ts:36
Extends
AliasPiece<Options,"commands">
Type Parameters
| Type Parameter | Default type |
|---|---|
PreParseReturn | Args |
Options extends Options | Options |
Constructors
Constructor
new Command<
PreParseReturn,Options>(context:LoaderContext,options:Options):Command<PreParseReturn,Options>
Defined in: projects/framework/src/lib/structures/Command.ts:107
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
Properties
applicationCommandRegistry
readonlyapplicationCommandRegistry:ApplicationCommandRegistry
Defined in: projects/framework/src/lib/structures/Command.ts:93
The application command registry associated with this command.
Since
3.0.0
description
description:
string
Defined in: projects/framework/src/lib/structures/Command.ts:49
A basic summary about the command
Since
1.0.0
detailedDescription
detailedDescription:
DetailedDescriptionCommand
Defined in: projects/framework/src/lib/structures/Command.ts:61
Longer version of command's summary and how to use it
Since
1.0.0
fullCategory
readonlyfullCategory: readonlystring[]
Defined in: projects/framework/src/lib/structures/Command.ts:74
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.tsthen this property will be['General', 'Info']. - If the command is virtual, then this will be
[].
Since
2.0.0
preconditions
preconditions:
PreconditionContainerArray
Defined in: projects/framework/src/lib/structures/Command.ts:55
The preconditions to be run.
Since
1.0.0
rawName
rawName:
string
Defined in: projects/framework/src/lib/structures/Command.ts:43
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.
strategy
strategy:
IUnorderedStrategy
Defined in: projects/framework/src/lib/structures/Command.ts:80
The strategy to use for the lexer.
Since
1.0.0
typing
typing:
boolean
Defined in: projects/framework/src/lib/structures/Command.ts:87
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
Accessors
category
Get Signature
get category():
null|string
Defined in: projects/framework/src/lib/structures/Command.ts:167
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
parentCategory
Get Signature
get parentCategory():
null|string
Defined in: projects/framework/src/lib/structures/Command.ts:191
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
subCategory
Get Signature
get subCategory():
null|string
Defined in: projects/framework/src/lib/structures/Command.ts:179
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
Methods
autocompleteRun()?
optionalautocompleteRun(interaction:AutocompleteInteraction):unknown
Defined in: projects/framework/src/lib/structures/Command.ts:229
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 | The interaction that triggered the autocomplete. |
Returns
unknown
chatInputRun()?
optionalchatInputRun(interaction:ChatInputCommandInteraction,context:ChatInputCommandContext):unknown
Defined in: projects/framework/src/lib/structures/Command.ts:208
Executes the application command's logic.
Parameters
| Parameter | Type | Description |
|---|---|---|
interaction | ChatInputCommandInteraction | The interaction that triggered the command. |
context | ChatInputCommandContext | The chat input command run context. |
Returns
unknown
contextMenuRun()?
optionalcontextMenuRun(interaction:ContextMenuCommandInteraction,context:ContextMenuCommandContext):unknown
Defined in: projects/framework/src/lib/structures/Command.ts:215
Executes the context menu's logic.
Parameters
| Parameter | Type | Description |
|---|---|---|
interaction | ContextMenuCommandInteraction | The interaction that triggered the command. |
context | ContextMenuCommandContext | The context menu command run context. |
Returns
unknown
messagePreParse()
messagePreParse(
message:Message,parameters:string,context:MessageCommandContext):Awaitable<PreParseReturn>
Defined in: projects/framework/src/lib/structures/Command.ts:153
The message pre-parse method. This method can be overridden by plugins to define their own argument parser.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | Message | 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>
messageRun()?
optionalmessageRun(message:Message,args:PreParseReturn,context:MessageCommandContext):unknown
Defined in: projects/framework/src/lib/structures/Command.ts:201
Executes the message command's logic.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | Message | 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
parseConstructorPreConditions()
protectedparseConstructorPreConditions(options:CommandOptions):void
Defined in: projects/framework/src/lib/structures/Command.ts:360
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
parseConstructorPreConditionsCooldown()
protectedparseConstructorPreConditionsCooldown(options:CommandOptions):void
Defined in: projects/framework/src/lib/structures/Command.ts:408
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
parseConstructorPreConditionsNsfw()
protectedparseConstructorPreConditionsNsfw(options:CommandOptions):void
Defined in: projects/framework/src/lib/structures/Command.ts:372
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
parseConstructorPreConditionsRequiredClientPermissions()
protectedparseConstructorPreConditionsRequiredClientPermissions(options:CommandOptions):void
Defined in: projects/framework/src/lib/structures/Command.ts:390
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
parseConstructorPreConditionsRequiredUserPermissions()
protectedparseConstructorPreConditionsRequiredUserPermissions(options:CommandOptions):void
Defined in: projects/framework/src/lib/structures/Command.ts:399
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
parseConstructorPreConditionsRunIn()
protectedparseConstructorPreConditionsRunIn(options:CommandOptions):void
Defined in: projects/framework/src/lib/structures/Command.ts:381
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
registerApplicationCommands()?
optionalregisterApplicationCommands(registry:ApplicationCommandRegistry):Awaitable<void>
Defined in: projects/framework/src/lib/structures/Command.ts:247
Registers the application commands that should be handled by this command.
Parameters
| Parameter | Type | Description |
|---|---|---|
registry | ApplicationCommandRegistry | This command's registry |
Returns
Awaitable<void>
reload()
reload():
Promise<void>
Defined in: projects/framework/src/lib/structures/Command.ts:277
Reloads the piece by loading the same path in the store.
Returns
Promise<void>
Overrides
AliasPiece.reload
resolveConstructorPreConditionsRunType()
protectedresolveConstructorPreConditionsRunType(types:CommandRunInUnion):null| readonlyChannelType[]
Defined in: projects/framework/src/lib/structures/Command.ts:424
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.
supportsAutocompleteInteractions()
supportsAutocompleteInteractions():
this is AutocompleteCommand
Defined in: projects/framework/src/lib/structures/Command.ts:273
Type-guard that ensures the command supports handling autocomplete interactions by checking if the handler for it is present
Returns
this is AutocompleteCommand
supportsChatInputCommands()
supportsChatInputCommands():
this is ChatInputCommand
Defined in: projects/framework/src/lib/structures/Command.ts:259
Type-guard that ensures the command supports chat input commands by checking if the handler for it is present
Returns
this is ChatInputCommand
supportsContextMenuCommands()
supportsContextMenuCommands():
this is ContextMenuCommand
Defined in: projects/framework/src/lib/structures/Command.ts:266
Type-guard that ensures the command supports context menu commands by checking if the handler for it is present
Returns
this is ContextMenuCommand
supportsMessageCommands()
supportsMessageCommands():
this is MessageCommand
Defined in: projects/framework/src/lib/structures/Command.ts:252
Type-guard that ensures the command supports message commands by checking if the handler for it is present
Returns
this is MessageCommand
toJSON()
toJSON():
CommandJSON
Defined in: projects/framework/src/lib/structures/Command.ts:234
Defines the JSON.stringify behavior of the command.
Returns
Overrides
AliasPiece.toJSON
runInTypeIsSpecificsObject()
staticrunInTypeIsSpecificsObject(types:CommandRunInUnion|CommandSpecificRunIn):types is CommandSpecificRunIn
Defined in: projects/framework/src/lib/structures/Command.ts:471
Parameters
| Parameter | Type |
|---|---|
types | CommandRunInUnion | CommandSpecificRunIn |
Returns
types is CommandSpecificRunIn