Skip to main content

Interface: SubcommandMappingMethod

Defined in: projects/plugins/packages/subcommands/src/lib/types/SubcommandMappings.ts:25

Describes how a subcommand method maps to the actual implementation of that subcommand.

Extends

  • SubcommandMappingBase.Pick<Command.Options, "preconditions" | "runIn" | "nsfw" | "cooldownLimit" | "cooldownDelay" | "cooldownScope" | "cooldownFilteredUsers" | "requiredClientPermissions" | "requiredUserPermissions">

Properties

chatInputRun?

optional chatInputRun: string | (interaction: ChatInputCommandInteraction, context: ChatInputCommandContext) => unknown

Defined in: projects/plugins/packages/subcommands/src/lib/types/SubcommandMappings.ts:93

The class method to call when invoking this subcommand through a chat input command, or a callback implementation of the subcommand.

Note that when providing a string you have to first define the method that will be called within your function before this will allow any values. This is to ensure that the property is strictly typed to the context of the class.

Type declaration

string

(interaction: ChatInputCommandInteraction, context: ChatInputCommandContext) => unknown

Executes the application command's logic.

Parameters

ParameterTypeDescription
interactionChatInputCommandInteractionThe interaction that triggered the command.
contextChatInputCommandContextThe chat input command run context.

Returns

unknown

Examples

chatInputRun: 'runModeratorConfig'
chatInputRun(interaction: Subcommand.Interaction) {
return interaction.reply(`<@${interaction.user.id}> has been granted moderator`);
}

cooldownDelay?

optional cooldownDelay: number

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1232

The time in milliseconds for the cooldown entries to reset, if set to a non-zero value alongside CommandOptions.cooldownLimit, the Cooldown precondition will be added to the list.

Since

2.0.0

Default

0

Inherited from

Pick.cooldownDelay


cooldownFilteredUsers?

optional cooldownFilteredUsers: string[]

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1245

The users that are exempt from the Cooldown precondition. Use this to filter out someone like a bot owner

Since

2.0.0

Default

undefined

Inherited from

Pick.cooldownFilteredUsers


cooldownLimit?

optional cooldownLimit: number

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1226

The amount of entries the cooldown can have before filling up, if set to a non-zero value alongside CommandOptions.cooldownDelay, the Cooldown precondition will be added to the list.

Since

2.0.0

Default

1

Inherited from

Pick.cooldownLimit


cooldownScope?

optional cooldownScope: BucketScope

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1238

The scope of the cooldown entries.

Since

2.0.0

Default

BucketScope.User

Inherited from

Pick.cooldownScope


default?

optional default: boolean

Defined in: projects/plugins/packages/subcommands/src/lib/types/SubcommandMappings.ts:51

Whether this is the default subcommand when none is provided.

Note that this is effectively only used for Message based subcommand (those implementing SubcommandMappingMethod.messageRun) because the subcommand is always provided for chat input commands.


messageRun?

optional messageRun: string | (message: Message, args: Args, context: MessageCommandContext) => unknown

Defined in: projects/plugins/packages/subcommands/src/lib/types/SubcommandMappings.ts:72

The class method to call when invoking this subcommand through a message command, or a callback implementation of the subcommand.

Note that when providing a string you have to first define the method that will be called within your function before this will allow any values. This is to ensure that the property is strictly typed to the context of the class.

Type declaration

string

(message: Message, args: Args, context: MessageCommandContext) => unknown

Executes the message command's logic.

Parameters

ParameterTypeDescription
messageMessageThe message that triggered the command.
argsArgsThe value returned by Command.messagePreParse, by default an instance of Args.
contextMessageCommandContextThe context in which the command was executed.

Returns

unknown

Examples

messageRun: 'runAdminConfig'
runAdminConfig(message: Message) {
return message.reply(`<@${message.author.id}> has been granted admin`);
}

name

name: string

Defined in: projects/plugins/packages/subcommands/src/lib/types/SubcommandMappings.ts:14

The name of this subcommand, or subcommand group

Inherited from

SubcommandMappingBase.name


nsfw?

optional nsfw: boolean

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1220

Sets whether the command should be treated as NSFW. If set to true, the NSFW precondition will be added to the list.

Since

2.0.0

Default

false

Inherited from

Pick.nsfw


preconditions?

optional preconditions: readonly PreconditionEntryResolvable[]

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1202

The Preconditions to be run, accepts an array of their names.

Seealso

PreconditionContainerArray

Since

1.0.0

Default

[]

Inherited from

Pick.preconditions


requiredClientPermissions?

optional requiredClientPermissions: PermissionResolvable

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1251

The required permissions for the client.

Since

2.0.0

Default

0

Inherited from

Pick.requiredClientPermissions


requiredUserPermissions?

optional requiredUserPermissions: PermissionResolvable

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1257

The required permissions for the user.

Since

2.0.0

Default

0

Inherited from

Pick.requiredUserPermissions


runIn?

optional runIn: CommandRunInUnion | CommandSpecificRunIn

Defined in: node_modules/@sapphire/framework/dist/esm/index.d.mts:1269

The channels the command should run in. If set to null, no precondition entry will be added. Some optimizations are applied when given an array to reduce the amount of preconditions run (e.g. 'GUILD_TEXT' and 'GUILD_NEWS' becomes 'GUILD_ANY', and if both 'DM' and 'GUILD_ANY' are defined, then no precondition entry is added as it runs in all channels).

This can be both CommandRunInUnion which will have the same precondition apply to all the types of commands, or you can use CommandSpecificRunIn to apply different preconditions to different types of commands.

Since

2.0.0

Default

null

Inherited from

Pick.runIn


type?

optional type: "method"

Defined in: projects/plugins/packages/subcommands/src/lib/types/SubcommandMappings.ts:43

This subcommand mapping describes a subcommand method and can therefore only ever be 'method'

Overrides

SubcommandMappingBase.type