mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-09 15:29:57 +00:00
[commands] Fix handling of nested subcommand help handling.
This commit is contained in:
parent
c29f0ea544
commit
31db6efc7f
@ -29,7 +29,6 @@ import discord
|
|||||||
import inspect
|
import inspect
|
||||||
import importlib
|
import importlib
|
||||||
import sys
|
import sys
|
||||||
import functools
|
|
||||||
|
|
||||||
from .core import GroupMixin, Command, command
|
from .core import GroupMixin, Command, command
|
||||||
from .view import StringView
|
from .view import StringView
|
||||||
@ -58,6 +57,7 @@ def _default_help_command(ctx, *commands : str):
|
|||||||
"""Shows this message."""
|
"""Shows this message."""
|
||||||
bot = ctx.bot
|
bot = ctx.bot
|
||||||
destination = ctx.message.channel if not bot.pm_help else ctx.message.author
|
destination = ctx.message.channel if not bot.pm_help else ctx.message.author
|
||||||
|
|
||||||
# help by itself just lists our own commands.
|
# help by itself just lists our own commands.
|
||||||
if len(commands) == 0:
|
if len(commands) == 0:
|
||||||
pages = bot.formatter.format_help_for(ctx, bot)
|
pages = bot.formatter.format_help_for(ctx, bot)
|
||||||
@ -75,12 +75,22 @@ def _default_help_command(ctx, *commands : str):
|
|||||||
|
|
||||||
pages = bot.formatter.format_help_for(ctx, command)
|
pages = bot.formatter.format_help_for(ctx, command)
|
||||||
else:
|
else:
|
||||||
try:
|
name = commands[0]
|
||||||
command = functools.reduce(dict.__getitem__, commands, bot.commands)
|
command = bot.commands.get(name)
|
||||||
except KeyError as e:
|
if command is None:
|
||||||
yield from bot.send_message(destination, 'No command called "{}" found.'.format(e))
|
yield from bot.send_message(destination, 'No command called "{}" found.'.format(name))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
for key in commands[1:]:
|
||||||
|
try:
|
||||||
|
command = command.commands.get(key)
|
||||||
|
if command is None:
|
||||||
|
yield from bot.send_message(destination, 'No command called "{}" found.'.format(key))
|
||||||
|
return
|
||||||
|
except AttributeError:
|
||||||
|
yield from bot.send_message(destination, 'Command "{0.name}" has no subcommands.'.format(command))
|
||||||
|
return
|
||||||
|
|
||||||
pages = bot.formatter.format_help_for(ctx, command)
|
pages = bot.formatter.format_help_for(ctx, command)
|
||||||
|
|
||||||
for page in pages:
|
for page in pages:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user