diff options
| author | Rapptz <[email protected]> | 2016-09-26 23:25:52 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-09-26 23:26:26 -0400 |
| commit | 7c0be1cade3f19587db458bc0fbeafd560068e2d (patch) | |
| tree | ebe7fc4ae28e34a7cceac27aceb7e84e64905e89 /discord/ext | |
| parent | Add Permissions.manage_emojis (diff) | |
| download | discord.py-7c0be1cade3f19587db458bc0fbeafd560068e2d.tar.xz discord.py-7c0be1cade3f19587db458bc0fbeafd560068e2d.zip | |
[commands] Raise exception if Paginator gets a line that is too big.
Fixes #340
Diffstat (limited to 'discord/ext')
| -rw-r--r-- | discord/ext/commands/formatter.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/discord/ext/commands/formatter.py b/discord/ext/commands/formatter.py index b00139b7..af45602f 100644 --- a/discord/ext/commands/formatter.py +++ b/discord/ext/commands/formatter.py @@ -74,13 +74,24 @@ class Paginator: def add_line(self, line='', *, empty=False): """Adds a line to the current page. + If the line exceeds the :attr:`max_size` then an exception + is raised. + Parameters ----------- line: str The line to add. empty: bool Indicates if another empty line should be added. + + Raises + ------ + RuntimeError + The line was too big for the current :attr:`max_size`. """ + if len(line) >= self.max_size: + raise RuntimeError('Line exceeds maximum page size %s' % (self.max_size)) + if self._count + len(line) + 1 > self.max_size: self.close_page() |