-
-
Save Gobot1234/30e7f8f3fcb1ac9021fcb55742ac18d6 to your computer and use it in GitHub Desktop.
Subclassing the help command in discord.py - get_command...(command) methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_command_signature(self, command): | |
"""Method to return a commands name and signature""" | |
if not command.signature and not command.parent: # checking if it has no args and isn't a subcommand | |
return f'`{self.clean_prefix}{command.name}`' | |
if command.signature and not command.parent: # checking if it has args and isn't a subcommand | |
return f'`{self.clean_prefix}{command.name}` `{command.signature}`' | |
if not command.signature and command.parent: # checking if it has no args and is a subcommand | |
return f'`{command.name}`' | |
else: # else assume it has args a signature and is a subcommand | |
return f'`{command.name}` `{command.signature}`' | |
def get_command_aliases(self, command): # this is a custom written method along with all the others below this | |
"""Method to return a commands aliases""" | |
if not command.aliases: # check if it has any aliases | |
return '' | |
else: | |
return f'command aliases are [`{"` | `".join([alias for alias in command.aliases])}`]' | |
def get_command_description(self, command): | |
"""Method to return a commands short doc/brief""" | |
if not command.short_doc: # check if it has any brief | |
return 'There is no documentation for this command currently' | |
else: | |
return command.short_doc | |
def get_command_help(self, command): | |
"""Method to return a commands full description/doc string""" | |
if not command.help: # check if it has any brief or doc string | |
return 'There is no documentation for this command currently' | |
else: | |
return command.help |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment