Skip to content

Commit

Permalink
Add support for locale and guild_locale fields in interactions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Rstar284 authored and arqunis committed Mar 15, 2022
1 parent d51b0b1 commit b4d0765
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 27 deletions.
14 changes: 5 additions & 9 deletions src/model/interactions/application_command.rs
Expand Up @@ -400,15 +400,11 @@ impl<'de> Deserialize<'de> for ApplicationCommandInteraction {
.and_then(u8::deserialize)
.map_err(DeError::custom)?;

let guild_locale = match map.contains_key("guild_locale") {
true => Some(
map.remove("guild_locale")
.ok_or_else(|| DeError::custom("expected guild_locale"))
.and_then(String::deserialize)
.map_err(DeError::custom)?,
),
false => None,
};
let guild_locale = map
.remove("guild_locale")
.map(String::deserialize)
.transpose()
.map_err(DeError::custom)?;

let locale = map
.remove("locale")
Expand Down
14 changes: 5 additions & 9 deletions src/model/interactions/autocomplete.rs
Expand Up @@ -180,15 +180,11 @@ impl<'de> Deserialize<'de> for AutocompleteInteraction {
.and_then(u8::deserialize)
.map_err(DeError::custom)?;

let guild_locale = match map.contains_key("guild_locale") {
true => Some(
map.remove("guild_locale")
.ok_or_else(|| DeError::custom("expected guild_locale"))
.and_then(String::deserialize)
.map_err(DeError::custom)?,
),
false => None,
};
let guild_locale = map
.remove("guild_locale")
.map(String::deserialize)
.transpose()
.map_err(DeError::custom)?;

let locale = map
.remove("locale")
Expand Down
14 changes: 5 additions & 9 deletions src/model/interactions/message_component.rs
Expand Up @@ -378,15 +378,11 @@ impl<'de> Deserialize<'de> for MessageComponentInteraction {
.and_then(u8::deserialize)
.map_err(DeError::custom)?;

let guild_locale = match map.contains_key("guild_locale") {
true => Some(
map.remove("guild_locale")
.ok_or_else(|| DeError::custom("expected guild_locale"))
.and_then(String::deserialize)
.map_err(DeError::custom)?,
),
false => None,
};
let guild_locale = map
.remove("guild_locale")
.map(String::deserialize)
.transpose()
.map_err(DeError::custom)?;

let locale = map
.remove("locale")
Expand Down

0 comments on commit b4d0765

Please sign in to comment.