diff --git a/CHANGELOG.md b/CHANGELOG.md index 51ae7c6ac3..a7468a1e42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,12 @@ These changes are available on the `master` branch, but have not yet been releas - Added new role tags `subscription_listing_id`, `guild_connections` and `available_for_purchase`. ([#2606](https://github.com/Pycord-Development/pycord/pull/2606)) +- Added missing `with_counts` parameter to `fetch_guilds` method. + ([#2615](https://github.com/Pycord-Development/pycord/pull/2615)) +- Added missing permissions: `Permissions.use_soundboard`, + `Permissions.use_external_sounds` and + `Permissions.view_creator_monetization_analytics`. + ([#2620](https://github.com/Pycord-Development/pycord/pull/2620)) ### Fixed diff --git a/discord/client.py b/discord/client.py index 1520952f04..cbc22813fd 100644 --- a/discord/client.py +++ b/discord/client.py @@ -1462,6 +1462,7 @@ def fetch_guilds( limit: int | None = 100, before: SnowflakeTime = None, after: SnowflakeTime = None, + with_counts: bool = True, ) -> GuildIterator: """Retrieves an :class:`.AsyncIterator` that enables receiving your guilds. @@ -1489,6 +1490,11 @@ def fetch_guilds( Retrieve guilds after this date or object. If a datetime is provided, it is recommended to use a UTC aware datetime. If the datetime is naive, it is assumed to be local time. + with_counts: :class:`bool` + Whether to include member count information in guilds. This fills the + :attr:`.Guild.approximate_member_count` and :attr:`.Guild.approximate_presence_count` + fields. + Defaults to ``True``. Yields ------ @@ -1515,7 +1521,9 @@ def fetch_guilds( All parameters are optional. """ - return GuildIterator(self, limit=limit, before=before, after=after) + return GuildIterator( + self, limit=limit, before=before, after=after, with_counts=with_counts + ) async def fetch_template(self, code: Template | str) -> Template: """|coro| diff --git a/discord/http.py b/discord/http.py index 1ca3135f8d..464710daac 100644 --- a/discord/http.py +++ b/discord/http.py @@ -1445,6 +1445,7 @@ def get_guilds( limit: int, before: Snowflake | None = None, after: Snowflake | None = None, + with_counts: bool = True, ) -> Response[list[guild.Guild]]: params: dict[str, Any] = { "limit": limit, @@ -1454,6 +1455,8 @@ def get_guilds( params["before"] = before if after: params["after"] = after + if with_counts: + params["with_counts"] = int(with_counts) return self.request(Route("GET", "/users/@me/guilds"), params=params) diff --git a/discord/iterators.py b/discord/iterators.py index 13f67266ea..eca3c72091 100644 --- a/discord/iterators.py +++ b/discord/iterators.py @@ -585,9 +585,14 @@ class GuildIterator(_AsyncIterator["Guild"]): Object before which all guilds must be. after: Optional[Union[:class:`abc.Snowflake`, :class:`datetime.datetime`]] Object after which all guilds must be. + with_counts: :class:`bool` + Whether to include member count information in guilds. This fills the + :attr:`.Guild.approximate_member_count` and :attr:`.Guild.approximate_presence_count` + fields. + Defaults to ``True``. """ - def __init__(self, bot, limit, before=None, after=None): + def __init__(self, bot, limit, before=None, after=None, with_counts=True): if isinstance(before, datetime.datetime): before = Object(id=time_snowflake(before, high=False)) if isinstance(after, datetime.datetime): @@ -597,6 +602,7 @@ def __init__(self, bot, limit, before=None, after=None): self.limit = limit self.before = before self.after = after + self.with_counts = with_counts self._filter = None @@ -654,7 +660,9 @@ async def _retrieve_guilds(self, retrieve) -> list[Guild]: async def _retrieve_guilds_before_strategy(self, retrieve): """Retrieve guilds using before parameter.""" before = self.before.id if self.before else None - data: list[GuildPayload] = await self.get_guilds(retrieve, before=before) + data: list[GuildPayload] = await self.get_guilds( + retrieve, before=before, with_counts=self.with_counts + ) if len(data): if self.limit is not None: self.limit -= retrieve @@ -664,7 +672,9 @@ async def _retrieve_guilds_before_strategy(self, retrieve): async def _retrieve_guilds_after_strategy(self, retrieve): """Retrieve guilds using after parameter.""" after = self.after.id if self.after else None - data: list[GuildPayload] = await self.get_guilds(retrieve, after=after) + data: list[GuildPayload] = await self.get_guilds( + retrieve, after=after, with_counts=self.with_counts + ) if len(data): if self.limit is not None: self.limit -= retrieve diff --git a/discord/permissions.py b/discord/permissions.py index 497ef597e1..110909384a 100644 --- a/discord/permissions.py +++ b/discord/permissions.py @@ -191,6 +191,7 @@ def all_channel(cls: type[P]) -> P: - :attr:`manage_emojis` - :attr:`view_audit_log` - :attr:`view_guild_insights` + - :attr:`view_creator_monetization_analytics` - :attr:`manage_guild` - :attr:`change_nickname` - :attr:`manage_nicknames` @@ -218,8 +219,10 @@ def general(cls: type[P]) -> P: permissions :attr:`administrator`, :attr:`create_instant_invite`, :attr:`kick_members`, :attr:`ban_members`, :attr:`change_nickname` and :attr:`manage_nicknames` are no longer part of the general permissions. + .. versionchanged:: 2.7 + Added :attr:`view_creator_monetization_analytics` permission. """ - return cls(0b01110000000010000000010010110000) + return cls(0b100000000001110000000010000000010010110000) @classmethod def membership(cls: type[P]) -> P: @@ -250,7 +253,7 @@ def voice(cls: type[P]) -> P: """A factory method that creates a :class:`Permissions` with all "Voice" permissions from the official Discord UI set to ``True``. """ - return cls(0b1000000001000000000000011111100000000001100000000) + return cls(0b1001001001000000000000011111100000000001100000000) @classmethod def stage(cls: type[P]) -> P: @@ -610,6 +613,30 @@ def moderate_members(self) -> int: """ return 1 << 40 + @flag_value + def view_creator_monetization_analytics(self) -> int: + """:class:`bool`: Returns ``True`` if a user can view creator monetization (role subscription) analytics. + + .. versionadded:: 2.7 + """ + return 1 << 41 + + @flag_value + def use_soundboard(self) -> int: + """:class:`bool`: Returns ``True`` if a user can use the soundboard in a voice channel. + + .. versionadded:: 2.7 + """ + return 1 << 42 + + @flag_value + def use_external_sounds(self) -> int: + """:class:`bool`: Returns ``True`` if a user can use external soundboard sounds in a voice channel. + + .. versionadded:: 2.7 + """ + return 1 << 45 + @flag_value def send_voice_messages(self) -> int: """:class:`bool`: Returns ``True`` if a member can send voice messages. @@ -762,6 +789,8 @@ class PermissionOverwrite: use_external_stickers: bool | None start_embedded_activities: bool | None moderate_members: bool | None + use_soundboard: bool | None + use_external_sounds: bool | None send_voice_messages: bool | None set_voice_channel_status: bool | None send_polls: bool | None