Skip to content

Conversation

@Paillat-dev
Copy link
Member

@Paillat-dev Paillat-dev commented Dec 6, 2025

Summary

depends on discord/discord-api-docs#8021

Ref: https://discord.com/channels/881207955029110855/1411737823635312693/1446851187625164827

Information

  • This PR fixes an issue.
  • This PR adds something new (e.g. new method or parameters).
  • This PR is a breaking change (e.g. methods or parameters removed/renamed).
  • This PR is not a code change (e.g. documentation, README, typehinting,
    examples, ...).

Checklist

  • I have searched the open pull requests for duplicates.
  • If code changes were made then they have been tested.
    • I have updated the documentation to reflect the changes.
  • If type: ignore comments were used, a comment is also left explaining why.
  • I have updated the changelog to include these changes.

@Paillat-dev Paillat-dev requested a review from a team as a code owner December 6, 2025 15:26
@pycord-app
Copy link

pycord-app bot commented Dec 6, 2025

Thanks for opening this pull request!
Please make sure you have read the Contributing Guidelines and Code of Conduct.

This pull request can be checked-out with:

git fetch origin pull/3020/head:pr-3020
git checkout pr-3020

This pull request can be installed with:

pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3020/head

@Paillat-dev Paillat-dev marked this pull request as draft December 6, 2025 15:26
@Paillat-dev Paillat-dev changed the title ✨ Add fetch_roles_member_counts method to Guild and corresponding HTTP route feat: ✨ Add fetch_roles_member_counts method to Guild and corresponding HTTP route Dec 6, 2025
@Paillat-dev Paillat-dev requested a review from Soheab December 6, 2025 15:31
@Paillat-dev Paillat-dev marked this pull request as ready for review December 6, 2025 15:32
@Paillat-dev Paillat-dev requested review from a team as code owners December 6, 2025 15:32
Comment on lines +1122 to +1132
async def fetch_roles_member_counts(self) -> dict[int, int]:
"""|coro|
Fetches a mapping of role IDs to their member counts for this guild.
Returns
-------
Dict[:class:`int`, :class:`int`]
A mapping of role IDs to their member counts.
"""
r = await self._state.http.get_roles_member_counts(self.id)
return {int(role_id): count for role_id, count in r.items()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be a better ux if we map it to Role: count instead of only the IDs? The role should be cached anyways, but we can fall back to Object if needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did think about that. I'm going to see again for mapping a role object, it just seemed weird to me but we could do that. As for Role.count I don't think that would be a good thing, it's not really what it is, you get it separately, it's not on the role object.

Copy link
Contributor

@Soheab Soheab Dec 7, 2025

Choose a reason for hiding this comment

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

Yeah, no Role.count wouldn't make sense and potentially even footgun us when Discord makes that an actual thing but with a different purpose.

Copy link
Member Author

Choose a reason for hiding this comment

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

The only thing with mapping ROle / Object instead of id is that it would force the user to create a discord.Object if they only have an id

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean? The library will be returning either Role or Object as the key, not the user?

Copy link
Member Author

Choose a reason for hiding this comment

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

By user I meant user of the library.

Basically, if they have some role id and they want to get its count, they'd need to create a discord.Object first (should be enough because it and Role both implement Hashable)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants