pub struct CommandInteraction { /* private fields */ }Expand description
A command interaction given to a Client::command route
(D-252): dereferences to the CommandData (get_string, subcommand, …) and
answers through InteractionExt (reply,
defer_reply, …).
discord.js counterpart: ChatInputCommandInteraction and the context menu command
interactions.
Implementations§
Source§impl CommandInteraction
impl CommandInteraction
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.
Methods from Deref<Target = CommandData>§
Sourcepub fn focused(&self) -> Option<&CommandDataOption>
pub fn focused(&self) -> Option<&CommandDataOption>
Returns the option that is being typed in an autocomplete interaction, searching subcommands and groups.
discord.js counterpart: CommandInteractionOptionResolver#getFocused.
Sourcepub fn leaf_options(&self) -> &[CommandDataOption]
pub fn leaf_options(&self) -> &[CommandDataOption]
Returns the options of the subcommand that was run, or the command’s own options if it has no subcommands: the options every getter searches.
discord.js counterpart: the hoisted options of CommandInteractionOptionResolver.
Sourcepub fn subcommand(&self) -> Option<&str>
pub fn subcommand(&self) -> Option<&str>
Returns the name of the subcommand that was run (also inside a group).
discord.js counterpart: CommandInteractionOptionResolver#getSubcommand.
Sourcepub fn subcommand_group(&self) -> Option<&str>
pub fn subcommand_group(&self) -> Option<&str>
Returns the name of the subcommand group of the subcommand that was run.
discord.js counterpart: CommandInteractionOptionResolver#getSubcommandGroup.
Sourcepub fn get(&self, name: &str) -> Option<&CommandOptionValue>
pub fn get(&self, name: &str) -> Option<&CommandOptionValue>
Returns the value of the option name (among the leaf_options),
whatever its type.
discord.js counterpart: CommandInteractionOptionResolver#get.
Sourcepub fn get_string(&self, name: &str) -> Option<&str>
pub fn get_string(&self, name: &str) -> Option<&str>
Returns the value of the string option name.
discord.js counterpart: CommandInteractionOptionResolver#getString.
Sourcepub fn get_integer(&self, name: &str) -> Option<i64>
pub fn get_integer(&self, name: &str) -> Option<i64>
Returns the value of the integer option name.
discord.js counterpart: CommandInteractionOptionResolver#getInteger.
Sourcepub fn get_number(&self, name: &str) -> Option<f64>
pub fn get_number(&self, name: &str) -> Option<f64>
Returns the value of the number (floating-point) option name.
discord.js counterpart: CommandInteractionOptionResolver#getNumber.
Sourcepub fn get_boolean(&self, name: &str) -> Option<bool>
pub fn get_boolean(&self, name: &str) -> Option<bool>
Returns the value of the boolean option name.
discord.js counterpart: CommandInteractionOptionResolver#getBoolean.
Sourcepub fn get_user(&self, name: &str) -> Option<&User>
pub fn get_user(&self, name: &str) -> Option<&User>
Returns the user chosen in the user (or mentionable) option name.
discord.js counterpart: CommandInteractionOptionResolver#getUser.
Sourcepub fn get_member(&self, name: &str) -> Option<(&User, &InteractionMember)>
pub fn get_member(&self, name: &str) -> Option<(&User, &InteractionMember)>
Returns the user chosen in the user (or mentionable) option name with their member
data; None outside guilds or if the user is not a member.
discord.js counterpart: CommandInteractionOptionResolver#getMember.
Sourcepub fn get_role(&self, name: &str) -> Option<&Role>
pub fn get_role(&self, name: &str) -> Option<&Role>
Returns the role chosen in the role (or mentionable) option name.
discord.js counterpart: CommandInteractionOptionResolver#getRole.
Sourcepub fn get_channel(&self, name: &str) -> Option<&InteractionChannel>
pub fn get_channel(&self, name: &str) -> Option<&InteractionChannel>
Returns the channel chosen in the channel option name (a partial channel with the
invoking member’s permissions in it).
discord.js counterpart: CommandInteractionOptionResolver#getChannel.
Sourcepub fn get_attachment(&self, name: &str) -> Option<&Attachment>
pub fn get_attachment(&self, name: &str) -> Option<&Attachment>
Returns the file uploaded in the attachment option name.
discord.js counterpart: CommandInteractionOptionResolver#getAttachment.
Sourcepub fn get_mentionable(&self, name: &str) -> Option<Mentionable<'_>>
pub fn get_mentionable(&self, name: &str) -> Option<Mentionable<'_>>
Returns the user or role chosen in the mentionable option name.
discord.js counterpart: CommandInteractionOptionResolver#getMentionable.
Sourcepub fn focused_value(&self) -> Option<&str>
pub fn focused_value(&self) -> Option<&str>
Returns what the user has typed so far in the focused option of an
autocomplete interaction.
discord.js counterpart: CommandInteractionOptionResolver#getFocused.
Sourcepub fn target_user(&self) -> Option<&User>
pub fn target_user(&self) -> Option<&User>
Returns the user a user command was used on.
discord.js counterpart: UserContextMenuCommandInteraction#targetUser.
Sourcepub fn target_member(&self) -> Option<(&User, &InteractionMember)>
pub fn target_member(&self) -> Option<(&User, &InteractionMember)>
Returns the user a user command was used on with their member data (in guilds).
discord.js counterpart: UserContextMenuCommandInteraction#targetMember.
Sourcepub fn target_message(&self) -> Option<&Message>
pub fn target_message(&self) -> Option<&Message>
Returns the message a message command was used on.
discord.js counterpart: MessageContextMenuCommandInteraction#targetMessage.
Trait Implementations§
Source§impl Clone for CommandInteraction
impl Clone for CommandInteraction
Source§impl Debug for CommandInteraction
impl Debug for CommandInteraction
Source§impl Deref for CommandInteraction
impl Deref for CommandInteraction
Source§type Target = CommandData
type Target = CommandData
Source§fn deref(&self) -> &CommandData
fn deref(&self) -> &CommandData
Source§impl InteractionExt for CommandInteraction
impl InteractionExt for CommandInteraction
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 CommandInteraction
impl RefUnwindSafe for CommandInteraction
impl Send for CommandInteraction
impl Sync for CommandInteraction
impl Unpin for CommandInteraction
impl UnsafeUnpin for CommandInteraction
impl UnwindSafe for CommandInteraction
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