@@ -506,7 +506,15 @@ async def dummy():
506506
507507 def should_add_reactions (self ):
508508 """:class:`bool`: Whether to add reactions to this menu session."""
509- return len (self .buttons )
509+ return len (self .buttons ) > 0
510+
511+ def should_add_buttons (self ):
512+ """:class:`bool`: Whether to add button components to this menu session."""
513+ return hasattr (self , 'children' ) and len (self .children ) > 0
514+
515+ def should_add_reactions_or_buttons (self ):
516+ """:class:`bool`: Whether to add reactions or buttons to this menu session."""
517+ return self .should_add_reactions () or self .should_add_buttons ()
510518
511519 def _verify_permissions (self , ctx , channel , permissions ):
512520 if not permissions .send_messages :
@@ -700,7 +708,7 @@ async def start(self, ctx, *, channel=None, wait=False):
700708 if msg is None :
701709 self .message = msg = await self .send_initial_message (ctx , channel )
702710
703- if self .should_add_reactions ():
711+ if self .should_add_reactions_or_buttons ():
704712 # Start the task first so we can listen to reactions before doing anything
705713 for task in self .__tasks :
706714 task .cancel ()
@@ -1144,11 +1152,12 @@ def _disable_unavailable_buttons(self):
11441152 Disables buttons that are unavailable to be pressed.
11451153 """
11461154 buttons : List [MenuPaginationButton ] = self .children
1155+ max_pages = self ._source .get_max_pages ()
11471156 for button in buttons :
11481157 if button .emoji .name in (self .FIRST_PAGE , self .PREVIOUS_PAGE ):
11491158 button .disabled = self .current_page == 0
1150- elif button .emoji .name in (self .LAST_PAGE , self .NEXT_PAGE ):
1151- button .disabled = self .current_page == self . _source . get_max_pages () - 1
1159+ elif max_pages and button .emoji .name in (self .LAST_PAGE , self .NEXT_PAGE ):
1160+ button .disabled = self .current_page == max_pages - 1
11521161
11531162
11541163
0 commit comments