aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Volcyy <[email protected]>2018-05-05 10:13:38 +0200
committerGravatar Leon Sandøy <[email protected]>2018-05-05 10:13:38 +0200
commitd641ca86dbb43882418e6c4481f7af56c0f4bb6c (patch)
treef528dd5e54b8d3914aaf201c0233e9f434c27069
parentUpgrade alpine (#65) (diff)
Show alternative syntax in help texts for `bot.tags.keys()` and `bot.tags` (#64)
* Show different footer for `keys` and `get`. * Add alternative syntax invocation to help command. * Differentiate between `()` in command invocation or not.
-rw-r--r--bot/cogs/tags.py9
-rw-r--r--bot/formatter.py7
2 files changed, 15 insertions, 1 deletions
diff --git a/bot/cogs/tags.py b/bot/cogs/tags.py
index 1c8f54d9f..a7c6b0248 100644
--- a/bot/cogs/tags.py
+++ b/bot/cogs/tags.py
@@ -251,11 +251,18 @@ class Tags:
# Paginate if this is a list of all tags
if tags:
+ if ctx.invoked_with == "tags.keys()":
+ detail_invocation = "bot.tags[<tagname>]"
+ elif ctx.invoked_with == "tags.get()":
+ detail_invocation = "bot.tags.get(<tagname>)"
+ else:
+ detail_invocation = "bot.tags.get <tagname>"
+
log.debug(f"Returning a paginated list of all tags.")
return await LinePaginator.paginate(
(lines for lines in tags),
ctx, embed,
- footer_text="To show a tag, type bot.tags.get <tagname>.",
+ footer_text=f"To show a tag, type {detail_invocation}.",
empty=False,
max_lines=15
)
diff --git a/bot/formatter.py b/bot/formatter.py
index f46aaa685..7c966108a 100644
--- a/bot/formatter.py
+++ b/bot/formatter.py
@@ -35,6 +35,13 @@ class Formatter(HelpFormatter):
shortened = self.shorten(entry)
self._paginator.add_line(shortened)
+ if name.endswith('get()'):
+ alternate_syntax_entry = " {0}{1:<{width}} # {2}".format(
+ HELP_PREFIX, name.split('.')[0] + '[<arg>]',
+ f"Alternative syntax for {name}", width=max_width
+ )
+ self._paginator.add_line(self.shorten(alternate_syntax_entry))
+
async def format(self):
"""
rewritten help command to make it more python-y