Skip to main content

ModalInteraction

Struct ModalInteraction 

Source
pub struct ModalInteraction { /* private fields */ }
Expand description

A modal-submit interaction given to a Client::modal route (D-252): dereferences to the ModalSubmitData (text_value, selected_users, …), with the args of its custom ID, and answers through InteractionExt.

discord.js counterpart: ModalSubmitInteraction.

Implementations§

Source§

impl ModalInteraction

Source

pub fn interaction(&self) -> &Interaction

Returns the whole interaction: its guild, channel, member, locale, …

discord.js counterpart: the interaction itself (discord.js routes nothing).

Source

pub const fn event(&self) -> &Arc<InteractionCreate> ⓘ

Returns the event payload, shared with the InteractionCreate handlers.

discord.js counterpart: the event’s arguments.

Source§

impl ModalInteraction

Source

pub fn args(&self) -> &str

Returns the part of the modal’s custom ID after the route name and its : (D-254), "" if none.

discord.js counterpart: none (discord.js leaves the customId to the bot).

Methods from Deref<Target = 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

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 ModalInteraction

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 Collectable for ModalInteraction

Source§

impl Debug for ModalInteraction

Source§

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

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

impl Deref for ModalInteraction

Source§

type Target = ModalSubmitData

The resulting type after dereferencing.
Source§

fn deref(&self) -> &ModalSubmitData

Dereferences the value.
Source§

impl InteractionExt for ModalInteraction

Source§

fn reply<B: Backend>( &self, ctx: &Context<B>, body: impl Into<MessageCallbackData>, ) -> impl Future<Output = Result<(), Error>> + Send

Responds with a message (ChannelMessageWithSource); accepts anything that converts into MessageCallbackData, such as &str. Set MessageFlags::EPHEMERAL in its flags for a message only the user sees. Read more
Source§

fn defer_reply<B: Backend>( &self, ctx: &Context<B>, flags: MessageFlags, ) -> impl Future<Output = Result<(), Error>> + Send

Acknowledges the interaction and shows “thinking…” (DeferredChannelMessageWithSource); the message follows with edit_reply. flags can only be MessageFlags::EPHEMERAL (for an ephemeral message) or empty. Read more
Source§

fn update<B: Backend>( &self, ctx: &Context<B>, body: impl Into<MessageCallbackData>, ) -> impl Future<Output = Result<(), Error>> + Send

Edits the message the component is on (UpdateMessage): fields left None keep their value. Component interactions and modals opened from a component. Read more
Source§

fn defer_update<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send

Acknowledges a component interaction without a loading state (DeferredUpdateMessage); the message can be edited later with edit_reply. Read more
Source§

fn show_modal<B: Backend>( &self, ctx: &Context<B>, modal: ModalCallbackData, ) -> impl Future<Output = Result<(), Error>> + Send

Opens a modal (Modal), for example one built with djs_builders::ModalBuilder. Its submission arrives as a new interaction. Not for modal-submit and autocomplete interactions. Read more
Source§

fn respond<B: Backend>( &self, ctx: &Context<B>, choices: AutocompleteChoices, ) -> impl Future<Output = Result<(), Error>> + Send

Suggests choices for the option being typed in an autocomplete interaction (AutocompleteResult); up to 25, typed like the option. An empty list shows “no suggestions”. Read more
Source§

fn launch_activity<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send

Launches the app’s Activity (LaunchActivity; apps with Activities enabled). Read more
Source§

fn fetch_reply<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send

The message of the initial response (Get Original Interaction Response). Read more
Source§

fn edit_reply<B: Backend>( &self, ctx: &Context<B>, body: impl Into<EditWebhookMessage>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send

Edits the message of the initial response — also how the message of a defer_reply is sent, and how a defer_updated message is edited (Edit Original Interaction Response). Accepts anything that converts into an EditWebhookMessage, such as &str. Read more
Source§

fn delete_reply<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send

Deletes the message of the initial response (Delete Original Interaction Response). Read more
Source§

fn follow_up<B: Backend>( &self, ctx: &Context<B>, body: impl Into<CreateFollowupMessage>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send

Sends another message for the interaction (Create Followup Message); accepts anything that converts into a CreateFollowupMessage, such as &str. After a defer_reply, the first follow-up replaces “thinking…”. Read more
Source§

fn fetch_follow_up<B: Backend>( &self, ctx: &Context<B>, message_id: MessageId, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send

A follow-up message (Get Followup Message). Read more
Source§

fn edit_follow_up<B: Backend>( &self, ctx: &Context<B>, message_id: MessageId, body: impl Into<EditWebhookMessage>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send

Edits a follow-up message (Edit Followup Message); accepts anything that converts into an EditWebhookMessage, such as &str. Read more
Source§

fn delete_follow_up<B: Backend>( &self, ctx: &Context<B>, message_id: MessageId, ) -> impl Future<Output = Result<(), Error>> + Send

Deletes a follow-up message (Delete Followup Message). Read more
Source§

fn component_collector<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction>

A collector of the component interactions on this interaction’s reply (and its follow-ups), matched by the interaction they belong to: no need to fetch the reply. For a component interaction (whose response edits its message), the components of that message. Read more
Source§

fn await_component<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction, First>

Waits for one component interaction on this interaction’s reply (D-268); set a time. Read more
Source§

fn await_modal_submit<B: Backend>( &self, ctx: &Context<B>, time: Duration, ) -> CollectorBuilder<ModalInteraction, First>

Waits up to time for the user of this interaction to submit a modal (D-268), usually the one shown with show_modal. Add a filter on the modal’s custom_id when several can be open. time is required, as in discord.js: a closed modal sends nothing. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Classify for T

§

type Classified = T

§

fn classify(self) -> T

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
§

impl<T> Declassify for T

§

type Declassified = T

§

fn declassify(self) -> T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more