Skip to content

GuildMemberRoleManager

classe · Source

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

Extends: DataManager

Properties

member

member: GuildMember

The GuildMember this manager belongs to Source

guild

guild: Guild

The Guild this manager belongs to Source

cache

readonly

cache: Collection<Snowflake, Role>

The roles of this member Source

hoist

readonly · nullable

hoist: Role

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

icon

readonly · nullable

icon: Role

The role of the member used to set their role icon Source

color

readonly · nullable

color: Role

The role of the member used to set their color Source

highest

readonly

highest: Role

The role of the member with the highest position Source

premiumSubscriberRole

readonly · nullable

premiumSubscriberRole: Role

The premium subscriber role of the guild, if present on the member Source

botRole

readonly · nullable

botRole: Role

The managed role this member created when joining the guild, if any Only ever available on bots Source

holds

readonly · private

holds: function

The data structure belonging to this manager. Source

client

readonly

client: Client

The client that instantiated this Manager Source

Methods

add

async

async add(roleOrRoles: RoleResolvable | Array<RoleResolvable> | Collection<Snowflake, Role>, reason?: string): Promise<GuildMember>

Adds a role (or multiple roles) to the member.

Uses the idempotent PUT route for singular roles, otherwise PATCHes the underlying guild member Parameters

NameTypeDescription
roleOrRolesRoleResolvable | Array<RoleResolvable> | Collection<Snowflake, Role>The role or roles to add
reason?stringReason for adding the role(s)

Returns: Promise<GuildMember>Source

remove

async

async remove(roleOrRoles: RoleResolvable | Array<RoleResolvable> | Collection<Snowflake, Role>, reason?: string): Promise<GuildMember>

Removes a role (or multiple roles) from the member.

Uses the idempotent DELETE route for singular roles, otherwise PATCHes the underlying guild member Parameters

NameTypeDescription
roleOrRolesRoleResolvable | Array<RoleResolvable> | Collection<Snowflake, Role>The role or roles to remove
reason?stringReason for removing the role(s)

Returns: Promise<GuildMember>Source

set

set(roles: Collection<Snowflake, Role> | Array<RoleResolvable>, reason?: string): Promise<GuildMember>

Sets the roles applied to the member. Parameters

NameTypeDescription
rolesCollection<Snowflake, Role> | Array<RoleResolvable>The roles or role ids to apply
reason?stringReason for applying the roles

Returns: Promise<GuildMember>

js
// Set the member's roles to a single role
guildMember.roles.set(['391156570408615936'])
  .then(console.log)
  .catch(console.error);
js
// 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);

Source

resolve

resolve(idOrInstance: string | Object): Object

Resolves a data entry to a data Object. Parameters

NameTypeDescription
idOrInstancestring | ObjectThe id or instance of something in this Manager

Returns: Object — An instance from this Manager Source

resolveId

resolveId(idOrInstance: string | Object): Snowflake

Resolves a data entry to an instance id. Parameters

NameTypeDescription
idOrInstancestring | ObjectThe id or instance of something in this Manager

Returns: SnowflakeSource

Unofficial software. Not affiliated with or supported by Discord.