From 4366af6f6cd976dfcec7535d984fc17e9a578f9c Mon Sep 17 00:00:00 2001 From: PredaaA <46051820+PredaaA@users.noreply.github.com> Date: Sat, 4 Sep 2021 00:38:03 +0200 Subject: [PATCH] [Cleanup] Handle NotFound error of prompt in check_100_plus (#5191) * [Cleanup] Handle HTTPException of prompt in check_100_plus * Update redbot/cogs/cleanup/cleanup.py Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> --- redbot/cogs/cleanup/cleanup.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/redbot/cogs/cleanup/cleanup.py b/redbot/cogs/cleanup/cleanup.py index a0a44fcec..3ab1df1f9 100644 --- a/redbot/cogs/cleanup/cleanup.py +++ b/redbot/cogs/cleanup/cleanup.py @@ -1,3 +1,4 @@ +import contextlib import logging from datetime import datetime, timedelta from typing import Callable, List, Optional, Set, Union @@ -61,11 +62,10 @@ class Cleanup(commands.Cog): response = await ctx.bot.wait_for("message", check=MessagePredicate.same_context(ctx)) if response.content.lower().startswith("y"): - await prompt.delete() - try: + with contextlib.suppress(discord.NotFound): + await prompt.delete() + with contextlib.suppress(discord.HTTPException): await response.delete() - except discord.HTTPException: - pass return True else: await ctx.send(_("Cancelled."))