-
Notifications
You must be signed in to change notification settings - Fork 36
Conversation
Sigmanificient
commented
Jan 10, 2022
Codecov Report
@@ Coverage Diff @@
## main #380 +/- ##
=======================================
Coverage 90.54% 90.54%
=======================================
Files 8 8
Lines 74 74
=======================================
Hits 67 67
Misses 7 7 Continue to review full report at Codecov.
|
while limit > 0: | ||
retrieve = min(limit, 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limit HAS to be capped to 100. If they choose a number too big there will be rate limits and that will cause it to stall because of an "invisible error"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't agree, we need to provide an user-friendly way to get all messages within a channel, even if it is extremely slow.
Discord.py do it has well, see channel.history(limit=...).flatten()
Also it deal very nicely with ratelimiting.
I test it with 4000
messages, in 41.18647676300316
seconds
For 8000
messages, it took 84.87266815700423
seconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point but you need to change things
There can be a lot of api calls so you should use gather. You can even use itertools.chain around gather. I bet that would be useful here.
while limit > 0: | ||
retrieve = min(limit, 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your point but you need to change things
There can be a lot of api calls so you should use gather. You can even use itertools.chain around gather. I bet that would be useful here.
pincer/objects/guild/channel.py
Outdated
if not raw_messages: | ||
break | ||
|
||
for _message in raw_messages[:-1]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry on mobile
before = raw_messages[-1].id
for message in raw_messages:
yield UserMessage.from_dict(message)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raw_messages
is not yet converted payload, so you cant access .id
, i guess we can do ["id"]
tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that would be bettr
Co-authored-by: Endercheif <[email protected]>
Co-authored-by: Endercheif <[email protected]>
Co-authored-by: Endercheif <[email protected]>