Skip to content

Commit 4675c6c

Browse files
LulalabyDorukyumplun1331pre-commit-ci[bot]
authored
fix: Reflect api for bans correctly (#1922)
Co-authored-by: Dorukyum <[email protected]> Co-authored-by: plun1331 <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 04da6ed commit 4675c6c

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ These changes are available on the `master` branch, but have not yet been releas
8080
([#2000](https://github.com/Pycord-Development/pycord/pull/2000))
8181
- Fixed `TypeError` in AutoModRule.
8282
([#2029](https://github.com/Pycord-Development/pycord/pull/2029))
83+
- Reflecting the api for gettings bans correctly.
84+
([#1922](https://github.com/Pycord-Development/pycord/pull/1922))
8385

8486
## [2.4.1] - 2023-03-20
8587

discord/guild.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,13 +2116,19 @@ async def fetch_channel(self, channel_id: int, /) -> GuildChannel | Thread:
21162116
def bans(
21172117
self,
21182118
limit: int | None = None,
2119-
before: SnowflakeTime | None = None,
2120-
after: SnowflakeTime | None = None,
2119+
before: Snowflake | None = None,
2120+
after: Snowflake | None = None,
21212121
) -> BanIterator:
21222122
"""|coro|
21232123
21242124
Retrieves an :class:`.AsyncIterator` that enables receiving the guild's bans. In order to use this, you must
21252125
have the :attr:`~Permissions.ban_members` permission.
2126+
Users will always be returned in ascending order sorted by user ID.
2127+
If both the ``before`` and ``after`` parameters are provided, only before is respected.
2128+
2129+
.. versionchanged:: 2.5
2130+
The ``before``. and ``after`` parameters were changed. They are now of the type :class:`.abc.Snowflake` instead of
2131+
`SnowflakeTime` to comply with the discord api.
21262132
21272133
.. versionchanged:: 2.0
21282134
The ``limit``, ``before``. and ``after`` parameters were added. Now returns a :class:`.BanIterator` instead
@@ -2134,14 +2140,10 @@ def bans(
21342140
----------
21352141
limit: Optional[:class:`int`]
21362142
The number of bans to retrieve. Defaults to 1000.
2137-
before: Optional[Union[:class:`.abc.Snowflake`, :class:`datetime.datetime`]]
2138-
Retrieve bans before this date or object.
2139-
If a datetime is provided, it is recommended to use a UTC aware datetime.
2140-
If the datetime is naive, it is assumed to be local time.
2141-
after: Optional[Union[:class:`.abc.Snowflake`, :class:`datetime.datetime`]]
2142-
Retrieve bans after this date or object.
2143-
If a datetime is provided, it is recommended to use a UTC aware datetime.
2144-
If the datetime is naive, it is assumed to be local time.
2143+
before: Optional[:class:`.abc.Snowflake`]
2144+
Retrieve bans before the given user.
2145+
after: Optional[:class:`.abc.Snowflake`]
2146+
Retrieve bans after the given user.
21452147
21462148
Yields
21472149
------

discord/iterators.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -689,12 +689,6 @@ def create_member(self, data):
689689

690690
class BanIterator(_AsyncIterator["BanEntry"]):
691691
def __init__(self, guild, limit=None, before=None, after=None):
692-
if isinstance(after, datetime.datetime):
693-
after = Object(id=time_snowflake(after, high=True))
694-
695-
if isinstance(before, datetime.datetime):
696-
before = Object(id=time_snowflake(before, high=True))
697-
698692
self.guild = guild
699693
self.limit = limit
700694
self.after = after

0 commit comments

Comments
 (0)