Check permissions before trying to clear reactions (#3589)

This commit is contained in:
jack1142 2020-02-29 16:00:19 +01:00 committed by GitHub
parent b52c838018
commit d6f9ddc3af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,10 +96,18 @@ async def menu(
)
except asyncio.TimeoutError:
try:
await message.clear_reactions()
except discord.Forbidden: # cannot remove all reactions
if message.channel.permissions_for(ctx.me).manage_messages:
await message.clear_reactions()
else:
raise RuntimeError
except (discord.Forbidden, RuntimeError): # cannot remove all reactions
for key in controls.keys():
await message.remove_reaction(key, ctx.bot.user)
try:
await message.remove_reaction(key, ctx.bot.user)
except discord.Forbidden:
return
except discord.HTTPException:
pass
except discord.NotFound:
return
else: