pub struct CreateQuickModal { /* private fields */ }
Expand description
Convenience builder to create a modal, wait for the user to submit and parse the response.
let modal = CreateQuickModal::new("About you")
.timeout(std::time::Duration::from_secs(600))
.short_field("First name")
.short_field("Last name")
.paragraph_field("Hobbies and interests");
let response = interaction.quick_modal(ctx, modal).await?;
let inputs = response.unwrap().inputs;
let (first_name, last_name, hobbies) = (&inputs[0], &inputs[1], &inputs[2]);
Implementations§
Source§impl CreateQuickModal
impl CreateQuickModal
pub fn new(title: impl Into<String>) -> Self
Sourcepub fn timeout(self, timeout: Duration) -> Self
pub fn timeout(self, timeout: Duration) -> Self
Sets a timeout when waiting for the modal response.
You should almost always set a timeout here. Otherwise, if the user exits the modal, you will wait forever.
Sourcepub fn field(self, input_text: CreateInputText) -> Self
pub fn field(self, input_text: CreateInputText) -> Self
Adds an input text field.
As the custom_id
field of CreateInputText
, just supply an empty string. All custom
IDs are overwritten by CreateQuickModal
when sending the modal.
Sourcepub fn short_field(self, label: impl Into<String>) -> Self
pub fn short_field(self, label: impl Into<String>) -> Self
Convenience method to add a single-line input text field.
Wraps Self::field
.
Sourcepub fn paragraph_field(self, label: impl Into<String>) -> Self
pub fn paragraph_field(self, label: impl Into<String>) -> Self
Convenience method to add a multi-line input text field.
Wraps Self::field
.
Sourcepub async fn execute(
self,
ctx: &Context,
interaction_id: InteractionId,
token: &str,
) -> Result<Option<QuickModalResponse>, Error>
pub async fn execute( self, ctx: &Context, interaction_id: InteractionId, token: &str, ) -> Result<Option<QuickModalResponse>, Error>
§Errors
Auto Trait Implementations§
impl Freeze for CreateQuickModal
impl RefUnwindSafe for CreateQuickModal
impl Send for CreateQuickModal
impl Sync for CreateQuickModal
impl Unpin for CreateQuickModal
impl UnwindSafe for CreateQuickModal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more