Skip to content

Commit

Permalink
nit: add docstring, constant, additional max_size shrinkage
Browse files Browse the repository at this point in the history
  • Loading branch information
onerandomusername committed Dec 2, 2021
1 parent 94da11e commit a20721d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions modmail/utils/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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] = []
Expand All @@ -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:
Expand Down

0 comments on commit a20721d

Please sign in to comment.