aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhazhyk <[email protected]>2017-07-16 13:58:00 -0700
committerRapptz <[email protected]>2017-07-24 00:11:05 -0400
commitf1e08cccac1a77233f85eca708721572b60153bd (patch)
tree0b099795389080b4f5e8aa6a7838e2f82e67016b
parentRaise in HTTPClient.request when out of retries (diff)
downloaddiscord.py-f1e08cccac1a77233f85eca708721572b60153bd.tar.xz
discord.py-f1e08cccac1a77233f85eca708721572b60153bd.zip
Add bulk argument to TextChannel.purge
bulk=False will never use bulk message delete. Useful e.g. for using the purge interface for deleting the bot's own messages.
-rw-r--r--discord/channel.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/discord/channel.py b/discord/channel.py
index 9aff327f..58559b34 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -214,7 +214,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
yield from self._state.http.delete_messages(self.id, message_ids, reason=reason)
@asyncio.coroutine
- def purge(self, *, limit=100, check=None, before=None, after=None, around=None, reverse=False, reason=None):
+ def purge(self, *, limit=100, check=None, before=None, after=None, around=None, reverse=False, reason=None, bulk=True):
"""|coro|
Purges a list of messages that meet the criteria given by the predicate
@@ -248,6 +248,11 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
Same as ``reverse`` in :meth:`history`.
reason: Optional[str]
The reason for doing this action. Shows up on the audit log.
+ bulk: 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
+ back to single delete if current account is a user bot, or if
+ messages are older than two weeks.
Raises
-------
@@ -281,7 +286,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
count = 0
minimum_time = int((time.time() - 14 * 24 * 60 * 60) * 1000.0 - 1420070400000) << 22
- strategy = self.delete_messages if self._state.is_bot else _single_delete_strategy
+ strategy = self.delete_messages if self._state.is_bot and bulk else _single_delete_strategy
while True:
try: