Browse Source

[commands] Context.send_help properly sends to on_help_command_error

pull/2514/head
Rapptz 5 years ago
parent
commit
97d1c970bf
  1. 32
      discord/ext/commands/context.py

32
discord/ext/commands/context.py

@ -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)
if hasattr(entity, '__cog_commands__'): try:
return await cmd.send_cog_help(entity) if hasattr(entity, '__cog_commands__'):
elif isinstance(entity, Group): injected = wrap_callback(cmd.send_cog_help)
return await cmd.send_group_help(entity) return await injected(entity)
elif isinstance(entity, Command): elif isinstance(entity, Group):
return await cmd.send_command_help(entity) injected = wrap_callback(cmd.send_group_help)
else: return await injected(entity)
return None elif isinstance(entity, Command):
injected = wrap_callback(cmd.send_command_help)
return await injected(entity)
else:
return None
except CommandError as e:
await cmd.on_help_command_error(self, e)

Loading…
Cancel
Save