Modal
Represents a legacy UI modal for InputText components.Constructor
The initial items displayed in the modal. Only supports InputText.
The title of the modal. Must be 45 characters or fewer.
The ID of the modal that gets received during an interaction. Auto-generated if not provided. Must be 100 characters or fewer.
Timeout in seconds from last interaction before no longer accepting input. If
None, there is no timeout.Whether this modal should be stored for callback listening. Setting to
False ignores its callback.Attributes
The title of the modal.
The child items attached to the modal.
The ID of the modal that gets received during an interaction.
Timeout from last interaction before no longer accepting input.
Methods
callback
callback
The coroutine called when the modal is submitted. Override to handle submitted values.Parameters:
interaction(Interaction): The interaction that submitted the modal.
add_item
add_item
Adds an InputText component to the modal.Parameters:
item(InputText): The item to add to the modal.
ValueError: Maximum of 5 items in a modal.TypeError: Item is not an InputText.
Selfremove_item
remove_item
Removes a component from the modal.Parameters:
item(InputText): The item to remove from the modal.
Selfstop
stop
Stops listening to interaction events from the modal.
wait
wait
Waits for the modal to be submitted.Returns:
bool - Whether the modal timed out.on_error
on_error
A callback called when the modal’s callback fails with an error.Parameters:
error(Exception): The exception that was raised.interaction(Interaction): The interaction that led to the failure.
on_timeout
on_timeout
A callback called when a modal’s timeout elapses without being explicitly stopped.
InputText
Represents a UI text input field.Constructor
The style of the input text field.
The ID of the input text field. Auto-generated if not provided.
The label for the input text field. Must be 45 characters or fewer.
The placeholder text shown if nothing is entered. Must be 100 characters or fewer.
The minimum number of characters that must be entered. Must be less than 4000. Defaults to 0.
The maximum number of characters that can be entered. Must be between 1 and 4000.
Whether the input text field is required or not.
Pre-fills the input text field with this value. Must be 4000 characters or fewer.
The relative row this input text field belongs to (0-4).
The input text field’s ID.
Attributes
The style of the input text field.
The ID of the input text field.
The label of the input text field.
The placeholder text shown before anything is entered.
The minimum number of characters that must be entered.
The maximum number of characters that can be entered.
Whether the input text field is required.
The value entered in the text field.
The width of the input in the UI layout. Always 5.
Input Text Styles
InputTextStyle.short- Single line input (default)InputTextStyle.long- Multi-line paragraph input
Examples
Notes
- Modals can contain a maximum of 5 InputText components
- Modal titles must be 45 characters or fewer
- InputText labels must be 45 characters or fewer
- InputText values can be up to 4000 characters
- Placeholders can be up to 100 characters
