Skip to content

Commit

Permalink
fix: Reflect api for bans correctly (#1922)
Browse files Browse the repository at this point in the history
Co-authored-by: Dorukyum <53639936+Dorukyum@users.noreply.github.com>
Co-authored-by: plun1331 <49261529+plun1331@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored May 1, 2023
1 parent 04da6ed commit 4675c6c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2000](https://github.com/Pycord-Development/pycord/pull/2000))
- Fixed `TypeError` in AutoModRule.
([#2029](https://github.com/Pycord-Development/pycord/pull/2029))
- Reflecting the api for gettings bans correctly.
([#1922](https://github.com/Pycord-Development/pycord/pull/1922))

## [2.4.1] - 2023-03-20

Expand Down
22 changes: 12 additions & 10 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2116,13 +2116,19 @@ 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.5
The ``before``. and ``after`` parameters were changed. They are now of the type :class:`.abc.Snowflake` instead of
`SnowflakeTime` to comply with the discord api.
.. versionchanged:: 2.0
The ``limit``, ``before``. and ``after`` parameters were added. Now returns a :class:`.BanIterator` instead
Expand All @@ -2134,14 +2140,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
6 changes: 0 additions & 6 deletions discord/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,12 +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
self.after = after
Expand Down

0 comments on commit 4675c6c

Please sign in to comment.