Skip to content

Commit

Permalink
fix(model): Entitlements would only deserialize it was before data
Browse files Browse the repository at this point in the history
closes #2358
  • Loading branch information
Erk- committed Jul 4, 2024
1 parent 6a44028 commit b39663d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions twilight-model/src/application/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl<'de> Visitor<'de> for InteractionVisitor {
let mut channel: Option<Channel> = None;
let mut channel_id: Option<Id<ChannelMarker>> = None;
let mut data: Option<Value> = None;
let mut entitlements: Vec<Entitlement> = Vec::new();
let mut entitlements: Option<Vec<Entitlement>> = None;
let mut guild_id: Option<Id<GuildMarker>> = None;
let mut guild_locale: Option<String> = None;
let mut id: Option<Id<InteractionMarker>> = None;
Expand Down Expand Up @@ -269,7 +269,7 @@ impl<'de> Visitor<'de> for InteractionVisitor {
data = map.next_value()?;
}
InteractionField::Entitlements => {
if data.is_some() {
if entitlements.is_some() {
return Err(DeError::duplicate_field("entitlements"));
}

Expand Down Expand Up @@ -387,6 +387,8 @@ impl<'de> Visitor<'de> for InteractionVisitor {
}
};

let entitlements = entitlements.unwrap_or_default();

Ok(Self::Value {
app_permissions,
application_id,
Expand Down

0 comments on commit b39663d

Please sign in to comment.