Skip to content

Commit 2df3733

Browse files
feat(model): add integration_type to audit log entries (#2266)
Ref: - discord/discord-api-docs#6367 This PR also adds a missing `guild_subscription` variant to `GuildIntegrationType`
1 parent a9b62eb commit 2df3733

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

twilight-model/src/guild/audit_log/optional_entry_info.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
use crate::id::{
2-
marker::{ChannelMarker, GenericMarker, MessageMarker},
3-
Id,
1+
use crate::{
2+
guild::GuildIntegrationType,
3+
id::{
4+
marker::{ChannelMarker, GenericMarker, MessageMarker},
5+
Id,
6+
},
47
};
58
use serde::{Deserialize, Serialize};
69

@@ -99,6 +102,17 @@ pub struct AuditLogOptionalEntryInfo {
99102
/// [`AuditLogEventType::ChannelOverwriteDelete`]: super::AuditLogEventType::ChannelOverwriteDelete
100103
/// [`AuditLogEventType::ChannelOverwriteUpdate`]: super::AuditLogEventType::ChannelOverwriteUpdate
101104
pub id: Option<Id<GenericMarker>>,
105+
/// Type of integration which performed the action.
106+
///
107+
/// The following events have this option:
108+
///
109+
/// - [`AuditLogEventType::MemberKick`]
110+
/// - [`AuditLogEventType::MemberRoleUpdate`]
111+
///
112+
/// [`AuditLogEventType::MemberKick`]: super::AuditLogEventType::MemberKick
113+
/// [`AuditLogEventType::MemberRoleUpdate`]: super::AuditLogEventType::MemberRoleUpdate
114+
#[serde(skip_serializing_if = "Option::is_none")]
115+
pub integration_type: Option<GuildIntegrationType>,
102116
/// Type of overwritten entity.
103117
///
104118
/// The following events have this option:

twilight-model/src/guild/integration_type.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub enum GuildIntegrationType {
1818
Twitch,
1919
/// Integration is a YouTube connection.
2020
YouTube,
21+
/// Integration is a Guild Subscription.
22+
GuildSubscription,
2123
/// Variant value is unknown to the library.
2224
Unknown(String),
2325
}
@@ -28,6 +30,7 @@ impl From<GuildIntegrationType> for Cow<'static, str> {
2830
GuildIntegrationType::Discord => "discord".into(),
2931
GuildIntegrationType::Twitch => "twitch".into(),
3032
GuildIntegrationType::YouTube => "youtube".into(),
33+
GuildIntegrationType::GuildSubscription => "guild_subscription".into(),
3134
GuildIntegrationType::Unknown(unknown) => unknown.into(),
3235
}
3336
}
@@ -39,6 +42,7 @@ impl From<String> for GuildIntegrationType {
3942
"discord" => Self::Discord,
4043
"twitch" => Self::Twitch,
4144
"youtube" => Self::YouTube,
45+
"guild_subscription" => Self::GuildSubscription,
4246
_ => Self::Unknown(value),
4347
}
4448
}
@@ -55,6 +59,10 @@ mod tests {
5559
(GuildIntegrationType::Discord, "discord"),
5660
(GuildIntegrationType::Twitch, "twitch"),
5761
(GuildIntegrationType::YouTube, "youtube"),
62+
(
63+
GuildIntegrationType::GuildSubscription,
64+
"guild_subscription",
65+
),
5866
];
5967

6068
for (integration_type, value) in MAP {

0 commit comments

Comments
 (0)