Skip to content

ApplicationCommandPermissionManager

ApplicationCommandPermissionManager ⇐ Base

Manages application command permissions for a specific guild.

Kind: global class
Extends: Base

new ApplicationCommandPermissionManager(client, guildId)

Constructs a new instance of the class.

ParamTypeDescription
clientClientThe client instance.
guildIdstringThe ID of the guild.

applicationCommandPermissionManager.cache ⇒

Getter method for the cache property.

Kind: instance property of ApplicationCommandPermissionManager
Returns: The Collection object representing the cache.

applicationCommandPermissionManager._add(commands, [guildId], [options]) ⇒ ApplicationCommandPermission

Adds a command permission to the guild.

Kind: instance method of ApplicationCommandPermissionManager
Returns: ApplicationCommandPermission - The added command permission.

ParamTypeDefaultDescription
commandsstring | ApplicationCommandThe command ID or the command object.
[guildId]string”this.guildId”The ID of the guild to add the permission to.
[options]object{cache: true, force: false}Additional options for adding the permission.
[options.cache]booleantrueWhether to cache the permission.
[options.force]booleanfalseWhether to force adding the permission even if it already exists in the cache.

applicationCommandPermissionManager.fetch(commands, [options]) ⇒ Promise.<Cache>

Fetches commands from the API based on the provided parameters.

Kind: instance method of ApplicationCommandPermissionManager
Returns: Promise.<Cache> - A promise that resolves to a cache object containing the fetched commands.
Throws:

  • RangeError If the guild ID is not provided.
ParamTypeDescription
commandsstring | objectThe command ID or an object containing the command details.
[options]objectAdditional options for the fetch operation.
[options.cache]booleanWhether to cache the fetched commands.
[options.force]booleanWhether to force fetch the commands even if they are already cached.
[options.guild]string | GuildThe ID or instance of the guild to fetch the commands for.

applicationCommandPermissionManager._fetchId(commands, [cache], [force], [guild]) ⇒ Promise.<any>

Fetches the ID of a command from the server’s command permissions.

Kind: instance method of ApplicationCommandPermissionManager
Returns: Promise.<any> - - A promise that resolves to the fetched permissions.
Throws:

  • RangeError - If the guild ID is not provided.
ParamTypeDefaultDescription
commandsstring | ObjectThe ID of the command or an object containing the command ID.
[cache]booleantrueWhether to cache the fetched permissions.
[force]booleanfalseWhether to force fetching the permissions even if they are already cached.
[guild]string | Object”this.guildId”The ID of the guild or an object containing the guild ID.

ApplicationCommandPermissionManager.transformPermissions(o) ⇒ Object

Transforms a permissions object into the desired format.

Kind: static method of ApplicationCommandPermissionManager
Returns: Object - - The transformed permissions object.

  • id: The ID of the permission. If the ID is a string, it is used as is. If it is an object, the “id” property is used. If neither is present, it is set to undefined.
  • type: The type of the permission. If the type is a string, it is converted to the corresponding ApplicationCommandPermissionType enum value. If it is already a valid enum value, it is used as is. If neither is present, it is set to 2 (USER).
  • permission: The
ParamTypeDescription
oObjectThe permissions object to transform.

ApplicationCommandPermissionManager.transformPermission(o) ⇒ Object

Transforms a permission object into a new format.

Kind: static method of ApplicationCommandPermissionManager
Returns: Object - - The transformed permission object.

ParamTypeDescription
oObjectThe permission object to transform.

ApplicationCommandPermissionManager.parseRemoveOptions(payload, fetchedData) ⇒ array

Parses the remove options from the payload and fetched data to create an array of objects that should be removed.

Kind: static method of ApplicationCommandPermissionManager
Returns: array - - An array of objects that should be removed based on the remove options.

ParamTypeDescription
payloadobjectThe payload object containing the remove options.
fetchedDataarrayThe fetched data array to filter and map.