diff --git a/twilight-cache-inmemory/src/event/interaction.rs b/twilight-cache-inmemory/src/event/interaction.rs index 2f224ec9c1..775267c57f 100644 --- a/twilight-cache-inmemory/src/event/interaction.rs +++ b/twilight-cache-inmemory/src/event/interaction.rs @@ -282,6 +282,7 @@ mod tests { target_id: None, }))), entitlements: Vec::new(), + guild: None, guild_id: Some(Id::new(3)), guild_locale: None, id: Id::new(4), diff --git a/twilight-model/src/application/interaction/mod.rs b/twilight-model/src/application/interaction/mod.rs index 2079681237..42190c1174 100644 --- a/twilight-model/src/application/interaction/mod.rs +++ b/twilight-model/src/application/interaction/mod.rs @@ -26,7 +26,7 @@ use self::{ }; use crate::{ channel::{Channel, Message}, - guild::{PartialMember, Permissions}, + guild::{GuildFeature, PartialMember, Permissions}, id::{ marker::{ApplicationMarker, ChannelMarker, GuildMarker, InteractionMarker, UserMarker}, AnonymizableId, Id, @@ -93,6 +93,9 @@ pub struct Interaction { pub data: Option, /// For monetized apps, any entitlements for the invoking user, representing access to premium SKUs pub entitlements: Vec, + /// Guild that the interaction was sent from. + #[serde(skip_serializing_if = "Option::is_none")] + pub guild: Option, /// ID of the guild the interaction was invoked in. #[serde(skip_serializing_if = "Option::is_none")] pub guild_id: Option>, @@ -193,6 +196,7 @@ enum InteractionField { ChannelId, Data, Entitlements, + Guild, GuildId, GuildLocale, Id, @@ -224,6 +228,7 @@ impl<'de> Visitor<'de> for InteractionVisitor { let mut context: Option = None; let mut data: Option = None; let mut entitlements: Option> = None; + let mut guild: Option = None; let mut guild_id: Option> = None; let mut guild_locale: Option = None; let mut id: Option> = None; @@ -298,6 +303,13 @@ impl<'de> Visitor<'de> for InteractionVisitor { entitlements = map.next_value()?; } + InteractionField::Guild => { + if guild.is_some() { + return Err(DeError::duplicate_field("guild")); + } + + guild = map.next_value()?; + } InteractionField::GuildId => { if guild_id.is_some() { return Err(DeError::duplicate_field("guild_id")); @@ -430,6 +442,7 @@ impl<'de> Visitor<'de> for InteractionVisitor { context, data, entitlements, + guild, guild_id, guild_locale, id, @@ -464,6 +477,22 @@ pub enum InteractionData { ModalSubmit(ModalInteractionData), } +/// Partial guild containing only the fields sent in the partial guild +/// in interactions. +/// +/// # Note that the field `locale` does not exists on the full guild +/// object, and is only found here. See +/// for more +/// info. +#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize, Hash)] +pub struct InteractionPartialGuild { + /// Id of the guild. + pub id: Option>, + /// Enabled guild features + pub features: Option>, + pub locale: Option, +} + #[cfg(test)] mod tests { use super::{ @@ -606,6 +635,7 @@ mod tests { starts_at: None, user_id: None, }], + guild: None, guild_id: Some(Id::new(400)), guild_locale: Some("de".to_owned()), id: Id::new(500), diff --git a/twilight-standby/src/lib.rs b/twilight-standby/src/lib.rs index 93e7983e31..2a39de6f55 100644 --- a/twilight-standby/src/lib.rs +++ b/twilight-standby/src/lib.rs @@ -1214,6 +1214,7 @@ mod tests { }, ))), entitlements: Vec::new(), + guild: None, guild_id: Some(Id::new(3)), guild_locale: None, id: Id::new(4),