Skip to content

CommandInteractionOptionResolver

classe · Source

A resolver for command interaction options.

Properties

client

readonly

client: Client

The client that instantiated this. Source

_group

nullable · private

_group: string

The name of the subcommand group. Source

_subcommand

nullable · private

_subcommand: string

The name of the subcommand. Source

_hoistedOptions

private

_hoistedOptions: Array<CommandInteractionOption>

The bottom-level options for the interaction. If there is a subcommand (or subcommand and group), this is the options for the subcommand. Source

data

readonly

data: ReadonlyArray<CommandInteractionOption>

The interaction options array. Source

resolved

resolved: Readonly<CommandInteractionResolvedData>

The interaction resolved data Source

Methods

get

get(name: string, required?: boolean): CommandInteractionOption

Gets an option by its name. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: CommandInteractionOption — The option, if found. Source

_getTypedOption

private

_getTypedOption(name: string, type: ApplicationCommandOptionType, properties: Array<string>, required: boolean): CommandInteractionOption

Gets an option by name and property and checks its type. Parameters

NameTypeDescription
namestringThe name of the option.
typeApplicationCommandOptionTypeThe type of the option.
propertiesArray<string>The properties to check for for required.
requiredbooleanWhether to throw an error if the option is not found.

Returns: CommandInteractionOption — The option, if found. Source

getSubcommand

getSubcommand(required?: boolean): string

Gets the selected subcommand. Parameters

NameTypeDescription
required?booleanWhether to throw an error if there is no subcommand. Default: true.

Returns: string — The name of the selected subcommand, or null if not set and not required. Source

getSubcommandGroup

getSubcommandGroup(required?: boolean): string

Gets the selected subcommand group. Parameters

NameTypeDescription
required?booleanWhether to throw an error if there is no subcommand group. Default: true.

Returns: string — The name of the selected subcommand group, or null if not set and not required. Source

getBoolean

getBoolean(name: string, required?: boolean): boolean

Gets a boolean option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: boolean — The value of the option, or null if not set and not required. Source

getChannel

getChannel(name: string, required?: boolean): GuildChannel | ThreadChannel | APIChannel

Gets a channel option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: GuildChannel \| ThreadChannel \| APIChannel — The value of the option, or null if not set and not required. Source

getString

getString(name: string, required?: boolean): string

Gets a string option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: string — The value of the option, or null if not set and not required. Source

getInteger

getInteger(name: string, required?: boolean): number

Gets an integer option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: number — The value of the option, or null if not set and not required. Source

getNumber

getNumber(name: string, required?: boolean): number

Gets a number option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: number — The value of the option, or null if not set and not required. Source

getUser

getUser(name: string, required?: boolean): User

Gets a user option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: User — The value of the option, or null if not set and not required. Source

getMember

getMember(name: string, required?: boolean): GuildMember | APIGuildMember

Gets a member option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: GuildMember \| APIGuildMember — The value of the option, or null if not set and not required. Source

getRole

getRole(name: string, required?: boolean): Role | APIRole

Gets a role option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: Role \| APIRole — The value of the option, or null if not set and not required. Source

getMentionable

getMentionable(name: string, required?: boolean): User | GuildMember | APIGuildMember | Role | APIRole

Gets a mentionable option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: User \| GuildMember \| APIGuildMember \| Role \| APIRole — The value of the option, or null if not set and not required. Source

getMessage

getMessage(name: string, required?: boolean): Message | APIMessage

Gets a message option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: Message \| APIMessage — The value of the option, or null if not set and not required. Source

getFocused

getFocused(getFull?: boolean): string | AutocompleteFocusedOption

Gets the focused option. Parameters

NameTypeDescription
getFull?booleanWhether to get the full option object Default: false.

Returns: string \| AutocompleteFocusedOption — The value of the option, or the whole option if getFull is true Source

getAttachment

getAttachment(name: string, required?: boolean): MessageAttachment

Gets an attachment option. Parameters

NameTypeDescription
namestringThe name of the option.
required?booleanWhether to throw an error if the option is not found. Default: false.

Returns: MessageAttachment — The value of the option, or null if not set and not required. Source

Unofficial software. Not affiliated with or supported by Discord.