diff options
| author | 2021-10-16 16:22:37 +0100 | |
|---|---|---|
| committer | 2021-10-17 09:52:21 +0100 | |
| commit | 581bea0ed8918cb38180f48ebf5e2ecda57a7192 (patch) | |
| tree | 68db64118f5d2e29b330db9c00673cd13d3c7b10 | |
| parent | Modlog: remove tzinfo from member_join (#1877) (diff) | |
Formats Help Command Output
Closes #1232
Modifies the docstring sent for per-command help to remove weird formatting issues mentioned in #1232. Removes newlines that are not used for paragraph breaks, after retrieving the docstring, and lets the embed handle it on the discord side.
Allow overriding this behaviour via \u2003 to denote a non-escapable break.
Co-authored-by: Hassan Abouelela <[email protected]>
| -rw-r--r-- | bot/exts/info/help.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bot/exts/info/help.py b/bot/exts/info/help.py index f413caded..743dfdd3f 100644 --- a/bot/exts/info/help.py +++ b/bot/exts/info/help.py @@ -1,4 +1,5 @@ import itertools +import re from collections import namedtuple from contextlib import suppress from typing import List, Union @@ -179,7 +180,10 @@ class CustomHelpCommand(HelpCommand): except CommandError: command_details += NOT_ALLOWED_TO_RUN_MESSAGE - command_details += f"*{command.help or 'No details provided.'}*\n" + # Remove line breaks from docstrings, if not used to separate paragraphs. + # Allow overriding this behaviour via putting \u2003 at the start of a line. + formatted_doc = re.sub("(?<!\n)\n(?![\n\u2003])", " ", command.help) + command_details += f"*{formatted_doc or 'No details provided.'}*\n" embed.description = command_details return embed |