Skip to content

Commit 97e06c3

Browse files
committed
Force ban pagination
1 parent 5e0e4d1 commit 97e06c3

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

discord/guild.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,15 +2835,19 @@ async def bans(
28352835
limit: Optional[int] = 1000,
28362836
before: Snowflake = MISSING,
28372837
after: Snowflake = MISSING,
2838-
paginate: bool = True,
28392838
) -> AsyncIterator[BanEntry]:
28402839
"""Retrieves an :term:`asynchronous iterator` of the users that are banned from the guild as a :class:`BanEntry`.
28412840
28422841
You must have :attr:`~Permissions.ban_members` to get this information.
28432842
28442843
.. versionchanged:: 2.0
2844+
28452845
Due to a breaking change in Discord's API, this now returns a paginated iterator instead of a list.
28462846
2847+
.. versionchanged:: 2.1
2848+
2849+
Removed the ``paginate`` parameter. It is now always paginated.
2850+
28472851
Examples
28482852
---------
28492853
@@ -2869,11 +2873,6 @@ async def bans(
28692873
Retrieves bans before this user.
28702874
after: :class:`.abc.Snowflake`
28712875
Retrieve bans after this user.
2872-
paginate: :class:`bool`
2873-
Whether to paginate the results. If ``False``, all bans are fetched with a single request and yielded,
2874-
``limit`` is ignored, and ``before`` and ``after`` must not be provided.
2875-
2876-
.. versionadded:: 2.0
28772876
28782877
Raises
28792878
-------
@@ -2897,15 +2896,6 @@ async def bans(
28972896
_state = self._state
28982897
endpoint = _state.http.get_bans
28992898

2900-
if not paginate:
2901-
# For user accounts, not providing a limit will return *every* ban,
2902-
# as they were too lazy to implement proper pagination in the client
2903-
# However, pagination may be wanted for guilds with massive ban lists
2904-
data = await endpoint(self.id)
2905-
for entry in data:
2906-
yield BanEntry(user=User(state=_state, data=entry['user']), reason=entry['reason'])
2907-
return
2908-
29092899
async def _before_strategy(retrieve: int, before: Optional[Snowflake], limit: Optional[int]):
29102900
before_id = before.id if before else None
29112901
data = await endpoint(self.id, limit=retrieve, before=before_id)

discord/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2148,7 +2148,7 @@ def create_from_template(self, code: str, name: str, icon: Optional[str]) -> Res
21482148
def get_bans(
21492149
self,
21502150
guild_id: Snowflake,
2151-
limit: Optional[int] = None,
2151+
limit: int = 1000,
21522152
before: Optional[Snowflake] = None,
21532153
after: Optional[Snowflake] = None,
21542154
) -> Response[List[guild.Ban]]:

0 commit comments

Comments
 (0)