mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 20:28:38 +00:00
Add with_counts param to fetch_guilds
This commit is contained in:
parent
53ce05b0d0
commit
66689e16e8
@ -2059,13 +2059,15 @@ class Client:
|
|||||||
limit: Optional[int] = 200,
|
limit: Optional[int] = 200,
|
||||||
before: Optional[SnowflakeTime] = None,
|
before: Optional[SnowflakeTime] = None,
|
||||||
after: Optional[SnowflakeTime] = None,
|
after: Optional[SnowflakeTime] = None,
|
||||||
|
with_counts: bool = True,
|
||||||
) -> AsyncIterator[Guild]:
|
) -> AsyncIterator[Guild]:
|
||||||
"""Retrieves an :term:`asynchronous iterator` that enables receiving your guilds.
|
"""Retrieves an :term:`asynchronous iterator` that enables receiving your guilds.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Using this, you will only receive :attr:`.Guild.owner`, :attr:`.Guild.icon`,
|
Using this, you will only receive :attr:`.Guild.owner`, :attr:`.Guild.icon`,
|
||||||
:attr:`.Guild.id`, and :attr:`.Guild.name` per :class:`.Guild`.
|
:attr:`.Guild.id`, :attr:`.Guild.name`, :attr:`.Guild.approximate_member_count`,
|
||||||
|
and :attr:`.Guild.approximate_presence_count` per :class:`.Guild`.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@ -2106,6 +2108,12 @@ class Client:
|
|||||||
Retrieve guilds after this date or object.
|
Retrieve guilds after this date or object.
|
||||||
If a datetime is provided, it is recommended to use a UTC aware datetime.
|
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.
|
If the datetime is naive, it is assumed to be local time.
|
||||||
|
with_counts: :class:`bool`
|
||||||
|
Whether to include count information in the guilds. This fills the
|
||||||
|
:attr:`.Guild.approximate_member_count` and :attr:`.Guild.approximate_presence_count`
|
||||||
|
attributes without needing any privileged intents. Defaults to ``True``.
|
||||||
|
|
||||||
|
.. versionadded:: 2.3
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
------
|
------
|
||||||
@ -2120,7 +2128,7 @@ class Client:
|
|||||||
|
|
||||||
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
|
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
|
||||||
before_id = before.id if before else None
|
before_id = before.id if before else None
|
||||||
data = await self.http.get_guilds(retrieve, before=before_id)
|
data = await self.http.get_guilds(retrieve, before=before_id, with_counts=with_counts)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
@ -2132,7 +2140,7 @@ class Client:
|
|||||||
|
|
||||||
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
|
async def _after_strategy(retrieve: int, after: Optional[Snowflake], limit: Optional[int]):
|
||||||
after_id = after.id if after else None
|
after_id = after.id if after else None
|
||||||
data = await self.http.get_guilds(retrieve, after=after_id)
|
data = await self.http.get_guilds(retrieve, after=after_id, with_counts=with_counts)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
if limit is not None:
|
if limit is not None:
|
||||||
|
@ -250,13 +250,13 @@ class Guild(Hashable):
|
|||||||
|
|
||||||
approximate_member_count: Optional[:class:`int`]
|
approximate_member_count: Optional[:class:`int`]
|
||||||
The approximate number of members in the guild. This is ``None`` unless the guild is obtained
|
The approximate number of members in the guild. This is ``None`` unless the guild is obtained
|
||||||
using :meth:`Client.fetch_guild` with ``with_counts=True``.
|
using :meth:`Client.fetch_guild` or :meth:`Client.fetch_guilds` with ``with_counts=True``.
|
||||||
|
|
||||||
.. versionadded:: 2.0
|
.. versionadded:: 2.0
|
||||||
approximate_presence_count: Optional[:class:`int`]
|
approximate_presence_count: Optional[:class:`int`]
|
||||||
The approximate number of members currently active in the guild.
|
The approximate number of members currently active in the guild.
|
||||||
Offline members are excluded. This is ``None`` unless the guild is obtained using
|
Offline members are excluded. This is ``None`` unless the guild is obtained using
|
||||||
:meth:`Client.fetch_guild` with ``with_counts=True``.
|
:meth:`Client.fetch_guild` or :meth:`Client.fetch_guilds` with ``with_counts=True``.
|
||||||
|
|
||||||
.. versionchanged:: 2.0
|
.. versionchanged:: 2.0
|
||||||
premium_progress_bar_enabled: :class:`bool`
|
premium_progress_bar_enabled: :class:`bool`
|
||||||
|
@ -1373,9 +1373,11 @@ class HTTPClient:
|
|||||||
limit: int,
|
limit: int,
|
||||||
before: Optional[Snowflake] = None,
|
before: Optional[Snowflake] = None,
|
||||||
after: Optional[Snowflake] = None,
|
after: Optional[Snowflake] = None,
|
||||||
|
with_counts: bool = True,
|
||||||
) -> Response[List[guild.Guild]]:
|
) -> Response[List[guild.Guild]]:
|
||||||
params: Dict[str, Any] = {
|
params: Dict[str, Any] = {
|
||||||
'limit': limit,
|
'limit': limit,
|
||||||
|
'with_counts': int(with_counts),
|
||||||
}
|
}
|
||||||
|
|
||||||
if before:
|
if before:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user