[commands] Context.send_help properly sends to on_help_command_error

This commit is contained in:
Rapptz 2020-01-18 19:43:20 -05:00
parent 87f9dcff9c
commit 97d1c970bf

View File

@ -258,7 +258,8 @@ class Context(discord.abc.Messageable):
Any Any
The result of the help command, if any. The result of the help command, if any.
""" """
from .core import Group, Command from .core import Group, Command, wrap_callback
from .errors import CommandError
bot = self.bot bot = self.bot
cmd = bot.help_command cmd = bot.help_command
@ -271,7 +272,12 @@ class Context(discord.abc.Messageable):
if len(args) == 0: if len(args) == 0:
await cmd.prepare_help_command(self, None) await cmd.prepare_help_command(self, None)
mapping = cmd.get_bot_mapping() mapping = cmd.get_bot_mapping()
return await cmd.send_bot_help(mapping) injected = wrap_callback(cmd.send_bot_help)
try:
return await injected(mapping)
except CommandError as e:
await cmd.on_help_command_error(self, e)
return None
entity = args[0] entity = args[0]
if entity is None: if entity is None:
@ -288,11 +294,17 @@ class Context(discord.abc.Messageable):
await cmd.prepare_help_command(self, entity.qualified_name) await cmd.prepare_help_command(self, entity.qualified_name)
try:
if hasattr(entity, '__cog_commands__'): if hasattr(entity, '__cog_commands__'):
return await cmd.send_cog_help(entity) injected = wrap_callback(cmd.send_cog_help)
return await injected(entity)
elif isinstance(entity, Group): elif isinstance(entity, Group):
return await cmd.send_group_help(entity) injected = wrap_callback(cmd.send_group_help)
return await injected(entity)
elif isinstance(entity, Command): elif isinstance(entity, Command):
return await cmd.send_command_help(entity) injected = wrap_callback(cmd.send_command_help)
return await injected(entity)
else: else:
return None return None
except CommandError as e:
await cmd.on_help_command_error(self, e)