Skip to content

Commit

Permalink
fix: TypeError when ScheduledEvent.subscribers limit is None (Pycor…
Browse files Browse the repository at this point in the history
  • Loading branch information
yoggys authored Mar 23, 2024
1 parent a29bc14 commit 548ca85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2402](https://github.com/Pycord-Development/pycord/pull/2402))
- Fixed the type-hinting of `ScheduledEvent.subscribers` to reflect actual behavior.
([#2400](https://github.com/Pycord-Development/pycord/pull/2400))
- Fixed `ScheduledEvent.subscribers` behavior with `limit=None`.
([#2407](https://github.com/Pycord-Development/pycord/pull/2407))

### Changed

Expand Down
10 changes: 8 additions & 2 deletions discord/iterators.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,8 +919,14 @@ async def fill_subs(self):
before=before,
after=after,
)
if data:
self.limit -= self.retrieve

data_length = len(data)
if data_length < self.retrieve:
self.limit = 0
elif data_length > 0:
if self.limit:
self.limit -= self.retrieve
self.after = Object(id=int(data[-1]["user_id"]))

for element in reversed(data):
if "member" in element:
Expand Down
1 change: 1 addition & 0 deletions discord/types/scheduled_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ class ScheduledEventEntityMetadata(TypedDict):

class ScheduledEventSubscriber(TypedDict):
guild_scheduled_event_id: Snowflake
user_id: Snowflake
user: User
member: Member | None

0 comments on commit 548ca85

Please sign in to comment.