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.

The interaction resolved data

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

Gets an option by its name.

Returns: The option, if found.

getAttachment(
name: string
required: true = false
) : 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 = false
) : 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 = false
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.

Gets the focused option.

Returns: The whole object of the option that is focused

getInteger(
name: string
required: true = false
) : 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 = false
) : 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 = false
) : 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 = false
) : number

Gets a number option.

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

getRole(
name: string
required: true = false
) : 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 = false
) : string

Gets a string option.

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

getSubcommand(
required?: true = true
) : string

Gets the selected subcommand.

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

getSubcommandGroup(
required: true = false
) : 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 = false
) : NonNullable<CommandInteractionOption<Cached>['user']>

Gets a user option.

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