mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
perf(Role): linear speed position getter (#9493)
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -188,8 +188,14 @@ class Role extends Base {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get position() {
|
get position() {
|
||||||
const sorted = this.guild._sortedRoles();
|
return this.guild.roles.cache.reduce(
|
||||||
return [...sorted.values()].indexOf(sorted.get(this.id));
|
(acc, role) =>
|
||||||
|
acc +
|
||||||
|
(this.rawPosition === role.rawPosition
|
||||||
|
? BigInt(this.id) > BigInt(role.id)
|
||||||
|
: this.rawPosition > role.rawPosition),
|
||||||
|
0,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user