diff options
| author | Harmon758 <[email protected]> | 2016-05-21 17:51:02 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-05-31 19:35:14 -0400 |
| commit | c8698787fa0e30e5bf65d9fc8ffd027bd68cdb03 (patch) | |
| tree | 6774884bf3f6da767258a6d4a81235d6ad9fc04c | |
| parent | Fix ytdl documentation link. (diff) | |
| download | discord.py-c8698787fa0e30e5bf65d9fc8ffd027bd68cdb03.tar.xz discord.py-c8698787fa0e30e5bf65d9fc8ffd027bd68cdb03.zip | |
Allow datetime in limit parameters for purge_from
Check for datetime instead of using logs_from, for 3.4 compatibility
| -rw-r--r-- | discord/client.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/discord/client.py b/discord/client.py index b0c920b3..7ac7ca66 100644 --- a/discord/client.py +++ b/discord/client.py @@ -1058,10 +1058,12 @@ class Client: check : predicate The function used to check if a message should be deleted. It must take a :class:`Message` as its sole parameter. - before : :class:`Message` - The message before scanning for purging must be. - after : :class:`Message` - The message after scanning for purging must be. + before : :class:`Message` or `datetime` + The message or date before which all deleted messages must be. + If a date is provided it must be a timezone-naive datetime representing UTC time. + after : :class:`Message` or `datetime` + The message or date after which all deleted messages must be. + If a date is provided it must be a timezone-naive datetime representing UTC time. Raises ------- @@ -1091,6 +1093,11 @@ class Client: if check is None: check = lambda m: True + if isinstance(before, datetime.datetime): + before = Object(utils.time_snowflake(before, high=False)) + if isinstance(after, datetime.datetime): + after = Object(utils.time_snowflake(after, high=True)) + iterator = LogsFromIterator.create(self, channel, limit, before=before, after=after) ret = [] count = 0 |