3333
3434logger : ModmailLogger = logging .getLogger (__name__ )
3535
36+ _AUTOGENERATE = object ()
37+
3638
3739class ButtonPaginator (ui .View , DpyPaginator ):
3840 """
@@ -57,7 +59,7 @@ def __init__(
5759 contents : Union [List [str ], str ],
5860 / ,
5961 source_message : Optional [discord .Message ] = None ,
60- embed : Embed = None ,
62+ embed : Optional [ Embed ] = _AUTOGENERATE ,
6163 timeout : float = 180 ,
6264 * ,
6365 footer_text : str = None ,
@@ -82,7 +84,13 @@ def __init__(
8284 self .suffix = suffix
8385 self .max_size = max_size
8486 self .linesep = linesep
85- self .embed = embed or Embed ()
87+ if embed is _AUTOGENERATE :
88+ self .embed = Embed ()
89+ else :
90+ self .embed = embed
91+
92+ # used if embed is None
93+ self .content = ""
8694
8795 # temporary to support strings as contents. This will be changed when we added wrapping.
8896 if isinstance (contents , str ):
@@ -116,8 +124,8 @@ def __init__(
116124
117125 # set footer to embed.footer if embed is set
118126 # this is because we will be modifying the footer of this embed
119- if embed is not None :
120- if not isinstance (embed .footer , EmbedProxy ) and footer_text is None :
127+ if self . embed is not None :
128+ if not isinstance (self . embed .footer , EmbedProxy ) and footer_text is None :
121129 footer_text = embed .footer
122130 self .footer_text = footer_text
123131 self .clear ()
@@ -140,7 +148,7 @@ async def paginate(
140148 source_message : discord .Message = None ,
141149 / ,
142150 timeout : float = 180 ,
143- embed : Embed = None ,
151+ embed : Embed = _AUTOGENERATE ,
144152 * ,
145153 footer_text : str = None ,
146154 only : Optional [discord .abc .User ] = None ,
@@ -178,18 +186,28 @@ async def paginate(
178186 channel = source_message .channel
179187
180188 paginator .update_states ()
181- paginator .embed .description = paginator .pages [paginator .index ]
189+ if paginator .embed :
190+ paginator .embed .description = paginator .pages [paginator .index ]
191+ else :
192+ paginator .content = paginator .pages [paginator .index ]
182193 # if there's only one page, don't send the view
183194 if len (paginator .pages ) < 2 :
184- await channel .send (embeds = [paginator .embed ])
195+ if paginator .embed :
196+ await channel .send (embeds = [paginator .embed ])
197+ else :
198+ await channel .send (content = paginator .content )
199+
185200 return
186201
187202 if len (paginator .pages ) < (show_jump_buttons_min_pages or 3 ):
188203 for item in paginator .children :
189204 if getattr (item , "custom_id" , None ) in ["pag_jump_first" , "pag_jump_last" ]:
190205 paginator .remove_item (item )
191206
192- msg : discord .Message = await channel .send (embeds = [paginator .embed ], view = paginator )
207+ if paginator .embed is None :
208+ msg : discord .Message = await channel .send (content = paginator .content , view = paginator )
209+ else :
210+ msg : discord .Message = await channel .send (embeds = [paginator .embed ], view = paginator )
193211
194212 await paginator .wait ()
195213 await msg .edit (view = None )
@@ -212,8 +230,11 @@ async def interaction_check(self, interaction: Interaction) -> bool:
212230 )
213231 return False
214232
215- def get_footer (self ) -> str :
233+ def get_footer (self ) -> Optional [ str ] :
216234 """Returns the footer text."""
235+ if self .embed is None :
236+ self .content = self ._pages [self .index ]
237+ return None
217238 self .embed .description = self ._pages [self .index ]
218239 page_indicator = f"Page { self .index + 1 } /{ len (self ._pages )} "
219240 footer_txt = (
@@ -230,7 +251,9 @@ def update_states(self) -> None:
230251 if the paginator is on the last page, the jump last/move forward buttons will be disabled.
231252 """
232253 # update the footer
233- self .embed .set_footer (text = self .get_footer ())
254+ text = self .get_footer ()
255+ if self .embed :
256+ self .embed .set_footer (text = text )
234257
235258 # determine if the jump buttons should be enabled
236259 more_than_two_pages = len (self ._pages ) > 2
@@ -264,7 +287,10 @@ async def send_page(self, interaction: Interaction) -> None:
264287 """Send new page to discord, after updating the view to have properly disabled buttons."""
265288 self .update_states ()
266289
267- await interaction .message .edit (embed = self .embed , view = self )
290+ if self .embed :
291+ await interaction .message .edit (embed = self .embed , view = self )
292+ else :
293+ await interaction .message .edit (content = self .content , view = self )
268294
269295 @ui .button (label = JUMP_FIRST_LABEL , custom_id = "pag_jump_first" , style = ButtonStyle .primary )
270296 async def go_first (self , _ : Button , interaction : Interaction ) -> None :
0 commit comments