feat(RoleManager): add fetchMemberCounts (#11352)

* feat(RoleManager): add `fetchMemberCounts`

* docs: improve description

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2026-07-14 21:23:15 +01:00
committed by Jiralite
co-authored by Jiralite kodiakhq[bot]
parent c4531d45a0
commit 3b738eef58
2 changed files with 12 additions and 0 deletions
@@ -89,6 +89,17 @@ class RoleManager extends CachedManager {
}
}
/**
* Fetches the member count of each role in the guild.
* <info>This does not include the `@everyone` role.</info>
*
* @returns {Promise<Collection<Snowflake, number>>} A collection mapping role ids to their respective member counts.
*/
async fetchMemberCounts() {
const data = await this.client.rest.get(Routes.guildRoleMemberCounts(this.guild.id));
return new Collection(Object.entries(data));
}
/**
* Data that can be resolved to a Role object. This can be:
* * A Role
+1
View File
@@ -5337,6 +5337,7 @@ export class RoleManager extends CachedManager<Snowflake, Role, RoleResolvable>
public botRoleFor(user: UserResolvable): Role | null;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role | null>;
public fetch(id?: undefined, options?: BaseFetchOptions): Promise<Collection<Snowflake, Role>>;
public fetchMemberCounts(): Promise<Collection<Snowflake, number>>;
public create(options?: RoleCreateOptions): Promise<Role>;
public edit(role: RoleResolvable, options: RoleEditOptions): Promise<Role>;
public delete(role: RoleResolvable, reason?: string): Promise<void>;