[Mutes] Fix NotFound error when trying to delete message (#5163)

* [Mutes] Fix NotFound error when trying to delete message

* other occurances
This commit is contained in:
Kreus Amredes 2021-08-31 19:47:32 +01:00 committed by GitHub
parent 299d6c57d9
commit c34f1e2f01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1030,11 +1030,13 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
try: try:
await ctx.bot.wait_for(event, check=pred, timeout=30) await ctx.bot.wait_for(event, check=pred, timeout=30)
except asyncio.TimeoutError: except asyncio.TimeoutError:
with contextlib.suppress(discord.NotFound):
await query.delete() await query.delete()
return False return False
if not pred.result: if not pred.result:
if can_react: if can_react:
with contextlib.suppress(discord.NotFound):
await query.delete() await query.delete()
else: else:
await ctx.send(_("OK then.")) await ctx.send(_("OK then."))
@ -1242,11 +1244,13 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass):
try: try:
await ctx.bot.wait_for(event, check=pred, timeout=30) await ctx.bot.wait_for(event, check=pred, timeout=30)
except asyncio.TimeoutError: except asyncio.TimeoutError:
with contextlib.suppress(discord.NotFound):
await query.delete() await query.delete()
return return
if not pred.result: if not pred.result:
if can_react: if can_react:
with contextlib.suppress(discord.NotFound):
await query.delete() await query.delete()
else: else:
await ctx.send(_("OK then.")) await ctx.send(_("OK then."))