fix(history_iterator): messages repeat if before & after not set#1273
Open
EmmmaTech wants to merge 3 commits intonextcord:masterfrom
Open
fix(history_iterator): messages repeat if before & after not set#1273EmmmaTech wants to merge 3 commits intonextcord:masterfrom
EmmmaTech wants to merge 3 commits intonextcord:masterfrom
Conversation
teaishealthy
requested changes
Oct 24, 2025
Collaborator
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.
Collaborator
Author
|
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 |
Collaborator
|
ran a few tests master EmmmaTech/fix/async-iterators |
Collaborator
|
oops accidentally closed this |
Collaborator
Author
|
could you share the testing code you used so I can locally test with my own changes? :> |
Collaborator
|
@EmmmaTech make sure to configure the constants at the top of the file, then just call run_history_tests with a TextChannel |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.