#[non_exhaustive]pub struct ModalCallbackData {
pub custom_id: CompactString,
pub title: CompactString,
pub components: Vec<Component>,
}Expand description
The data of a modal response: the popup’s ID, title and components.
discord.js counterpart: ModalBuilder (what showModal sends).
§Examples
use djs_model::{
component::{Label, TextInput, TextInputStyle},
interaction::{InteractionResponse, ModalCallbackData},
};
let input = TextInput::new("feedback", TextInputStyle::Paragraph);
let modal = ModalCallbackData::new(
"feedback_modal",
"Feedback",
vec![Label::new("Your feedback", input.into()).into()],
);
let json = serde_json::to_value(InteractionResponse::Modal(Box::new(modal))).unwrap();
assert_eq!(json["type"], 9);
assert_eq!(json["data"]["components"][0]["component"]["custom_id"], "feedback");Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.custom_id: CompactStringThe modal’s custom ID (1-100 characters), sent back in
ModalSubmitData::custom_id.
title: CompactStringThe title (max 45 characters).
components: Vec<Component>The components (1-5): labels, text displays and (deprecated) action rows with text inputs.
Implementations§
Trait Implementations§
Source§impl Clone for ModalCallbackData
impl Clone for ModalCallbackData
Source§impl Debug for ModalCallbackData
impl Debug for ModalCallbackData
impl Eq for ModalCallbackData
Source§impl PartialEq for ModalCallbackData
impl PartialEq for ModalCallbackData
Source§impl Serialize for ModalCallbackData
impl Serialize for ModalCallbackData
impl StructuralPartialEq for ModalCallbackData
Auto Trait Implementations§
impl Freeze for ModalCallbackData
impl RefUnwindSafe for ModalCallbackData
impl Send for ModalCallbackData
impl Sync for ModalCallbackData
impl Unpin for ModalCallbackData
impl UnsafeUnpin for ModalCallbackData
impl UnwindSafe for ModalCallbackData
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