[3.4] [Cleanup] Handle NotFound error of prompt in check_100_plus (#5191) (#5291)

* [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>

(cherry picked from commit 4366af6f6c)

Co-authored-by: PredaaA <46051820+PredaaA@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: PredaaA <46051820+PredaaA@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Red-GitHubBot
2021-09-08 22:32:11 +02:00
committed by GitHub
parent ca3b314b5b
commit ded19fe4fe

View File

@@ -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."))