BaseMenu¶
-
class
dpymenus.BaseMenu(ctx)¶ The abstract base menu object. All menu types derive from this class. Implements generic properties, menu loop handling, and defines various helper methods.
-
set_timeout(duration)¶ Sets the timeout on a menu. Returns itself for fluent-style chaining.
-
set_destination(dest)¶ Sets the message destination for the menu. Returns itself for fluent-style chaining.
- Parameters
dest (
Union[User,TextChannel]) – Where, in Discord, to send and display the menu.- Return type
-
disable_replies()¶ Disables the Reply feature on Discord from being used with this menu. Overrides the global settings. Returns itself for fluent-style chaining.
- Return type
-
show_command_message()¶ Persists user command invocation messages in the chat instead of deleting them after execution. Returns itself for fluent-style chaining.
- Return type
-
persist_on_close()¶ Prevents message cleanup from running when a menu closes. Returns itself for fluent-style chaining.
- Return type
-
set_custom_check(fn)¶ Overrides the default check method for user responses. Returns itself for fluent-style chaining.
-
set_initial_page(index)¶ Sets the initial page of the menu when opened based on a pages index in the add_pages list. Defaults to 0.
-
add_hook(when, event, callback)¶ Sets various callback attributes on the menu so users can hook into specific events. See https://dpymenus.com/lifecycle for the full list of events and hook structure.
- Parameters
- Return type
-
async
close()¶ Gracefully exits out of the menu, performing necessary cleanup of sessions, reactions, and messages.
-
async
next()¶ Transitions to the next page.
-
async
previous()¶ Transitions to the previous page.
-
async
to_first()¶ Transitions to the first page.
-
async
to_last()¶ Transitions to the last page.
-
async
go_to(page=None)¶ Transitions to a specific page.
-
add_pages(pages, template=None)¶ Adds a list of pages to a menu, setting their index based on the position in the list. Returns itself for fluent-style chaining.
- Parameters
pages (
List[ForwardRef]) – A list of pages to display; ordered from first to last in linear menus.template (Template) – An optional
Templateto define a menu style.
- Return type
-
async
send_message(page)¶ Updates the output message if it can be edited, otherwise sends a new message.
- Parameters
page (PageType) – A
PageTypeto send to Discord.
-