RoleManager
RoleManager ⇐ Base
Section titled “RoleManager ⇐ Base”Represents a Role Manager that handles operations related to roles in a guild.
Kind: global class
Extends: Base
- RoleManager ⇐
Base- new RoleManager(client)
- instance
- .cache ⇒
- ._add(roles, [guildId], [options]) ⇒
Role|null - .fetch(roles, options) ⇒
Promise - .create(options) ⇒
Promise.<Role> - .edit(role, [options]) ⇒
Promise.<Role> - .delete(role, reason) ⇒
Promise.<Role> - .clone([role]) ⇒
Promise - .modifyPosition([options]) ⇒
Promise
- static
- .transformPayload(o, [modifyPosition]) ⇒
Promise.<object>
- .transformPayload(o, [modifyPosition]) ⇒
new RoleManager(client)
Section titled “new RoleManager(client)”Constructs a new instance of the class.
| Param | Type | Description |
|---|---|---|
| client | Client | The client object used for communication with the server. |
roleManager.cache ⇒
Section titled “roleManager.cache ⇒”Getter method for the cache property.
Kind: instance property of RoleManager
Returns: The Collection object representing the cache.
roleManager._add(roles, [guildId], [options]) ⇒ Role | null
Section titled “roleManager._add(roles, [guildId], [options]) ⇒ Role | null”Adds a role to the cache and returns the role object.
Kind: instance method of RoleManager
Returns: Role | null - The role object that was added to the cache
| Param | Type | Default | Description |
|---|---|---|---|
| roles | string | Role | The role ID or role object to add to the cache. | |
| [guildId] | string | ”this.guildId” | The ID of the guild the role belongs to. |
| [options] | object | {cache: true, force: false} | Additional options for role caching. |
| [options.cache] | boolean | true | Whether to cache the role object. |
| [options.force] | boolean | false | Whether to force fetching the role from the API even if it is already in the cache. |
roleManager.fetch(roles, options) ⇒ Promise
Section titled “roleManager.fetch(roles, options) ⇒ Promise”Fetches roles from the server based on the provided roles and options.
Kind: instance method of RoleManager
Returns: Promise - - A promise that resolves to the fetched roles.
| Param | Type | Description |
|---|---|---|
| roles | string | object | The roles to fetch. Can be a string representing a role ID or an object containing options. |
| options | object | The options for fetching roles. Can contain properties like cache and force. |
roleManager.create(options) ⇒ Promise.<Role>
Section titled “roleManager.create(options) ⇒ Promise.<Role>”Creates a new role in the guild with the given options.
Kind: instance method of RoleManager
Returns: Promise.<Role> - A promise that resolves with the created role.
| Param | Type | Description |
|---|---|---|
| options | Object | The options for creating the role. |
| options.reason | string | The reason for creating the role. |
| options.position | number | The position of the role in the hierarchy. |
roleManager.edit(role, [options]) ⇒ Promise.<Role>
Section titled “roleManager.edit(role, [options]) ⇒ Promise.<Role>”Edits a role in the guild.
Kind: instance method of RoleManager
Returns: Promise.<Role> - A promise that resolves with the edited role object.
| Param | Type | Description |
|---|---|---|
| role | string | Role | The role ID or role object to edit. |
| [options] | Object | Additional options for editing the role. |
| [options.reason] | string | The reason for editing the role. |
| [options.position] | number | The new position of the role. |
roleManager.delete(role, reason) ⇒ Promise.<Role>
Section titled “roleManager.delete(role, reason) ⇒ Promise.<Role>”Deletes a role from the guild.
Kind: instance method of RoleManager
Returns: Promise.<Role> - - The deleted role.
Throws:
Error- If the role cannot be deleted.
| Param | Type | Description |
|---|---|---|
| role | string | Role | The role to delete. Can be either the role ID or the Role object. |
| reason | string | The reason for deleting the role. |
roleManager.clone([role]) ⇒ Promise
Section titled “roleManager.clone([role]) ⇒ Promise”Clones a role by creating a new instance of it.
Kind: instance method of RoleManager
Returns: Promise - - A promise that resolves with the cloned role.
Throws:
RangeError- If the role is not found in the cache.
| Param | Type | Description |
|---|---|---|
| [role] | string | Object | The role to clone. Can be either a role ID or a role object. |
roleManager.modifyPosition([options]) ⇒ Promise
Section titled “roleManager.modifyPosition([options]) ⇒ Promise”Modifies the position of roles in a guild.
Kind: instance method of RoleManager
Returns: Promise - A promise that resolves with the modified roles.
| Param | Type | Description |
|---|---|---|
| [options] | Object | The options for modifying the position. |
| [options.reason] | string | The reason for the modification. |
| [options.data] | Array | The data containing the roles to modify. |
RoleManager.transformPayload(o, [modifyPosition]) ⇒ Promise.<object>
Section titled “RoleManager.transformPayload(o, [modifyPosition]) ⇒ Promise.<object>”Transforms the payload object based on the provided parameters.
Kind: static method of RoleManager
Returns: Promise.<object> - - The transformed payload object.
| Param | Type | Default | Description |
|---|---|---|---|
| o | object | The payload object to transform. | |
| [modifyPosition] | boolean | false | Whether to modify the position property. |