diff options
| author | 2021-07-23 16:27:27 +0100 | |
|---|---|---|
| committer | 2021-07-23 16:27:27 +0100 | |
| commit | e76057e63452d91b48dbbba70c287cdf3d18423a (patch) | |
| tree | da80bc9fcd71006ba4bf107dbb7f513630518c98 | |
| parent | Remove blankline that flake8 doesn't like (diff) | |
Update code to use `utils.messages.wait_for_deletion`
| -rw-r--r-- | bot/exts/info/doc/_cog.py | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index c9daa3680..e00c64150 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -6,7 +6,6 @@ import sys import textwrap from collections import defaultdict from contextlib import suppress -from functools import partial from types import SimpleNamespace from typing import Dict, NamedTuple, Optional, Tuple, Union @@ -35,7 +34,6 @@ FORCE_PREFIX_GROUPS = ( "pdbcommand", "2to3fixer", ) -DELETE_ERROR_MESSAGE_REACTION = '\u274c' # :x: NOT_FOUND_DELETE_DELAY = RedirectOutput.delete_delay # Delay to wait before trying to reach a rescheduled inventory again, in minutes FETCH_RESCHEDULE_DELAY = SimpleNamespace(first=2, repeated=5) @@ -343,29 +341,12 @@ class DocCog(commands.Cog): if doc_embed is None: error_message = await send_denial(ctx, "No documentation found for the requested symbol.") - if ctx.message.mentions or ctx.message.role_mentions: - await error_message.add_reaction(DELETE_ERROR_MESSAGE_REACTION) + await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY) - _predicate_emoji_reaction = partial(predicate_emoji_reaction, ctx, error_message) - try: - await self.bot.wait_for( - 'reaction_add', - check=_predicate_emoji_reaction, - timeout=NOT_FOUND_DELETE_DELAY - ) - - with suppress(discord.NotFound): - await error_message.delete() - - except asyncio.TimeoutError: - await error_message.clear_reaction(DELETE_ERROR_MESSAGE_REACTION) - - else: - await wait_for_deletion(error_message, (ctx.author.id,), timeout=NOT_FOUND_DELETE_DELAY) + if not (ctx.message.mentions or ctx.message.role_mentions): with suppress(discord.NotFound): await ctx.message.delete() - with suppress(discord.NotFound): - await error_message.delete() + else: msg = await ctx.send(embed=doc_embed) await wait_for_deletion(msg, (ctx.author.id,)) |