views ¶
View components for Discord UI interactions.
This module contains reusable view components for complex Discord interactions.
Modules:
-
config–Tux Configuration UI Package.
-
confirmation–Discord Confirmation Views for Tux Bot.
-
tldr–TLDR Paginator View.
Classes:
-
BaseConfirmationView–Base confirmation view with confirm and cancel buttons.
-
ConfirmationDanger–Confirmation view with a danger button.
-
ConfirmationNormal–Confirmation view with a normal button.
-
TldrPaginatorView–Paginator view for navigating through long TLDR pages.
Classes¶
BaseConfirmationView ¶
BaseConfirmationView(user: int)
Bases: View
Base confirmation view with confirm and cancel buttons.
Initialize the base confirmation view.
Parameters:
-
user(int) –The user ID that can interact with this view.
Methods:
-
confirm–Handle the confirm button press.
-
cancel–Handle the cancel button press.
-
update_button_styles–Update button styles for the confirmation view.
Functions¶
confirm async ¶
confirm(interaction: Interaction, button: Button[View]) -> None
Handle the confirm button press.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
cancel async ¶
cancel(interaction: Interaction, button: Button[View]) -> None
Handle the cancel button press.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
update_button_styles ¶
update_button_styles() -> None
Update button styles for the confirmation view.
ConfirmationDanger ¶
ConfirmationDanger(user: int)
Bases: BaseConfirmationView
Confirmation view with a danger button.
Initialize the danger confirmation view.
Parameters:
-
user(int) –The user ID that can interact with this view.
Methods:
-
confirm–Handle the confirm button press.
-
cancel–Handle the cancel button press.
-
update_button_styles–Update button styles for the confirmation view.
Functions¶
confirm async ¶
confirm(interaction: Interaction, button: Button[View]) -> None
Handle the confirm button press.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
cancel async ¶
cancel(interaction: Interaction, button: Button[View]) -> None
Handle the cancel button press.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
update_button_styles ¶
update_button_styles() -> None
Update button styles for the confirmation view.
ConfirmationNormal ¶
ConfirmationNormal(user: int)
Bases: BaseConfirmationView
Confirmation view with a normal button.
Initialize the normal confirmation view.
Parameters:
-
user(int) –The user ID that can interact with this view.
Methods:
-
confirm–Handle the confirm button press.
-
cancel–Handle the cancel button press.
-
update_button_styles–Update button styles for the confirmation view.
Functions¶
confirm async ¶
confirm(interaction: Interaction, button: Button[View]) -> None
Handle the confirm button press.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
cancel async ¶
cancel(interaction: Interaction, button: Button[View]) -> None
Handle the cancel button press.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
update_button_styles ¶
update_button_styles() -> None
Update button styles for the confirmation view.
TldrPaginatorView ¶
Bases: View
Paginator view for navigating through long TLDR pages.
Initialize the TLDR paginator view.
Parameters:
-
pages(list[str]) –List of page content strings to paginate through.
-
title(str) –Title for the paginated content.
-
user(User) –User who can interact with this view.
-
bot(Tux) –Bot instance for embed creation.
Methods:
-
interaction_check–Check if the interaction user is allowed to interact with this view.
-
on_timeout–Handle view timeout by removing the view from the message.
-
prev–Navigate to the previous page.
-
next–Navigate to the next page.
-
update_message–Update the message with the current page content.
Functions¶
interaction_check async ¶
interaction_check(interaction: Interaction) -> bool
Check if the interaction user is allowed to interact with this view.
Parameters:
-
interaction(Interaction) –The interaction to check.
Returns:
-
bool–True if the user is allowed to interact.
on_timeout async ¶
on_timeout() -> None
Handle view timeout by removing the view from the message.
prev async ¶
prev(interaction: Interaction, button: Button[View])
Navigate to the previous page.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
next async ¶
next(interaction: Interaction, button: Button[View])
Navigate to the next page.
Parameters:
-
interaction(Interaction) –The interaction that triggered this action.
-
button(Button[View]) –The button that was pressed.
update_message async ¶
update_message(interaction: Interaction) -> None
Update the message with the current page content.
Parameters:
-
interaction(Interaction) –The interaction to update the message for.