Skip to content

Commit a20721d

Browse files
nit: add docstring, constant, additional max_size shrinkage
1 parent 94da11e commit a20721d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modmail/utils/pagination.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,14 @@
3131
JUMP_LAST_LABEL = " \u276f\u276f " # >>
3232
STOP_PAGINATE_EMOJI = "\u274c" # [:x:] This is an emoji, which is treated differently from the above
3333

34-
logger: ModmailLogger = logging.getLogger(__name__)
34+
NO_EMBED_FOOTER_BUMP = 15
3535

3636
_AUTOGENERATE = object()
3737

3838

39+
logger: ModmailLogger = logging.getLogger(__name__)
40+
41+
3942
class ButtonPaginator(ui.View, DpyPaginator):
4043
"""
4144
A class that helps in paginating long messages/embeds, which can be interacted via discord buttons.
@@ -78,6 +81,8 @@ def __init__(
7881
If source message is provided and only_users is NOT provided, the paginator will respond
7982
to the author of the source message. To override this, pass an empty list to `only_users`.
8083
84+
By default, an embed is created. However, a custom embed can
85+
be passed, or None can be passed to not use an embed.
8186
"""
8287
self.index = 0
8388
self._pages: List[str] = []
@@ -92,11 +97,11 @@ def __init__(
9297

9398
# used if embed is None
9499
self.content = ""
95-
if embed is None:
100+
if self.embed is None:
96101
self.title = title
97102
# need to set the max_size down a few to be able to set a "footer"
98103
# page indicator is "page xx of xx"
99-
self.max_size -= 15
104+
self.max_size -= NO_EMBED_FOOTER_BUMP + len(self.title or "")
100105
if self.title is not None:
101106
self.max_size -= len(title)
102107
if footer_text is not None:

0 commit comments

Comments
 (0)