From c1fa9c473a6ca61f40caeb69a30c3b29afebdcd5 Mon Sep 17 00:00:00 2001 From: "Alex M. M." Date: Sun, 24 Dec 2023 12:34:51 +0100 Subject: [PATCH] Fix parsing of role add/remove audit log changes --- src/model/guild/audit_log/change.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/model/guild/audit_log/change.rs b/src/model/guild/audit_log/change.rs index b08bf39f822..c57ab2bee29 100644 --- a/src/model/guild/audit_log/change.rs +++ b/src/model/guild/audit_log/change.rs @@ -56,6 +56,29 @@ macro_rules! generate_change { }, )* + /* These changes are special because their variant names do not match their keys. */ + + /// Role was added to a member. + #[serde(rename = "$add")] + RolesAdded { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(rename = "old_value")] + old: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(rename = "new_value")] + new: Option>, + }, + /// Role was removed to a member. + #[serde(rename = "$remove")] + RolesRemove { + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(rename = "old_value")] + old: Option>, + #[serde(skip_serializing_if = "Option::is_none")] + #[serde(rename = "new_value")] + new: Option>, + }, + /// Unknown key was changed. Other { name: String, @@ -77,6 +100,8 @@ macro_rules! generate_change { pub fn key(&self) -> &str { match self { $( Self::$name { .. } => $key, )* + Self::RolesAdded { .. } => "$add", + Self::RolesRemove { .. } => "$remove", Self::Other { name, .. } => name, Self::Unknown => "unknown", } @@ -200,10 +225,6 @@ generate_change! { "rate_limit_per_user" => RateLimitPerUser(u16), /// Region of a guild was changed. "region" => Region(String), - /// Role was added to a member. - "add" => RolesAdded(Vec), - /// Role was removed to a member. - "remove" => RolesRemove(Vec), /// ID of the rules channel was changed. "rules_channel_id" => RulesChannelId(ChannelId), /// Invite splash page artwork was changed.