ApplicationCommandPermissionManager
ApplicationCommandPermissionManager ⇐ Base
Section titled “ApplicationCommandPermissionManager ⇐ Base”Manages application command permissions for a specific guild.
Kind: global class
Extends: Base
- ApplicationCommandPermissionManager ⇐
Base- new ApplicationCommandPermissionManager(client, guildId)
- instance
- .cache ⇒
- ._add(commands, [guildId], [options]) ⇒
ApplicationCommandPermission - .fetch(commands, [options]) ⇒
Promise.<Cache> - ._fetchId(commands, [cache], [force], [guild]) ⇒
Promise.<any>
- static
- .transformPermissions(o) ⇒
Object - .transformPermission(o) ⇒
Object - .parseRemoveOptions(payload, fetchedData) ⇒
array
- .transformPermissions(o) ⇒
new ApplicationCommandPermissionManager(client, guildId)
Section titled “new ApplicationCommandPermissionManager(client, guildId)”Constructs a new instance of the class.
| Param | Type | Description |
|---|---|---|
| client | Client | The client instance. |
| guildId | string | The ID of the guild. |
applicationCommandPermissionManager.cache ⇒
Section titled “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
Section titled “applicationCommandPermissionManager._add(commands, [guildId], [options]) ⇒ ApplicationCommandPermission”Adds a command permission to the guild.
Kind: instance method of ApplicationCommandPermissionManager
Returns: ApplicationCommandPermission - The added command permission.
| Param | Type | Default | Description |
|---|---|---|---|
| commands | string | ApplicationCommand | The 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] | boolean | true | Whether to cache the permission. |
| [options.force] | boolean | false | Whether to force adding the permission even if it already exists in the cache. |
applicationCommandPermissionManager.fetch(commands, [options]) ⇒ Promise.<Cache>
Section titled “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:
RangeErrorIf the guild ID is not provided.
| Param | Type | Description |
|---|---|---|
| commands | string | object | The command ID or an object containing the command details. |
| [options] | object | Additional options for the fetch operation. |
| [options.cache] | boolean | Whether to cache the fetched commands. |
| [options.force] | boolean | Whether to force fetch the commands even if they are already cached. |
| [options.guild] | string | Guild | The ID or instance of the guild to fetch the commands for. |
applicationCommandPermissionManager._fetchId(commands, [cache], [force], [guild]) ⇒ Promise.<any>
Section titled “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.
| Param | Type | Default | Description |
|---|---|---|---|
| commands | string | Object | The ID of the command or an object containing the command ID. | |
| [cache] | boolean | true | Whether to cache the fetched permissions. |
| [force] | boolean | false | Whether 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
Section titled “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
| Param | Type | Description |
|---|---|---|
| o | Object | The permissions object to transform. |
ApplicationCommandPermissionManager.transformPermission(o) ⇒ Object
Section titled “ApplicationCommandPermissionManager.transformPermission(o) ⇒ Object”Transforms a permission object into a new format.
Kind: static method of ApplicationCommandPermissionManager
Returns: Object - - The transformed permission object.
| Param | Type | Description |
|---|---|---|
| o | Object | The permission object to transform. |
ApplicationCommandPermissionManager.parseRemoveOptions(payload, fetchedData) ⇒ array
Section titled “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.
| Param | Type | Description |
|---|---|---|
| payload | object | The payload object containing the remove options. |
| fetchedData | array | The fetched data array to filter and map. |