diff options
| author | 2020-01-12 09:42:31 -0800 | |
|---|---|---|
| committer | 2020-01-12 09:42:31 -0800 | |
| commit | 48041b83bd426aa1988bd1abbc492d82b20670b1 (patch) | |
| tree | 52de2c09649be22e1b42d543a0e1ade113b0f290 | |
| parent | Empty commit for autodeploy. (diff) | |
| parent | Merge branch 'master' into doc-fix (diff) | |
Merge pull request #715 from Numerlor/doc-fix
Make sure docs command's output description is truncated.
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/doc.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py index 9506b195a..cb6f4f972 100644 --- a/bot/cogs/doc.py +++ b/bot/cogs/doc.py @@ -306,10 +306,17 @@ class Doc(commands.Cog): # of a double newline (interpreted as a paragraph) before index 1000. if len(description) > 1000: shortened = description[:1000] - last_paragraph_end = shortened.rfind('\n\n', 100) - if last_paragraph_end == -1: - last_paragraph_end = shortened.rfind('. ') - description = description[:last_paragraph_end] + description_cutoff = shortened.rfind('\n\n', 100) + if description_cutoff == -1: + # Search the shortened version for cutoff points in decreasing desirability, + # cutoff at 1000 if none are found. + for string in (". ", ", ", ",", " "): + description_cutoff = shortened.rfind(string) + if description_cutoff != -1: + break + else: + description_cutoff = 1000 + description = description[:description_cutoff] # If there is an incomplete code block, cut it out if description.count("```") % 2: @@ -318,7 +325,6 @@ class Doc(commands.Cog): description += f"... [read more]({permalink})" description = WHITESPACE_AFTER_NEWLINES_RE.sub('', description) - if signatures is None: # If symbol is a module, don't show signature. embed_description = description |