diff options
| author | 2020-06-29 16:27:24 +0200 | |
|---|---|---|
| committer | 2020-06-29 16:27:24 +0200 | |
| commit | 782cd1771ce9254761a70bbfbfa8e883c1330c6c (patch) | |
| tree | 2478d9e68afdcdfbf61578eb76040edccfe85e8c | |
| parent | Trigger typing in converter instead of command. (diff) | |
Add option for user to delete the not found message before it's auto deleted.
| -rw-r--r-- | bot/cogs/doc.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py index 50aa9bbad..b288a92b1 100644 --- a/bot/cogs/doc.py +++ b/bot/cogs/doc.py @@ -12,7 +12,6 @@ from urllib.parse import urljoin import discord from bs4 import BeautifulSoup from bs4.element import PageElement, Tag -from discord.errors import NotFound from discord.ext import commands from markdownify import MarkdownConverter from requests import ConnectTimeout, ConnectionError, HTTPError @@ -24,6 +23,7 @@ from bot.constants import MODERATION_ROLES, RedirectOutput from bot.converters import ValidPythonIdentifier, ValidURL from bot.decorators import with_role from bot.pagination import LinePaginator +from bot.utils.messages import wait_for_deletion log = logging.getLogger(__name__) @@ -468,9 +468,16 @@ class Doc(commands.Cog): colour=discord.Colour.red() ) error_message = await ctx.send(embed=error_embed) - with suppress(NotFound): - await error_message.delete(delay=NOT_FOUND_DELETE_DELAY) - await ctx.message.delete(delay=NOT_FOUND_DELETE_DELAY) + await wait_for_deletion( + error_message, + (ctx.author.id,), + timeout=NOT_FOUND_DELETE_DELAY, + client=self.bot + ) + with suppress(discord.NotFound): + await ctx.message.delete() + with suppress(discord.NotFound): + await error_message.delete() else: await ctx.send(embed=doc_embed) |