CommandInteractionOptionResolver
Class: CommandInteractionOptionResolver
Section titled “Class: 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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new CommandInteractionOptionResolver(
options,resolved):CommandInteractionOptionResolver
Defined in: resolvers/CommandOptionResolver.ts:60
Parameters
Section titled “Parameters”options
Section titled “options”APIApplicationCommandInteractionDataOption<ApplicationCommand | ApplicationCommandAutocomplete>[] | undefined
resolved
Section titled “resolved”APIInteractionDataResolved | undefined
Returns
Section titled “Returns”CommandInteractionOptionResolver
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get data():
APIApplicationCommandInteractionDataOption<ApplicationCommand|ApplicationCommandAutocomplete>[]
Defined in: resolvers/CommandOptionResolver.ts:97
Returns
Section titled “Returns”APIApplicationCommandInteractionDataOption<ApplicationCommand | ApplicationCommandAutocomplete>[]
Methods
Section titled “Methods”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.
Type Parameters
Section titled “Type Parameters”T extends ApplicationCommandOptionType
Parameters
Section titled “Parameters”string
The name of the option.
T
The expected type of the option.
required?
Section titled “required?”boolean = false
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”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()
Section titled “getAttachment()”Call Signature
Section titled “Call Signature”getAttachment(
name,required?):APIAttachment|null
Defined in: resolvers/CommandOptionResolver.ts:295
Gets an attachment option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIAttachment | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getAttachment(
name,required):APIAttachment
Defined in: resolvers/CommandOptionResolver.ts:296
Gets an attachment option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIAttachment
The value of the option, or null if not set and not required.
getBoolean()
Section titled “getBoolean()”Call Signature
Section titled “Call Signature”getBoolean(
name,required?):boolean|null
Defined in: resolvers/CommandOptionResolver.ts:169
Gets a boolean option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”boolean | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getBoolean(
name,required):boolean
Defined in: resolvers/CommandOptionResolver.ts:170
Gets a boolean option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”boolean
The value of the option, or null if not set and not required.
getChannel()
Section titled “getChannel()”Call Signature
Section titled “Call Signature”getChannel(
name,required,channelTypes):APIInteractionDataResolvedChannel|null
Defined in: resolvers/CommandOptionResolver.ts:184
Gets a channel option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”false
Whether to throw an error if the option is not found.
channelTypes
Section titled “channelTypes”ChannelType[]
The allowed types of channels. If empty, all channel types are allowed.
Returns
Section titled “Returns”APIInteractionDataResolvedChannel | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getChannel(
name,required,channelTypes):APIInteractionDataResolvedChannel
Defined in: resolvers/CommandOptionResolver.ts:185
Gets a channel option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
channelTypes
Section titled “channelTypes”ChannelType[]
The allowed types of channels. If empty, all channel types are allowed.
Returns
Section titled “Returns”APIInteractionDataResolvedChannel
The value of the option, or null if not set and not required.
getFocused()
Section titled “getFocused()”getFocused():
AutocompleteFocusedOption|null
Defined in: resolvers/CommandOptionResolver.ts:158
Gets the currently-focused option during an autocomplete request, or null if none is focused.
Returns
Section titled “Returns”AutocompleteFocusedOption | null
getInteger()
Section titled “getInteger()”Call Signature
Section titled “Call Signature”getInteger(
name,required?):number|null
Defined in: resolvers/CommandOptionResolver.ts:222
Gets an integer option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”number | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getInteger(
name,required):number
Defined in: resolvers/CommandOptionResolver.ts:223
Gets an integer option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”number
The value of the option, or null if not set and not required.
getMember()
Section titled “getMember()”Call Signature
Section titled “Call Signature”getMember(
name,required?):ResolvedSelectedGuildMember|null
Defined in: resolvers/CommandOptionResolver.ts:265
Gets a member option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”ResolvedSelectedGuildMember | null
The value of the option, or null if the user is not present in the guild or the option is not set.
Call Signature
Section titled “Call Signature”getMember(
name,required):ResolvedSelectedGuildMember
Defined in: resolvers/CommandOptionResolver.ts:266
Gets a member option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”The value of the option, or null if the user is not present in the guild or the option is not set.
getMentionable()
Section titled “getMentionable()”Call Signature
Section titled “Call Signature”getMentionable(
name,required?):APIRole|APIUser|ResolvedSelectedGuildMember|null
Defined in: resolvers/CommandOptionResolver.ts:310
Gets a mentionable option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIRole | APIUser | ResolvedSelectedGuildMember | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getMentionable(
name,required):APIRole|APIUser|ResolvedSelectedGuildMember
Defined in: resolvers/CommandOptionResolver.ts:311
Gets a mentionable option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIRole | APIUser | ResolvedSelectedGuildMember
The value of the option, or null if not set and not required.
getNumber()
Section titled “getNumber()”Call Signature
Section titled “Call Signature”getNumber(
name,required?):number|null
Defined in: resolvers/CommandOptionResolver.ts:236
Gets a number option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”number | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getNumber(
name,required):number
Defined in: resolvers/CommandOptionResolver.ts:237
Gets a number option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”number
The value of the option, or null if not set and not required.
getRole()
Section titled “getRole()”Call Signature
Section titled “Call Signature”getRole(
name,required?):APIRole|null
Defined in: resolvers/CommandOptionResolver.ts:280
Gets a role option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIRole | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getRole(
name,required):APIRole
Defined in: resolvers/CommandOptionResolver.ts:281
Gets a role option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIRole
The value of the option, or null if not set and not required.
getString()
Section titled “getString()”Call Signature
Section titled “Call Signature”getString<
T>(name,required?):T|null
Defined in: resolvers/CommandOptionResolver.ts:208
Gets a string option.
Type Parameters
Section titled “Type Parameters”T extends string = string
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”T | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getString<
T>(name,required):T
Defined in: resolvers/CommandOptionResolver.ts:209
Gets a string option.
Type Parameters
Section titled “Type Parameters”T extends string = string
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”T
The value of the option, or null if not set and not required.
getSubcommand()
Section titled “getSubcommand()”Call Signature
Section titled “Call Signature”getSubcommand():
string|null
Defined in: resolvers/CommandOptionResolver.ts:131
Gets the selected subcommand.
Returns
Section titled “Returns”string | null
The name of the selected subcommand, or null if not set and not required.
Call Signature
Section titled “Call Signature”getSubcommand(
required):string
Defined in: resolvers/CommandOptionResolver.ts:132
Gets the selected subcommand.
Parameters
Section titled “Parameters”required
Section titled “required”true
Returns
Section titled “Returns”string
The name of the selected subcommand, or null if not set and not required.
getSubcommandGroup()
Section titled “getSubcommandGroup()”Call Signature
Section titled “Call Signature”getSubcommandGroup(
required?):string|null
Defined in: resolvers/CommandOptionResolver.ts:147
Gets the selected subcommand group.
Parameters
Section titled “Parameters”required?
Section titled “required?”boolean
Whether to throw an error if there is no subcommand group.
Returns
Section titled “Returns”string | null
The name of the selected subcommand group, or null if not set and not required.
Call Signature
Section titled “Call Signature”getSubcommandGroup(
required):string
Defined in: resolvers/CommandOptionResolver.ts:148
Gets the selected subcommand group.
Parameters
Section titled “Parameters”required
Section titled “required”true
Whether to throw an error if there is no subcommand group.
Returns
Section titled “Returns”string
The name of the selected subcommand group, or null if not set and not required.
getUser()
Section titled “getUser()”Call Signature
Section titled “Call Signature”getUser(
name,required?):APIUser|null
Defined in: resolvers/CommandOptionResolver.ts:250
Gets a user option.
Parameters
Section titled “Parameters”string
The name of the option.
required?
Section titled “required?”boolean
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIUser | null
The value of the option, or null if not set and not required.
Call Signature
Section titled “Call Signature”getUser(
name,required):APIUser
Defined in: resolvers/CommandOptionResolver.ts:251
Gets a user option.
Parameters
Section titled “Parameters”string
The name of the option.
required
Section titled “required”true
Whether to throw an error if the option is not found.
Returns
Section titled “Returns”APIUser
The value of the option, or null if not set and not required.
