diff options
| author | 2018-09-26 15:58:16 +0100 | |
|---|---|---|
| committer | 2018-09-26 15:58:16 +0100 | |
| commit | ebc77fa5016a7f204779b0291ec2b6f1cc5596d4 (patch) | |
| tree | 0654655784c00bd5e7198f15d0cadff5d83f015e /modules/commands.py | |
| parent | Update where README.md says bot.db is (diff) | |
| signature | ||
Support using docstrings as command help
Diffstat (limited to 'modules/commands.py')
| -rw-r--r-- | modules/commands.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/commands.py b/modules/commands.py index 02787791..74f70e1d 100644 --- a/modules/commands.py +++ b/modules/commands.py @@ -179,8 +179,12 @@ class Module(object): if command in self.events.on("received").on( "command").get_children(): hooks = self.events.on("received.command").on(command).get_hooks() - if hooks and "help" in hooks[0].kwargs: - event["stdout"].write("%s: %s" % (command, hooks[0].kwargs["help"])) + kwargs = hooks[0].kwargs + help = hooks[0].kwargs.get("help", None + ) or hooks[0].function.__doc__ + + if help: + event["stdout"].write("%s: %s" % (command, help.strip())) else: event["stderr"].write("No help available for %s" % command) else: |
