aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/error_handler.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/bot/cogs/error_handler.py b/bot/cogs/error_handler.py
index 7078d425d..6a0aef13e 100644
--- a/bot/cogs/error_handler.py
+++ b/bot/cogs/error_handler.py
@@ -1,10 +1,12 @@
import contextlib
import logging
+import typing as t
from discord.ext.commands import (
BadArgument,
BotMissingPermissions,
CheckFailure,
+ Command,
CommandError,
CommandInvokeError,
CommandNotFound,
@@ -53,18 +55,9 @@ class ErrorHandler(Cog):
10. Otherwise, handling is deferred to `handle_unexpected_error`
"""
command = ctx.command
- parent = None
- if command is not None:
- parent = command.parent
-
- # Retrieve the help command for the invoked command.
- if parent and command:
- help_command = (self.bot.get_command("help"), parent.name, command.name)
- elif command:
- help_command = (self.bot.get_command("help"), command.name)
- else:
- help_command = (self.bot.get_command("help"),)
+ # TODO: use ctx.send_help() once PR #519 is merged.
+ help_command = await self.get_help_command(command)
if hasattr(e, "handled"):
log.trace(f"Command {command} had its error already handled locally; ignoring.")
@@ -100,6 +93,20 @@ class ErrorHandler(Cog):
# MaxConcurrencyReached, ExtensionError
await self.handle_unexpected_error(ctx, e)
+ async def get_help_command(self, command: t.Optional[Command]) -> t.Tuple:
+ """Return the help command invocation args to display help for `command`."""
+ parent = None
+ if command is not None:
+ parent = command.parent
+
+ # Retrieve the help command for the invoked command.
+ if parent and command:
+ return self.bot.get_command("help"), parent.name, command.name
+ elif command:
+ return self.bot.get_command("help"), command.name
+ else:
+ return self.bot.get_command("help")
+
async def try_get_tag(self, ctx: Context) -> None:
"""
Attempt to display a tag by interpreting the command name as a tag name.