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
Properties
data
privatereadonlydata:null|APIApplicationCommandInteractionDataOption[] =null
The interaction options array
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:34
group
privatereadonlygroup:null|string=null
The name of the subcommand group
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:54
hoistedOptions
privatereadonlyhoistedOptions:null|APIApplicationCommandInteractionDataOption[] =null
Bottom-level options for the interaction If there is a subcommand (or subcommand and group), this represents the options for the subcommand.
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:49
interaction
privatereadonlyinteraction:APIApplicationCommandInteraction|APIApplicationCommandAutocompleteInteraction|APIModalSubmitInteraction
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:29
resolved
privatereadonlyresolved:null|APIInteractionDataResolved|APIUserInteractionDataResolved|APIMessageApplicationCommandInteractionDataResolved=null
The interaction resolved data
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:39
subcommand
privatereadonlysubcommand:null|string=null
The name of the subcommand
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:59
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:88
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:227
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:134
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:145
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:309
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:168
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:201
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:238
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:179
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:216
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:157
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:107
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:120
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:280
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:298
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:268
getTypedOption()
privategetTypedOption<Option,Required>(name:string,type:Option,required:Required):If<Required,TypeToOptionMap[Option],null|TypeToOptionMap[Option]>
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]>
Defined in
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:330
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
projects/utilities/packages/discord-utilities/src/lib/InteractionOptionResolver.ts:190