Discord UI Views¶
Compilation of Discord UI Views
- validate()[source]¶
Validate a function.
- Parameters
in_view (bool) – Whether the check is in a view.
- Returns
The decorated function.
- Return type
Callable
- class BaseView[source]¶
The overriden Base class for discord.ui.View.
- Parameters
timeout – The timeout to wait for a response., default is 180.0 seconds.
check – A check function for validating the interaction.
- class SelectComponent[source]¶
A Select Component that allows the user to choose an option.
- Parameters
heading (str) – The heading of the component.
options (Dict) – The options for the Select.
serializer (Optional[Callable]) – The serializer to be used for the options., defaults to
str
.
- callback()[source]¶
On Selecting a choice, execute the required function.
- Parameters
interaction (
discord.Interaction
) – The interaction that triggered the callback.
- class SelectView[source]¶
A Select View that allows the user to choose an option.
- Parameters
no_response (bool) – Whether an Ephemeral response should be sent., defaults to True.
- class MultiSelectView[source]¶
A Multi Select View that requires the user to choose all Selects before proceeding.
- Parameters
kwarg_list (List[dict]) – The keyword arguments for the Selects.
kwargs (dict) – Additional keyword arguments for the View.
- class Button[source]¶
Overridden discord button to accomodate custom checks.
- callback()[source]¶
Overridden callback to check if the check passes.
- Parameters
interaction (Interaction) –
- class ConfirmButton[source]¶
A button that confirms the action.
- callback()[source]¶
Overridden callback to check if the check passes. Sets value to True.
- Parameters
interaction (Interaction) –
- class CancelButton[source]¶
A button that cancels the action.
- callback()[source]¶
Overridden callback to check if the check passes. Sets value to False.
- Parameters
interaction (Interaction) –
- class CallbackButton[source]¶
A button that calls a callback function when pressed.
- callback()[source]¶
When the button is pressed, call the callback.
- Parameters
button (
discord.ui.Button
) – The button that was pressed.interaction (
discord.Interaction
) – The interaction that triggered the callback.
- class CallbackButtonView[source]¶
A view that contains a callback button.
- perform_action()[source]¶
Perform the action.
- Parameters
interaction (
discord.Interaction
) – The interaction that triggered the callback.value (bool) – The value to be set.
- class ConfirmView[source]¶
A simple View that gives us a confirmation menu.
- perform_action()[source]¶
Perform the action.
- Parameters
interaction (
discord.Interaction
) – The interaction that triggered the callback.value (bool) – The value to be set.
- class ConfirmOrCancelView[source]¶
The
ConfirmView
view with a Cancel button.
- class SimpleSelect[source]¶
A simple Select that allows the user to choose an option. Updates the view’s result when the user selects an option.
- callback()[source]¶
When the select is changed, set the inner value to the new value.
- Parameters
interaction (
discord.Interaction
) – The interaction that triggered the callback.
- class LinkView[source]¶
A View that allows the user to visit a link.
- Parameters
url (str) – The url to be linked to.
label (str) – The text to be displayed on the button.
emoji (Optional[str]) – The emoji to be displayed on the button.
- class EmojiButton[source]¶
A read-only View with an emoji Button.
- Parameters
emoji (str) – The emoji to be displayed.
- class GambleCounter[source]¶
A view which tracks and updates the registration list for a gamble match.
- Parameters
gamble_cmd (
GambleCommands
) – The GambleCommands module.gamble_thread (
discord.Thread
) – The discord thread where the match is taking place.reg_embed (
discord.Embed
) – The discord embed to be used for registration.fee (Optional[int]) – The fee for the gamble match., defaults to 50.
max_players (Optional[int]) – The maximum number of players for the match, defaults to 12.
timeout – The timeout for the registration, defaults to 180.
- property deadline: int¶
Returns the deadline (in seconds) for the registration.
- Returns
The deadline for the registration.
- Return type
int
- property transaction_fee: str¶
Calculates the transaction fee for the registration.
Note
The Fee scales up by 5% for every extra player more than 12.
- Returns
The transaction fee for the registration.
- Return type
str
- async register_user()[source]¶
Register a user to the list.
- Parameters
button (
discord.ui.Button
) – The button that was pressed.interaction (
discord.Interaction
) – The interaction that triggered the callback.
- class MoreInfoView[source]¶
A view that morphs the message content/embed on button click.
- Parameters
content (Optional[str]) – The content to be displayed after the button is clicked.
embed (Optional[
discord.Embed
]) – The embed to be displayed after the button is clicked.
- async more_info()[source]¶
Morph the message content/embed on button click.
- Parameters
button (
discord.ui.Button
) – The button that was pressed.interaction (
discord.Interaction
) – The interaction that triggered the callback.
- class MorphView[source]¶
Dynamically Morphing Embed based on Select component’s value.
- Parameters
info_dict (Dict[str,
discord.Embed
]) – The mapping between Select label and its embed.
- async morph()[source]¶
Morph the message content/embed on SelectComponent’s label change.
- Parameters
interaction (
discord.Interaction
) – The interaction that triggered the callback.label (str) – The new label of the SelectComponent.