Skip to content

CommandInteractionOptionResolver

Defined in: resolvers/CommandOptionResolver.ts:41

Resolves typed option values from a slash command or autocomplete interaction, including subcommand/subcommand-group hoisting and lookups into resolved entity data (users, members, roles, channels, attachments). Available as interaction.options on ChatInputCommandInteraction and AutocompleteInteraction.

new CommandInteractionOptionResolver(options, resolved): CommandInteractionOptionResolver

Defined in: resolvers/CommandOptionResolver.ts:60

APIApplicationCommandInteractionDataOption<ApplicationCommand | ApplicationCommandAutocomplete>[] | undefined

APIInteractionDataResolved | undefined

CommandInteractionOptionResolver

get data(): APIApplicationCommandInteractionDataOption<ApplicationCommand | ApplicationCommandAutocomplete>[]

Defined in: resolvers/CommandOptionResolver.ts:97

APIApplicationCommandInteractionDataOption<ApplicationCommand | ApplicationCommandAutocomplete>[]

get<T>(name, type, required?): Extract<APIApplicationCommandInteractionDataAttachmentOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataBooleanOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataChannelOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataMentionableOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataRoleOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataStringOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataUserOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataIntegerOption<ApplicationCommand>, { type: T; }> | Extract<APIApplicationCommandInteractionDataNumberOption<ApplicationCommand>, { type: T; }> | Extract<APIApplicationCommandInteractionDataSubcommandGroupOption<ApplicationCommand>, { type: T; }> | Extract<APIApplicationCommandInteractionDataSubcommandOption<ApplicationCommand>, { type: T; }> | null

Defined in: resolvers/CommandOptionResolver.ts:109

Gets an option by its name.

T extends ApplicationCommandOptionType

string

The name of the option.

T

The expected type of the option.

boolean = false

Whether to throw an error if the option is not found.

Extract<APIApplicationCommandInteractionDataAttachmentOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataBooleanOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataChannelOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataMentionableOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataRoleOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataStringOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataUserOption, { type: T; }> | Extract<APIApplicationCommandInteractionDataIntegerOption<ApplicationCommand>, { type: T; }> | Extract<APIApplicationCommandInteractionDataNumberOption<ApplicationCommand>, { type: T; }> | Extract<APIApplicationCommandInteractionDataSubcommandGroupOption<ApplicationCommand>, { type: T; }> | Extract<APIApplicationCommandInteractionDataSubcommandOption<ApplicationCommand>, { type: T; }> | null

The option, if found.


getAttachment(name, required?): APIAttachment | null

Defined in: resolvers/CommandOptionResolver.ts:295

Gets an attachment option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

APIAttachment | null

The value of the option, or null if not set and not required.

getAttachment(name, required): APIAttachment

Defined in: resolvers/CommandOptionResolver.ts:296

Gets an attachment option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

APIAttachment

The value of the option, or null if not set and not required.


getBoolean(name, required?): boolean | null

Defined in: resolvers/CommandOptionResolver.ts:169

Gets a boolean option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

boolean | null

The value of the option, or null if not set and not required.

getBoolean(name, required): boolean

Defined in: resolvers/CommandOptionResolver.ts:170

Gets a boolean option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

boolean

The value of the option, or null if not set and not required.


getChannel(name, required, channelTypes): APIInteractionDataResolvedChannel | null

Defined in: resolvers/CommandOptionResolver.ts:184

Gets a channel option.

string

The name of the option.

false

Whether to throw an error if the option is not found.

ChannelType[]

The allowed types of channels. If empty, all channel types are allowed.

APIInteractionDataResolvedChannel | null

The value of the option, or null if not set and not required.

getChannel(name, required, channelTypes): APIInteractionDataResolvedChannel

Defined in: resolvers/CommandOptionResolver.ts:185

Gets a channel option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

ChannelType[]

The allowed types of channels. If empty, all channel types are allowed.

APIInteractionDataResolvedChannel

The value of the option, or null if not set and not required.


getFocused(): AutocompleteFocusedOption | null

Defined in: resolvers/CommandOptionResolver.ts:158

Gets the currently-focused option during an autocomplete request, or null if none is focused.

AutocompleteFocusedOption | null


getInteger(name, required?): number | null

Defined in: resolvers/CommandOptionResolver.ts:222

Gets an integer option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

number | null

The value of the option, or null if not set and not required.

getInteger(name, required): number

Defined in: resolvers/CommandOptionResolver.ts:223

Gets an integer option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

number

The value of the option, or null if not set and not required.


getMember(name, required?): ResolvedSelectedGuildMember | null

Defined in: resolvers/CommandOptionResolver.ts:265

Gets a member option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

ResolvedSelectedGuildMember | null

The value of the option, or null if the user is not present in the guild or the option is not set.

getMember(name, required): ResolvedSelectedGuildMember

Defined in: resolvers/CommandOptionResolver.ts:266

Gets a member option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

ResolvedSelectedGuildMember

The value of the option, or null if the user is not present in the guild or the option is not set.


getMentionable(name, required?): APIRole | APIUser | ResolvedSelectedGuildMember | null

Defined in: resolvers/CommandOptionResolver.ts:310

Gets a mentionable option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

APIRole | APIUser | ResolvedSelectedGuildMember | null

The value of the option, or null if not set and not required.

getMentionable(name, required): APIRole | APIUser | ResolvedSelectedGuildMember

Defined in: resolvers/CommandOptionResolver.ts:311

Gets a mentionable option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

APIRole | APIUser | ResolvedSelectedGuildMember

The value of the option, or null if not set and not required.


getNumber(name, required?): number | null

Defined in: resolvers/CommandOptionResolver.ts:236

Gets a number option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

number | null

The value of the option, or null if not set and not required.

getNumber(name, required): number

Defined in: resolvers/CommandOptionResolver.ts:237

Gets a number option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

number

The value of the option, or null if not set and not required.


getRole(name, required?): APIRole | null

Defined in: resolvers/CommandOptionResolver.ts:280

Gets a role option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

APIRole | null

The value of the option, or null if not set and not required.

getRole(name, required): APIRole

Defined in: resolvers/CommandOptionResolver.ts:281

Gets a role option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

APIRole

The value of the option, or null if not set and not required.


getString<T>(name, required?): T | null

Defined in: resolvers/CommandOptionResolver.ts:208

Gets a string option.

T extends string = string

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

T | null

The value of the option, or null if not set and not required.

getString<T>(name, required): T

Defined in: resolvers/CommandOptionResolver.ts:209

Gets a string option.

T extends string = string

string

The name of the option.

true

Whether to throw an error if the option is not found.

T

The value of the option, or null if not set and not required.


getSubcommand(): string | null

Defined in: resolvers/CommandOptionResolver.ts:131

Gets the selected subcommand.

string | null

The name of the selected subcommand, or null if not set and not required.

getSubcommand(required): string

Defined in: resolvers/CommandOptionResolver.ts:132

Gets the selected subcommand.

true

string

The name of the selected subcommand, or null if not set and not required.


getSubcommandGroup(required?): string | null

Defined in: resolvers/CommandOptionResolver.ts:147

Gets the selected subcommand group.

boolean

Whether to throw an error if there is no subcommand group.

string | null

The name of the selected subcommand group, or null if not set and not required.

getSubcommandGroup(required): string

Defined in: resolvers/CommandOptionResolver.ts:148

Gets the selected subcommand group.

true

Whether to throw an error if there is no subcommand group.

string

The name of the selected subcommand group, or null if not set and not required.


getUser(name, required?): APIUser | null

Defined in: resolvers/CommandOptionResolver.ts:250

Gets a user option.

string

The name of the option.

boolean

Whether to throw an error if the option is not found.

APIUser | null

The value of the option, or null if not set and not required.

getUser(name, required): APIUser

Defined in: resolvers/CommandOptionResolver.ts:251

Gets a user option.

string

The name of the option.

true

Whether to throw an error if the option is not found.

APIUser

The value of the option, or null if not set and not required.