lightbulb.components.modals¶
- class Modal[source]¶
Class representing a modal.
- add(component: BaseComponentT) BaseComponentT ¶
Adds the given component to the container.
- Parameters:
component – The component to add.
- Returns:
The added component.
- add_paragraph_text_input(label: str, *, custom_id: str | UndefinedType = UNDEFINED, min_length: int = 0, max_length: int = 4000, required: bool = True, value: str | UndefinedType = UNDEFINED, placeholder: str | UndefinedType = UNDEFINED) TextInput [source]¶
Add a paragraph text input component to this modal.
- Parameters:
label – The label for the text input.
custom_id – The custom ID for the text input. You probably never want to specify this as it should be unique across all modals that your application creates. If unspecified, one will be generated for you.
min_length – The minimum length of the inputted text.
max_length – The maximum length of the inputted text.
required – Whether the text input is required to be filled.
value – The default value of the text input.
placeholder – The placeholder value for the text input.
- Returns:
The created text input component.
- add_short_text_input(label: str, *, custom_id: str | UndefinedType = UNDEFINED, min_length: int = 0, max_length: int = 4000, required: bool = True, value: str | UndefinedType = UNDEFINED, placeholder: str | UndefinedType = UNDEFINED) TextInput [source]¶
Add a short text input component to this modal.
- Parameters:
label – The label for the text input.
custom_id – The custom ID for the text input. You probably never want to specify this as it should be unique across all modals that your application creates. If unspecified, one will be generated for you.
min_length – The minimum length of the inputted text.
max_length – The maximum length of the inputted text.
required – Whether the text input is required to be filled.
value – The default value of the text input.
placeholder – The placeholder value for the text input.
- Returns:
The created text input component.
- async attach(client: client_.Client, custom_id: str, *, timeout: float = 30) None [source]¶
Attach this modal to the given client, starting the interaction listener for it.
- Parameters:
client – The client to attach this modal to.
custom_id – The custom ID used when sending the modal response.
timeout – The number of seconds to wait for the correct modal interaction before timing out.
- Returns:
- Raises:
TimeoutError – If the timeout is exceeded.
- clear_current_row() t_ex.Self ¶
Remove all components from the current row.
- clear_rows() t_ex.Self ¶
Remove all components from this container.
- count(value) integer -- return number of occurrences of value ¶
- index(value[, start[, stop]]) integer -- return first index of value. ¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- next_row() t_ex.Self ¶
Move the current row pointer to the next row.
- abstract async on_submit(ctx: ModalContext) None [source]¶
The method to call when the modal is submitted. This must be overridden by subclasses.
- Parameters:
ctx – The context for the modal submission.
- Returns:
- previous_row() t_ex.Self ¶
Move the current row pointer back to the previous row.
- class ModalContext(client: client_.Client, modal: Modal, interaction: ModalInteraction)[source]¶
Class representing the context for a modal interaction.
- async defer(*, ephemeral: bool = False) None ¶
Defer the creation of a response for the interaction that this context represents.
- Parameters:
ephemeral – Whether to defer ephemerally (message only visible to the user that triggered the command).
- Returns:
- async delete_response(response_id: Snowflake | int) None ¶
Delete the response with the given identifier.
- Parameters:
response_id – The identifier of the response to delete - as returned by
respond()
.- Returns:
- async edit_response(response_id: hikari.Snowflakeish, content: hikari.UndefinedNoneOr[t.Any] = UNDEFINED, *, attachment: hikari.UndefinedNoneOr[hikari.Resourceish | Attachment] = UNDEFINED, attachments: hikari.UndefinedNoneOr[Sequence[hikari.Resourceish | Attachment]] = UNDEFINED, component: hikari.UndefinedNoneOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedNoneOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedNoneOr[Embed] = UNDEFINED, embeds: hikari.UndefinedNoneOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) Message ¶
Edit the response with the given identifier.
- Parameters:
response_id – The identifier of the response to delete - as returned by
respond()
.content – The message contents.
attachment – The message attachment.
attachments – The message attachments.
component – The builder object of the component to include in this message.
components – The sequence of the component builder objects to include in this message.
embed – The message embed.
embeds – The message embeds.
mentions_everyone – Whether the message should parse @everyone/@here mentions.
user_mentions – The user mentions to include in the message.
role_mentions – The role mentions to include in the message.
- Returns:
The updated message object for the response with the given identifier.
- Return type:
Note
This documentation does not contain a full description of the parameters as they would just be copy-pasted from the hikari documentation. See
edit_initial_response()
for a more detailed description.
- async fetch_response(response_id: Snowflake | int) Message ¶
Fetch the message object for the response with the given identifier.
- Parameters:
response_id – The identifier of the response to fetch - as returned by
respond()
.- Returns:
The message for the response with the given identifier.
- Return type:
- async respond(content: hikari.UndefinedOr[t.Any] = UNDEFINED, *, ephemeral: bool = False, flags: int | MessageFlag | UndefinedType = UNDEFINED, tts: hikari.UndefinedOr[bool] = UNDEFINED, attachment: hikari.UndefinedOr[hikari.Resourceish] = UNDEFINED, attachments: hikari.UndefinedOr[Sequence[hikari.Resourceish]] = UNDEFINED, component: hikari.UndefinedOr[special_endpoints.ComponentBuilder] = UNDEFINED, components: hikari.UndefinedOr[Sequence[special_endpoints.ComponentBuilder]] = UNDEFINED, embed: hikari.UndefinedOr[Embed] = UNDEFINED, embeds: hikari.UndefinedOr[Sequence[Embed]] = UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = UNDEFINED, user_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialUser] | bool] = UNDEFINED, role_mentions: hikari.UndefinedOr[hikari.SnowflakeishSequence[PartialRole] | bool] = UNDEFINED) hikari.Snowflakeish ¶
Create a response to the interaction that this context represents.
- Parameters:
content – The message contents.
ephemeral – Whether the message should be ephemeral (only visible to the user that triggered the command). This is just a convenience argument - passing
flags=hikari.MessageFlag.EPHEMERAL
will function the same way.attachment – The message attachment.
attachments – The message attachments.
component – The builder object of the component to include in this message.
components – The sequence of the component builder objects to include in this message.
embed – The message embed.
embeds – The message embeds.
flags – The message flags this response should have.
tts – Whether the message will be read out by a screen reader using Discord’s TTS (text-to-speech) system.
mentions_everyone – Whether the message should parse @everyone/@here mentions.
user_mentions – The user mentions to include in the message.
role_mentions – The role mentions to include in the message.
- Returns:
- An identifier for the response. This can then be used to edit,
delete, or fetch the response message using the appropriate methods.
- Return type:
Note
This documentation does not contain a full description of the parameters as they would just be copy-pasted from the hikari documentation. See
create_initial_response()
for a more detailed description.See also
edit_response()
delete_response()
fetch_response()
- value_for(input: TextInput) str | None [source]¶
Get the submitted value for the given text input component.
- Parameters:
input – The text input component to get the value for.
- Returns:
The value submitted for the given text input component, or
None
if no value was submitted.
- client: client_.Client¶
The client that is handling interactions for this context.
- property guild_id: Snowflake | None¶
The ID of the guild that the interaction was created in.
None
if the interaction occurred in DM.
- property interaction: ModalInteraction¶
The interaction this context is for.
- property member: InteractionMember | None¶
The member that created the interaction, if it was created in a guild.
- class TextInput(custom_id: str, style: TextInputStyle, label: str, min_length: int, max_length: int, required: bool, value: str | UndefinedType, placeholder: str | UndefinedType)[source]¶
Class representing a text input.
- add_to_row(row: ModalActionRowBuilder) ModalActionRowBuilder [source]¶
Add this component to the given action row builder, and return the updated builder.
- Parameters:
row – The row to add the component to.
- Returns:
The updated builder.
- placeholder: str | UndefinedType¶
The placeholder value for the text input.
- style: TextInputStyle¶
The style of the text input.
- value: str | UndefinedType¶
The default value of the text input.