mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Mod] Bots can delete own messages w/ [p]cleanup user (#461)
Bulk delete endpoint needs `manage_messages`
This commit is contained in:
parent
ae6756c637
commit
8593c08f77
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user