components ¶
UI components for the help command system.
This module contains all the UI components used by the help command, including: - Base views and components - Select menus for categories, commands, and subcommands - Navigation buttons - Pagination components
Classes:
-
HelpCommandProtocol–Protocol defining methods a help command must implement.
-
BaseHelpView–Base view for all help command navigation.
-
BaseSelectMenu–Base class for help selection menus.
-
BaseButton–Base class for help navigation buttons.
-
CategorySelectMenu–Select menu for choosing a command category.
-
CommandSelectMenu–Select menu for choosing a command within a category.
-
SubcommandSelectMenu–Select menu for choosing a subcommand within a command group.
-
BackButton–Button for navigating back to the previous page.
-
CloseButton–Button for closing the help menu.
-
PaginationButton–Base class for pagination buttons.
-
NextButton–Button for navigating to the next page of subcommands.
-
PrevButton–Button for navigating to the previous page of subcommands.
-
HelpView–Main view for the help command with standard navigation.
-
DirectHelpView–View for paginated direct help commands with previous/next buttons.
Classes¶
HelpCommandProtocol ¶
Bases: Protocol
Protocol defining methods a help command must implement.
Methods:
-
on_category_select–Handle category selection from dropdown menu.
-
on_command_select–Handle command selection from dropdown menu.
-
on_subcommand_select–Handle subcommand selection from dropdown menu.
-
on_back_button–Handle back navigation button press.
-
on_next_button–Handle next page navigation button press.
-
on_prev_button–Handle previous page navigation button press.
Attributes:
Attributes¶
Functions¶
on_category_select async ¶
on_category_select(interaction: Interaction, category: str) -> None
Handle category selection from dropdown menu.
on_command_select async ¶
on_command_select(interaction: Interaction, command_name: str) -> None
Handle command selection from dropdown menu.
on_subcommand_select async ¶
on_subcommand_select(interaction: Interaction, subcommand_name: str) -> None
Handle subcommand selection from dropdown menu.
on_back_button async ¶
on_back_button(interaction: Interaction) -> None
Handle back navigation button press.
on_next_button async ¶
on_next_button(interaction: Interaction) -> None
Handle next page navigation button press.
on_prev_button async ¶
on_prev_button(interaction: Interaction) -> None
Handle previous page navigation button press.
BaseHelpView ¶
BaseHelpView(help_command: HelpCommandProtocol, timeout: int = 180)
Bases: View
Base view for all help command navigation.
Initialize the base help view.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this view belongs to.
-
timeout(int, default:180) –View timeout in seconds (default 180).
Methods:
-
interaction_check–Ensure only the invoker can interact with this view.
Functions¶
interaction_check async ¶
interaction_check(interaction: Interaction) -> bool
Ensure only the invoker can interact with this view.
Returns:
-
bool–True if the interaction user is the author, False otherwise.
BaseSelectMenu ¶
BaseSelectMenu(
help_command: HelpCommandProtocol, options: list[SelectOption], placeholder: str
)
Bases: Select[BaseHelpView]
Base class for help selection menus.
Initialize the base select menu.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this menu belongs to.
-
options(list[SelectOption]) –List of options for the select menu.
-
placeholder(str) –Placeholder text for the select menu.
Methods:
-
handle_select–Handle a selection from this menu.
-
callback–Handle the callback when an option is selected.
Functions¶
handle_select abstractmethod async ¶
handle_select(interaction: Interaction, selected_value: str) -> None
Handle a selection from this menu.
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when an option is selected.
BaseButton ¶
BaseButton(
help_command: HelpCommandProtocol,
style: ButtonStyle,
label: str,
emoji: str,
custom_id: str,
disabled: bool = False,
)
Bases: Button[BaseHelpView]
Base class for help navigation buttons.
Initialize the base button.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this button belongs to.
-
style(ButtonStyle) –The button style (primary, secondary, success, danger, link).
-
label(str) –The button label text.
-
emoji(str) –The button emoji.
-
custom_id(str) –Unique identifier for the button.
-
disabled(bool, default:False) –Whether the button is disabled (default False).
Methods:
-
handle_click–Handle a click on this button.
-
callback–Handle the callback when the button is clicked.
Functions¶
handle_click abstractmethod async ¶
handle_click(interaction: Interaction) -> None
Handle a click on this button.
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when the button is clicked.
CategorySelectMenu ¶
CategorySelectMenu(
help_command: HelpCommandProtocol, options: list[SelectOption], placeholder: str
)
Bases: BaseSelectMenu
Select menu for choosing a command category.
Initialize the base select menu.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this menu belongs to.
-
options(list[SelectOption]) –List of options for the select menu.
-
placeholder(str) –Placeholder text for the select menu.
Methods:
-
callback–Handle the callback when an option is selected.
-
handle_select–Handle when a category is selected.
Functions¶
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when an option is selected.
handle_select async ¶
handle_select(interaction: Interaction, selected_value: str) -> None
Handle when a category is selected.
CommandSelectMenu ¶
CommandSelectMenu(
help_command: HelpCommandProtocol, options: list[SelectOption], placeholder: str
)
Bases: BaseSelectMenu
Select menu for choosing a command within a category.
Initialize the base select menu.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this menu belongs to.
-
options(list[SelectOption]) –List of options for the select menu.
-
placeholder(str) –Placeholder text for the select menu.
Methods:
-
callback–Handle the callback when an option is selected.
-
handle_select–Handle when a command is selected.
Functions¶
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when an option is selected.
handle_select async ¶
handle_select(interaction: Interaction, selected_value: str) -> None
Handle when a command is selected.
SubcommandSelectMenu ¶
SubcommandSelectMenu(
help_command: HelpCommandProtocol, options: list[SelectOption], placeholder: str
)
Bases: BaseSelectMenu
Select menu for choosing a subcommand within a command group.
Initialize the base select menu.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this menu belongs to.
-
options(list[SelectOption]) –List of options for the select menu.
-
placeholder(str) –Placeholder text for the select menu.
Methods:
-
callback–Handle the callback when an option is selected.
-
handle_select–Handle when a subcommand is selected.
Functions¶
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when an option is selected.
handle_select async ¶
handle_select(interaction: Interaction, selected_value: str) -> None
Handle when a subcommand is selected.
BackButton ¶
BackButton(help_command: HelpCommandProtocol)
Bases: BaseButton
Button for navigating back to the previous page.
Initialize the back navigation button.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this button belongs to.
Methods:
-
callback–Handle the callback when the button is clicked.
-
handle_click–Handle when the back button is clicked.
Functions¶
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when the button is clicked.
handle_click async ¶
handle_click(interaction: Interaction) -> None
Handle when the back button is clicked.
CloseButton ¶
CloseButton()
Bases: Button[BaseHelpView]
Button for closing the help menu.
Initialize the close button for dismissing the help menu.
Methods:
-
callback–Handle when the close button is clicked.
Functions¶
callback async ¶
callback(interaction: Interaction) -> None
Handle when the close button is clicked.
PaginationButton ¶
PaginationButton(
help_command: HelpCommandProtocol,
label: str,
emoji: str,
custom_id: str,
is_next: bool,
)
Bases: BaseButton
Base class for pagination buttons.
Initialize the pagination button.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this button belongs to.
-
label(str) –The button label text.
-
emoji(str) –The button emoji.
-
custom_id(str) –Unique identifier for the button.
-
is_next(bool) –Whether this is a "next" button (True) or "previous" button (False).
Methods:
-
handle_click–Handle a click on this button.
-
callback–Handle the callback when the button is clicked.
Functions¶
handle_click abstractmethod async ¶
handle_click(interaction: Interaction) -> None
Handle a click on this button.
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when the button is clicked.
NextButton ¶
NextButton(help_command: HelpCommandProtocol)
Bases: PaginationButton
Button for navigating to the next page of subcommands.
Initialize the next page navigation button.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this button belongs to.
Methods:
-
callback–Handle the callback when the button is clicked.
-
handle_click–Handle when the next button is clicked.
Functions¶
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when the button is clicked.
handle_click async ¶
handle_click(interaction: Interaction) -> None
Handle when the next button is clicked.
PrevButton ¶
PrevButton(help_command: HelpCommandProtocol)
Bases: PaginationButton
Button for navigating to the previous page of subcommands.
Initialize the previous page navigation button.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this button belongs to.
Methods:
-
callback–Handle the callback when the button is clicked.
-
handle_click–Handle when the previous button is clicked.
Functions¶
callback async ¶
callback(interaction: Interaction) -> None
Handle the callback when the button is clicked.
handle_click async ¶
handle_click(interaction: Interaction) -> None
Handle when the previous button is clicked.
HelpView ¶
HelpView(help_command: HelpCommandProtocol, timeout: int = 180)
Bases: BaseHelpView
Main view for the help command with standard navigation.
Initialize the base help view.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this view belongs to.
-
timeout(int, default:180) –View timeout in seconds (default 180).
Methods:
-
interaction_check–Ensure only the invoker can interact with this view.
Functions¶
interaction_check async ¶
interaction_check(interaction: Interaction) -> bool
Ensure only the invoker can interact with this view.
Returns:
-
bool–True if the interaction user is the author, False otherwise.
DirectHelpView ¶
DirectHelpView(
help_command: HelpCommandProtocol,
group: Group[Any, Any, Any],
pages: list[list[Command[Any, Any, Any]]],
)
Bases: BaseHelpView
View for paginated direct help commands with previous/next buttons.
Initialize the direct help view with pagination.
Parameters:
-
help_command(HelpCommandProtocol) –The help command instance this view belongs to.
-
group(Group[Any, Any, Any]) –The command group to display help for.
-
pages(list[list[Command[Any, Any, Any]]]) –Pre-paginated list of commands for navigation.
Methods:
-
interaction_check–Ensure only the invoker can interact with this view.
-
get_embed–Get the embed for the current page.
-
prev_button_callback–Handle previous page button press.
-
next_button_callback–Handle next page button press.
-
close_button_callback–Handle close button press.
Functions¶
interaction_check async ¶
interaction_check(interaction: Interaction) -> bool
Ensure only the invoker can interact with this view.
Returns:
-
bool–True if the interaction user is the author, False otherwise.
prev_button_callback async ¶
prev_button_callback(interaction: Interaction) -> None
Handle previous page button press.
next_button_callback async ¶
next_button_callback(interaction: Interaction) -> None
Handle next page button press.
close_button_callback async ¶
close_button_callback(interaction: Interaction) -> None
Handle close button press.