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.
Extended by
Constructors
Constructor
new OptionsHandler(
__namedParameters
):OptionsHandler
Parameters
Parameter | Type |
---|---|
__namedParameters | { client : Client ; definitions : CommandOptions ; interactionData : APIAutocompleteApplicationCommandInteractionData | APIChatInputApplicationCommandInteractionData ; options : APIApplicationCommandInteractionDataOption []; } |
__namedParameters.client | Client |
__namedParameters.definitions | CommandOptions |
__namedParameters.interactionData | APIAutocompleteApplicationCommandInteractionData | APIChatInputApplicationCommandInteractionData |
__namedParameters.options | APIApplicationCommandInteractionDataOption [] |
Returns
OptionsHandler
Overrides
Base.constructor
Properties
Property | Modifier | Type | Description | Inherited from |
---|---|---|---|---|
client | public | Client | - | Base.client |
raw | readonly | APIApplicationCommandInteractionDataBasicOption [] | The raw options that were in the interaction data, before they were parsed. | - |
Methods
getAttachment()
Call Signature
getAttachment(
key
,required?
):undefined
|APIAttachment
Parameters
Parameter | Type |
---|---|
key | string |
required? | false |
Returns
undefined
| APIAttachment
Call Signature
getAttachment(
key
,required
):APIAttachment
Parameters
Parameter | Type |
---|---|
key | string |
required | true |
Returns
APIAttachment
getBoolean()
Call Signature
getBoolean(
key
,required?
):undefined
|boolean
Get the value of a boolean option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether 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.
Call Signature
getBoolean(
key
,required
):boolean
Get the value of a boolean option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
boolean
The value of the option, or undefined if the option was not provided and it is not required.
getChannel()
Call Signature
getChannel(
key
,required?
):Promise
<undefined
|null
|DmChannel
<false
> |GroupDmChannel
<false
> |GuildTextChannel
<false
> |GuildVoiceChannel
<false
> |GuildCategoryChannel
<false
> |GuildAnnouncementChannel
<false
> |GuildThreadChannel
<ThreadChannelType
,false
> |GuildStageChannel
<false
> |GuildForumChannel
<false
> |GuildMediaChannel
>
Get the value of a channel option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether the option is required. |
Returns
Promise
<undefined
| null
| DmChannel
<false
> | GroupDmChannel
<false
> | GuildTextChannel
<false
> | GuildVoiceChannel
<false
> | GuildCategoryChannel
<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.
Call Signature
getChannel(
key
,required
):Promise
<null
|DmChannel
<false
> |GroupDmChannel
<false
> |GuildTextChannel
<false
> |GuildVoiceChannel
<false
> |GuildCategoryChannel
<false
> |GuildAnnouncementChannel
<false
> |GuildThreadChannel
<ThreadChannelType
,false
> |GuildStageChannel
<false
> |GuildForumChannel
<false
> |GuildMediaChannel
>
Get the value of a channel option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
Promise
<null
| DmChannel
<false
> | GroupDmChannel
<false
> | GuildTextChannel
<false
> | GuildVoiceChannel
<false
> | GuildCategoryChannel
<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.
getInteger()
Call Signature
getInteger(
key
,required?
):undefined
|number
Get the value of an integer option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether 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.
Call Signature
getInteger(
key
,required
):number
Get the value of an integer option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
number
The value of the option, or undefined if the option was not provided and it is not required.
getMentionable()
Call Signature
getMentionable(
key
,required?
):Promise
<undefined
|User
<false
> |Role
<true
>>
Get the value of a mentionable option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether 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.
Call Signature
getMentionable(
key
,required
):Promise
<User
<false
> |Role
<true
>>
Get the value of a mentionable option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
Promise
<User
<false
> | Role
<true
>>
The value of the option, or undefined if the option was not provided and it is not required.
getNumber()
Call Signature
getNumber(
key
,required?
):undefined
|number
Get the value of a number option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether 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.
Call Signature
getNumber(
key
,required
):number
Get the value of a number option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
number
The value of the option, or undefined if the option was not provided and it is not required.
getRole()
Call Signature
getRole(
key
,required?
):undefined
|Role
<true
>
Get the value of a role option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether 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.
Call Signature
getRole(
key
,required
):Role
<true
>
Get the value of a role option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
Role
<true
>
The value of the option, or undefined if the option was not provided and it is not required.
getString()
Call Signature
getString(
key
,required?
):undefined
|string
Get the value of a string option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether 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.
Call Signature
getString(
key
,required
):string
Get the value of a string option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
string
The value of the option, or undefined if the option was not provided and it is not required.
getUser()
Call Signature
getUser(
key
,required?
):undefined
|User
<true
>
Get the value of a user option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required? | false | Whether 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.
Call Signature
getUser(
key
,required
):User
<true
>
Get the value of a user option.
Parameters
Parameter | Type | Description |
---|---|---|
key | string | The name of the option to get the value of. |
required | true | Whether the option is required. |
Returns
User
<true
>
The value of the option, or undefined if the option was not provided and it is not required.