Struct serenity::model::interactions::Interaction [−][src]
unstable_discord_api
only.Information about an interaction.
An interaction is sent when a user invokes a slash command and is the same for slash commands and other future interaction types.
Fields (Non-exhaustive)
Struct {{ .. }}
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.id: InteractionId
kind: InteractionType
data: Option<ApplicationCommandInteractionData>
guild_id: GuildId
channel_id: ChannelId
member: Member
token: String
version: u8
Implementations
impl Interaction
[src]
pub async fn create_global_application_command<F>(
http: impl AsRef<Http>,
application_id: u64,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateInteraction) -> &mut CreateInteraction,
[src]
http: impl AsRef<Http>,
application_id: u64,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateInteraction) -> &mut CreateInteraction,
Creates a global ApplicationCommand
,
overriding an existing one with the same name if it exists.
When a created ApplicationCommand
is used, the InteractionCreate
event will be emitted.
Note: Global commands may take up to an hour to become available.
As such, it is recommended that guild application commands be used for testing purposes.
Examples
Create a simple ping command
use serenity::model::interactions::Interaction; let application_id = 42; // usually this will be the bot's UserId let _ = Interaction::create_global_application_command(&http, application_id, |a| { a.name("ping") .description("A simple ping command") }) .await;
Create a command that echoes what is inserted
use serenity::model::interactions::{Interaction, ApplicationCommandOptionType}; let application_id = 42; // usually this will be the bot's UserId let _ = Interaction::create_global_application_command(&http, application_id, |a| { a.name("echo") .description("What is said is echoed") .create_interaction_option(|o| { o.name("to_say") .description("What will be echoed") .kind(ApplicationCommandOptionType::String) .required(true) }) }) .await;
Errors
May return an Error::Http
if the ApplicationCommand
is illformed,
such as if more than 10 choices
are set. See the API Docs for further details.
Can also return an Error::Json
if there is an error in deserializing
the response.
pub async fn create_guild_application_command<F>(
http: impl AsRef<Http>,
guild_id: GuildId,
application_id: u64,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateInteraction) -> &mut CreateInteraction,
[src]
http: impl AsRef<Http>,
guild_id: GuildId,
application_id: u64,
f: F
) -> Result<ApplicationCommand> where
F: FnOnce(&mut CreateInteraction) -> &mut CreateInteraction,
Creates a guild specific ApplicationCommand
Note: Unlike global ApplicationCommand
s, guild commands will update instantly.
Errors
Returns the same possible errors as create_global_application_command
.
pub async fn create_interaction_response<F>(
&self,
http: impl AsRef<Http>,
f: F
) -> Result<()> where
F: FnOnce(&mut CreateInteractionResponse) -> &mut CreateInteractionResponse,
[src]
&self,
http: impl AsRef<Http>,
f: F
) -> Result<()> where
F: FnOnce(&mut CreateInteractionResponse) -> &mut CreateInteractionResponse,
Creates a response to the interaction received.
Note: Message contents must be under 2000 unicode code points.
Errors
Returns an Error::Model
if the message content is too long.
May also return an Error::Http
if the API returns an error,
or an Error::Json
if there is an error in deserializing the
API response.
Errors
pub async fn edit_original_interaction_response<F>(
&self,
http: impl AsRef<Http>,
application_id: u64,
f: F
) -> Result<Message> where
F: FnOnce(&mut EditInteractionResponse) -> &mut EditInteractionResponse,
[src]
&self,
http: impl AsRef<Http>,
application_id: u64,
f: F
) -> Result<Message> where
F: FnOnce(&mut EditInteractionResponse) -> &mut EditInteractionResponse,
Edits the initial interaction response.
application_id
will usually be the bot’s [UserId]
, except in cases of bots being very old.
Refer to Discord’s docs for Edit Webhook Message for field information.
Note: Message contents must be under 2000 unicode code points, does not work on ephemeral messages.
Errors
Returns Error::Model
if the edited content is too long.
May also return Error::Http
if the API returns an error,
or an Error::Json
if there is an error deserializing the response.
pub async fn delete_original_interaction_response(
&self,
http: impl AsRef<Http>,
application_id: u64
) -> Result<()>
[src]
&self,
http: impl AsRef<Http>,
application_id: u64
) -> Result<()>
Deletes the initial interaction response.
Errors
May return Error::Http
if the API returns an error.
Such as if the response was already deleted.
pub async fn create_followup_message<'a, F>(
&self,
http: impl AsRef<Http>,
application_id: u64,
wait: bool,
f: F
) -> Result<Option<Message>> where
F: FnOnce(&'b mut CreateInteractionResponseFollowup<'a>) -> &'b mut CreateInteractionResponseFollowup<'a>,
[src]
&self,
http: impl AsRef<Http>,
application_id: u64,
wait: bool,
f: F
) -> Result<Option<Message>> where
F: FnOnce(&'b mut CreateInteractionResponseFollowup<'a>) -> &'b mut CreateInteractionResponseFollowup<'a>,
Creates a followup response to the response sent.
Note: Message contents must be under 2000 unicode code points.
Errors
Will return Error::Model
if the content is too long.
May also return Error::Http
if the API returns an error,
or a Error::Json
if there is an error in deserializing the response.
Trait Implementations
impl Clone for Interaction
[src]
fn clone(&self) -> Interaction
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for Interaction
[src]
impl<'de> Deserialize<'de> for Interaction
[src]
fn deserialize<D: Deserializer<'de>>(
deserializer: D
) -> StdResult<Self, D::Error>
[src]
deserializer: D
) -> StdResult<Self, D::Error>
impl Serialize for Interaction
[src]
Auto Trait Implementations
impl RefUnwindSafe for Interaction
impl Send for Interaction
impl Sync for Interaction
impl Unpin for Interaction
impl UnwindSafe for Interaction
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,