fix(history_iterator): messages repeat if before & after not set#1273
fix(history_iterator): messages repeat if before & after not set#1273EmmmaTech wants to merge 4 commits into
Conversation
teaishealthy
left a comment
There was a problem hiding this comment.
I can't seem to get more than 100 messages
counter = 0
async for _ in channel.history(limit=200):
counter += 1
print(counter) # 100 (?)in order to fix the functionality, the oldest_first parameter now defaults to True and the after parameter defaults to OLDEST_OBJECT to mimick the desired default behavior of fetching limit messages from the beginning of channel history.
|
this might be more than a fix now, it's a semi-refactor to try and more closely match the original discord.py behavior while fixing the desired result to fetch limit messages from the beginning of channel history. :p |
|
ran a few tests master EmmmaTech/fix/async-iterators |
|
oops accidentally closed this |
|
could you share the testing code you used so I can locally test with my own changes? :> |
|
@EmmmaTech make sure to configure the constants at the top of the file, then just call run_history_tests with a TextChannel |
teaishealthy
left a comment
There was a problem hiding this comment.
fixed the limit pagination issue.
but: defaulting oldest_first=True changes the default iteration order of channel.history(limit=10) from the newest to the oldest messages. this also creates counterintuitive behavior when using before, as it now walks forward (oldest first) instead of backward from the anchor.
Summary
fixes #1238, an issue introduced with the async iterator rewrite in 3.0 where messages would loop every 100 messages due to the
afterparameter never being updated. I also updated the documentation a bit to clarify this default behavior of the iterator since the original documentation never mentions it.This is a Code Change
task pyrightand fixed the relevant issues.