#[non_exhaustive]pub struct Interaction {Show 19 fields
pub id: InteractionId,
pub application_id: ApplicationId,
pub data: InteractionData,
pub guild: Option<InteractionGuild>,
pub guild_id: Option<GuildId>,
pub channel: Option<Box<InteractionChannel>>,
pub channel_id: Option<ChannelId>,
pub member: Option<Box<InteractionMember>>,
pub user: Option<Box<User>>,
pub token: CompactString,
pub version: u8,
pub message: Option<Box<Message>>,
pub app_permissions: Permissions,
pub locale: Option<Locale>,
pub guild_locale: Option<Locale>,
pub entitlements: Vec<Entitlement>,
pub authorizing_integration_owners: AuthorizingIntegrationOwners,
pub context: Option<InteractionContextType>,
pub attachment_size_limit: Option<u64>,
}Expand description
An interaction: a user used one of the app’s commands, components or modals (or Discord checks the app’s HTTP endpoint).
The data enum tells which kind it is (D-067). The interaction is answered
with an InteractionResponse within 3 seconds; its token then stays
valid for follow-up messages for 15 minutes. Debug does not print the token.
Contains floats (number options), so it is PartialEq but not Eq (D-064).
discord.js counterpart: BaseInteraction and its subclasses.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: InteractionIdThe interaction’s ID.
application_id: ApplicationIdThe application the interaction is for.
data: InteractionDataThe kind of interaction and its kind-specific data (D-067).
guild: Option<InteractionGuild>The guild it was triggered in (a partial object).
guild_id: Option<GuildId>The guild it was triggered in.
channel: Option<Box<InteractionChannel>>The channel it was triggered in (a partial object).
channel_id: Option<ChannelId>The channel it was triggered in.
member: Option<Box<InteractionMember>>The invoking member, with their permissions in the channel (guild interactions).
user: Option<Box<User>>§token: CompactStringThe token to respond with; secret, valid for 15 minutes.
version: u8Always 1.
message: Option<Box<Message>>The message the component was on (component interactions and modals opened by one).
app_permissions: PermissionsThe app’s permissions in the channel (with the extra permissions apps get in DMs).
locale: Option<Locale>The invoking user’s language (every interaction except pings).
guild_locale: Option<Locale>The guild’s preferred locale.
entitlements: Vec<Entitlement>The user’s and guild’s entitlements to the app’s SKUs (monetized apps).
The installations that authorized the interaction.
context: Option<InteractionContextType>Where the interaction was triggered.
attachment_size_limit: Option<u64>The maximum size of attachments in a response, in bytes.
Implementations§
Source§impl Interaction
impl Interaction
Sourcepub const fn kind(&self) -> InteractionType
pub const fn kind(&self) -> InteractionType
Returns the interaction type.
discord.js counterpart: BaseInteraction#type.
Sourcepub fn command(&self) -> Option<&CommandData>
pub fn command(&self) -> Option<&CommandData>
Returns the command data if a user ran one of the app’s commands (not for
autocomplete, unlike InteractionData::command; D-249).
discord.js counterpart: BaseInteraction#isCommand.
Sourcepub fn autocomplete(&self) -> Option<&CommandData>
pub fn autocomplete(&self) -> Option<&CommandData>
Returns the command data if a user is typing an option with autocomplete (D-249); the
typed option is CommandData::focused.
discord.js counterpart: BaseInteraction#isAutocomplete.
Sourcepub fn component(&self) -> Option<&ComponentData>
pub fn component(&self) -> Option<&ComponentData>
Returns the component data if a user clicked a button or chose in a select menu (D-249).
discord.js counterpart: BaseInteraction#isMessageComponent.
Sourcepub fn modal(&self) -> Option<&ModalSubmitData>
pub fn modal(&self) -> Option<&ModalSubmitData>
Returns the submitted fields if a user submitted one of the app’s modals (D-249).
discord.js counterpart: BaseInteraction#isModalSubmit.