Carbon
CoreClasses

OptionsHandler

This class is used to parse the options of a command, and provide errors for any missing or invalid options. It is used internally by the Command class.

Extends

  • Base

Extended by

Constructors

new OptionsHandler()

new OptionsHandler(client, options): OptionsHandler

Parameters

ParameterType
clientClient
optionsAPIApplicationCommandInteractionDataOption[]

Returns

OptionsHandler

Overrides

Base.constructor

Properties

PropertyModifierTypeDescriptionInherited from
clientpublicClient-Base.client
rawreadonlyAPIApplicationCommandInteractionDataBasicOption[]The raw options that were in the interaction data, before they were parsed.-

Methods

getBoolean()

getBoolean(key, required)

getBoolean(key, required?): undefined | boolean

Get the value of a boolean option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

undefined | boolean

The value of the option, or undefined if the option was not provided and it is not required.

getBoolean(key, required)

getBoolean(key, required): boolean

Parameters
ParameterType
keystring
requiredtrue
Returns

boolean


getChannel()

getChannel(key, required)

getChannel(key, required?): Promise<undefined | null | GuildCategoryChannel<false> | DmChannel<false> | GroupDmChannel<false> | GuildTextChannel<false> | GuildVoiceChannel<false> | GuildAnnouncementChannel<false> | GuildThreadChannel<ThreadChannelType, false> | GuildStageChannel<false> | GuildForumChannel<false> | GuildMediaChannel>

Get the value of a channel option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

Promise<undefined | null | GuildCategoryChannel<false> | DmChannel<false> | GroupDmChannel<false> | GuildTextChannel<false> | GuildVoiceChannel<false> | GuildAnnouncementChannel<false> | GuildThreadChannel<ThreadChannelType, false> | GuildStageChannel<false> | GuildForumChannel<false> | GuildMediaChannel>

The value of the option, or undefined if the option was not provided and it is not required.

getChannel(key, required)

getChannel(key, required): Promise<null | GuildCategoryChannel<false> | DmChannel<false> | GroupDmChannel<false> | GuildTextChannel<false> | GuildVoiceChannel<false> | GuildAnnouncementChannel<false> | GuildThreadChannel<ThreadChannelType, false> | GuildStageChannel<false> | GuildForumChannel<false> | GuildMediaChannel>

Parameters
ParameterType
keystring
requiredtrue
Returns

Promise<null | GuildCategoryChannel<false> | DmChannel<false> | GroupDmChannel<false> | GuildTextChannel<false> | GuildVoiceChannel<false> | GuildAnnouncementChannel<false> | GuildThreadChannel<ThreadChannelType, false> | GuildStageChannel<false> | GuildForumChannel<false> | GuildMediaChannel>


getInteger()

getInteger(key, required)

getInteger(key, required?): undefined | number

Get the value of an integer option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

undefined | number

The value of the option, or undefined if the option was not provided and it is not required.

getInteger(key, required)

getInteger(key, required): number

Parameters
ParameterType
keystring
requiredtrue
Returns

number


getMentionable()

getMentionable(key, required)

getMentionable(key, required?): Promise<undefined | User<false> | Role<true>>

Get the value of a mentionable option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

Promise<undefined | User<false> | Role<true>>

The value of the option, or undefined if the option was not provided and it is not required.

getMentionable(key, required)

getMentionable(key, required): Promise<User<false> | Role<true>>

Parameters
ParameterType
keystring
requiredtrue
Returns

Promise<User<false> | Role<true>>


getNumber()

getNumber(key, required)

getNumber(key, required?): undefined | number

Get the value of a number option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

undefined | number

The value of the option, or undefined if the option was not provided and it is not required.

getNumber(key, required)

getNumber(key, required): number

Parameters
ParameterType
keystring
requiredtrue
Returns

number


getRole()

getRole(key, required)

getRole(key, required?): undefined | Role<true>

Get the value of a role option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

undefined | Role<true>

The value of the option, or undefined if the option was not provided and it is not required.

getRole(key, required)

getRole(key, required): Role<true>

Parameters
ParameterType
keystring
requiredtrue
Returns

Role<true>


getString()

getString(key, required)

getString(key, required?): undefined | string

Get the value of a string option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

undefined | string

The value of the option, or undefined if the option was not provided and it is not required.

getString(key, required)

getString(key, required): string

Parameters
ParameterType
keystring
requiredtrue
Returns

string


getUser()

getUser(key, required)

getUser(key, required?): undefined | User<true>

Get the value of a user option.

Parameters
ParameterTypeDescription
keystringThe name of the option to get the value of.
required?falseWhether the option is required.
Returns

undefined | User<true>

The value of the option, or undefined if the option was not provided and it is not required.

getUser(key, required)

getUser(key, required): User<true>

Parameters
ParameterType
keystring
requiredtrue
Returns

User<true>

On this page

Edit on GitHub