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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:61
Methods
get()
Gets an option by its name
Param
The name of the option
Param
Whether to throw an error if the option is not found
get(name, required)
get(
name
:string
,required
?:boolean
):null
|APIApplicationCommandInteractionDataOption
Gets an option by its name
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| APIApplicationCommandInteractionDataOption
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:83
get(name, required)
get(
name
:string
,required
:true
):APIApplicationCommandInteractionDataOption
Gets an option by its name
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
APIApplicationCommandInteractionDataOption
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:84
getAttachment()
Gets an attachment option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getAttachment(name, required)
getAttachment(
name
:string
,required
?:boolean
):null
|APIAttachment
Gets an attachment option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| APIAttachment
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:238
getAttachment(name, required)
getAttachment(
name
:string
,required
:true
):APIAttachment
Gets an attachment option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
APIAttachment
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:239
getBoolean()
Gets a boolean option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getBoolean(name, required)
getBoolean(
name
:string
,required
?:boolean
):null
|boolean
Gets a boolean option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| boolean
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:134
getBoolean(name, required)
getBoolean(
name
:string
,required
:true
):boolean
Gets a boolean option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
boolean
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:135
getChannel()
Gets a channel option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getChannel(name, required)
getChannel(
name
:string
,required
?:boolean
):null
|APIInteractionDataResolvedChannel
Gets a channel option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| APIInteractionDataResolvedChannel
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:147
getChannel(name, required)
getChannel(
name
:string
,required
:true
):APIInteractionDataResolvedChannel
Gets a channel option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
APIInteractionDataResolvedChannel
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:148
getFocusedOption()
getFocusedOption():
object
|object
|object
Gets the focused option for an autocomplete interaction
Returns
object
| object
| object
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:327
getInteger()
Gets an integer option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getInteger(name, required)
getInteger(
name
:string
,required
?:boolean
):null
|number
Gets an integer option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| number
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:173
getInteger(name, required)
getInteger(
name
:string
,required
:true
):number
Gets an integer option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
number
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:174
getMember()
Gets a member option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getMember(name, required)
getMember(
name
:string
,required
?:boolean
):null
|APIInteractionDataResolvedGuildMember
Gets a member option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| APIInteractionDataResolvedGuildMember
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:212
getMember(name, required)
getMember(
name
:string
,required
:true
):APIInteractionDataResolvedGuildMember
Gets a member option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
APIInteractionDataResolvedGuildMember
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:213
getMentionable()
Gets a mentionable option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getMentionable(name, required)
getMentionable(
name
:string
,required
?:boolean
):null
|APIRole
|APIUser
|APIInteractionDataResolvedGuildMember
Gets a mentionable option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| APIRole
| APIUser
| APIInteractionDataResolvedGuildMember
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:251
getMentionable(name, required)
getMentionable(
name
:string
,required
:true
):APIRole
|APIUser
|APIInteractionDataResolvedGuildMember
Gets a mentionable option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
APIRole
| APIUser
| APIInteractionDataResolvedGuildMember
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:252
getNumber()
Gets a number option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getNumber(name, required)
getNumber(
name
:string
,required
?:boolean
):null
|number
Gets a number option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| number
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:186
getNumber(name, required)
getNumber(
name
:string
,required
:true
):number
Gets a number option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
number
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:187
getRole()
Gets a role option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getRole(name, required)
getRole(
name
:string
,required
?:boolean
):null
|APIRole
Gets a role option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| APIRole
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:225
getRole(name, required)
getRole(
name
:string
,required
:true
):APIRole
Gets a role option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
APIRole
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:226
getString()
Gets a string option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getString(name, required)
getString(
name
:string
,required
?:boolean
):null
|string
Gets a string option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| string
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:160
getString(name, required)
getString(
name
:string
,required
:true
):string
Gets a string option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
string
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:161
getSubcommand()
Gets the selected subcommand
Param
Whether to throw an error if there is no subcommand
getSubcommand(required)
getSubcommand(
required
?:boolean
):null
|string
Gets the selected subcommand
Parameters
Parameter | Type |
---|---|
required ? | boolean |
Returns
null
| string
Param
Whether to throw an error if there is no subcommand
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:104
getSubcommand(required)
getSubcommand(
required
:true
):string
Gets the selected subcommand
Parameters
Parameter | Type |
---|---|
required | true |
Returns
string
Param
Whether to throw an error if there is no subcommand
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:105
getSubcommandGroup()
Gets the selected subcommand group
Param
Whether to throw an error if there is no subcommand group
getSubcommandGroup(required)
getSubcommandGroup(
required
?:boolean
):null
|string
Gets the selected subcommand group
Parameters
Parameter | Type |
---|---|
required ? | boolean |
Returns
null
| string
Param
Whether to throw an error if there is no subcommand group
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:119
getSubcommandGroup(required)
getSubcommandGroup(
required
:true
):string
Gets the selected subcommand group
Parameters
Parameter | Type |
---|---|
required | true |
Returns
string
Param
Whether to throw an error if there is no subcommand group
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:120
getTargetMember()
Gets the target member for a context menu interaction
Param
Whether to throw an error if the member data is not present
getTargetMember(required)
getTargetMember(
required
?:boolean
):null
|APIInteractionDataResolvedGuildMember
Gets the target member for a context menu interaction
Parameters
Parameter | Type |
---|---|
required ? | boolean |
Returns
null
| APIInteractionDataResolvedGuildMember
Param
Whether to throw an error if the member data is not present
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:292
getTargetMember(required)
getTargetMember(
required
:true
):APIInteractionDataResolvedGuildMember
Gets the target member for a context menu interaction
Parameters
Parameter | Type |
---|---|
required | true |
Returns
APIInteractionDataResolvedGuildMember
Param
Whether to throw an error if the member data is not present
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:293
getTargetMessage()
getTargetMessage():
APIMessage
Gets the target message for a context menu interaction
Returns
APIMessage
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:316
getTargetUser()
getTargetUser():
APIUser
Gets the target user for a context menu interaction
Returns
APIUser
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:284
getUser()
Gets a user option
Param
The name of the option
Param
Whether to throw an error if the option is not found
getUser(name, required)
getUser(
name
:string
,required
?:boolean
):null
|APIUser
Gets a user option
Parameters
Parameter | Type |
---|---|
name | string |
required ? | boolean |
Returns
null
| APIUser
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:199
getUser(name, required)
getUser(
name
:string
,required
:true
):APIUser
Gets a user option
Parameters
Parameter | Type |
---|---|
name | string |
required | true |
Returns
APIUser
Param
The name of the option
Param
Whether to throw an error if the option is not found
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:200