A library to create a discord.py 2.0+ paginator (reaction menu/buttons menu). Supports pagination with buttons, reactions, and category selection using selects.
MIT License
Bot releases are hidden (Show)
Published by Defxult over 1 year ago
Published by Defxult almost 2 years ago
pip
installing the libraryPublished by Defxult almost 2 years ago
ViewMenu
would result in an exception/indefinite "thinking" state if the user already responded to the interaction (#38)Published by Defxult about 2 years ago
ctx
has been changed to method
for ReactionMenu
& ViewMenu
constructor and is now positional onlymenu_type
for ReactionMenu
& ViewMenu
constructor is now keyword onlyReactionMenu
has been removedPage
class has been added. Represents each "page" added via .add_page()
/.add_pages()
.last_viewed
now returns a Page
. .pages
now returns a List[Page]
ViewButton.skip()
& ReactionButton.skip()
has been renamed to .generate_skip()
because of an earlier name conflict.ReactionMenu
& ViewMenu
. With this update, each method by default now returns or stops menu's according to whichever class the method was invoked from. For example, ViewMenu.stop_all_sessions()
only stops all ViewMenu
sessions instead of all ReactionMenu
sessions as well as ViewMenu
sessions.
.get_all_dm_sessions()
.get_all_sessions()
.get_session(name: str)
.stop_all_sessions()
.stop_session(name: str, include_all=False)
.get_sessions_count()
.split_sessions()
& .stop_only()
have been removedViewMenu
, method .refresh_menu_buttons()
has been renamed to .refresh_menu_items()
remove_buttons
and disable_buttons
have been removed from method ViewMenu.stop()
. With the addition of selects, the following new parameters will now take their place
remove_items
disable_items
ViewMenu
class
disable_buttons_on_timeout
→ disable_items_on_timeout
remove_buttons_on_timeout
→ remove_items_on_timeout
.add_from_messages()
is no longer async
ViewButton
link buttons would be removed even after setting it as persistentreply
kwarg for ReactionMenu
in a thread or voice channel now works as intended.add_page()
has two new parameters
.add_page(embed)
.add_page(embed=MISSING, content=None, files=MISSING)
quick_start()
. Start a menu with it's default settings only adding the pagesmenu_type
. Displays the menu type that was set in the constructorrows
. Returns all the data that was added to the menu via .add_row()
.randomize_embed_colors()
. Selects a random color for all embeds added to the menuseparator
parameter
.set_page_director_style(..., separator=DEFAULT)
send_to
parameter in the .start()
method.persist
kwarg to ViewButton
. This prevents link buttons from being disabled/removed when the menu times out or is stopped so they can remain clickableViewSelect
. Used to choose categories in the menu. With the addition of selects, the following methods have been added
.add_select(select: ViewSelect)
.remove_select(select: ViewSelect)
.remove_all_selects()
.disable_select(select: ViewSelect)
.disable_all_selects()
.enable_select(select: ViewSelect)
.enable_all_selects()
.get_select(title: Union[str, None])
.set_select_option_relay(func: Callable[[NamedTuple], None], *, only: Optional[Sequence[str]]=None)
.remove_select_option_relay()
.selects
. Returns all ViewSelect
associated with the menuSelectNotFound
Page
class has been added to __init__
and is now available for usemethod
parameter in either the ReactionMenu
or ViewMenu
constructor is of the wrong type, IncorrectType
is now raisedPublished by Defxult over 2 years ago
quick_start()
. Start a menu with it's default settings only adding the pagesmenu_type
. Displays the menu type that was set in the constructorpersist
kwarg to ViewButton
. This prevents link buttons from being disabled/removed when the menu times out or is stopped so they can remain clickableThe default behavior for the below methods have changed. Previously, using the below methods would return/stop menu's for both ReactionMenu
& ViewMenu
. With this update, each method by default now returns or stops menu's according to whichever class the method was invoked from. For example, ViewMenu.stop_all_sessions()
only stops all ViewMenu
sessions instead of all ReactionMenu
sessions and ViewMenu
sessions. This is done with the addition of the fixed
parameter for the following methods. If you like the old behavior, simply set the fixed
parameter to False
.get_all_dm_sessions(fixed=True)
.get_all_sessions(fixed=True)
.get_session(name: str, fixed=True)
.stop_all_sessions(fixed=True)
.stop_session(name: str, include_all=False, fixed=True)
.get_sessions_count(fixed=True)
With this change, method .stop_only()
is now deprecated
Published by Defxult over 2 years ago
ReactionMenu
only) await wait_until_close()
Published by Defxult over 2 years ago
ReactionMenu.STATIC
and ReactionMenu.DYNAMIC
have been renamed
ReactionMenu.STATIC
ReactionMenu.TypeEmbed
ReactionMenu.DYNAMIC
ReactionMenu.TypeEmbedDynamic
ReactionMenu
have been changed
ReactionMenu(ctx, back_button='⬅️', next_button='➡️', config=ReactionMenu.STATIC)
ReactionMenu(ctx, menu_type=ReactionMenu.TypeEmbed)
ReactionMenu
and TextMenu
are no longer separate classes. TextMenu
has been merged into ReactionMenu
. You can use a text menu by doing the following
ReactionMenu(..., menu_type=ReactionMenu.TypeText)
Button
class has been renamed to ReactionButton
to avoid compatibility issues with pycord 2.0ButtonType
has been moved and setting the linked_to
of a button is now set through the button itself
Button(..., linked_to=ButtonType.NEXT_PAGE)
ReactionButton(..., linked_to=ReactionButton.Type.NEXT_PAGE)
ButtonType.caller_details()
has been renamed and moved to ReactionButton
Button(..., details=ButtonType.caller_details())
ReactionButton(..., details=ReactionButton.set_caller_details())
ReactionMenu
parameters back_button
and next_button
have been removed. Use ReactionMenu.add_button()
insteadReactionMenu
parameter config
has been removed/replaced with parameter menu_type
ReactionMenu.run_time
ReactionMenu.default_next_button
ReactionMenu.default_back_button
ReactionMenu.all_buttons
. Use ReactionMenu.buttons
insteadReactionMenu.next_buttons
ReactionMenu.back_buttons
ReactionMenu.first_page_buttons
ReactionMenu.last_page_buttons
ReactionMenu.caller_buttons
ReactionMenu.end_session_buttons
ReactionMenu.go_to_page_buttons
ReactionMenu.help_appear_order()
ReactionMenu.change_appear_order()
SingleUseOnly
ReactionMenu.clear_all_buttons()
to ReactionMenu.remove_all_buttons()
ReactionMenu.all_can_react
is now ReactionMenu.all_can_click
turn_every
in methods ReactionMenu.set_as_auto_paginator()
and ReactionMenu.update_turn_every()
are now keyword only argumentsReactionMenu
attributes are no longer property getters/setters. They are now normal attributes with type hints.get_menu_from_message()
is now positional onlylist
instead of list
or None
(if no sessions/buttons were found). If no sessions/buttons were found, an empty list is returned
.get_all_dm_sessions()
.get_all_sessions()
.get_session()
.buttons_most_clicked
.buttons
Discords Buttons feature has been implemented using pycord. Two classes have been renamed/removed to support discord.ui.View
ButtonsMenu
class
ViewMenu
ViewMenu.update()
method arguments are now keyword onlyComponentsButton
class
ViewButton
ComponentsButton
factory methods. They've been renamed and are now apart of the ViewButton
class
ComponentsButton.basic_back()
ComponentsButton.basic_next()
ViewButton.back()
ViewButton.next()
ReactionMenu.EMOJI_BACK_BUTTON
ReactionMenu.EMOJI_NEXT_BUTTON
ReactionMenu.Emojis.BACK_BUTTON
ReactionMenu.Emojis.NEXT_BUTTON
ReactionButton
names are now case sensitive if you were to get
a buttonReactionMenu
has been replaced by a new method
ReactionMenu.get_button_by_name(name: str)
ReactionMenu.get_button(identity: Union[str, int], *, search_by='name')
. This method now returns only a list
of buttons instead of either a single button or multiple buttonsID_CALLER
information is different now. See the documentation for proper implementationReactionButton(..., skip=ReactionButton.Skip(...))
ReactionMenu.set_relay(..., only: List[ReactionButton]=None)
ReactionMenu.remove_on_timeout()
ReactionMenu.add_pages(pages: Sequence[Union[discord.Embed, str]])
ReactionMenu.add_buttons(buttons: Sequence[ReactionButton])
reply
to the start
method. Enables the menu message to reply to the message that triggered it
ReactionMenu.start(..., reply: bool=False)
ReactionMenu.last_viewed
. Returns the last page that was seen by the user in the pagination processReactionMenu.add_from_ids(messageable: discord.abc.Messageable, message_ids: Sequence[int])
ReactionMenu.add_from_messages(messages: Sequence[discord.Message])
Reactionmenu.separate(values: Sequence[Any])
discord.Embed
or str
ReactionMenu.all_embeds(values: Sequence[Any])
ReactionMenu.all_strings(values: Sequence[Any])
ReactionMenu
's and ViewMenu
's into two separate lists
ReactionMenu.split_sessions()
ReactionMenu
's or ViewMenu
's
ReactionMenu.stop_only(session_type: str)
ReactionMenu.set_page_director_style(style_id: int)
ReactionButton
ReactionButton.back()
ReactionButton.next()
ReactionButton.go_to_first_page()
ReactionButton.go_to_last_page()
ReactionButton.go_to_page()
ReactionButton.end_session()
ReactionButton.all()
ReactionButton.skip(emoji: str, action: str, amount: int)
ReactionMenu.remove_extra_emojis
ViewButton
ViewButton.link(label: str, url: str)
ViewButton.skip(label: str, action: str, amount: int)
ViewMenu.randomize_button_styles()
ViewMenu.set_button_styles(style: discord.ButtonStyle)
ViewButton
now has a name
attributeViewMenu.get_button()
to get buttons by name
ViewMenu.get_button(..., search_by='name')
ReactionButton
& ViewButton
attribute last_clicked
now supports an aware datetime.datetime
send_to
parameter in method .start()
now supports threads.set_on_timeout()
now raises IncorrectType
instead of MenuException
if the parameter given was not callableReactionMenu.add_button()
now also raises MenuSettingsMismatch
ReactionMenu.refresh_auto_pagination_data()
now raises an error if no data was given in it's parameterViewMenuException
and MenuException
. All library exceptions can be caught using MenuException
reactionmenu.version_info()
. Used if submitting a GitHub issue__all__
for reactionmenu
(from reactionmenu import *
)__repr__
for ViewButton.Followup
Published by Defxult almost 3 years ago
BM
= ButtonsMenu
RM
= ReactionMenu
TM
= TextMenu
BM
Fixed an issue where multiple link buttons couldn't be usedPublished by Defxult about 3 years ago
BM
= ButtonsMenu
RM
= ReactionMenu
TM
= TextMenu
RM|TM
The Button
class now has similar attributes to ComponentsButton
Button.menu
Button.clicked_by
Button.total_clicks
Button.last_clicked
BM|RM|TM
ReactionMenu.EMOJI_END_SESSION
is now ⏹️ instead of ❌Published by Defxult over 3 years ago
BM
= ButtonsMenu
RM
= ReactionMenu
TM
= TextMenu
BM
Added the ability to disable or remove a button from the menu when it has been clicked x amount of timesPublished by Defxult over 3 years ago
BM
= ButtonsMenu
RM
= ReactionMenu
TM
= TextMenu
DescriptionOversized
, typically raised when using a dynamic menu and the amount of rows_requested
is too large for the amount of information received, has been updated to reflect that changeBM
Added ComponentsButton.ID_CUSTOM_EMBED
for ComponentsButton
. Buttons that go to the specified embed when clicked and are not apart of the normal pagination processBM
Added the ability to get the ButtonsMenu
instance from a ComponentsButton
ComponentsButton.menu
BM
Added the ability to call a function when buttons are pressed
ButtonsMenu.set_relay()
ButtonsMenu.remove_relay()
RM|TM
Added the ability to remove relays that have been set
ReactionMenu.remove_relay()
BM
Fixed an issue where a button with ComponentsButton.ID_CALLER
could not call discord.py command functionsBM
Fixes for method ButtonsMenu.update()
ComponentsButton.ID_CALLER
or ComponentsButton.ID_SEND_MESSAGE
was already registered to the menu and an attempt to reuse that button during a ButtonsMenu.update()
call, an error would occurnew_pages
, the page index value would still be from before the update, and clicking a back/next button would go to the wrong pagenew_pages
(embeds) that contained footers, the footer information would be removedPublished by Defxult over 3 years ago
BM
= ButtonsMenu
RM
= ReactionMenu
TM
= TextMenu
ButtonsMenu
). Discords new Buttons featureRM|TM
Added the ability to call a function upon menu timeout
ReactionMenu.set_on_timeout(func: object)
RM|TM
Added the ability to get the menu object from a message ID
ReactionMenu.get_menu_from_message(message_id: int)
RM|TM
Added the ability to set menu session limits per guild, channel, or member (before you could only set per guild)RM|TM
Added the ability to remove limits that have been set
ReactionMenu.remove_limit()
RM|TM
Added the ability to access the discord.Member
object of the person that started the menu
ReactionMenu.owner
RM|TM
Added owner
to __repr__
RM|TM
Added the ability to get all active DM sessions
ReactionMenu.get_all_dm_sessions()
Published by Defxult over 3 years ago
TextMenu
). Just like the normal reaction menu but no embeds are involved, only plain text is used. TextMenu
has limited options compared to ReactionMenu
(docs)ReactionMenu
constructors back_button
and next_button
parameters can now be set to None
if you intend to set the menu as an auto-pagination menu (docs)
ReactionMenu.set_as_auto_paginator(turn_every: Union[int, float])
ReactionMenu.update_turn_every(turn_every: Union[int, float])
ReactionMenu.update_all_turn_every(turn_every: Union[int, float])
ReactionMenu.refresh_auto_pagination_data(*embeds: Embed)
ReactionMenu.stop_all_auto_sessions()
ReactionMenu.auto_turn_every
ReactionMenu.auto_paginator
back_button
/next_button
parameters in ReactionMenu
/TextMenu
as well as the emoji
parameter in Button
(docs)
ReactionMenu.EMOJI_NEXT_BUTTON
ReactionMenu.EMOJI_BACK_BUTTON
ReactionMenu.EMOJI_FIRST_PAGE
ReactionMenu.EMOJI_LAST_PAGE
ReactionMenu.EMOJI_GO_TO_PAGE
ReactionMenu.EMOJI_END_SESSION
ReactionMenu.clear_reactions_after
(set to False
)ReactionMenu.navigation_speed
(set to ReactionMenu.FAST
)ReactionMenu.delete_interactions
(set to False
)ReactionMenu.only_roles
(set to None
)ReactionMenu.timeout
(set to 60.0
if set to None
)ReactionMenu.auto_paginator
(set to False
)ReactionMenu.run_time
ReactionMenu.only_roles
discord.Message
object the menu is operating from (docs)
ReactionMenu.message
ReactionMenu.stop_all_sessions()
ReactionMenu.stop_session(name: str, include_all=False)
ReactionMenu.get_session(name: str)
ReactionMenu.get_all_sessions()
ReactionMenu.set_relay(func)
__repr__
for ReactionMenu
IncorrectType
, mainly raised when using a property setter and the supplied value type was not what was expected. NoButtons
, raised when the menu was started but there were no buttons registeredFixed an issue where it was possible to call ReactionMenu.set_main_pages()
and ReactionMenu.set_last_pages()
without actually implementing the necessary parameters
Fixed an issue where if ReactionMenu.clear_all_buttons()
was called and an attempt to access properties ReactionMenu.default_back_button
or ReactionMenu.default_next_button
, an error would occur. In addition, if other buttons were added to the menu after ReactionMenu.clear_all_buttons()
was called and the default back/next properties were accessed, it would not return the true default back/next buttons. It would return the most recently added button after ReactionMenu.clear_all_buttons()
was called. Accessing ReactionMenu.default_back_button
or ReactionMenu.default_next_button
now returns the true default back/next buttons (the buttons set in the ReactionMenu
constructor), even if all buttons were cleared
Fixed an issue where if a menu was sent to a channel other than the one it was triggered in using the send_to
kwarg in method ReactionMenu.start()
. Using a Button
with ButtonType.GO_TO_PAGE
, the prompt would ask what page you'd like to go to but wouldn't respond when a message was sent in the channel where the prompt was
Fixed an issue where if the menu was started with no buttons registered, an error would occur that was not informative. If there's an attempt to start the menu when no buttons are registered, an informative error (exception NoButtons
) is now raised
Fixed an issue where if buttons were added after all buttons were removed and those buttons did not have their name
kwarg set, an error would occur. The menu will now run as expected if buttons were added after all buttons were removed from the menu regardless of if a buttons optional kwarg was not set
ReactionMenu.cancel_all_sessions()
.cancel_all_sessions()
was used as an easy way to essentially "pull the plug" on all menu session processing. Although it being effective, it left certain values of the menu unchanged/not removed which was okay in versions <= 1.0.8
. With this update, because of the changes made for how the overall menu functions, those values are now way too important to be left unchanged/not removed. Using the new class method ReactionMenu.stop_all_sessions()
provides a much cleaner way to end all processing for active menusv1.0.9
, the below properties now return None
instead of an empty list if their list contains no itemsReactionMenu.all_buttons
ReactionMenu.next_buttons
ReactionMenu.back_buttons
Published by Defxult over 3 years ago
ReactionMenu.delete_on_timeout
Published by Defxult over 3 years ago
None
and the navigation_speed
was set to ReactionMenu.FAST
, an error would occurPublished by Defxult over 3 years ago