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
2025-12-17 18:59:50 +00:00
committed by GitHub
parent 51b5d38342
commit cad826fc03
2 changed files with 12 additions and 0 deletions

View File

@@ -81,6 +81,17 @@ class RoleManager extends CachedManager {
return this._add(data, cache);
}
/**
* 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

View File

@@ -4723,6 +4723,7 @@ export class RoleManager extends CachedManager<Snowflake, Role, RoleResolvable>
public botRoleFor(user: UserResolvable): Role | null;
public fetch(id: Snowflake, options?: BaseFetchOptions): Promise<Role>;
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>;