aboutsummaryrefslogtreecommitdiff
path: root/discord/abc.py
diff options
context:
space:
mode:
authorkhazhyk <[email protected]>2019-04-07 21:47:59 -0700
committerkhazhyk <[email protected]>2019-04-07 22:46:40 -0700
commit366dc4855b16422df0d22549820a5d5b87ef3c08 (patch)
tree8cbd794830d03a197cbd65ab5fc009b7f58f1c42 /discord/abc.py
parentallow passing 0 for logs_from parameters (diff)
downloaddiscord.py-366dc4855b16422df0d22549820a5d5b87ef3c08.tar.xz
discord.py-366dc4855b16422df0d22549820a5d5b87ef3c08.zip
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.
Diffstat (limited to 'discord/abc.py')
-rw-r--r--discord/abc.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/discord/abc.py b/discord/abc.py
index 4b34e566..86466d3d 100644
--- a/discord/abc.py
+++ b/discord/abc.py
@@ -863,7 +863,7 @@ class Messageable(metaclass=abc.ABCMeta):
data = await state.http.pins_from(channel.id)
return [state.create_message(channel=channel, data=m) for m in data]
- def history(self, *, limit=100, before=None, after=None, around=None, reverse=None):
+ def history(self, *, limit=100, before=None, after=None, around=None, oldest_first=None):
"""Return an :class:`.AsyncIterator` that enables receiving the destination's message history.
You must have :attr:`~.Permissions.read_message_history` permissions to use this.
@@ -902,11 +902,9 @@ class Messageable(metaclass=abc.ABCMeta):
If a date is provided it must be a timezone-naive datetime representing UTC time.
When using this argument, the maximum limit is 101. Note that if the limit is an
even number then this will return at most limit + 1 messages.
- reverse: Optional[:class:`bool`]
- If set to true, return messages in oldest->newest order. If unspecified,
- this defaults to ``False`` for most cases. However if passing in a
- ``after`` parameter then this is set to ``True``. This avoids getting messages
- out of order in the ``after`` case.
+ oldest_first: Optional[:class:`bool`]
+ If set to true, return messages in oldest->newest order. Defaults to True if
+ ``after`` is specified, otherwise False.
Raises
------
@@ -920,7 +918,7 @@ class Messageable(metaclass=abc.ABCMeta):
:class:`.Message`
The message with the message data parsed.
"""
- return HistoryIterator(self, limit=limit, before=before, after=after, around=around, reverse=reverse)
+ return HistoryIterator(self, limit=limit, before=before, after=after, around=around, oldest_first=oldest_first)
class Connectable(metaclass=abc.ABCMeta):