pub struct ComponentInteraction { /* private fields */ }Expand description
A component interaction given to a Client::component
route (D-252): dereferences to the ComponentData (custom_id, values, users,
…), with the args of its custom ID, and answers through
InteractionExt (update, reply, show_modal, …).
discord.js counterpart: ButtonInteraction and the select menu interactions.
Implementations§
Source§impl ComponentInteraction
impl ComponentInteraction
Sourcepub fn interaction(&self) -> &Interaction
pub fn interaction(&self) -> &Interaction
Returns the whole interaction: its guild, channel, member, locale, …
discord.js counterpart: the interaction itself (discord.js routes nothing).
Sourcepub const fn event(&self) -> &Arc<InteractionCreate> ⓘ
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 ComponentInteraction
impl ComponentInteraction
Sourcepub fn args(&self) -> &str
pub fn args(&self) -> &str
Returns the part of the custom ID after the route name and its : (D-254): "42"
for vote:42, "a:b" for vote:a:b, "" for vote.
discord.js counterpart: none (discord.js leaves the customId to the bot).
§Examples
// A button with the custom ID `vote:42` votes for option 42.
client.component("vote", |ctx, button| async move {
let option: u32 = button.args().parse()?;
button.reply(&ctx, format!("You voted for {option}")).await?;
Ok(())
});Methods from Deref<Target = ComponentData>§
Sourcepub fn ids<T>(&self) -> impl Iterator<Item = Id<T>>
pub fn ids<T>(&self) -> impl Iterator<Item = Id<T>>
Parses the selected values of a user, role, mentionable or channel
select menu as IDs, skipping values that are not snowflakes.
discord.js counterpart: UserSelectMenuInteraction#values and its siblings.
Sourcepub fn users(&self) -> impl Iterator<Item = &User>
pub fn users(&self) -> impl Iterator<Item = &User>
Returns the users chosen in a user or mentionable select menu.
discord.js counterpart: UserSelectMenuInteraction#users.
Sourcepub fn members(&self) -> impl Iterator<Item = (&User, &InteractionMember)>
pub fn members(&self) -> impl Iterator<Item = (&User, &InteractionMember)>
Returns the users chosen in a user or mentionable select menu in a guild, with their member data.
discord.js counterpart: UserSelectMenuInteraction#members.
Sourcepub fn roles(&self) -> impl Iterator<Item = &Role>
pub fn roles(&self) -> impl Iterator<Item = &Role>
Returns the roles chosen in a role or mentionable select menu.
discord.js counterpart: RoleSelectMenuInteraction#roles.
Sourcepub fn channels(&self) -> impl Iterator<Item = &InteractionChannel>
pub fn channels(&self) -> impl Iterator<Item = &InteractionChannel>
Returns the channels chosen in a channel select menu.
discord.js counterpart: ChannelSelectMenuInteraction#channels.
Sourcepub fn mentionables(&self) -> impl Iterator<Item = Mentionable<'_>>
pub fn mentionables(&self) -> impl Iterator<Item = Mentionable<'_>>
Returns the users and roles chosen in a mentionable select menu.
discord.js counterpart: MentionableSelectMenuInteraction (users, members,
roles).
Trait Implementations§
Source§impl Clone for ComponentInteraction
impl Clone for ComponentInteraction
impl Collectable for ComponentInteraction
Source§impl Debug for ComponentInteraction
impl Debug for ComponentInteraction
Source§impl Deref for ComponentInteraction
impl Deref for ComponentInteraction
Source§type Target = ComponentData
type Target = ComponentData
Source§fn deref(&self) -> &ComponentData
fn deref(&self) -> &ComponentData
Source§impl InteractionExt for ComponentInteraction
impl InteractionExt for ComponentInteraction
Source§fn reply<B: Backend>(
&self,
ctx: &Context<B>,
body: impl Into<MessageCallbackData>,
) -> impl Future<Output = Result<(), Error>> + Send
fn reply<B: Backend>( &self, ctx: &Context<B>, body: impl Into<MessageCallbackData>, ) -> impl Future<Output = Result<(), Error>> + Send
ChannelMessageWithSource);
accepts anything that converts into MessageCallbackData, such as &str. Set
MessageFlags::EPHEMERAL in its flags for a message only the user sees. Read moreSource§fn defer_reply<B: Backend>(
&self,
ctx: &Context<B>,
flags: MessageFlags,
) -> impl Future<Output = Result<(), Error>> + Send
fn defer_reply<B: Backend>( &self, ctx: &Context<B>, flags: MessageFlags, ) -> impl Future<Output = Result<(), Error>> + Send
DeferredChannelMessageWithSource);
the message follows with edit_reply. flags can only be
MessageFlags::EPHEMERAL (for an ephemeral message) or empty. Read moreSource§fn update<B: Backend>(
&self,
ctx: &Context<B>,
body: impl Into<MessageCallbackData>,
) -> impl Future<Output = Result<(), Error>> + Send
fn update<B: Backend>( &self, ctx: &Context<B>, body: impl Into<MessageCallbackData>, ) -> impl Future<Output = Result<(), Error>> + Send
UpdateMessage): fields left None keep their
value. Component interactions and modals opened from a component. Read moreSource§fn defer_update<B: Backend>(
&self,
ctx: &Context<B>,
) -> impl Future<Output = Result<(), Error>> + Send
fn defer_update<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send
DeferredUpdateMessage); the message
can be edited later with edit_reply. Read moreSource§fn show_modal<B: Backend>(
&self,
ctx: &Context<B>,
modal: ModalCallbackData,
) -> impl Future<Output = Result<(), Error>> + Send
fn show_modal<B: Backend>( &self, ctx: &Context<B>, modal: ModalCallbackData, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn respond<B: Backend>(
&self,
ctx: &Context<B>,
choices: AutocompleteChoices,
) -> impl Future<Output = Result<(), Error>> + Send
fn respond<B: Backend>( &self, ctx: &Context<B>, choices: AutocompleteChoices, ) -> impl Future<Output = Result<(), Error>> + Send
AutocompleteResult); up to 25, typed like
the option. An empty list shows “no suggestions”. Read moreSource§fn launch_activity<B: Backend>(
&self,
ctx: &Context<B>,
) -> impl Future<Output = Result<(), Error>> + Send
fn launch_activity<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send
LaunchActivity;
apps with Activities enabled). Read moreSource§fn fetch_reply<B: Backend>(
&self,
ctx: &Context<B>,
) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
fn fetch_reply<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
Source§fn edit_reply<B: Backend>(
&self,
ctx: &Context<B>,
body: impl Into<EditWebhookMessage>,
) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
fn edit_reply<B: Backend>( &self, ctx: &Context<B>, body: impl Into<EditWebhookMessage>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
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 moreSource§fn delete_reply<B: Backend>(
&self,
ctx: &Context<B>,
) -> impl Future<Output = Result<(), Error>> + Send
fn delete_reply<B: Backend>( &self, ctx: &Context<B>, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn follow_up<B: Backend>(
&self,
ctx: &Context<B>,
body: impl Into<CreateFollowupMessage>,
) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
fn follow_up<B: Backend>( &self, ctx: &Context<B>, body: impl Into<CreateFollowupMessage>, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
CreateFollowupMessage, such as &str. After a
defer_reply, the first follow-up replaces “thinking…”. Read moreSource§fn fetch_follow_up<B: Backend>(
&self,
ctx: &Context<B>,
message_id: MessageId,
) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
fn fetch_follow_up<B: Backend>( &self, ctx: &Context<B>, message_id: MessageId, ) -> impl Future<Output = Result<Arc<CachedMessage>, Error>> + Send
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
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
EditWebhookMessage, such as &str. Read moreSource§fn delete_follow_up<B: Backend>(
&self,
ctx: &Context<B>,
message_id: MessageId,
) -> impl Future<Output = Result<(), Error>> + Send
fn delete_follow_up<B: Backend>( &self, ctx: &Context<B>, message_id: MessageId, ) -> impl Future<Output = Result<(), Error>> + Send
Source§fn component_collector<B: Backend>(
&self,
ctx: &Context<B>,
) -> CollectorBuilder<ComponentInteraction>
fn component_collector<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction>
Source§fn await_component<B: Backend>(
&self,
ctx: &Context<B>,
) -> CollectorBuilder<ComponentInteraction, First>
fn await_component<B: Backend>( &self, ctx: &Context<B>, ) -> CollectorBuilder<ComponentInteraction, First>
Source§fn await_modal_submit<B: Backend>(
&self,
ctx: &Context<B>,
time: Duration,
) -> CollectorBuilder<ModalInteraction, First>
fn await_modal_submit<B: Backend>( &self, ctx: &Context<B>, time: Duration, ) -> CollectorBuilder<ModalInteraction, First>
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 moreAuto Trait Implementations§
impl Freeze for ComponentInteraction
impl RefUnwindSafe for ComponentInteraction
impl Send for ComponentInteraction
impl Sync for ComponentInteraction
impl Unpin for ComponentInteraction
impl UnsafeUnpin for ComponentInteraction
impl UnwindSafe for ComponentInteraction
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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