Skip to content

Commit

Permalink
fix: Reflect the api for bans (Pycord-Development#1828)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby authored Dec 25, 2022
1 parent a960c19 commit 71bbac2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
17 changes: 7 additions & 10 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2156,13 +2156,14 @@ async def fetch_channel(self, channel_id: int, /) -> GuildChannel | Thread:
def bans(
self,
limit: int | None = None,
before: SnowflakeTime | None = None,
after: SnowflakeTime | None = None,
before: Snowflake | None = None,
after: Snowflake | None = None,
) -> BanIterator:
"""|coro|
Retrieves an :class:`.AsyncIterator` that enables receiving the guild's bans. In order to use this, you must
have the :attr:`~Permissions.ban_members` permission.
Users will always be returned in ascending order sorted by user ID. If both the ``before`` and ``after`` parameters are provided, only before is respected.
.. versionchanged:: 2.0
The ``limit``, ``before``. and ``after`` parameters were added. Now returns a :class:`.BanIterator` instead
Expand All @@ -2174,14 +2175,10 @@ def bans(
----------
limit: Optional[:class:`int`]
The number of bans to retrieve. Defaults to 1000.
before: Optional[Union[:class:`.abc.Snowflake`, :class:`datetime.datetime`]]
Retrieve bans before 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.
after: Optional[Union[:class:`.abc.Snowflake`, :class:`datetime.datetime`]]
Retrieve bans 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.
before: Optional[:class:`.abc.Snowflake`]
Retrieve bans before the given user.
after: Optional[:class:`.abc.Snowflake`]
Retrieve bans after the given user.
Yields
------
Expand Down
5 changes: 0 additions & 5 deletions discord/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,11 +689,6 @@ def create_member(self, data):

class BanIterator(_AsyncIterator["BanEntry"]):
def __init__(self, guild, limit=None, before=None, after=None):
if isinstance(after, datetime.datetime):
after = Object(id=time_snowflake(after, high=True))

if isinstance(before, datetime.datetime):
before = Object(id=time_snowflake(before, high=True))

self.guild = guild
self.limit = limit
Expand Down

0 comments on commit 71bbac2

Please sign in to comment.