mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-07 10:31:59 +00:00
Fix HelpCommand.invoked_with raising an error
This would happen if the context hasn't been set yet.
This commit is contained in:
parent
e15415413b
commit
13355f3712
@ -45,6 +45,8 @@ __all__ = (
|
|||||||
'MinimalHelpCommand',
|
'MinimalHelpCommand',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
MISSING = discord.utils.MISSING
|
||||||
|
|
||||||
# help -> shows info of bot on top/bottom and lists subcommands
|
# help -> shows info of bot on top/bottom and lists subcommands
|
||||||
# help command -> shows detailed info of command
|
# help command -> shows detailed info of command
|
||||||
# help command <subcommand chain> -> same as above
|
# help command <subcommand chain> -> same as above
|
||||||
@ -318,7 +320,7 @@ class HelpCommand:
|
|||||||
self.command_attrs = attrs = options.pop('command_attrs', {})
|
self.command_attrs = attrs = options.pop('command_attrs', {})
|
||||||
attrs.setdefault('name', 'help')
|
attrs.setdefault('name', 'help')
|
||||||
attrs.setdefault('help', 'Shows this message')
|
attrs.setdefault('help', 'Shows this message')
|
||||||
self.context: Context = discord.utils.MISSING
|
self.context: Context = MISSING
|
||||||
self._command_impl = _HelpCommandImpl(self, **self.command_attrs)
|
self._command_impl = _HelpCommandImpl(self, **self.command_attrs)
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
@ -398,7 +400,7 @@ class HelpCommand:
|
|||||||
"""
|
"""
|
||||||
command_name = self._command_impl.name
|
command_name = self._command_impl.name
|
||||||
ctx = self.context
|
ctx = self.context
|
||||||
if ctx is None or ctx.command is None or ctx.command.qualified_name != command_name:
|
if ctx is MISSING or ctx.command is None or ctx.command.qualified_name != command_name:
|
||||||
return command_name
|
return command_name
|
||||||
return ctx.invoked_with
|
return ctx.invoked_with
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user