Repository: discordjs/discord.js
File: packages/discord.js/src/managers/RoleManager.js (JavaScript)

Code before:
   *   .catch(console.error);
   * @example
   * // Fetch a single role
   * message.guild.roles.fetch('222078108977594368')
   *   .then(role => console.log(`The role color is: ${role.colors.primaryColor}`))
   *   .catch(console.error);
   */
  async fetch(id, { cache = true, force = false } = {}) {
    if (!id) {
      const innerData = await this.client.rest.get(Routes.guildRoles(this.guild.id));
      const roles = new Collection();
      for (const role of innerData) roles.set(role.id, this._add(role, cache));
      return roles;
    }

    if (!force) {
      const existing = this.cache.get(id);
      if (existing) return existing;
    }

    const data = await this.client.rest.get(Routes.guildRole(this.guild.id, id));
    return this._add(data, cache);
  }

  /**
   * Fetches the number of members that have 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
   * - A Snowflake
   *
   * @typedef {Role|Snowflake} RoleResolvable
   */

  /**
   * Resolves a {@link RoleResolvable} to a {@link Role} object.
   *
   * @method resolve
   * @memberof RoleManager
   * @instance
   * @param {RoleResolvable} role The role resolvable to resolve
   * @returns {?Role}

Review comment (suggestion):
https://canary.discord.com/channels/222078108977594368/999796393810067607/1448595402302685225

```suggestion
   * Fetches the member count of each role in the guild.
```

Code after:
   *   .catch(console.error);
   * @example
   * // Fetch a single role
   * message.guild.roles.fetch('222078108977594368')
   *   .then(role => console.log(`The role color is: ${role.colors.primaryColor}`))
   *   .catch(console.error);
   */
  async fetch(id, { cache = true, force = false } = {}) {
    if (!id) {
      const innerData = await this.client.rest.get(Routes.guildRoles(this.guild.id));
      const roles = new Collection();
      for (const role of innerData) roles.set(role.id, this._add(role, cache));
      return roles;
    }

    if (!force) {
      const existing = this.cache.get(id);
      if (existing) return existing;
    }

    const data = await this.client.rest.get(Routes.guildRole(this.guild.id, id));
    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
   * - A Snowflake
   *
   * @typedef {Role|Snowflake} RoleResolvable
   */

  /**
   * Resolves a {@link RoleResolvable} to a {@link Role} object.
   *
   * @method resolve
   * @memberof RoleManager
   * @instance
   * @param {RoleResolvable} role The role resolvable to resolve
   * @returns {?Role}