Skip to content

feat(RoleManager): add fetchMemberCounts#11352

Merged
kodiakhq[bot] merged 4 commits into
mainfrom
feat/guild-role-member-counts
Dec 17, 2025
Merged

feat(RoleManager): add fetchMemberCounts#11352
kodiakhq[bot] merged 4 commits into
mainfrom
feat/guild-role-member-counts

Conversation

@almeidx

@almeidx almeidx commented Dec 9, 2025

Copy link
Copy Markdown
Member

Integrates the new endpoint into the RoleManager

Upstream:

Copilot AI review requested due to automatic review settings December 9, 2025 21:30
@almeidx almeidx requested a review from a team as a code owner December 9, 2025 21:30
@vercel

vercel Bot commented Dec 9, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
discord-js Skipped Skipped Dec 17, 2025 6:57pm
discord-js-guide Skipped Skipped Dec 17, 2025 6:57pm

@coderabbitai

coderabbitai Bot commented Dec 9, 2025

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a new public method fetchMemberCounts() to the RoleManager class that fetches per-role member counts via a REST API call and returns a Collection mapping role IDs to member counts.

Changes

Cohort / File(s) Change Summary
RoleManager fetchMemberCounts method
packages/discord.js/src/managers/RoleManager.js, packages/discord.js/typings/index.d.ts
Added new public async method fetchMemberCounts() that calls REST endpoint Routes.guildRoleMemberCounts(this.guild.id) and returns a Collection of role ID to member count pairs; includes JSDoc documentation noting @everyone role is excluded

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Verify the REST endpoint path and guild ID parameter are correct
  • Confirm Collection construction from API response data matches expected format
  • Review JSDoc accuracy regarding @everyone exclusion and return type documentation

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a new fetchMemberCounts method to RoleManager.
Description check ✅ Passed The description is related to the changeset, explaining that the PR integrates a new endpoint and references the upstream API change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/guild-role-member-counts

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 548d752 and 808b450.

📒 Files selected for processing (2)
  • packages/discord.js/src/managers/RoleManager.js (1 hunks)
  • packages/discord.js/typings/index.d.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/discord.js/typings/index.d.ts (1)
packages/collection/src/collection.ts (2)
  • Collection (12-19)
  • Collection (29-1107)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Agent
  • GitHub Check: Tests
🔇 Additional comments (2)
packages/discord.js/typings/index.d.ts (1)

4701-4711: RoleManager typings match runtime API

fetchMemberCounts(): Promise<Collection<Snowflake, number>> correctly reflects the new method’s runtime behavior and placement alongside the existing fetch overloads is consistent. No issues from a typing/API-surface perspective.

packages/discord.js/src/managers/RoleManager.js (1)

84-93: Implementation of fetchMemberCounts is consistent and straightforward

The method cleanly wraps the member-counts REST endpoint and returns a Collection keyed by role ID with count values, matching the new typings and JSDoc description (including the documented exclusion of @everyone). No correctness or integration issues spotted.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR integrates a new Discord API endpoint into the RoleManager class by adding a fetchMemberCounts() method that retrieves the number of members for each role in a guild. This implementation follows the upstream Discord API documentation update (PR #8025).

Key Changes

  • Added fetchMemberCounts() method to fetch role member counts from the Discord API
  • TypeScript type definitions updated to include the new method signature

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/discord.js/typings/index.d.ts Added TypeScript type definition for the new fetchMemberCounts() method returning a Promise of a Collection mapping Snowflake role IDs to numbers
packages/discord.js/src/managers/RoleManager.js Implemented fetchMemberCounts() method that calls the new Discord API endpoint and transforms the response into a Collection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/discord.js/src/managers/RoleManager.js

This comment was marked as outdated.

Comment thread packages/discord.js/src/managers/RoleManager.js Outdated
@github-project-automation github-project-automation Bot moved this from Todo to Review in Progress in discord.js Dec 11, 2025
Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
@vercel vercel Bot temporarily deployed to Preview – discord-js-guide December 11, 2025 09:10 Inactive
@vercel vercel Bot temporarily deployed to Preview – discord-js December 11, 2025 09:10 Inactive
@almeidx almeidx removed the blocked label Dec 11, 2025
@Jiralite

This comment has been minimized.

@github-project-automation github-project-automation Bot moved this from Review in Progress to Review Approved in discord.js Dec 17, 2025
@vercel vercel Bot temporarily deployed to Preview – discord-js-guide December 17, 2025 18:57 Inactive
@vercel vercel Bot temporarily deployed to Preview – discord-js December 17, 2025 18:57 Inactive
@kodiakhq kodiakhq Bot merged commit cad826f into main Dec 17, 2025
9 checks passed
@kodiakhq kodiakhq Bot deleted the feat/guild-role-member-counts branch December 17, 2025 18:59
@github-project-automation github-project-automation Bot moved this from Review Approved to Done in discord.js Dec 17, 2025
OfficialSirH pushed a commit to OfficialSirH/discord.js that referenced this pull request Jul 5, 2026
* 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>
Jiralite added a commit that referenced this pull request Jul 14, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants