Struct ComponentInteraction

Source
#[non_exhaustive]
pub struct ComponentInteraction {
Show 17 fields pub id: InteractionId, pub application_id: ApplicationId, pub data: ComponentInteractionData, pub guild_id: Option<GuildId>, pub channel: Option<PartialChannel>, pub channel_id: ChannelId, pub member: Option<Member>, pub user: User, pub token: String, pub version: u8, pub message: Box<Message>, pub app_permissions: Option<Permissions>, pub locale: String, pub guild_locale: Option<String>, pub entitlements: Vec<Entitlement>, pub authorizing_integration_owners: AuthorizingIntegrationOwners, pub context: Option<InteractionContext>,
}
Expand description

An interaction triggered by a message component.

Discord docs.

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.
§id: InteractionId

Id of the interaction.

§application_id: ApplicationId

Id of the application this interaction is for.

§data: ComponentInteractionData

The data of the interaction which was triggered.

§guild_id: Option<GuildId>

The guild Id this interaction was sent from, if there is one.

§channel: Option<PartialChannel>

Channel that the interaction was sent from.

§channel_id: ChannelId

The channel Id this interaction was sent from.

§member: Option<Member>

The member data for the invoking user.

Note: It is only present if the interaction is triggered in a guild.

§user: User

The user object for the invoking user.

§token: String

A continuation token for responding to the interaction.

§version: u8

Always 1.

§message: Box<Message>

The message this interaction was triggered by, if it is a component.

§app_permissions: Option<Permissions>

Permissions the app or bot has within the channel the interaction was sent from.

§locale: String

The selected language of the invoking user.

§guild_locale: Option<String>

The guild’s preferred locale.

§entitlements: Vec<Entitlement>

For monetized applications, any entitlements of the invoking user.

§authorizing_integration_owners: AuthorizingIntegrationOwners

The owners of the applications that authorized the interaction, such as a guild or user.

§context: Option<InteractionContext>

The context where the interaction was triggered from.

Implementations§

Source§

impl<'de> ComponentInteraction

Source

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

Source§

impl ComponentInteraction

Source

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

Source§

impl ComponentInteraction

Source

pub async fn get_response(&self, http: impl AsRef<Http>) -> Result<Message>

Gets the interaction response.

§Errors

Returns an Error::Http if there is no interaction response.

Source

pub async fn create_response( &self, cache_http: impl CacheHttp, builder: CreateInteractionResponse, ) -> Result<()>

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.

Source

pub async fn edit_response( &self, cache_http: impl CacheHttp, builder: EditInteractionResponse, ) -> Result<Message>

Edits the initial interaction response.

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.

Source

pub async fn delete_response(&self, http: impl AsRef<Http>) -> Result<()>

Deletes the initial interaction response.

Does not work on ephemeral messages.

§Errors

May return Error::Http if the API returns an error. Such as if the response was already deleted.

Source

pub async fn create_followup( &self, cache_http: impl CacheHttp, builder: CreateInteractionResponseFollowup, ) -> Result<Message>

Creates a followup response to the response sent.

Note: Message contents must be under 2000 unicode code points.

§Errors

Returns Error::Model if the content is too long. May also return Error::Http if the API returns an error, or Error::Json if there is an error in deserializing the response.

Source

pub async fn edit_followup( &self, cache_http: impl CacheHttp, message_id: impl Into<MessageId>, builder: CreateInteractionResponseFollowup, ) -> Result<Message>

Edits a followup response to the response sent.

Note: Message contents must be under 2000 unicode code points.

§Errors

Returns Error::Model if the content is too long. May also return Error::Http if the API returns an error, or Error::Json if there is an error in deserializing the response.

Source

pub async fn delete_followup<M: Into<MessageId>>( &self, http: impl AsRef<Http>, message_id: M, ) -> Result<()>

Deletes a followup message.

§Errors

May return Error::Http if the API returns an error. Such as if the response was already deleted.

Source

pub async fn get_followup<M: Into<MessageId>>( &self, http: impl AsRef<Http>, message_id: M, ) -> Result<Message>

Gets a followup message.

§Errors

May return Error::Http if the API returns an error. Such as if the response was deleted.

Source

pub async fn defer(&self, cache_http: impl CacheHttp) -> Result<()>

Helper function to defer an interaction.

§Errors

Returns an Error::Http if the API returns an error, or an Error::Json if there is an error in deserializing the API response.

Source

pub async fn defer_ephemeral(&self, cache_http: impl CacheHttp) -> Result<()>

Helper function to defer an interaction ephemerally

§Errors

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.

Source

pub async fn quick_modal( &self, ctx: &Context, builder: CreateQuickModal, ) -> Result<Option<QuickModalResponse>>

Trait Implementations§

Source§

impl Clone for ComponentInteraction

Source§

fn clone(&self) -> ComponentInteraction

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ComponentInteraction

Source§

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

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

impl<'de> Deserialize<'de> for ComponentInteraction

Source§

fn deserialize<D: Deserializer<'de>>( deserializer: D, ) -> StdResult<Self, D::Error>

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

impl Serialize for ComponentInteraction

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> StdResult<S::Ok, S::Error>

Serialize this value into the given Serde serializer. 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
Source§

impl<T> CloneDebuggableStorage for T

Source§

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

Source§

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

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

impl<T> CloneableStorage for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,

Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T