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

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

* other occurances
(cherry picked from commit c34f1e2f01)

Co-authored-by: Kreus Amredes <67752638+Kreusada@users.noreply.github.com>

Co-authored-by: Kreus Amredes <67752638+Kreusada@users.noreply.github.com>
This commit is contained in:
Red-GitHubBot
2021-09-08 21:41:28 +02:00
committed by GitHub
parent 339cc6b3dc
commit 267720bbba

View File

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