Skip to main content

ModalSubmitData

Struct ModalSubmitData 

Source
#[non_exhaustive]
pub struct ModalSubmitData { pub custom_id: CompactString, pub components: Vec<SubmittedComponent>, pub resolved: Option<Box<Resolved>>, }
Expand description

The data of a modal-submit interaction: the values the user entered in the modal’s components.

discord.js counterpart: ModalSubmitInteraction (customId, fields).

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: CompactString

The modal’s custom ID.

§components: Vec<SubmittedComponent>

The submitted components, in the modal’s layout.

§resolved: Option<Box<Resolved>>

The selected users, members, roles, channels and uploaded attachments.

Implementations§

Source§

impl ModalSubmitData

Source

pub fn get(&self, custom_id: &str) -> Option<&SubmittedComponent>

Finds the submitted input with the given custom ID, inside labels and action rows.

discord.js counterpart: ModalSubmitFields#getField.

Source

pub fn text_value(&self, custom_id: &str) -> Option<&str>

Returns the text entered in the text input with the given custom ID.

discord.js counterpart: ModalSubmitFields#getTextInputValue.

Source§

impl ModalSubmitData

Reads submitted modal fields by custom ID and component type (D-250); see also get and text_value.

Each getter returns None when no component has the custom ID or it is of another type; the selected_* getters return the resolved objects in the order they were selected.

discord.js counterpart: ModalSubmitFields.

Source

pub fn string_select_values(&self, custom_id: &str) -> Option<&[CompactString]>

Returns the values chosen in the string select menu custom_id.

discord.js counterpart: ModalSubmitFields#getStringSelectValues.

Source

pub fn checkbox_group_values(&self, custom_id: &str) -> Option<&[CompactString]>

Returns the values of the checked boxes of the checkbox group custom_id.

discord.js counterpart: ModalSubmitFields#getCheckboxGroup.

Source

pub fn radio_group_value(&self, custom_id: &str) -> Option<&str>

Returns the value chosen in the radio group custom_id (None also when nothing was chosen).

discord.js counterpart: ModalSubmitFields#getRadioGroup.

Source

pub fn checkbox_value(&self, custom_id: &str) -> Option<bool>

Returns whether the checkbox custom_id was checked.

discord.js counterpart: ModalSubmitFields#getCheckbox.

Source

pub fn selected_users<'a>( &'a self, custom_id: &str, ) -> Option<impl Iterator<Item = &'a User> + use<'a>>

Returns the users chosen in the user or mentionable select menu custom_id.

discord.js counterpart: ModalSubmitFields#getSelectedUsers.

Source

pub fn selected_members<'a>( &'a self, custom_id: &str, ) -> Option<impl Iterator<Item = (&'a User, &'a InteractionMember)> + use<'a>>

Returns the users chosen in the user or mentionable select menu custom_id, with their member data (in guilds).

discord.js counterpart: ModalSubmitFields#getSelectedMembers.

Source

pub fn selected_roles<'a>( &'a self, custom_id: &str, ) -> Option<impl Iterator<Item = &'a Role> + use<'a>>

Returns the roles chosen in the role or mentionable select menu custom_id.

discord.js counterpart: ModalSubmitFields#getSelectedRoles.

Source

pub fn selected_channels<'a>( &'a self, custom_id: &str, ) -> Option<impl Iterator<Item = &'a InteractionChannel> + use<'a>>

Returns the channels chosen in the channel select menu custom_id.

discord.js counterpart: ModalSubmitFields#getSelectedChannels.

Source

pub fn selected_mentionables<'a>( &'a self, custom_id: &str, ) -> Option<impl Iterator<Item = Mentionable<'a>> + use<'a>>

Returns the users and roles chosen in the mentionable select menu custom_id.

discord.js counterpart: ModalSubmitFields#getSelectedMentionables.

Source

pub fn uploaded_files<'a>( &'a self, custom_id: &str, ) -> Option<impl Iterator<Item = &'a Attachment> + use<'a>>

Returns the files uploaded in the file upload custom_id.

discord.js counterpart: ModalSubmitFields#getUploadedFiles.

Trait Implementations§

Source§

impl Clone for ModalSubmitData

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ModalSubmitData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ModalSubmitData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ModalSubmitData

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ModalSubmitData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ModalSubmitData

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.