Skip to main content

Class: SubCommandPluginCommand<ArgType, CommandType>

@sapphire/plugin-subcommands.SubCommandPluginCommand

Type parameters

NameType
ArgTypeextends Args = Args
CommandTypeextends Command<ArgType> = Command<ArgType>

Hierarchy

  • Command<ArgType>

    โ†ณ SubCommandPluginCommand

Constructors

constructor

โ€ข new SubCommandPluginCommand<ArgType, CommandType>(context, options)

Type parameters

NameType
ArgTypeextends Args<ArgType> = Args
CommandTypeextends Command<ArgType, CommandOptions, CommandType> = Command<ArgType, CommandOptions>

Parameters

NameType
contextPieceContext
optionsSubCommandPluginCommandOptions<ArgType, Command<ArgType, CommandOptions>>

Overrides

Command<ArgType\>.constructor

Defined in

projects/plugins/packages/subcommands/src/lib/SubCommandPluginCommand.ts:8

Properties

aliases

โ€ข aliases: readonly string[]

The aliases for the piece.

Inherited from

Command.aliases

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:690


description

โ€ข description: string

A basic summary about the command

since 1.0.0

Inherited from

Command.description

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:770


detailedDescription

โ€ข detailedDescription: string

Longer version of command's summary and how to use it

since 1.0.0

Inherited from

Command.detailedDescription

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:780


enabled

โ€ข enabled: boolean

Whether or not the piece is enabled.

Inherited from

Command.enabled

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:447


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 for how you setup 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

Inherited from

Command.fullCategory

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:789


lexer

โ€ข Private lexer: Lexer

The lexer to be used for command parsing

since 1.0.0

Inherited from

Command.lexer

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:806


location

โ€ข Readonly location: PieceLocation

The location metadata for the piece's file.

Inherited from

Command.location

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:439


name

โ€ข Readonly name: string

The name of the piece.

Inherited from

Command.name

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:443


options

โ€ข Readonly options: CommandOptions

The raw options passed to this {@link Piece}

Inherited from

Command.options

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:451


preconditions

โ€ข preconditions: PreconditionContainerArray

The preconditions to be run.

since 1.0.0

Inherited from

Command.preconditions

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:775


store

โ€ข Readonly store: Store<Piece<PieceOptions>>

The store that contains the piece.

Inherited from

Command.store

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:435


strategy

โ€ข strategy: UnorderedStrategy

The strategy to use for the lexer.

since 1.0.0

Inherited from

Command.strategy

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:794


subCommands

โ€ข Readonly subCommands: null | SubCommandManager<ArgType, CommandType>

Defined in

projects/plugins/packages/subcommands/src/lib/SubCommandPluginCommand.ts:6


typing

โ€ข typing: boolean

If {@link 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

Inherited from

Command.typing

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:800

Accessors

category

โ€ข get category(): null | string

The main category for the command, if any.

This getter retrieves the first value of {@link Command.fullCategory}, if it has at least one item, otherwise it returns null.

note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.

Returns

null | string

Inherited from

Command.category

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:828


container

โ€ข get container(): Container

A reference to the {@link Container} object for ease of use.

see container

Returns

Container

Inherited from

Command.container

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:457


parentCategory

โ€ข get parentCategory(): null | string

The parent category for the command.

This getter retrieves the last value of {@link Command.fullCategory}, if it has at least one item, otherwise it returns null.

note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.

Returns

null | string

Inherited from

Command.parentCategory

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:846


subCategory

โ€ข get subCategory(): null | string

The sub-category for the command, if any.

This getter retrieves the second value of {@link Command.fullCategory}, if it has at least two items, otherwise it returns null.

note You can set {@link Command.Options.fullCategory} to override the built-in category resolution.

Returns

null | string

Inherited from

Command.subCategory

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:837

Methods

messageRun

โ–ธ messageRun(message, args, context): unknown

Parameters

NameType
messageMessage<boolean>
argsArgType
contextCommandContext

Returns

unknown

Overrides

Command.messageRun

Defined in

projects/plugins/packages/subcommands/src/lib/SubCommandPluginCommand.ts:14


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

Command.onLoad

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:462


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

Command.onUnload

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:467


parseConstructorPreConditions

โ–ธ Protected parseConstructorPreConditions(options): void

Parses the command's options and processes them, calling {@link Command#parseConstructorPreConditionsRunIn}, {@link Command#parseConstructorPreConditionsNsfw}, {@link Command#parseConstructorPreConditionsRequiredClientPermissions}, and {@link Command#parseConstructorPreConditionsCooldown}.

since 2.0.0

Parameters

NameTypeDescription
optionsCommandOptionsThe command options given from the constructor.

Returns

void

Inherited from

Command.parseConstructorPreConditions

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:865


parseConstructorPreConditionsCooldown

โ–ธ Protected parseConstructorPreConditionsCooldown(options): void

Appends the Cooldown precondition when {@link Command.Options.cooldownLimit} and {@link Command.Options.cooldownDelay} are both non-zero.

Parameters

NameTypeDescription
optionsCommandOptionsThe command options given from the constructor.

Returns

void

Inherited from

Command.parseConstructorPreConditionsCooldown

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:895


parseConstructorPreConditionsNsfw

โ–ธ Protected parseConstructorPreConditionsNsfw(options): void

Appends the NSFW precondition if {@link Command.Options.nsfw} is set to true.

Parameters

NameTypeDescription
optionsCommandOptionsThe command options given from the constructor.

Returns

void

Inherited from

Command.parseConstructorPreConditionsNsfw

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:870


parseConstructorPreConditionsRequiredClientPermissions

โ–ธ Protected parseConstructorPreConditionsRequiredClientPermissions(options): void

Appends the ClientPermissions precondition when {@link Command.Options.requiredClientPermissions} resolves to a non-zero bitfield.

Parameters

NameTypeDescription
optionsCommandOptionsThe command options given from the constructor.

Returns

void

Inherited from

Command.parseConstructorPreConditionsRequiredClientPermissions

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:883


parseConstructorPreConditionsRequiredUserPermissions

โ–ธ Protected parseConstructorPreConditionsRequiredUserPermissions(options): void

Appends the UserPermissions precondition when {@link Command.Options.requiredUserPermissions} resolves to a non-zero bitfield.

Parameters

NameTypeDescription
optionsCommandOptionsThe command options given from the constructor.

Returns

void

Inherited from

Command.parseConstructorPreConditionsRequiredUserPermissions

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:889


parseConstructorPreConditionsRunIn

โ–ธ Protected parseConstructorPreConditionsRunIn(options): void

Appends the DMOnly, GuildOnly, NewsOnly, and TextOnly preconditions based on the values passed in {@link Command.Options.runIn}, optimizing in specific cases (NewsOnly + TextOnly = GuildOnly; DMOnly + GuildOnly = null), defaulting to null, which doesn't add a precondition.

Parameters

NameTypeDescription
optionsCommandOptionsThe command options given from the constructor.

Returns

void

Inherited from

Command.parseConstructorPreConditionsRunIn

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:877


preParse

โ–ธ preParse(message, parameters, context): Awaitable<ArgType>

The pre-parse method. This method can be overridden by plugins to define their own argument parser.

Parameters

NameTypeDescription
messageMessage<boolean>The message that triggered the command.
parametersstringThe raw parameters as a single string.
contextCommandContextThe command-context used in this execution.

Returns

Awaitable<ArgType>

Inherited from

Command.preParse

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:819


reload

โ–ธ reload(): Promise<void>

Reloads the piece by loading the same path in the store.

Returns

Promise<void>

Inherited from

Command.reload

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:475


run

โ–ธ Optional run(message, args, context): unknown

Executes the command's logic.

deprecated Use messageRun instead.

Parameters

NameTypeDescription
messageMessage<boolean>The message that triggered the command.
argsArgTypeThe value returned by {@link Command.preParse}, by default an instance of {@link Args}.
contextCommandContext-

Returns

unknown

Inherited from

Command.run

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:905


toJSON

โ–ธ toJSON(): CommandJSON

Defines the JSON.stringify behavior of the command.

Returns

CommandJSON

Inherited from

Command.toJSON

Defined in

node_modules/@sapphire/framework/dist/index.d.ts:856


unload

โ–ธ unload(): Promise<void>

Unloads and disables the piece.

Returns

Promise<void>

Inherited from

Command.unload

Defined in

node_modules/@sapphire/pieces/dist/index.d.ts:471