Class: GuildMemberRoleManager

GuildMemberRoleManager

Manages API methods for roles of a GuildMember and stores their cache.

Constructor

new GuildMemberRoleManager()

Source:

Members

(private, readonly) _roles :Collection.<Snowflake, Role>

The filtered collection of roles of the member
Type:
Source:

(readonly) cache :Collection.<Snowflake, Role>

The roles of this member
Type:
Source:

(readonly, nullable) color :Role

The role of the member used to set their color
Type:
Source:

guild :Guild

The Guild this manager belongs to
Type:
Source:

(readonly) highest :Role

The role of the member with the highest position
Type:
Source:

(readonly, nullable) hoist :Role

The role of the member used to hoist them in a separate category in the users list
Type:
Source:

member :GuildMember

The GuildMember this manager belongs to
Type:
Source:

Methods

add(roleOrRoles, reasonopt) → {Promise.<GuildMember>}

Adds a role (or multiple roles) to the member.
Parameters:
Name Type Attributes Description
roleOrRoles RoleResolvable | Array.<RoleResolvable> | Collection.<Snowflake, Role> The role or roles to add
reason string <optional>
Reason for adding the role(s)
Source:
Returns:
Type
Promise.<GuildMember>

remove(roleOrRoles, reasonopt) → {Promise.<GuildMember>}

Removes a role (or multiple roles) from the member.
Parameters:
Name Type Attributes Description
roleOrRoles RoleResolvable | Array.<RoleResolvable> | Collection.<Snowflake, Role> The role or roles to remove
reason string <optional>
Reason for removing the role(s)
Source:
Returns:
Type
Promise.<GuildMember>

set(roles, reasonopt) → {Promise.<GuildMember>}

Sets the roles applied to the member.
Parameters:
Name Type Attributes Description
roles Collection.<Snowflake, Role> | Array.<RoleResolvable> The roles or role IDs to apply
reason string <optional>
Reason for applying the roles
Source:
Returns:
Type
Promise.<GuildMember>
Examples
// Set the member's roles to a single role
guildMember.roles.set(['391156570408615936'])
  .then(console.log)
  .catch(console.error);
// Remove all the roles from a member
guildMember.roles.set([])
  .then(member => console.log(`Member roles is now of ${member.roles.cache.size} size`))
  .catch(console.error);