Skip to content

RoleManager

RoleManager ⇐ Base

Represents a Role Manager that handles operations related to roles in a guild.

Kind: global class
Extends: Base

new RoleManager(client)

Constructs a new instance of the class.

ParamTypeDescription
clientClientThe client object used for communication with the server.

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

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

ParamTypeDefaultDescription
rolesstring | RoleThe 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]booleantrueWhether to cache the role object.
[options.force]booleanfalseWhether to force fetching the role from the API even if it is already in the cache.

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.

ParamTypeDescription
rolesstring | objectThe roles to fetch. Can be a string representing a role ID or an object containing options.
optionsobjectThe options for fetching roles. Can contain properties like cache and force.

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.

ParamTypeDescription
optionsObjectThe options for creating the role.
options.reasonstringThe reason for creating the role.
options.positionnumberThe position of the role in the hierarchy.

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.

ParamTypeDescription
rolestring | RoleThe role ID or role object to edit.
[options]ObjectAdditional options for editing the role.
[options.reason]stringThe reason for editing the role.
[options.position]numberThe new position of the role.

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.
ParamTypeDescription
rolestring | RoleThe role to delete. Can be either the role ID or the Role object.
reasonstringThe reason for deleting the role.

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.
ParamTypeDescription
[role]string | ObjectThe role to clone. Can be either a role ID or a role object.

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.

ParamTypeDescription
[options]ObjectThe options for modifying the position.
[options.reason]stringThe reason for the modification.
[options.data]ArrayThe data containing the roles to modify.

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.

ParamTypeDefaultDescription
oobjectThe payload object to transform.
[modifyPosition]booleanfalseWhether to modify the position property.