From 170fa3acc2ed1c6441c91199a1bf17b74924c976 Mon Sep 17 00:00:00 2001 From: onerandomusername Date: Thu, 2 Dec 2021 00:40:25 -0500 Subject: [PATCH] nit: add docstring, constant, additional max_size shrinkage --- modmail/utils/pagination.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modmail/utils/pagination.py b/modmail/utils/pagination.py index 877bc2d1..3625bdea 100644 --- a/modmail/utils/pagination.py +++ b/modmail/utils/pagination.py @@ -31,11 +31,14 @@ JUMP_LAST_LABEL = " \u276f\u276f " # >> STOP_PAGINATE_EMOJI = "\u274c" # [:x:] This is an emoji, which is treated differently from the above -logger: ModmailLogger = logging.getLogger(__name__) +NO_EMBED_FOOTER_BUMP = 15 _AUTOGENERATE = object() +logger: ModmailLogger = logging.getLogger(__name__) + + class ButtonPaginator(ui.View, DpyPaginator): """ A class that helps in paginating long messages/embeds, which can be interacted via discord buttons. @@ -78,6 +81,8 @@ def __init__( If source message is provided and only_users is NOT provided, the paginator will respond to the author of the source message. To override this, pass an empty list to `only_users`. + By default, an embed is created. However, a custom embed can + be passed, or None can be passed to not use an embed. """ self.index = 0 self._pages: List[str] = [] @@ -92,11 +97,11 @@ def __init__( # used if embed is None self.content = "" - if embed is None: + if self.embed is None: self.title = title # need to set the max_size down a few to be able to set a "footer" # page indicator is "page xx of xx" - self.max_size -= 15 + self.max_size -= NO_EMBED_FOOTER_BUMP + len(self.title or "") if self.title is not None: self.max_size -= len(title) if footer_text is not None: