CommandInteractionOptionResolver
Classes
CommandInteractionOptionResolver ⇐ Base
Kind: global class
Extends: Base
- CommandInteractionOptionResolver ⇐
Base
- new CommandInteractionOptionResolver([data], guildId, channelId, client)
- new CommandInteractionOptionResolver([data], guildId, channelId, client)
- .guild ⇒
- .channel ⇒
- ._parse([options]) ⇒
Array
|null
- .getString(name, [required]) ⇒
string
|null
- .getNumber(name, [required]) ⇒
number
|null
- .getInteger(name, [required]) ⇒
number
|null
- .getBoolean(name, [required]) ⇒
boolean
|null
- .getAttachment([required]) ⇒
MessageAttachment
|null
- .getUser(name, [required]) ⇒
User
|null
- .getMember(name, [required]) ⇒
GuildMember
|null
- .getContextUser() ⇒
User
|null
- .getMessage() ⇒
Message
|null
- .getChannel(name, [required]) ⇒
Channel
|null
- .getRole(name, [required]) ⇒
Role
|null
- .getMentionable(name, [required]) ⇒
User
|GuildMember
|Role
|null
- .getSubCommand([required]) ⇒
string
|null
- .getSubCommandGroup([required]) ⇒
string
|null
new CommandInteractionOptionResolver([data], guildId, channelId, client)
A class that provides methods to resolve command interaction options.
Param | Type | Description |
---|---|---|
[data] | Object | The data object containing the command interaction options. |
guildId | string | The ID of the guild where the command interaction occurred. |
channelId | string | The ID of the channel where the command interaction occurred. |
client | Client | The client instance. |
new CommandInteractionOptionResolver([data], guildId, channelId, client)
Constructs a new instance of the class.
Param | Type | Description |
---|---|---|
[data] | Object | The data object for the instance. |
guildId | string | The ID of the guild. |
channelId | string | The ID of the channel. |
client | Client | The client object. |
commandInteractionOptionResolver.guild ⇒
Get the guild object associated with this guildId.
Kind: instance property of CommandInteractionOptionResolver
Returns: The guild object.
commandInteractionOptionResolver.channel ⇒
Get the channel object associated with this instance.
Kind: instance property of CommandInteractionOptionResolver
Returns: The channel object.
commandInteractionOptionResolver._parse([options]) ⇒ Array
| null
Parses the options array and returns the parsed result.
Kind: instance method of CommandInteractionOptionResolver
Returns: Array
| null
- - The parsed options array or null if the data type is 2 or 3, or if the options array is empty.
Param | Type | Default | Description |
---|---|---|---|
[options] | Array | this.options | The options array to parse. |
commandInteractionOptionResolver.getString(name, [required]) ⇒ string
| null
Retrieves the value of a string option by its name.
Kind: instance method of CommandInteractionOptionResolver
Returns: string
| null
- The value of the option, or null if the option is not found and not required.
Throws:
RangeError
If the option is required and not found, or if the option is found but its type is not string.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError is thrown. |
commandInteractionOptionResolver.getNumber(name, [required]) ⇒ number
| null
Retrieves the value of a number option by its name.
Kind: instance method of CommandInteractionOptionResolver
Returns: number
| null
- The value of the number option, or null if the option is not found.
Throws:
RangeError
If the option is required and not found, or if the option type is not Number.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError is thrown. |
commandInteractionOptionResolver.getInteger(name, [required]) ⇒ number
| null
Retrieves the integer value of the specified option name from the options list.
Kind: instance method of CommandInteractionOptionResolver
Returns: number
| null
- The integer value of the option, or null if the option is not found.
Throws:
RangeError
If the option is required and not found, or if the option type is not an integer.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option to retrieve. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getBoolean(name, [required]) ⇒ boolean
| null
Retrieves the boolean value of the specified option name from the options list.
Kind: instance method of CommandInteractionOptionResolver
Returns: boolean
| null
- - The boolean value of the option, or null if the option is not found and not required.
Throws:
RangeError
- If the option is required and not found, or if the option type is not boolean.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option to retrieve. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError is thrown. |
commandInteractionOptionResolver.getAttachment([required]) ⇒ MessageAttachment
| null
Retrieves an attachment from the message data based on the provided options.
Kind: instance method of CommandInteractionOptionResolver
Returns: MessageAttachment
| null
- - The retrieved attachment, or null if no attachment is found and it is not required.
Throws:
RangeError
- If the required parameter is set to true and no attachment is found.
Param | Type | Default | Description |
---|---|---|---|
[required] | boolean | false | Indicates whether the attachment is required. If set to true and no attachment is found, a RangeError will be thrown. |
commandInteractionOptionResolver.getUser(name, [required]) ⇒ User
| null
Retrieves a user based on the given name.
Kind: instance method of CommandInteractionOptionResolver
Returns: User
| null
- - The retrieved user object, or null if the user is not found and is not required.
Throws:
RangeError
- If the option type is not User or if the option name does not match the specified option and is required.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the user to retrieve. | |
[required] | boolean | false | Indicates whether the user is required. If set to true and the user is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getMember(name, [required]) ⇒ GuildMember
| null
Retrieves a member by name from the guild’s options.
Kind: instance method of CommandInteractionOptionResolver
Returns: GuildMember
| null
- The retrieved member, or null if not found (unless required is set to true).
Throws:
RangeError
If the option type is not User or if the option name does not match the specified option (if required is set to true).
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the member to retrieve. | |
[required] | boolean | false | Whether the member is required. If set to true and the member is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getContextUser() ⇒ User
| null
Retrieves the context user from the data object.
Kind: instance method of CommandInteractionOptionResolver
Returns: User
| null
- The context user, or null if the data object is not available.
Throws:
RangeError
If the data object is resolved and its type is not 2 (context user).
commandInteractionOptionResolver.getMessage() ⇒ Message
| null
Retrieves the message associated with the current context.
Kind: instance method of CommandInteractionOptionResolver
Returns: Message
| null
- The message object if found, otherwise null.
Throws:
RangeError
If the message is not of type “Context Message”.
commandInteractionOptionResolver.getChannel(name, [required]) ⇒ Channel
| null
Retrieves a channel based on its name from the available options.
Kind: instance method of CommandInteractionOptionResolver
Returns: Channel
| null
- - The retrieved channel or null if not found (unless required is set to true).
Throws:
RangeError
- If the type of option is not Channel or if the name of the option does not match the selected option (if required is set to true).
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the channel to retrieve. | |
[required] | boolean | false | Whether the channel is required. If set to true and the channel is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getRole(name, [required]) ⇒ Role
| null
Retrieves the role with the specified name from the options.
Kind: instance method of CommandInteractionOptionResolver
Returns: Role
| null
- The role object if found, or null if not found and not required.
Throws:
RangeError
If the option type is not Role and required is set to true, or if the name of the option does not match the selected option and required is set to true.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the role to retrieve. | |
[required] | boolean | false | Whether the role is required. If set to true and the role is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getMentionable(name, [required]) ⇒ User
| GuildMember
| Role
| null
Retrieves the mentionable value for the specified option name.
Kind: instance method of CommandInteractionOptionResolver
Returns: User
| GuildMember
| Role
| null
- The mentionable value for the option, or null if not found.
Throws:
RangeError
If the option type is not Mentionable.RangeError
If the name of the option does not match the selected option and is required.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option. | |
[required] | boolean | false | Indicates whether the option is required. |
commandInteractionOptionResolver.getSubCommand([required]) ⇒ string
| null
Retrieves the sub command name from the options array.
Kind: instance method of CommandInteractionOptionResolver
Returns: string
| null
- - The name of the sub command, or null if not found.
Throws:
RangeError
- If the sub command is required but not found.
Param | Type | Default | Description |
---|---|---|---|
[required] | boolean | false | Indicates whether the sub command is required. |
commandInteractionOptionResolver.getSubCommandGroup([required]) ⇒ string
| null
Retrieves the sub command group from the options array.
Kind: instance method of CommandInteractionOptionResolver
Returns: string
| null
- - The name of the sub command group, or null if not found.
Throws:
RangeError
- If the sub command group is required but not found.
Param | Type | Default | Description |
---|---|---|---|
[required] | boolean | false | Indicates whether the sub command group is required. |
CommandInteractionOptionResolver
Kind: global class
- CommandInteractionOptionResolver
- new CommandInteractionOptionResolver([data], guildId, channelId, client)
- new CommandInteractionOptionResolver([data], guildId, channelId, client)
- .guild ⇒
- .channel ⇒
- ._parse([options]) ⇒
Array
|null
- .getString(name, [required]) ⇒
string
|null
- .getNumber(name, [required]) ⇒
number
|null
- .getInteger(name, [required]) ⇒
number
|null
- .getBoolean(name, [required]) ⇒
boolean
|null
- .getAttachment([required]) ⇒
MessageAttachment
|null
- .getUser(name, [required]) ⇒
User
|null
- .getMember(name, [required]) ⇒
GuildMember
|null
- .getContextUser() ⇒
User
|null
- .getMessage() ⇒
Message
|null
- .getChannel(name, [required]) ⇒
Channel
|null
- .getRole(name, [required]) ⇒
Role
|null
- .getMentionable(name, [required]) ⇒
User
|GuildMember
|Role
|null
- .getSubCommand([required]) ⇒
string
|null
- .getSubCommandGroup([required]) ⇒
string
|null
new CommandInteractionOptionResolver([data], guildId, channelId, client)
A class that provides methods to resolve command interaction options.
Param | Type | Description |
---|---|---|
[data] | Object | The data object containing the command interaction options. |
guildId | string | The ID of the guild where the command interaction occurred. |
channelId | string | The ID of the channel where the command interaction occurred. |
client | Client | The client instance. |
new CommandInteractionOptionResolver([data], guildId, channelId, client)
Constructs a new instance of the class.
Param | Type | Description |
---|---|---|
[data] | Object | The data object for the instance. |
guildId | string | The ID of the guild. |
channelId | string | The ID of the channel. |
client | Client | The client object. |
commandInteractionOptionResolver.guild ⇒
Get the guild object associated with this guildId.
Kind: instance property of CommandInteractionOptionResolver
Returns: The guild object.
commandInteractionOptionResolver.channel ⇒
Get the channel object associated with this instance.
Kind: instance property of CommandInteractionOptionResolver
Returns: The channel object.
commandInteractionOptionResolver._parse([options]) ⇒ Array
| null
Parses the options array and returns the parsed result.
Kind: instance method of CommandInteractionOptionResolver
Returns: Array
| null
- - The parsed options array or null if the data type is 2 or 3, or if the options array is empty.
Param | Type | Default | Description |
---|---|---|---|
[options] | Array | this.options | The options array to parse. |
commandInteractionOptionResolver.getString(name, [required]) ⇒ string
| null
Retrieves the value of a string option by its name.
Kind: instance method of CommandInteractionOptionResolver
Returns: string
| null
- The value of the option, or null if the option is not found and not required.
Throws:
RangeError
If the option is required and not found, or if the option is found but its type is not string.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError is thrown. |
commandInteractionOptionResolver.getNumber(name, [required]) ⇒ number
| null
Retrieves the value of a number option by its name.
Kind: instance method of CommandInteractionOptionResolver
Returns: number
| null
- The value of the number option, or null if the option is not found.
Throws:
RangeError
If the option is required and not found, or if the option type is not Number.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError is thrown. |
commandInteractionOptionResolver.getInteger(name, [required]) ⇒ number
| null
Retrieves the integer value of the specified option name from the options list.
Kind: instance method of CommandInteractionOptionResolver
Returns: number
| null
- The integer value of the option, or null if the option is not found.
Throws:
RangeError
If the option is required and not found, or if the option type is not an integer.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option to retrieve. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getBoolean(name, [required]) ⇒ boolean
| null
Retrieves the boolean value of the specified option name from the options list.
Kind: instance method of CommandInteractionOptionResolver
Returns: boolean
| null
- - The boolean value of the option, or null if the option is not found and not required.
Throws:
RangeError
- If the option is required and not found, or if the option type is not boolean.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option to retrieve. | |
[required] | boolean | false | Indicates whether the option is required. If set to true and the option is not found, a RangeError is thrown. |
commandInteractionOptionResolver.getAttachment([required]) ⇒ MessageAttachment
| null
Retrieves an attachment from the message data based on the provided options.
Kind: instance method of CommandInteractionOptionResolver
Returns: MessageAttachment
| null
- - The retrieved attachment, or null if no attachment is found and it is not required.
Throws:
RangeError
- If the required parameter is set to true and no attachment is found.
Param | Type | Default | Description |
---|---|---|---|
[required] | boolean | false | Indicates whether the attachment is required. If set to true and no attachment is found, a RangeError will be thrown. |
commandInteractionOptionResolver.getUser(name, [required]) ⇒ User
| null
Retrieves a user based on the given name.
Kind: instance method of CommandInteractionOptionResolver
Returns: User
| null
- - The retrieved user object, or null if the user is not found and is not required.
Throws:
RangeError
- If the option type is not User or if the option name does not match the specified option and is required.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the user to retrieve. | |
[required] | boolean | false | Indicates whether the user is required. If set to true and the user is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getMember(name, [required]) ⇒ GuildMember
| null
Retrieves a member by name from the guild’s options.
Kind: instance method of CommandInteractionOptionResolver
Returns: GuildMember
| null
- The retrieved member, or null if not found (unless required is set to true).
Throws:
RangeError
If the option type is not User or if the option name does not match the specified option (if required is set to true).
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the member to retrieve. | |
[required] | boolean | false | Whether the member is required. If set to true and the member is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getContextUser() ⇒ User
| null
Retrieves the context user from the data object.
Kind: instance method of CommandInteractionOptionResolver
Returns: User
| null
- The context user, or null if the data object is not available.
Throws:
RangeError
If the data object is resolved and its type is not 2 (context user).
commandInteractionOptionResolver.getMessage() ⇒ Message
| null
Retrieves the message associated with the current context.
Kind: instance method of CommandInteractionOptionResolver
Returns: Message
| null
- The message object if found, otherwise null.
Throws:
RangeError
If the message is not of type “Context Message”.
commandInteractionOptionResolver.getChannel(name, [required]) ⇒ Channel
| null
Retrieves a channel based on its name from the available options.
Kind: instance method of CommandInteractionOptionResolver
Returns: Channel
| null
- - The retrieved channel or null if not found (unless required is set to true).
Throws:
RangeError
- If the type of option is not Channel or if the name of the option does not match the selected option (if required is set to true).
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the channel to retrieve. | |
[required] | boolean | false | Whether the channel is required. If set to true and the channel is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getRole(name, [required]) ⇒ Role
| null
Retrieves the role with the specified name from the options.
Kind: instance method of CommandInteractionOptionResolver
Returns: Role
| null
- The role object if found, or null if not found and not required.
Throws:
RangeError
If the option type is not Role and required is set to true, or if the name of the option does not match the selected option and required is set to true.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the role to retrieve. | |
[required] | boolean | false | Whether the role is required. If set to true and the role is not found, a RangeError will be thrown. |
commandInteractionOptionResolver.getMentionable(name, [required]) ⇒ User
| GuildMember
| Role
| null
Retrieves the mentionable value for the specified option name.
Kind: instance method of CommandInteractionOptionResolver
Returns: User
| GuildMember
| Role
| null
- The mentionable value for the option, or null if not found.
Throws:
RangeError
If the option type is not Mentionable.RangeError
If the name of the option does not match the selected option and is required.
Param | Type | Default | Description |
---|---|---|---|
name | string | The name of the option. | |
[required] | boolean | false | Indicates whether the option is required. |
commandInteractionOptionResolver.getSubCommand([required]) ⇒ string
| null
Retrieves the sub command name from the options array.
Kind: instance method of CommandInteractionOptionResolver
Returns: string
| null
- - The name of the sub command, or null if not found.
Throws:
RangeError
- If the sub command is required but not found.
Param | Type | Default | Description |
---|---|---|---|
[required] | boolean | false | Indicates whether the sub command is required. |
commandInteractionOptionResolver.getSubCommandGroup([required]) ⇒ string
| null
Retrieves the sub command group from the options array.
Kind: instance method of CommandInteractionOptionResolver
Returns: string
| null
- - The name of the sub command group, or null if not found.
Throws:
RangeError
- If the sub command group is required but not found.
Param | Type | Default | Description |
---|---|---|---|
[required] | boolean | false | Indicates whether the sub command group is required. |