aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorslice <[email protected]>2019-03-16 20:24:31 -0700
committerDanny <[email protected]>2019-03-16 23:24:31 -0400
commit66af80511f63cb5cb24b06c65bb8aa4697419cfc (patch)
treeed175c4b8534136fb0aaa1107f8c7afc89af6aa8
parentConsider news channel type as a TextChannel (diff)
downloaddiscord.py-66af80511f63cb5cb24b06c65bb8aa4697419cfc.tar.xz
discord.py-66af80511f63cb5cb24b06c65bb8aa4697419cfc.zip
Fix pagination of huge command help messages (> ~2,000 chars)
Previously, calls to add_line in add_command_formatting of default help commands would fail if the command's help message would overflow the current page. This would also result in silent failure as the RuntimeError raised from add_line is never caught. This patch adds behavior that adds lines individually should it raise, which guarantees safe pagination as long as every line is smaller than the maximum page size, which is highly unlikely.
-rw-r--r--discord/ext/commands/help.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py
index 375fe1be..8ad58a6a 100644
--- a/discord/ext/commands/help.py
+++ b/discord/ext/commands/help.py
@@ -889,7 +889,12 @@ class DefaultHelpCommand(HelpCommand):
self.paginator.add_line(signature, empty=True)
if command.help:
- self.paginator.add_line(command.help, empty=True)
+ try:
+ self.paginator.add_line(command.help, empty=True)
+ except RuntimeError:
+ for line in command.help.splitlines():
+ self.paginator.add_line(line)
+ self.paginator.add_line()
def get_destination(self):
ctx = self.context
@@ -1115,7 +1120,12 @@ class MinimalHelpCommand(HelpCommand):
self.paginator.add_line(signature, empty=True)
if command.help:
- self.paginator.add_line(command.help, empty=True)
+ try:
+ self.paginator.add_line(command.help, empty=True)
+ except RuntimeError:
+ for line in command.help.splitlines():
+ self.paginator.add_line(line)
+ self.paginator.add_line()
def get_destination(self):
ctx = self.context