Class: InteractionOptionResolver
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:28
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
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:61
Parameters
Parameter | Type |
---|---|
interaction | APIApplicationCommandInteraction | APIApplicationCommandAutocompleteInteraction | APIModalSubmitInteraction |
Returns
Properties
data
private
readonly
data:null
|APIApplicationCommandInteractionDataOption
[] =null
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:34
The interaction options array
group
private
readonly
group:null
|string
=null
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:54
The name of the subcommand group
hoistedOptions
private
readonly
hoistedOptions:null
|APIApplicationCommandInteractionDataOption
[] =null
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:49
Bottom-level options for the interaction If there is a subcommand (or subcommand and group), this represents the options for the subcommand.
interaction
private
readonly
interaction:APIApplicationCommandInteraction
|APIApplicationCommandAutocompleteInteraction
|APIModalSubmitInteraction
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:29
resolved
private
readonly
resolved:null
|APIInteractionDataResolved
|APIUserInteractionDataResolved
|APIMessageApplicationCommandInteractionDataResolved
=null
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:39
The interaction resolved data
subcommand
private
readonly
subcommand:null
|string
=null
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:59
The name of the subcommand
Methods
get()
get<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIApplicationCommandInteractionDataOption
,null
|APIApplicationCommandInteractionDataOption
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:88
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
>
getAttachment()
getAttachment<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIAttachment
,null
|APIAttachment
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:227
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
>
getBoolean()
getBoolean<
Required
>(name
:string
,required
?:Required
):If
<Required
,boolean
,null
|boolean
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:134
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
>
getChannel()
getChannel<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIInteractionDataResolvedChannel
,null
|APIInteractionDataResolvedChannel
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:145
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
>
getFocusedOption()
getFocusedOption(): {
name
:string
;type
:Integer
;value
:number
; } | {name
:string
;type
:Number
;value
:number
; } | {name
:string
;type
:String
;value
:string
; }
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:309
Gets the focused option for an autocomplete interaction
Returns
{ name
: string
; type
: Integer
; value
: number
; } | { name
: string
; type
: Number
; value
: number
; } | { name
: string
; type
: String
; value
: string
; }
getInteger()
getInteger<
Required
>(name
:string
,required
?:Required
):If
<Required
,number
,null
|number
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:168
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
>
getMember()
getMember<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIInteractionDataResolvedGuildMember
,null
|APIInteractionDataResolvedGuildMember
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:201
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
>
getMentionable()
getMentionable<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIRole
|APIUser
|APIInteractionDataResolvedGuildMember
,null
|APIRole
|APIUser
|APIInteractionDataResolvedGuildMember
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:238
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
>
getNumber()
getNumber<
Required
>(name
:string
,required
?:Required
):If
<Required
,number
,null
|number
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:179
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
>
getRole()
getRole<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIRole
,null
|APIRole
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:216
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
>
getString()
getString<
Required
>(name
:string
,required
?:Required
):If
<Required
,string
,null
|string
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:157
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
>
getSubcommand()
getSubcommand<
Required
>(required
?:Required
):If
<Required
,string
,null
|string
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:107
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
>
getSubcommandGroup()
getSubcommandGroup<
Required
>(required
?:Required
):If
<Required
,string
,null
|string
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:120
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
>
getTargetMember()
getTargetMember<
Required
>(required
?:Required
):If
<Required
,APIInteractionDataResolvedGuildMember
,null
|APIInteractionDataResolvedGuildMember
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:280
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
>
getTargetMessage()
getTargetMessage():
APIMessage
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:298
Gets the target message for a context menu interaction
Returns
APIMessage
getTargetUser()
getTargetUser():
APIUser
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:268
Gets the target user for a context menu interaction
Returns
APIUser
getTypedOption()
private
getTypedOption<Option
,Required
>(name
:string
,type
:Option
,required
:Required
):If
<Required
,TypeToOptionMap
[Option
],null
|TypeToOptionMap
[Option
]>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:330
Type Parameters
Type Parameter | Default type |
---|---|
Option extends String | Integer | Boolean | User | Channel | Role | Mentionable | Number | Attachment | - |
Required extends boolean | false |
Parameters
Parameter | Type |
---|---|
name | string |
type | Option |
required | Required |
Returns
If
<Required
, TypeToOptionMap
[Option
], null
| TypeToOptionMap
[Option
]>
getUser()
getUser<
Required
>(name
:string
,required
?:Required
):If
<Required
,APIUser
,null
|APIUser
>
Defined in: projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:190
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
>