[Mod] Bots can delete own messages w/ [p]cleanup user (#461)

Bulk delete endpoint needs `manage_messages`
This commit is contained in:
Will 2016-12-17 20:34:12 -05:00 committed by Twentysix
parent ae6756c637
commit 8593c08f77

View File

@ -505,6 +505,7 @@ class Mod:
server = author.server
is_bot = self.bot.user.bot
has_permissions = channel.permissions_for(server.me).manage_messages
self_delete = user == self.bot.user
def check(m):
if m.author == user:
@ -516,7 +517,7 @@ class Mod:
to_delete = [ctx.message]
if not has_permissions:
if not has_permissions and not self_delete:
await self.bot.say("I'm not allowed to delete messages.")
return
@ -536,7 +537,8 @@ class Mod:
"".format(author.name, author.id, len(to_delete),
user.name, user.id, channel.name))
if is_bot:
if is_bot and not self_delete:
# For whatever reason the purge endpoint requires manage_messages
await self.mass_purge(to_delete)
else:
await self.slow_deletion(to_delete)