GuildMemberRoleManager: add role that sets the role icon/emoji (#6768)

Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
MarkusRost
2021-10-07 18:28:12 +02:00
committed by GitHub
parent 45ebea3216
commit 03c4b60384
2 changed files with 12 additions and 0 deletions

View File

@@ -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}

1
typings/index.d.ts vendored
View File

@@ -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;