Browse Source

Fix HelpCommand.invoked_with raising an error

This would happen if the context hasn't been set yet.
pull/7548/head
Stocker 3 years ago
committed by GitHub
parent
commit
13355f3712
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      discord/ext/commands/help.py

6
discord/ext/commands/help.py

@ -45,6 +45,8 @@ __all__ = (
'MinimalHelpCommand',
)
MISSING = discord.utils.MISSING
# help -> shows info of bot on top/bottom and lists subcommands
# help command -> shows detailed info of command
# help command <subcommand chain> -> same as above
@ -318,7 +320,7 @@ class HelpCommand:
self.command_attrs = attrs = options.pop('command_attrs', {})
attrs.setdefault('name', 'help')
attrs.setdefault('help', 'Shows this message')
self.context: Context = discord.utils.MISSING
self.context: Context = MISSING
self._command_impl = _HelpCommandImpl(self, **self.command_attrs)
def copy(self):
@ -398,7 +400,7 @@ class HelpCommand:
"""
command_name = self._command_impl.name
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 ctx.invoked_with

Loading…
Cancel
Save