aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/cogs/doc.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py
index 8b81b3053..4a095fa51 100644
--- a/bot/cogs/doc.py
+++ b/bot/cogs/doc.py
@@ -284,7 +284,13 @@ class Doc(commands.Cog):
if len(description) > 1000:
shortened = description[:1000]
last_paragraph_end = shortened.rfind('\n\n')
- description = description[:last_paragraph_end] + f"... [read more]({permalink})"
+ description = description[:last_paragraph_end]
+
+ # If there is an incomplete code block, cut it out
+ if description.count("```") % 2:
+ codeblock_start = description.rfind('```py')
+ description = description[:codeblock_start].rstrip()
+ description += f"... [read more]({permalink})"
description = WHITESPACE_AFTER_NEWLINES_RE.sub('', description)