@@ -66,6 +66,7 @@ def __init__(
66
66
prefix : str = "```" ,
67
67
suffix : str = "```" ,
68
68
max_size : int = 2000 ,
69
+ title : str = None ,
69
70
linesep : str = "\n " ,
70
71
only_users : Optional [List [Union [discord .Object , discord .abc .User ]]] = None ,
71
72
only_roles : Optional [List [Union [discord .Object , discord .Role ]]] = None ,
@@ -91,6 +92,19 @@ def __init__(
91
92
92
93
# used if embed is None
93
94
self .content = ""
95
+ if embed is not None :
96
+ if title :
97
+ raise TypeError ("Cannot set title if embed is None." )
98
+ self .title = None
99
+ else :
100
+ self .title = title
101
+ # need to set the max_size down a few to be able to set a "footer"
102
+ # page indicator is "page xx of xx"
103
+ self .max_size -= 15
104
+ if self .title is not None :
105
+ self .max_size -= len (title )
106
+ if footer_text is not None :
107
+ self .max_size -= len (footer_text ) + 1
94
108
95
109
# temporary to support strings as contents. This will be changed when we added wrapping.
96
110
if isinstance (contents , str ):
@@ -157,6 +171,7 @@ async def paginate(
157
171
prefix : str = "" ,
158
172
suffix : str = "" ,
159
173
max_size : int = 4000 ,
174
+ title : str = None ,
160
175
linesep : str = "\n " ,
161
176
only_users : Optional [List [Union [discord .Object , discord .abc .User ]]] = None ,
162
177
only_roles : Optional [List [Union [discord .Object , discord .abc .Role ]]] = None ,
@@ -175,6 +190,7 @@ async def paginate(
175
190
prefix = prefix ,
176
191
suffix = suffix ,
177
192
max_size = max_size ,
193
+ title = title ,
178
194
linesep = linesep ,
179
195
only_users = only_users ,
180
196
only_roles = only_roles ,
@@ -186,10 +202,6 @@ async def paginate(
186
202
channel = source_message .channel
187
203
188
204
paginator .update_states ()
189
- if paginator .embed :
190
- paginator .embed .description = paginator .pages [paginator .index ]
191
- else :
192
- paginator .content = paginator .pages [paginator .index ]
193
205
# if there's only one page, don't send the view
194
206
if len (paginator .pages ) < 2 :
195
207
if paginator .embed :
@@ -239,18 +251,18 @@ def update_states(self) -> None:
239
251
if the paginator is on the last page, the jump last/move forward buttons will be disabled.
240
252
"""
241
253
# update the footer
254
+ page_indicator = f"Page { self .index + 1 } /{ len (self ._pages )} "
255
+ footer_text = (
256
+ f"{ self .footer_text } ({ page_indicator } )" if self .footer_text is not None else page_indicator
257
+ )
242
258
if self .embed is None :
243
- self .content = self ._pages [self .index ]
259
+ self .content = (self .title or "" ) + "\n "
260
+ self .content += self ._pages [self .index ]
261
+ self .content += "\n " + footer_text
262
+
244
263
else :
245
264
self .embed .description = self ._pages [self .index ]
246
- page_indicator = f"Page { self .index + 1 } /{ len (self ._pages )} "
247
- self .embed .set_footer (
248
- text = (
249
- f"{ self .footer_text } ({ page_indicator } )"
250
- if self .footer_text is not None
251
- else page_indicator
252
- )
253
- )
265
+ self .embed .set_footer (text = footer_text )
254
266
255
267
# determine if the jump buttons should be enabled
256
268
more_than_two_pages = len (self ._pages ) > 2
@@ -287,6 +299,7 @@ async def send_page(self, interaction: Interaction) -> None:
287
299
if self .embed :
288
300
await interaction .message .edit (embed = self .embed , view = self )
289
301
else :
302
+ print (len (self .content ))
290
303
await interaction .message .edit (content = self .content , view = self )
291
304
292
305
@ui .button (label = JUMP_FIRST_LABEL , custom_id = "pag_jump_first" , style = ButtonStyle .primary )
0 commit comments