@@ -250,7 +250,7 @@ def to_component_dict(self) -> 'ButtonComponent':
250
250
return self ._underlying .to_dict ()
251
251
252
252
253
- class PaginatorInterface (ui .View ): # pylint: disable=too-many-instance-attributes
253
+ class PaginatorInterface (ui .View ): # pylint: disable=too-many-instance-attributes, too-many-public-methods
254
254
"""
255
255
A message and reaction based interface for paginators.
256
256
@@ -287,7 +287,13 @@ class PaginatorInterface(ui.View): # pylint: disable=too-many-instance-attribut
287
287
await interface.add_line("I'm still here!")
288
288
"""
289
289
290
- def __init__ (self , bot : BotT , paginator : commands .Paginator , additional_buttons : typing .Optional [typing .List [ui .Button [typing .Self ]]] = None , ** kwargs : typing .Any ):
290
+ def __init__ (
291
+ self ,
292
+ bot : BotT ,
293
+ paginator : commands .Paginator ,
294
+ additional_buttons : typing .Optional [typing .List [ui .Button [typing .Self ]]] = None ,
295
+ ** kwargs : typing .Any
296
+ ):
291
297
if not isinstance (paginator , commands .Paginator ): # type: ignore
292
298
raise TypeError ('paginator must be a commands.Paginator instance' )
293
299
@@ -318,13 +324,27 @@ def __init__(self, bot: BotT, paginator: commands.Paginator, additional_buttons:
318
324
319
325
super ().__init__ (timeout = self .timeout_length )
320
326
321
- self .button_start : DynamicButton [typing .Self ] = DynamicButton (self .button_start_callback , self .button_start_label , style = discord .ButtonStyle .secondary )
322
- self .button_previous : DynamicButton [typing .Self ] = DynamicButton (self .button_previous_callback , self .button_previous_label , style = discord .ButtonStyle .secondary )
323
- self .button_current : DynamicButton [typing .Self ] = DynamicButton (self .button_current_callback , self .button_current_label , style = discord .ButtonStyle .primary )
324
- self .button_next : DynamicButton [typing .Self ] = DynamicButton (self .button_next_callback , self .button_next_label , style = discord .ButtonStyle .secondary )
325
- self .button_last : DynamicButton [typing .Self ] = DynamicButton (self .button_last_callback , self .button_last_label , style = discord .ButtonStyle .secondary )
326
- self .button_goto : DynamicButton [typing .Self ] = DynamicButton (self .button_goto_callback , self .button_goto_label , style = discord .ButtonStyle .primary )
327
- self .button_close : DynamicButton [typing .Self ] = DynamicButton (self .button_close_callback , self .button_close_label , style = discord .ButtonStyle .danger )
327
+ self .button_start : DynamicButton [typing .Self ] = DynamicButton (
328
+ self .button_start_callback , self .button_start_label , style = discord .ButtonStyle .secondary
329
+ )
330
+ self .button_previous : DynamicButton [typing .Self ] = DynamicButton (
331
+ self .button_previous_callback , self .button_previous_label , style = discord .ButtonStyle .secondary
332
+ )
333
+ self .button_current : DynamicButton [typing .Self ] = DynamicButton (
334
+ self .button_current_callback , self .button_current_label , style = discord .ButtonStyle .primary
335
+ )
336
+ self .button_next : DynamicButton [typing .Self ] = DynamicButton (
337
+ self .button_next_callback , self .button_next_label , style = discord .ButtonStyle .secondary
338
+ )
339
+ self .button_last : DynamicButton [typing .Self ] = DynamicButton (
340
+ self .button_last_callback , self .button_last_label , style = discord .ButtonStyle .secondary
341
+ )
342
+ self .button_goto : DynamicButton [typing .Self ] = DynamicButton (
343
+ self .button_goto_callback , self .button_goto_label , style = discord .ButtonStyle .primary
344
+ )
345
+ self .button_close : DynamicButton [typing .Self ] = DynamicButton (
346
+ self .button_close_callback , self .button_close_label , style = discord .ButtonStyle .danger
347
+ )
328
348
329
349
self .additional_buttons = additional_buttons or []
330
350
@@ -530,6 +550,7 @@ async def button_start_callback(self, interaction: discord.Interaction): # pyli
530
550
await interaction .response .edit_message (** self .send_kwargs )
531
551
532
552
def button_start_label (self , _button : ui .Button [typing .Self ]) -> str :
553
+ """Label for returning to the first page (constant)"""
533
554
return f"1 \u200b { self .emojis .start } "
534
555
535
556
async def button_previous_callback (self , interaction : discord .Interaction ): # pylint: disable=unused-argument
@@ -539,6 +560,7 @@ async def button_previous_callback(self, interaction: discord.Interaction): # p
539
560
await interaction .response .edit_message (** self .send_kwargs )
540
561
541
562
def button_previous_label (self , _button : ui .Button [typing .Self ]) -> str :
563
+ """Left arrow label for going to the previous page (constant)"""
542
564
return str (self .emojis .back )
543
565
544
566
async def button_current_callback (self , interaction : discord .Interaction ): # pylint: disable=unused-argument
@@ -547,6 +569,7 @@ async def button_current_callback(self, interaction: discord.Interaction): # py
547
569
await interaction .response .edit_message (** self .send_kwargs )
548
570
549
571
def button_current_label (self , _button : ui .Button [typing .Self ]) -> str :
572
+ """Current page label (changes on page updates)"""
550
573
return str (self .display_page + 1 )
551
574
552
575
async def button_next_callback (self , interaction : discord .Interaction ): # pylint: disable=unused-argument
@@ -556,6 +579,7 @@ async def button_next_callback(self, interaction: discord.Interaction): # pylin
556
579
await interaction .response .edit_message (** self .send_kwargs )
557
580
558
581
def button_next_label (self , _button : ui .Button [typing .Self ]) -> str :
582
+ """Right arrow label for going to the next page (constant)"""
559
583
return str (self .emojis .forward )
560
584
561
585
async def button_last_callback (self , interaction : discord .Interaction ): # pylint: disable=unused-argument
@@ -565,6 +589,7 @@ async def button_last_callback(self, interaction: discord.Interaction): # pylin
565
589
await interaction .response .edit_message (** self .send_kwargs )
566
590
567
591
def button_last_label (self , _button : ui .Button [typing .Self ]) -> str :
592
+ """Endstop label for going to the last page (changes on page count)"""
568
593
return f"{ self .emojis .end } \u200b { self .page_count } "
569
594
570
595
class PageChangeModal (ui .Modal , title = "Go to page" ):
@@ -599,6 +624,7 @@ async def button_goto_callback(self, interaction: discord.Interaction): # pylin
599
624
await interaction .response .send_modal (self .PageChangeModal (self ))
600
625
601
626
def button_goto_label (self , _button : ui .Button [typing .Self ]) -> str :
627
+ """Label for selecting a page (constant)"""
602
628
return "\N{RIGHTWARDS ARROW WITH HOOK} \u200b Go to page"
603
629
604
630
async def button_close_callback (self , interaction : discord .Interaction ): # pylint: disable=unused-argument
@@ -613,6 +639,7 @@ async def button_close_callback(self, interaction: discord.Interaction): # pyli
613
639
await message .delete ()
614
640
615
641
def button_close_label (self , _button : ui .Button [typing .Self ]) -> str :
642
+ """Label for closing the paginator (constant)"""
616
643
return f"{ self .emojis .close } \u200b Close paginator"
617
644
618
645
0 commit comments