Skip to content

Commit

Permalink
GuildMemberRoleManager: add role that sets the role icon/emoji (#6768)
Browse files Browse the repository at this point in the history
Co-authored-by: Almeida <almeidx@pm.me>
  • Loading branch information
Markus-Rost and almeidx committed Oct 7, 2021
1 parent 45ebea3 commit 03c4b60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/managers/GuildMemberRoleManager.js
Expand Up @@ -47,6 +47,17 @@ class GuildMemberRoleManager extends DataManager {
return hoistedRoles.reduce((prev, role) => (!prev || role.comparePositionTo(prev) > 0 ? role : prev));
}

/**
* The role of the member used to set their role icon
* @type {?Role}
* @readonly
*/
get icon() {
const iconRoles = this.cache.filter(role => role.icon || role.unicodeEmoji);
if (!iconRoles.size) return null;
return iconRoles.reduce((prev, role) => (role.comparePositionTo(prev) > 0 ? role : prev));
}

/**
* The role of the member used to set their color
* @type {?Role}
Expand Down
1 change: 1 addition & 0 deletions typings/index.d.ts
Expand Up @@ -2751,6 +2751,7 @@ export class GuildStickerManager extends CachedManager<Snowflake, Sticker, Stick
export class GuildMemberRoleManager extends DataManager<Snowflake, Role, RoleResolvable> {
private constructor(member: GuildMember);
public readonly hoist: Role | null;
public readonly icon: Role | null;
public readonly color: Role | null;
public readonly highest: Role;
public readonly premiumSubscriberRole: Role | null;
Expand Down

0 comments on commit 03c4b60

Please sign in to comment.