class CommandInteractionOptionResolver

export class CommandInteractionOptionResolver<Cached extends CacheType = CacheType>

A resolver for command interaction options.

Type Parameters

optional
Cached? extends CacheType = CacheType

readonly
client : Client

The client that instantiated this.

readonly
data : readonly CommandInteractionOption<Cached>[]

The interaction options array.

readonly
resolved : Readonly<CommandInteractionResolvedData<Cached>> | null

The interaction resolved data

get(
name: string
required: true
) : CommandInteractionOption<Cached>

Gets an option by its name.

Returns: The option, if found.

getAttachment(
name: string
required: true
) : NonNullable<CommandInteractionOption<Cached>['attachment']>

Gets an attachment option.

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

getBoolean(
name: string
required: true
) : boolean

Gets a boolean option.

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

getChannel<

Type? extends ChannelType = ChannelType

>(
name: string
required: true
channelTypes?: readonly Type[]
) : Extract<NonNullable<CommandInteractionOption<Cached>['channel']>, { type: Type extends ChannelType.PublicThread | ChannelType.AnnouncementThread ? ChannelType.PublicThread | ChannelType.AnnouncementThread : Type; }>

Gets a channel option.

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

getFocused(
getFull: true
) : AutocompleteFocusedOption

Gets the focused option.

Returns: The value of the option, or the whole option if getFull is true

getInteger(
name: string
required: true
) : number

Gets an integer option.

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

getMember(
name: string
) : NonNullable<CommandInteractionOption<Cached>['member']> | null

Gets a member option.

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

getMentionable(
name: string
required: true
) : NonNullable<CommandInteractionOption<Cached>['member' | 'role' | 'user']>

Gets a mentionable option.

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

getMessage(
name: string
required: true
) : NonNullable<CommandInteractionOption<Cached>['message']>

Gets a message option.

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

getNumber(
name: string
required: true
) : number

Gets a number option.

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

getRole(
name: string
required: true
) : NonNullable<CommandInteractionOption<Cached>['role']>

Gets a role option.

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

getString(
name: string
required: true
) : string

Gets a string option.

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

getSubcommand(
required?: true
) : string

Gets the selected subcommand.

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

getSubcommandGroup(
required: true
) : string

Gets the selected subcommand group.

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

getUser(
name: string
required: true
) : NonNullable<CommandInteractionOption<Cached>['user']>

Gets a user option.

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