mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-08 10:53:10 +00:00
simplify HistoryIterator message ordering
rename reverse -> oldest_first, which is more obvious what it does. Then, honor it entirely - if you specify no `after` endpoint, we default to the beginning of message history, similar to how `before` defaults to the end of message history. This is a breaking change, and will change the behavior of any iterator that previously would have been returning messages in a weird order for limits over 100 `for msg in history(reversed=True, limit=300)` would return the newest 300 messages, in a messed up order (100..0, 200..100, 300..200). `for msg in history(oldest_first=True, limit=300)` will now return the oldest 300 messages in order. And so on. `for msg in history(after=msg)` is unchanged, this previously would return the oldest 100 messages after `msg`, oldest->newest order, and still will.
This commit is contained in:
@ -265,7 +265,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
message_ids = [m.id for m in messages]
|
||||
await self._state.http.delete_messages(self.id, message_ids)
|
||||
|
||||
async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, reverse=False, bulk=True):
|
||||
async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True):
|
||||
"""|coro|
|
||||
|
||||
Purges a list of messages that meet the criteria given by the predicate
|
||||
@ -306,8 +306,8 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
Same as ``after`` in :meth:`history`.
|
||||
around
|
||||
Same as ``around`` in :meth:`history`.
|
||||
reverse
|
||||
Same as ``reverse`` in :meth:`history`.
|
||||
oldest_first
|
||||
Same as ``oldest_first`` in :meth:`history`.
|
||||
bulk: class:`bool`
|
||||
If True, use bulk delete. bulk=False is useful for mass-deleting
|
||||
a bot's own messages without manage_messages. When True, will fall
|
||||
@ -330,7 +330,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
|
||||
if check is None:
|
||||
check = lambda m: True
|
||||
|
||||
iterator = self.history(limit=limit, before=before, after=after, reverse=reverse, around=around)
|
||||
iterator = self.history(limit=limit, before=before, after=after, oldest_first=oldest_first, around=around)
|
||||
ret = []
|
||||
count = 0
|
||||
|
||||
|
Reference in New Issue
Block a user