Skip to content

CommandInteractionOptionResolver

Classes

CommandInteractionOptionResolverBase
CommandInteractionOptionResolver

CommandInteractionOptionResolver ⇐ Base

Kind: global class
Extends: Base

new CommandInteractionOptionResolver([data], guildId, channelId, client)

A class that provides methods to resolve command interaction options.

ParamTypeDescription
[data]ObjectThe data object containing the command interaction options.
guildIdstringThe ID of the guild where the command interaction occurred.
channelIdstringThe ID of the channel where the command interaction occurred.
clientClientThe client instance.

new CommandInteractionOptionResolver([data], guildId, channelId, client)

Constructs a new instance of the class.

ParamTypeDescription
[data]ObjectThe data object for the instance.
guildIdstringThe ID of the guild.
channelIdstringThe ID of the channel.
clientClientThe 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.

ParamTypeDefaultDescription
[options]Arraythis.optionsThe 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.
ParamTypeDefaultDescription
namestringThe name of the option.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the option.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the option to retrieve.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the option to retrieve.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the user to retrieve.
[required]booleanfalseIndicates 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).
ParamTypeDefaultDescription
namestringThe name of the member to retrieve.
[required]booleanfalseWhether 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).
ParamTypeDefaultDescription
namestringThe name of the channel to retrieve.
[required]booleanfalseWhether 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.
ParamTypeDefaultDescription
namestringThe name of the role to retrieve.
[required]booleanfalseWhether 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.
ParamTypeDefaultDescription
namestringThe name of the option.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
[required]booleanfalseIndicates whether the sub command group is required.

CommandInteractionOptionResolver

Kind: global class

new CommandInteractionOptionResolver([data], guildId, channelId, client)

A class that provides methods to resolve command interaction options.

ParamTypeDescription
[data]ObjectThe data object containing the command interaction options.
guildIdstringThe ID of the guild where the command interaction occurred.
channelIdstringThe ID of the channel where the command interaction occurred.
clientClientThe client instance.

new CommandInteractionOptionResolver([data], guildId, channelId, client)

Constructs a new instance of the class.

ParamTypeDescription
[data]ObjectThe data object for the instance.
guildIdstringThe ID of the guild.
channelIdstringThe ID of the channel.
clientClientThe 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.

ParamTypeDefaultDescription
[options]Arraythis.optionsThe 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.
ParamTypeDefaultDescription
namestringThe name of the option.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the option.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the option to retrieve.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the option to retrieve.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
namestringThe name of the user to retrieve.
[required]booleanfalseIndicates 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).
ParamTypeDefaultDescription
namestringThe name of the member to retrieve.
[required]booleanfalseWhether 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).
ParamTypeDefaultDescription
namestringThe name of the channel to retrieve.
[required]booleanfalseWhether 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.
ParamTypeDefaultDescription
namestringThe name of the role to retrieve.
[required]booleanfalseWhether 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.
ParamTypeDefaultDescription
namestringThe name of the option.
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
[required]booleanfalseIndicates 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.
ParamTypeDefaultDescription
[required]booleanfalseIndicates whether the sub command group is required.