[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>
This commit is contained in:
PredaaA 2021-09-04 00:38:03 +02:00 committed by GitHub
parent 42edb12b2e
commit 4366af6f6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import contextlib
import logging import logging
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Callable, List, Optional, Set, Union 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)) response = await ctx.bot.wait_for("message", check=MessagePredicate.same_context(ctx))
if response.content.lower().startswith("y"): if response.content.lower().startswith("y"):
await prompt.delete() with contextlib.suppress(discord.NotFound):
try: await prompt.delete()
with contextlib.suppress(discord.HTTPException):
await response.delete() await response.delete()
except discord.HTTPException:
pass
return True return True
else: else:
await ctx.send(_("Cancelled.")) await ctx.send(_("Cancelled."))