Class: InteractionOptionResolver
Utility class for resolving command interaction options while working with the raw API. Based on https://github.com/discordjs/discord.js/blob/main/packages/discord.js/src/structures/CommandInteractionOptionResolver.js
Constructors
new InteractionOptionResolver()
new InteractionOptionResolver(
interaction
:APIApplicationCommandInteraction
|APIApplicationCommandAutocompleteInteraction
|APIModalSubmitInteraction
):InteractionOptionResolver
Parameters
Parameter | Type |
---|---|
interaction | APIApplicationCommandInteraction | APIApplicationCommandAutocompleteInteraction | APIModalSubmitInteraction |
Returns
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:30
Properties
data
private
readonly
data:any
The interaction options array
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:12
getTypedOption
private
getTypedOption:any
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:136
group
private
readonly
group:any
The name of the subcommand group
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:25
hoistedOptions
private
readonly
hoistedOptions:any
Bottom-level options for the interaction If there is a subcommand (or subcommand and group), this represents the options for the subcommand.
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:21
interaction
private
readonly
interaction:any
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:8
resolved
private
readonly
resolved:any
The interaction resolved data
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:16
subcommand
private
readonly
subcommand:any
The name of the subcommand
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:29
Methods
get()
get<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIApplicationCommandInteractionDataOption
,null
|APIApplicationCommandInteractionDataOption
>
Gets an option by its name
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, APIApplicationCommandInteractionDataOption
, null
| APIApplicationCommandInteractionDataOption
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:36
getAttachment()
getAttachment<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIAttachment
,null
|APIAttachment
>
Gets an attachment option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, APIAttachment
, null
| APIAttachment
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:100
getBoolean()
getBoolean<
Required
>(name
:string
,required
?:Required
):If
<Required
,boolean
,null
|boolean
>
Gets a boolean option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, boolean
, null
| boolean
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:52
getChannel()
getChannel<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIInteractionDataResolvedChannel
,null
|APIInteractionDataResolvedChannel
>
Gets a channel option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, APIInteractionDataResolvedChannel
, null
| APIInteractionDataResolvedChannel
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:58
getFocusedOption()
getFocusedOption():
object
|object
|object
Gets the focused option for an autocomplete interaction
Returns
object
| object
| object
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:123
getInteger()
getInteger<
Required
>(name
:string
,required
?:Required
):If
<Required
,number
,null
|number
>
Gets an integer option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, number
, null
| number
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:70
getMember()
getMember<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIInteractionDataResolvedGuildMember
,null
|APIInteractionDataResolvedGuildMember
>
Gets a member option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, APIInteractionDataResolvedGuildMember
, null
| APIInteractionDataResolvedGuildMember
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:88
getMentionable()
getMentionable<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIRole
|APIUser
|APIInteractionDataResolvedGuildMember
,null
|APIRole
|APIUser
|APIInteractionDataResolvedGuildMember
>
Gets a mentionable option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, APIRole
| APIUser
| APIInteractionDataResolvedGuildMember
, null
| APIRole
| APIUser
| APIInteractionDataResolvedGuildMember
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:106
getNumber()
getNumber<
Required
>(name
:string
,required
?:Required
):If
<Required
,number
,null
|number
>
Gets a number option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, number
, null
| number
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:76
getRole()
getRole<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIRole
,null
|APIRole
>
Gets a role option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, APIRole
, null
| APIRole
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:94
getString()
getString<
Required
>(name
:string
,required
?:Required
):If
<Required
,string
,null
|string
>
Gets a string option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, string
, null
| string
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:64
getSubcommand()
getSubcommand<
Required
>(required
?:Required
):If
<Required
,string
,null
|string
>
Gets the selected subcommand
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
required ? | Required | Whether to throw an error if there is no subcommand |
Returns
If
<Required
, string
, null
| string
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:41
getSubcommandGroup()
getSubcommandGroup<
Required
>(required
?:Required
):If
<Required
,string
,null
|string
>
Gets the selected subcommand group
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
required ? | Required | Whether to throw an error if there is no subcommand group |
Returns
If
<Required
, string
, null
| string
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:46
getTargetMember()
getTargetMember<
Required
>(required
?:Required
):If
<Required
,APIInteractionDataResolvedGuildMember
,null
|APIInteractionDataResolvedGuildMember
>
Gets the target member for a context menu interaction
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
required ? | Required | Whether to throw an error if the member data is not present |
Returns
If
<Required
, APIInteractionDataResolvedGuildMember
, null
| APIInteractionDataResolvedGuildMember
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:115
getTargetMessage()
getTargetMessage():
APIMessage
Gets the target message for a context menu interaction
Returns
APIMessage
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:119
getTargetUser()
getTargetUser():
APIUser
Gets the target user for a context menu interaction
Returns
APIUser
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:110
getUser()
getUser<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIUser
,null
|APIUser
>
Gets a user option
Type Parameters
Type Parameter | Default type |
---|---|
Required extends boolean | false |
Parameters
Parameter | Type | Description |
---|---|---|
name | string | The name of the option |
required ? | Required | Whether to throw an error if the option is not found |
Returns
If
<Required
, APIUser
, null
| APIUser
>
Defined in
node_modules/@sapphire/discord-utilities/dist/esm/index.d.mts:82