diff options
| author | Matt (IPv4) Cowley <[email protected]> | 2019-06-28 11:20:08 +0100 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2019-06-29 20:28:32 -0400 |
| commit | 391ff7a486c2511dd0916ba5eaea48fe5b38810e (patch) | |
| tree | 4b0678237c8509c05bf4f320bf186de9c1d1909a | |
| parent | Add support for suppressing embeds. (diff) | |
| download | discord.py-391ff7a486c2511dd0916ba5eaea48fe5b38810e.tar.xz discord.py-391ff7a486c2511dd0916ba5eaea48fe5b38810e.zip | |
[commands] Calculate suffix length at each add_line
| -rw-r--r-- | discord/ext/commands/help.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/discord/ext/commands/help.py b/discord/ext/commands/help.py index 172217ce..72c74d33 100644 --- a/discord/ext/commands/help.py +++ b/discord/ext/commands/help.py @@ -83,7 +83,7 @@ class Paginator: def __init__(self, prefix='```', suffix='```', max_size=2000): self.prefix = prefix self.suffix = suffix - self.max_size = max_size - (0 if suffix is None else len(suffix)) + self.max_size = max_size self.clear() def clear(self): @@ -100,6 +100,10 @@ class Paginator: def _prefix_len(self): return len(self.prefix) if self.prefix else 0 + @property + def _suffix_len(self): + return len(self.suffix) if self.suffix else 0 + def add_line(self, line='', *, empty=False): """Adds a line to the current page. @@ -118,11 +122,11 @@ class Paginator: RuntimeError The line was too big for the current :attr:`max_size`. """ - max_page_size = self.max_size - self._prefix_len - 2 + max_page_size = self.max_size - self._prefix_len - self._suffix_len - 2 if len(line) > max_page_size: raise RuntimeError('Line exceeds maximum page size %s' % (max_page_size)) - if self._count + len(line) + 1 > self.max_size: + if self._count + len(line) + 1 > self.max_size - self._suffix_len: self.close_page() self._count += len(line) + 1 |