Skip to content

Commit

Permalink
Revert "fix: Reflect the api for bans (#1828)"
Browse files Browse the repository at this point in the history
This reverts commit 71bbac2.
  • Loading branch information
BobDotCom committed Feb 10, 2023
1 parent 5904b51 commit 777a2c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
17 changes: 10 additions & 7 deletions discord/guild.py
Expand Up @@ -2158,14 +2158,13 @@ async def fetch_channel(self, channel_id: int, /) -> GuildChannel | Thread:
def bans(
self,
limit: int | None = None,
before: Snowflake | None = None,
after: Snowflake | None = None,
before: SnowflakeTime | None = None,
after: SnowflakeTime | 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 @@ -2177,10 +2176,14 @@ def bans(
----------
limit: Optional[:class:`int`]
The number of bans to retrieve. Defaults to 1000.
before: Optional[:class:`.abc.Snowflake`]
Retrieve bans before the given user.
after: Optional[:class:`.abc.Snowflake`]
Retrieve bans after the given user.
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.
Yields
------
Expand Down
6 changes: 6 additions & 0 deletions discord/iterators.py
Expand Up @@ -689,6 +689,12 @@ 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
self.after = after
Expand Down

0 comments on commit 777a2c6

Please sign in to comment.