diff --git a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationRequestCreatedChangeSet.cs b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationRequestCreatedChangeSet.cs index c7f0cb67c..ca86d0fc3 100644 --- a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationRequestCreatedChangeSet.cs +++ b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationRequestCreatedChangeSet.cs @@ -1,7 +1,18 @@ -namespace DisCatSharp.Entities; +using DisCatSharp.Enums; + +namespace DisCatSharp.Entities; /// /// Represents a change set for the creation of a creator monetization request. /// public class CreatorMonetizationRequestCreatedChangeSet : DiscordAuditLogEntry -{ } +{ + public CreatorMonetizationRequestCreatedChangeSet() + { + this.ValidFor = AuditLogActionType.CreatorMonetizationRequestCreated; + } + + /// + internal override string? ChangeDescription + => $"{this.UserId} created Creator Monetization Request"; +} diff --git a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationTermsAcceptedChangeSet.cs b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationTermsAcceptedChangeSet.cs index e7692c6e9..370e97722 100644 --- a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationTermsAcceptedChangeSet.cs +++ b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/CreatorMonetizationTermsAcceptedChangeSet.cs @@ -1,7 +1,18 @@ -namespace DisCatSharp.Entities; +using DisCatSharp.Enums; + +namespace DisCatSharp.Entities; /// /// Represents a change set for the acceptance of creator monetization terms. /// public class CreatorMonetizationTermsAcceptedChangeSet : DiscordAuditLogEntry -{ } +{ + public CreatorMonetizationTermsAcceptedChangeSet() + { + this.ValidFor = AuditLogActionType.CreatorMonetizationTermsAccepted; + } + + /// + internal override string? ChangeDescription + => $"{this.UserId} accepted Creator Monetization Terms"; +} diff --git a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiCreateChangeSet.cs b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiCreateChangeSet.cs index 31336fb63..56cd8e230 100644 --- a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiCreateChangeSet.cs +++ b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiCreateChangeSet.cs @@ -1,7 +1,36 @@ -namespace DisCatSharp.Entities; +using System.Collections.Generic; +using System.Linq; + +using DisCatSharp.Enums; + +namespace DisCatSharp.Entities; /// /// Represents a change set for creating an emoji. /// public class EmojiCreateChangeSet : DiscordAuditLogEntry -{ } +{ + public EmojiCreateChangeSet() + { + this.ValidFor = AuditLogActionType.EmojiCreate; + } + + public string? EmojiName => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.NewValue; + public IReadOnlyList? RolesAllowed => ((IReadOnlyList?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.NewValue)?.Select(x => ConvertToUlong(x)!.Value).ToList(); + public bool EmojiNameChanged => this.EmojiName is not null; + public bool RolesAllowedChanged => this.RolesAllowed is not null; + + /// + internal override string ChangeDescription + { + get + { + var description = $"{this.UserId} created a new emoji with the following details:\n"; + if (this.EmojiNameChanged) + description += $"- Emoji Name: {this.EmojiName}\n"; + if (this.RolesAllowedChanged) + description += $"- Roles Allowed: {string.Join(", ", this.RolesAllowed)}\n"; + return description; + } + } +} diff --git a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiDeleteChangeSet.cs b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiDeleteChangeSet.cs index b6dbc0240..95420ec11 100644 --- a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiDeleteChangeSet.cs +++ b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiDeleteChangeSet.cs @@ -1,7 +1,36 @@ -namespace DisCatSharp.Entities; +using System.Collections.Generic; +using System.Linq; + +using DisCatSharp.Enums; + +namespace DisCatSharp.Entities; /// /// Represents a change set for deleting an emoji. /// public class EmojiDeleteChangeSet : DiscordAuditLogEntry -{ } +{ + public EmojiDeleteChangeSet() + { + this.ValidFor = AuditLogActionType.EmojiDelete; + } + + public string? EmojiName => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.OldValue; + public IReadOnlyList? RolesAllowed => ((IReadOnlyList?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.OldValue)?.Select(x => ConvertToUlong(x)!.Value).ToList(); + public bool EmojiNameChanged => this.EmojiName is not null; + public bool RolesAllowedChanged => this.RolesAllowed is not null; + + /// + internal override string ChangeDescription + { + get + { + var description = $"{this.UserId} deleted emoji {this.TargetId}:\n"; + if (this.EmojiNameChanged) + description += $"- Name: {this.EmojiName}\n"; + if (this.RolesAllowedChanged) + description += $"- Roles Allowed: {string.Join(", ", this.RolesAllowed)}\n"; + return description; + } + } +} diff --git a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiUpdateChangeSet.cs b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiUpdateChangeSet.cs index ce37fe407..a103e6ee2 100644 --- a/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiUpdateChangeSet.cs +++ b/DisCatSharp/Entities/Guild/AuditLog/ChangeSet/EmojiUpdateChangeSet.cs @@ -1,7 +1,46 @@ -namespace DisCatSharp.Entities; +using System.Collections.Generic; +using System.Linq; + +using DisCatSharp.Enums; + +namespace DisCatSharp.Entities; /// /// Represents a change set for updating the name of an emoji. /// public class EmojiUpdateChangeSet : DiscordAuditLogEntry -{ } +{ + public EmojiUpdateChangeSet() + { + this.ValidFor = AuditLogActionType.EmojiUpdate; + } + + public string? EmojiNameBefore => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.OldValue; + public string? EmojiNameAfter => (string?)this.Changes.FirstOrDefault(x => x.Key == "name")?.NewValue; + public IReadOnlyList? RolesAllowedBefore => ((IReadOnlyList?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.OldValue)?.Select(x => ConvertToUlong(x)!.Value).ToList(); + public IReadOnlyList? RolesAllowedAfter => ((IReadOnlyList?)this.Changes.FirstOrDefault(x => x.Key == "roles")?.NewValue)?.Select(x => ConvertToUlong(x)!.Value).ToList(); + public bool EmojiNameChanged => this.EmojiNameBefore is not null || this.EmojiNameAfter is not null; + public bool RolesAllowedChanged => this.RolesAllowedBefore is not null || this.RolesAllowedAfter is not null; + + /// + internal override string ChangeDescription + { + get + { + var description = $"{this.UserId} updated emoji {this.TargetId}:\n"; + if (this.EmojiNameChanged) + { + description += this.EmojiNameBefore is not null ? $"- Emoji Name Before: {this.EmojiNameBefore}\n" : "- Emoji Name Before: Not set\n"; + description += this.EmojiNameAfter is not null ? $"- Emoji Name After: {this.EmojiNameAfter}\n" : "- Emoji Name After: Not set\n"; + } + + if (this.RolesAllowedChanged) + { + description += this.RolesAllowedBefore is not null ? $"- Roles Before: {string.Join(", ", this.RolesAllowedBefore)}\n" : "- Roles Before: Not set\n"; + description += this.RolesAllowedAfter is not null ? $"- Roles After: {string.Join(", ", this.RolesAllowedAfter)}\n" : "- Roles After: Not set\n"; + } + + return description; + } + } +}