mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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:
@@ -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
|
||||
|
||||
1
packages/discord.js/typings/index.d.ts
vendored
1
packages/discord.js/typings/index.d.ts
vendored
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user