diff --git a/src/Discord.Net.Core/Entities/AuditLogs/ActionType.cs b/src/Discord.Net.Core/Entities/AuditLogs/ActionType.cs
index ad2d659e..a7e4efaa 100644
--- a/src/Discord.Net.Core/Entities/AuditLogs/ActionType.cs
+++ b/src/Discord.Net.Core/Entities/AuditLogs/ActionType.cs
@@ -205,6 +205,50 @@ namespace Discord
///
/// A thread was deleted.
///
- ThreadDelete = 112
+ ThreadDelete = 112,
+ ///
+ /// Permissions were updated for a command.
+ ///
+ ApplicationCommandPermissionUpdate = 121,
+
+ ///
+ /// Auto Moderation rule was created.
+ ///
+ AutoModerationRuleCreate = 140,
+ ///
+ /// Auto Moderation rule was updated.
+ ///
+ AutoModerationRuleUpdate = 141,
+ ///
+ /// Auto Moderation rule was deleted.
+ ///
+ AutoModerationRuleDelete = 142,
+ ///
+ /// Message was blocked by Auto Moderation.
+ ///
+ AutoModerationBlockMessage = 143,
+ ///
+ /// Message was flagged by Auto Moderation.
+ ///
+ AutoModerationFlagToChannel = 144,
+ ///
+ /// Member was timed out by Auto Moderation.
+ ///
+ AutoModerationUserCommunicationDisabled = 145,
+
+ ///
+ /// Guild Onboarding Question was created.
+ ///
+ OnboardingQuestionCreated = 163,
+
+ ///
+ /// Guild Onboarding Question was updated.
+ ///
+ OnboardingQuestionUpdated = 164,
+
+ ///
+ /// Guild Onboarding was updated.
+ ///
+ OnboardingUpdated = 167
}
}
diff --git a/src/Discord.Net.Core/Entities/AuditLogs/IAuditLogInfoModel.cs b/src/Discord.Net.Core/Entities/AuditLogs/IAuditLogInfoModel.cs
new file mode 100644
index 00000000..880c6e37
--- /dev/null
+++ b/src/Discord.Net.Core/Entities/AuditLogs/IAuditLogInfoModel.cs
@@ -0,0 +1,6 @@
+namespace Discord;
+
+public interface IAuditLogInfoModel
+{
+
+}
diff --git a/src/Discord.Net.Core/Entities/Channels/ThreadArchiveDuration.cs b/src/Discord.Net.Core/Entities/Channels/ThreadArchiveDuration.cs
index 2c8a0652..6c1b7a4c 100644
--- a/src/Discord.Net.Core/Entities/Channels/ThreadArchiveDuration.cs
+++ b/src/Discord.Net.Core/Entities/Channels/ThreadArchiveDuration.cs
@@ -17,17 +17,11 @@ namespace Discord
///
/// Three days (4320 minutes).
- ///
- /// This option is explicitly available to nitro users.
- ///
///
ThreeDays = 4320,
///
/// One week (10080 minutes).
- ///
- /// This option is explicitly available to nitro users.
- ///
///
OneWeek = 10080
}
diff --git a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
index 97ee481b..aec5bff1 100644
--- a/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/IGuild.cs
@@ -7,6 +7,8 @@ using System.Threading.Tasks;
namespace Discord
{
+ // when adding properties to guilds please check if they are returned in audit log events and add them to the
+ // 'GuildInfo.cs' file for socket and rest audit logs.
///
/// Represents a generic guild/server.
///
diff --git a/src/Discord.Net.Rest/API/AuditLogs/AutoModRuleInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/AutoModRuleInfoAuditLogModel.cs
new file mode 100644
index 00000000..452ff07f
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/AutoModRuleInfoAuditLogModel.cs
@@ -0,0 +1,30 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class AutoModRuleInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("event_type")]
+ public AutoModEventType EventType { get; set; }
+
+ [JsonField("trigger_type")]
+ public AutoModTriggerType TriggerType { get; set; }
+
+ [JsonField("trigger_metadata")]
+ public TriggerMetadata TriggerMetadata { get; set; }
+
+ [JsonField("actions")]
+ public AutoModAction[] Actions { get; set; }
+
+ [JsonField("enabled")]
+ public bool Enabled { get; set; }
+
+ [JsonField("exempt_roles")]
+ public ulong[] ExemptRoles { get; set; }
+
+ [JsonField("exempt_channels")]
+ public ulong[] ExemptChannels { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/ChannelInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/ChannelInfoAuditLogModel.cs
new file mode 100644
index 00000000..75f04710
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/ChannelInfoAuditLogModel.cs
@@ -0,0 +1,57 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class ChannelInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("type")]
+ public ChannelType? Type { get; set; }
+
+ [JsonField("permission_overwrites")]
+ public Overwrite[] Overwrites { get; set; }
+
+ [JsonField("flags")]
+ public ChannelFlags? Flags { get; set; }
+
+ [JsonField("default_thread_rate_limit_per_user")]
+ public int? DefaultThreadRateLimitPerUser { get; set; }
+
+ [JsonField("default_auto_archive_duration")]
+ public ThreadArchiveDuration? DefaultArchiveDuration { get; set; }
+
+ [JsonField("rate_limit_per_user")]
+ public int? RateLimitPerUser { get; set; }
+
+ [JsonField("auto_archive_duration")]
+ public ThreadArchiveDuration? AutoArchiveDuration { get; set; }
+
+ [JsonField("nsfw")]
+ public bool? IsNsfw { get; set; }
+
+ [JsonField("topic")]
+ public string Topic { get; set; }
+
+ // Forum channels
+ [JsonField("available_tags")]
+ public ForumTag[] AvailableTags { get; set; }
+
+ [JsonField("default_reaction_emoji")]
+ public ForumReactionEmoji DefaultEmoji { get; set; }
+
+ // Voice channels
+
+ [JsonField("user_limit")]
+ public int? UserLimit { get; set; }
+
+ [JsonField("rtc_region")]
+ public string Region { get; set; }
+
+ [JsonField("video_quality_mode")]
+ public VideoQualityMode? VideoQualityMode { get; set; }
+
+ [JsonField("bitrate")]
+ public int? Bitrate { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/GuildInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/GuildInfoAuditLogModel.cs
new file mode 100644
index 00000000..fd4a85fb
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/GuildInfoAuditLogModel.cs
@@ -0,0 +1,82 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+public class GuildInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("afk_timeout")]
+ public int? AfkTimeout { get; set; }
+
+ [JsonField("widget_enabled")]
+ public bool? IsEmbeddable { get; set; }
+
+ [JsonField("default_message_notifications")]
+ public DefaultMessageNotifications? DefaultMessageNotifications { get; set; }
+
+ [JsonField("mfa_level")]
+ public MfaLevel? MfaLevel { get; set; }
+
+ [JsonField("verification_level")]
+ public VerificationLevel? VerificationLevel { get; set; }
+
+ [JsonField("explicit_content_filter")]
+ public ExplicitContentFilterLevel? ExplicitContentFilterLevel { get; set; }
+
+ [JsonField("icon_hash")]
+ public string IconHash { get; set; }
+
+ [JsonField("discovery_splash")]
+ public string DiscoverySplash { get; set; }
+
+ [JsonField("splash")]
+ public string Splash { get; set; }
+
+ [JsonField("afk_channel_id")]
+ public ulong? AfkChannelId { get; set; }
+
+ [JsonField("widget_channel_id")]
+ public ulong? EmbeddedChannelId { get; set; }
+
+ [JsonField("system_channel_id")]
+ public ulong? SystemChannelId { get; set; }
+
+ [JsonField("rules_channel_id")]
+ public ulong? RulesChannelId { get; set; }
+
+ [JsonField("public_updates_channel_id")]
+ public ulong? PublicUpdatesChannelId { get; set; }
+
+ [JsonField("owner_id")]
+ public ulong? OwnerId { get; set; }
+
+ [JsonField("application_id")]
+ public ulong? ApplicationId { get; set; }
+
+ [JsonField("region")]
+ public string RegionId { get; set; }
+
+ [JsonField("banner")]
+ public string Banner { get; set; }
+
+ [JsonField("vanity_url_code")]
+ public string VanityUrl { get; set; }
+
+ [JsonField("system_channel_flags")]
+ public SystemChannelMessageDeny? SystemChannelFlags { get; set; }
+
+ [JsonField("description")]
+ public string Description { get; set; }
+
+ [JsonField("preferred_locale")]
+ public string PreferredLocale { get; set; }
+
+ [JsonField("nsfw_level")]
+ public NsfwLevel? NsfwLevel { get; set; }
+
+ [JsonField("premium_progress_bar_enabled")]
+ public bool? ProgressBarEnabled { get; set; }
+
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/IntegrationInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/IntegrationInfoAuditLogModel.cs
new file mode 100644
index 00000000..f63ab96d
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/IntegrationInfoAuditLogModel.cs
@@ -0,0 +1,33 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class IntegrationInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("type")]
+ public string Type { get; set; }
+
+ [JsonField("enabled")]
+ public bool? Enabled { get; set; }
+
+ [JsonField("syncing")]
+ public bool? Syncing { get; set; }
+
+ [JsonField("role_id")]
+ public ulong? RoleId { get; set; }
+
+ [JsonField("enable_emoticons")]
+ public bool? EnableEmojis { get; set; }
+
+ [JsonField("expire_behavior")]
+ public IntegrationExpireBehavior? ExpireBehavior { get; set; }
+
+ [JsonField("expire_grace_period")]
+ public int? ExpireGracePeriod { get; set; }
+
+ [JsonField("scopes")]
+ public string[] Scopes { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/InviteInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/InviteInfoAuditLogModel.cs
new file mode 100644
index 00000000..836d4ed2
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/InviteInfoAuditLogModel.cs
@@ -0,0 +1,27 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class InviteInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("code")]
+ public string Code { get; set; }
+
+ [JsonField("channel_id")]
+ public ulong? ChannelId { get; set; }
+
+ [JsonField("inviter_id")]
+ public ulong? InviterId { get; set; }
+
+ [JsonField("uses")]
+ public int? Uses { get; set; }
+
+ [JsonField("max_uses")]
+ public int? MaxUses { get; set; }
+
+ [JsonField("max_age")]
+ public int? MaxAge { get; set; }
+
+ [JsonField("temporary")]
+ public bool? Temporary { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/MemberInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/MemberInfoAuditLogModel.cs
new file mode 100644
index 00000000..f81cea2e
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/MemberInfoAuditLogModel.cs
@@ -0,0 +1,19 @@
+using Discord.Rest;
+using System;
+
+namespace Discord.API.AuditLogs;
+
+internal class MemberInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("nick")]
+ public string Nickname { get; set; }
+
+ [JsonField("mute")]
+ public bool? IsMuted { get; set; }
+
+ [JsonField("deaf")]
+ public bool? IsDeafened { get; set; }
+
+ [JsonField("communication_disabled_until")]
+ public DateTimeOffset? TimeOutUntil { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/OnboardingAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/OnboardingAuditLogModel.cs
new file mode 100644
index 00000000..5b36734a
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/OnboardingAuditLogModel.cs
@@ -0,0 +1,15 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class OnboardingAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("default_channel_ids")]
+ public ulong[] DefaultChannelIds { get; set; }
+
+ [JsonField("prompts")]
+ public GuildOnboardingPrompt[] Prompts { get; set; }
+
+ [JsonField("enabled")]
+ public bool? Enabled { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/OnboardingPromptAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/OnboardingPromptAuditLogModel.cs
new file mode 100644
index 00000000..31eea7f9
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/OnboardingPromptAuditLogModel.cs
@@ -0,0 +1,27 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class OnboardingPromptAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("id")]
+ public ulong? Id { get; set; }
+
+ [JsonField("title")]
+ public string Title { get; set; }
+
+ [JsonField("options")]
+ public GuildOnboardingPromptOption[] Options { get; set; }
+
+ [JsonField("single_select")]
+ public bool? IsSingleSelect { get; set; }
+
+ [JsonField("required")]
+ public bool? IsRequired { get; set; }
+
+ [JsonField("in_onboarding")]
+ public bool? IsInOnboarding { get; set; }
+
+ [JsonField("type")]
+ public GuildOnboardingPromptType? Type { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/RoleInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/RoleInfoAuditLogModel.cs
new file mode 100644
index 00000000..351a4eee
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/RoleInfoAuditLogModel.cs
@@ -0,0 +1,24 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class RoleInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("color")]
+ public uint? Color { get; set; }
+
+ [JsonField("hoist")]
+ public bool? Hoist { get; set; }
+
+ [JsonField("permissions")]
+ public ulong? Permissions { get; set; }
+
+ [JsonField("mentionable")]
+ public bool? IsMentionable { get; set; }
+
+ [JsonField("icon_hash")]
+ public string IconHash { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/ScheduledEventInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/ScheduledEventInfoAuditLogModel.cs
new file mode 100644
index 00000000..a8f27626
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/ScheduledEventInfoAuditLogModel.cs
@@ -0,0 +1,43 @@
+using Discord.Rest;
+using System;
+
+namespace Discord.API.AuditLogs;
+
+internal class ScheduledEventInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("channel_id")]
+ public ulong? ChannelId { get; set; }
+
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("description")]
+ public string Description { get; set; }
+
+ [JsonField("scheduled_start_time")]
+ public DateTimeOffset? StartTime { get; set; }
+
+ [JsonField("scheduled_end_time")]
+ public DateTimeOffset? EndTime { get; set; }
+
+ [JsonField("privacy_level")]
+ public GuildScheduledEventPrivacyLevel? PrivacyLevel { get; set; }
+
+ [JsonField("status")]
+ public GuildScheduledEventStatus? EventStatus { get; set; }
+
+ [JsonField("entity_type")]
+ public GuildScheduledEventType? EventType { get; set; }
+
+ [JsonField("entity_id")]
+ public ulong? EntityId { get; set; }
+
+ [JsonField("user_count")]
+ public int? UserCount { get; set; }
+
+ [JsonField("location")]
+ public string Location { get; set; }
+
+ [JsonField("image")]
+ public string Image { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/StickerInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/StickerInfoAuditLogModel.cs
new file mode 100644
index 00000000..38686743
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/StickerInfoAuditLogModel.cs
@@ -0,0 +1,15 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class StickerInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("tags")]
+ public string Tags { get; set; }
+
+ [JsonField("description")]
+ public string Description { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/ThreadInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/ThreadInfoAuditLogModel.cs
new file mode 100644
index 00000000..5215d586
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/ThreadInfoAuditLogModel.cs
@@ -0,0 +1,30 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class ThreadInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("type")]
+ public ThreadType Type { get; set; }
+
+ [JsonField("archived")]
+ public bool? IsArchived { get; set; }
+
+ [JsonField("locked")]
+ public bool? IsLocked { get; set;}
+
+ [JsonField("auto_archive_duration")]
+ public ThreadArchiveDuration? ArchiveDuration { get; set; }
+
+ [JsonField("rate_limit_per_user")]
+ public int? SlowModeInterval { get; set; }
+
+ [JsonField("flags")]
+ public ChannelFlags? ChannelFlags { get; set; }
+
+ [JsonField("applied_tags")]
+ public ulong[] AppliedTags { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/AuditLogs/WebhookInfoAuditLogModel.cs b/src/Discord.Net.Rest/API/AuditLogs/WebhookInfoAuditLogModel.cs
new file mode 100644
index 00000000..e8d8a193
--- /dev/null
+++ b/src/Discord.Net.Rest/API/AuditLogs/WebhookInfoAuditLogModel.cs
@@ -0,0 +1,18 @@
+using Discord.Rest;
+
+namespace Discord.API.AuditLogs;
+
+internal class WebhookInfoAuditLogModel : IAuditLogInfoModel
+{
+ [JsonField("channel_id")]
+ public ulong? ChannelId { get; set; }
+
+ [JsonField("name")]
+ public string Name { get; set; }
+
+ [JsonField("type")]
+ public WebhookType? Type { get; set; }
+
+ [JsonField("avatar_hash")]
+ public string AvatarHash { get; set; }
+}
diff --git a/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs b/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs
index 40bd0c1b..1b27e6e7 100644
--- a/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs
+++ b/src/Discord.Net.Rest/API/Common/ApplicationCommand.cs
@@ -14,6 +14,9 @@ namespace Discord.API
[JsonProperty("application_id")]
public ulong ApplicationId { get; set; }
+ [JsonProperty("guild_id")]
+ public Optional GuildId { get; set; }
+
[JsonProperty("name")]
public string Name { get; set; }
diff --git a/src/Discord.Net.Rest/API/Common/AuditLog.cs b/src/Discord.Net.Rest/API/Common/AuditLog.cs
index c8bd6d3e..f6264efd 100644
--- a/src/Discord.Net.Rest/API/Common/AuditLog.cs
+++ b/src/Discord.Net.Rest/API/Common/AuditLog.cs
@@ -18,5 +18,14 @@ namespace Discord.API
[JsonProperty("audit_log_entries")]
public AuditLogEntry[] Entries { get; set; }
+
+ [JsonProperty("application_commands")]
+ public ApplicationCommand[] Commands { get; set; }
+
+ [JsonProperty("auto_moderation_rules")]
+ public AutoModerationRule[] AutoModerationRules { get; set;}
+
+ [JsonProperty("guild_scheduled_events")]
+ public GuildScheduledEvent[] GuildScheduledEvents { get; set; }
}
}
diff --git a/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs b/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs
index 1b0144cf..f91c6d32 100644
--- a/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs
+++ b/src/Discord.Net.Rest/API/Common/AuditLogOptions.cs
@@ -1,28 +1,39 @@
using Newtonsoft.Json;
-namespace Discord.API
+namespace Discord.API;
+
+internal class AuditLogOptions
{
- internal class AuditLogOptions
- {
- [JsonProperty("count")]
- public int? Count { get; set; }
- [JsonProperty("channel_id")]
- public ulong? ChannelId { get; set; }
- [JsonProperty("message_id")]
- public ulong? MessageId { get; set; }
+ [JsonProperty("count")]
+ public int? Count { get; set; }
+ [JsonProperty("channel_id")]
+ public ulong? ChannelId { get; set; }
+ [JsonProperty("message_id")]
+ public ulong? MessageId { get; set; }
- //Prune
- [JsonProperty("delete_member_days")]
- public int? PruneDeleteMemberDays { get; set; }
- [JsonProperty("members_removed")]
- public int? PruneMembersRemoved { get; set; }
+ //Prune
+ [JsonProperty("delete_member_days")]
+ public int? PruneDeleteMemberDays { get; set; }
+ [JsonProperty("members_removed")]
+ public int? PruneMembersRemoved { get; set; }
- //Overwrite Update
- [JsonProperty("role_name")]
- public string OverwriteRoleName { get; set; }
- [JsonProperty("type")]
- public PermissionTarget OverwriteType { get; set; }
- [JsonProperty("id")]
- public ulong? OverwriteTargetId { get; set; }
- }
+ //Overwrite Update
+ [JsonProperty("role_name")]
+ public string OverwriteRoleName { get; set; }
+ [JsonProperty("type")]
+ public PermissionTarget OverwriteType { get; set; }
+ [JsonProperty("id")]
+ public ulong? OverwriteTargetId { get; set; }
+
+ // App command perm update
+ [JsonProperty("application_id")]
+ public ulong? ApplicationId { get; set; }
+
+ // Automod
+
+ [JsonProperty("auto_moderation_rule_name")]
+ public string AutoModRuleName { get; set; }
+
+ [JsonProperty("auto_moderation_rule_trigger_type")]
+ public AutoModTriggerType? AutoModRuleTriggerType { get; set; }
}
diff --git a/src/Discord.Net.Rest/API/Common/Channel.cs b/src/Discord.Net.Rest/API/Common/Channel.cs
index 8ceaf2b0..bbfe432e 100644
--- a/src/Discord.Net.Rest/API/Common/Channel.cs
+++ b/src/Discord.Net.Rest/API/Common/Channel.cs
@@ -72,7 +72,7 @@ namespace Discord.API
//ForumChannel
[JsonProperty("available_tags")]
- public Optional ForumTags { get; set; }
+ public Optional ForumTags { get; set; }
[JsonProperty("applied_tags")]
public Optional AppliedTags { get; set; }
diff --git a/src/Discord.Net.Rest/API/Common/ForumTags.cs b/src/Discord.Net.Rest/API/Common/ForumTag.cs
similarity index 95%
rename from src/Discord.Net.Rest/API/Common/ForumTags.cs
rename to src/Discord.Net.Rest/API/Common/ForumTag.cs
index c4a1fa2a..d287bcbf 100644
--- a/src/Discord.Net.Rest/API/Common/ForumTags.cs
+++ b/src/Discord.Net.Rest/API/Common/ForumTag.cs
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Discord.API
{
- internal class ForumTags
+ internal class ForumTag
{
[JsonProperty("id")]
public ulong Id { get; set; }
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs b/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs
index 2b850924..8bc431ed 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/AuditLogHelper.cs
@@ -1,71 +1,122 @@
using System;
using System.Collections.Generic;
+using System.Linq;
+
+using AuditLogChange = Discord.API.AuditLogChange;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+internal static class AuditLogHelper
{
- internal static class AuditLogHelper
- {
- private static readonly Dictionary> CreateMapping
- = new Dictionary>()
- {
- [ActionType.GuildUpdated] = GuildUpdateAuditLogData.Create,
-
- [ActionType.ChannelCreated] = ChannelCreateAuditLogData.Create,
- [ActionType.ChannelUpdated] = ChannelUpdateAuditLogData.Create,
- [ActionType.ChannelDeleted] = ChannelDeleteAuditLogData.Create,
-
- [ActionType.OverwriteCreated] = OverwriteCreateAuditLogData.Create,
- [ActionType.OverwriteUpdated] = OverwriteUpdateAuditLogData.Create,
- [ActionType.OverwriteDeleted] = OverwriteDeleteAuditLogData.Create,
-
- [ActionType.Kick] = KickAuditLogData.Create,
- [ActionType.Prune] = PruneAuditLogData.Create,
- [ActionType.Ban] = BanAuditLogData.Create,
- [ActionType.Unban] = UnbanAuditLogData.Create,
- [ActionType.MemberUpdated] = MemberUpdateAuditLogData.Create,
- [ActionType.MemberRoleUpdated] = MemberRoleAuditLogData.Create,
- [ActionType.MemberMoved] = MemberMoveAuditLogData.Create,
- [ActionType.MemberDisconnected] = MemberDisconnectAuditLogData.Create,
- [ActionType.BotAdded] = BotAddAuditLogData.Create,
-
- [ActionType.RoleCreated] = RoleCreateAuditLogData.Create,
- [ActionType.RoleUpdated] = RoleUpdateAuditLogData.Create,
- [ActionType.RoleDeleted] = RoleDeleteAuditLogData.Create,
-
- [ActionType.InviteCreated] = InviteCreateAuditLogData.Create,
- [ActionType.InviteUpdated] = InviteUpdateAuditLogData.Create,
- [ActionType.InviteDeleted] = InviteDeleteAuditLogData.Create,
-
- [ActionType.WebhookCreated] = WebhookCreateAuditLogData.Create,
- [ActionType.WebhookUpdated] = WebhookUpdateAuditLogData.Create,
- [ActionType.WebhookDeleted] = WebhookDeleteAuditLogData.Create,
-
- [ActionType.EmojiCreated] = EmoteCreateAuditLogData.Create,
- [ActionType.EmojiUpdated] = EmoteUpdateAuditLogData.Create,
- [ActionType.EmojiDeleted] = EmoteDeleteAuditLogData.Create,
-
- [ActionType.MessageDeleted] = MessageDeleteAuditLogData.Create,
- [ActionType.MessageBulkDeleted] = MessageBulkDeleteAuditLogData.Create,
- [ActionType.MessagePinned] = MessagePinAuditLogData.Create,
- [ActionType.MessageUnpinned] = MessageUnpinAuditLogData.Create,
-
- [ActionType.EventCreate] = ScheduledEventCreateAuditLogData.Create,
- [ActionType.EventUpdate] = ScheduledEventUpdateAuditLogData.Create,
- [ActionType.EventDelete] = ScheduledEventDeleteAuditLogData.Create,
-
- [ActionType.ThreadCreate] = ThreadCreateAuditLogData.Create,
- [ActionType.ThreadUpdate] = ThreadUpdateAuditLogData.Create,
- [ActionType.ThreadDelete] = ThreadDeleteAuditLogData.Create,
- };
-
- public static IAuditLogData CreateData(BaseDiscordClient discord, Model log, EntryModel entry)
+ private static readonly Dictionary> CreateMapping
+ = new ()
{
- if (CreateMapping.TryGetValue(entry.Action, out var func))
- return func(discord, log, entry);
+ [ActionType.GuildUpdated] = GuildUpdateAuditLogData.Create, // log
+ [ActionType.ChannelCreated] = ChannelCreateAuditLogData.Create,
+ [ActionType.ChannelUpdated] = ChannelUpdateAuditLogData.Create,
+ [ActionType.ChannelDeleted] = ChannelDeleteAuditLogData.Create,
- return null;
+ [ActionType.OverwriteCreated] = OverwriteCreateAuditLogData.Create,
+ [ActionType.OverwriteUpdated] = OverwriteUpdateAuditLogData.Create,
+ [ActionType.OverwriteDeleted] = OverwriteDeleteAuditLogData.Create,
+
+ [ActionType.Kick] = KickAuditLogData.Create,
+ [ActionType.Prune] = PruneAuditLogData.Create,
+ [ActionType.Ban] = BanAuditLogData.Create,
+ [ActionType.Unban] = UnbanAuditLogData.Create,
+ [ActionType.MemberUpdated] = MemberUpdateAuditLogData.Create,
+ [ActionType.MemberRoleUpdated] = MemberRoleAuditLogData.Create,
+ [ActionType.MemberMoved] = MemberMoveAuditLogData.Create,
+ [ActionType.MemberDisconnected] = MemberDisconnectAuditLogData.Create,
+ [ActionType.BotAdded] = BotAddAuditLogData.Create,
+
+ [ActionType.RoleCreated] = RoleCreateAuditLogData.Create,
+ [ActionType.RoleUpdated] = RoleUpdateAuditLogData.Create,
+ [ActionType.RoleDeleted] = RoleDeleteAuditLogData.Create,
+
+ [ActionType.InviteCreated] = InviteCreateAuditLogData.Create,
+ [ActionType.InviteUpdated] = InviteUpdateAuditLogData.Create,
+ [ActionType.InviteDeleted] = InviteDeleteAuditLogData.Create,
+
+ [ActionType.WebhookCreated] = WebhookCreateAuditLogData.Create,
+ [ActionType.WebhookUpdated] = WebhookUpdateAuditLogData.Create,
+ [ActionType.WebhookDeleted] = WebhookDeleteAuditLogData.Create,
+
+ [ActionType.EmojiCreated] = EmoteCreateAuditLogData.Create,
+ [ActionType.EmojiUpdated] = EmoteUpdateAuditLogData.Create,
+ [ActionType.EmojiDeleted] = EmoteDeleteAuditLogData.Create,
+
+ [ActionType.MessageDeleted] = MessageDeleteAuditLogData.Create,
+ [ActionType.MessageBulkDeleted] = MessageBulkDeleteAuditLogData.Create,
+ [ActionType.MessagePinned] = MessagePinAuditLogData.Create,
+ [ActionType.MessageUnpinned] = MessageUnpinAuditLogData.Create,
+
+ [ActionType.EventCreate] = ScheduledEventCreateAuditLogData.Create,
+ [ActionType.EventUpdate] = ScheduledEventUpdateAuditLogData.Create,
+ [ActionType.EventDelete] = ScheduledEventDeleteAuditLogData.Create,
+
+ [ActionType.ThreadCreate] = ThreadCreateAuditLogData.Create,
+ [ActionType.ThreadUpdate] = ThreadUpdateAuditLogData.Create,
+ [ActionType.ThreadDelete] = ThreadDeleteAuditLogData.Create,
+
+ [ActionType.ApplicationCommandPermissionUpdate] = CommandPermissionUpdateAuditLogData.Create,
+
+ [ActionType.IntegrationCreated] = IntegrationCreatedAuditLogData.Create,
+ [ActionType.IntegrationUpdated] = IntegrationUpdatedAuditLogData.Create,
+ [ActionType.IntegrationDeleted] = IntegrationDeletedAuditLogData.Create,
+
+ [ActionType.StageInstanceCreated] = StageInstanceCreateAuditLogData.Create,
+ [ActionType.StageInstanceUpdated] = StageInstanceUpdatedAuditLogData.Create,
+ [ActionType.StageInstanceDeleted] = StageInstanceDeleteAuditLogData.Create,
+
+ [ActionType.StickerCreated] = StickerCreatedAuditLogData.Create,
+ [ActionType.StickerUpdated] = StickerUpdatedAuditLogData.Create,
+ [ActionType.StickerDeleted] = StickerDeletedAuditLogData.Create,
+
+ [ActionType.AutoModerationRuleCreate] = AutoModRuleCreatedAuditLogData.Create,
+ [ActionType.AutoModerationRuleUpdate] = AutoModRuleUpdatedAuditLogData.Create,
+ [ActionType.AutoModerationRuleDelete] = AutoModRuleDeletedAuditLogData.Create,
+
+ [ActionType.AutoModerationBlockMessage] = AutoModBlockedMessageAuditLogData.Create,
+ [ActionType.AutoModerationFlagToChannel] = AutoModFlaggedMessageAuditLogData.Create,
+ [ActionType.AutoModerationUserCommunicationDisabled] = AutoModTimeoutUserAuditLogData.Create,
+
+ [ActionType.OnboardingQuestionCreated] = OnboardingPromptCreatedAuditLogData.Create,
+ [ActionType.OnboardingQuestionUpdated] = OnboardingPromptUpdatedAuditLogData.Create,
+ [ActionType.OnboardingUpdated] = OnboardingUpdatedAuditLogData.Create,
+ };
+
+ public static IAuditLogData CreateData(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ if (CreateMapping.TryGetValue(entry.Action, out var func))
+ return func(discord, entry, log);
+
+ return null;
+ }
+
+ internal static (T, T) CreateAuditLogEntityInfo(AuditLogChange[] changes, BaseDiscordClient discord) where T : IAuditLogInfoModel
+ {
+ var oldModel = (T)Activator.CreateInstance(typeof(T))!;
+ var newModel = (T)Activator.CreateInstance(typeof(T))!;
+
+ var props = typeof(T).GetProperties();
+
+ foreach (var property in props)
+ {
+ if (property.GetCustomAttributes(typeof(JsonFieldAttribute), true).FirstOrDefault() is not JsonFieldAttribute jsonAttr)
+ continue;
+
+ var change = changes.FirstOrDefault(x => x.ChangedProperty == jsonAttr.FieldName);
+
+ if (change is null)
+ continue;
+
+ property.SetValue(oldModel, change.OldValue?.ToObject(property.PropertyType, discord.ApiClient.Serializer));
+ property.SetValue(newModel, change.NewValue?.ToObject(property.PropertyType, discord.ApiClient.Serializer));
}
+
+ return (oldModel, newModel);
}
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModBlockedMessageAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModBlockedMessageAuditLogData.cs
new file mode 100644
index 00000000..c0b4a39d
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModBlockedMessageAuditLogData.cs
@@ -0,0 +1,38 @@
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to message getting blocked by automod.
+///
+public class AutoModBlockedMessageAuditLogData : IAuditLogData
+{
+ internal AutoModBlockedMessageAuditLogData(ulong channelId, string autoModRuleName, AutoModTriggerType autoModRuleTriggerType)
+ {
+ ChannelId = channelId;
+ AutoModRuleName = autoModRuleName;
+ AutoModRuleTriggerType = autoModRuleTriggerType;
+ }
+
+ internal static AutoModBlockedMessageAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ return new(entry.Options.ChannelId!.Value, entry.Options.AutoModRuleName,
+ entry.Options.AutoModRuleTriggerType!.Value);
+ }
+
+ ///
+ /// Gets the channel the message was sent in.
+ ///
+ public ulong ChannelId { get; set; }
+
+ ///
+ /// Gets the name of the auto moderation rule that got triggered.
+ ///
+ public string AutoModRuleName { get; set; }
+
+ ///
+ /// Gets the trigger type of the auto moderation rule that got triggered.
+ ///
+ public AutoModTriggerType AutoModRuleTriggerType { get; set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModFlaggedMessageAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModFlaggedMessageAuditLogData.cs
new file mode 100644
index 00000000..5b0f13f8
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModFlaggedMessageAuditLogData.cs
@@ -0,0 +1,38 @@
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to message getting flagged by automod.
+///
+public class AutoModFlaggedMessageAuditLogData : IAuditLogData
+{
+ internal AutoModFlaggedMessageAuditLogData(ulong channelId, string autoModRuleName, AutoModTriggerType autoModRuleTriggerType)
+ {
+ ChannelId = channelId;
+ AutoModRuleName = autoModRuleName;
+ AutoModRuleTriggerType = autoModRuleTriggerType;
+ }
+
+ internal static AutoModFlaggedMessageAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ return new(entry.Options.ChannelId!.Value, entry.Options.AutoModRuleName,
+ entry.Options.AutoModRuleTriggerType!.Value);
+ }
+
+ ///
+ /// Gets the channel the message was sent in.
+ ///
+ public ulong ChannelId { get; set; }
+
+ ///
+ /// Gets the name of the auto moderation rule that got triggered.
+ ///
+ public string AutoModRuleName { get; set; }
+
+ ///
+ /// Gets the trigger type of the auto moderation rule that got triggered.
+ ///
+ public AutoModTriggerType AutoModRuleTriggerType { get; set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleCreatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleCreatedAuditLogData.cs
new file mode 100644
index 00000000..3ee382e3
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleCreatedAuditLogData.cs
@@ -0,0 +1,31 @@
+using Discord.API.AuditLogs;
+
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an auto moderation rule creation.
+///
+public class AutoModRuleCreatedAuditLogData : IAuditLogData
+{
+ private AutoModRuleCreatedAuditLogData(AutoModRuleInfo data)
+ {
+ Data = data;
+ }
+
+ internal static AutoModRuleCreatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (_, data) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new AutoModRuleCreatedAuditLogData(new (data));
+ }
+
+ ///
+ /// Gets the auto moderation rule information after the changes.
+ ///
+ public AutoModRuleInfo Data { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleDeletedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleDeletedAuditLogData.cs
new file mode 100644
index 00000000..5e127643
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleDeletedAuditLogData.cs
@@ -0,0 +1,31 @@
+using Discord.API.AuditLogs;
+
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an auto moderation rule removal.
+///
+public class AutoModRuleDeletedAuditLogData : IAuditLogData
+{
+ private AutoModRuleDeletedAuditLogData(AutoModRuleInfo data)
+ {
+ Data = data;
+ }
+
+ internal static AutoModRuleDeletedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (data, _) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new AutoModRuleDeletedAuditLogData(new (data));
+ }
+
+ ///
+ /// Gets the auto moderation rule information before the changes.
+ ///
+ public AutoModRuleInfo Data { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleInfo.cs
new file mode 100644
index 00000000..98b0d721
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleInfo.cs
@@ -0,0 +1,113 @@
+using Discord.API.AuditLogs;
+
+using System;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+
+namespace Discord.Rest;
+
+///
+/// Represents information for an auto moderation rule.
+///
+public class AutoModRuleInfo
+{
+ internal AutoModRuleInfo(AutoModRuleInfoAuditLogModel model)
+ {
+ Actions = model.Actions?.Select(x => new AutoModRuleAction(
+ x.Type,
+ x.Metadata.GetValueOrDefault()?.ChannelId.ToNullable(),
+ x.Metadata.GetValueOrDefault()?.DurationSeconds.ToNullable(),
+ x.Metadata.IsSpecified
+ ? x.Metadata.Value.CustomMessage.IsSpecified
+ ? x.Metadata.Value.CustomMessage.Value
+ : null
+ : null
+ )).ToImmutableArray();
+ KeywordFilter = model.TriggerMetadata?.KeywordFilter.GetValueOrDefault(Array.Empty())?.ToImmutableArray();
+ Presets = model.TriggerMetadata?.Presets.GetValueOrDefault(Array.Empty())?.ToImmutableArray();
+ RegexPatterns = model.TriggerMetadata?.RegexPatterns.GetValueOrDefault(Array.Empty())?.ToImmutableArray();
+ AllowList = model.TriggerMetadata?.AllowList.GetValueOrDefault(Array.Empty())?.ToImmutableArray();
+ MentionTotalLimit = model.TriggerMetadata?.MentionLimit.IsSpecified ?? false
+ ? model.TriggerMetadata?.MentionLimit.Value
+ : null;
+ Name = model.Name;
+ Enabled = model.Enabled;
+ ExemptRoles = model.ExemptRoles?.ToImmutableArray();
+ ExemptChannels = model.ExemptChannels?.ToImmutableArray();
+ TriggerType = model.TriggerType;
+ EventType = model.EventType;
+ }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public string Name { get; set; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public AutoModEventType? EventType { get; set; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public AutoModTriggerType? TriggerType { get; set; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public bool? Enabled { get; set; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public IReadOnlyCollection ExemptRoles { get; set; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public IReadOnlyCollection ExemptChannels { get; set; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public IReadOnlyCollection KeywordFilter { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public IReadOnlyCollection RegexPatterns { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public IReadOnlyCollection AllowList { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public IReadOnlyCollection Presets { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public int? MentionTotalLimit { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ public IReadOnlyCollection Actions { get; private set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleUpdatedAuditLogData .cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleUpdatedAuditLogData .cs
new file mode 100644
index 00000000..ef173b14
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModRuleUpdatedAuditLogData .cs
@@ -0,0 +1,45 @@
+using Discord.API.AuditLogs;
+using System.Linq;
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an auto moderation rule update.
+///
+public class AutoModRuleUpdatedAuditLogData : IAuditLogData
+{
+ private AutoModRuleUpdatedAuditLogData(AutoModRuleInfo before, AutoModRuleInfo after, IAutoModRule rule)
+ {
+ Before = before;
+ After = after;
+ Rule = rule;
+ }
+
+ internal static AutoModRuleUpdatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ var rule = RestAutoModRule.Create(discord, log.AutoModerationRules.FirstOrDefault(x => x.Id == entry.TargetId));
+
+ return new AutoModRuleUpdatedAuditLogData(new (before), new(after), rule);
+ }
+
+ ///
+ /// Gets the auto moderation rule the changes correspond to.
+ ///
+ public IAutoModRule Rule { get; }
+
+ ///
+ /// Gets the auto moderation rule information before the changes.
+ ///
+ public AutoModRuleInfo Before { get; }
+
+ ///
+ /// Gets the auto moderation rule information after the changes.
+ ///
+ public AutoModRuleInfo After { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModTimeoutUserAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModTimeoutUserAuditLogData.cs
new file mode 100644
index 00000000..ced0dadb
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/AutoModTimeoutUserAuditLogData.cs
@@ -0,0 +1,38 @@
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to user getting in timeout by automod.
+///
+public class AutoModTimeoutUserAuditLogData : IAuditLogData
+{
+ internal AutoModTimeoutUserAuditLogData(ulong channelId, string autoModRuleName, AutoModTriggerType autoModRuleTriggerType)
+ {
+ ChannelId = channelId;
+ AutoModRuleName = autoModRuleName;
+ AutoModRuleTriggerType = autoModRuleTriggerType;
+ }
+
+ internal static AutoModTimeoutUserAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ return new(entry.Options.ChannelId!.Value, entry.Options.AutoModRuleName,
+ entry.Options.AutoModRuleTriggerType!.Value);
+ }
+
+ ///
+ /// Gets the channel the message was sent in.
+ ///
+ public ulong ChannelId { get; set; }
+
+ ///
+ /// Gets the name of the auto moderation rule that got triggered.
+ ///
+ public string AutoModRuleName { get; set; }
+
+ ///
+ /// Gets the trigger type of the auto moderation rule that got triggered.
+ ///
+ public AutoModTriggerType AutoModRuleTriggerType { get; set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs
index 3a599ca0..1c9bfa04 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BanAuditLogData.cs
@@ -2,33 +2,32 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a ban.
+///
+public class BanAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a ban.
- ///
- public class BanAuditLogData : IAuditLogData
+ private BanAuditLogData(IUser user)
{
- private BanAuditLogData(IUser user)
- {
- Target = user;
- }
-
- internal static BanAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- return new BanAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null);
- }
-
- ///
- /// Gets the user that was banned.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user object representing the banned user.
- ///
- public IUser Target { get; }
+ Target = user;
}
+
+ internal static BanAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ return new BanAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null);
+ }
+
+ ///
+ /// Gets the user that was banned.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user object representing the banned user.
+ ///
+ public IUser Target { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs
index 3e9394e8..2d5b21e4 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/BotAddAuditLogData.cs
@@ -2,33 +2,32 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a adding a bot to a guild.
+///
+public class BotAddAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a adding a bot to a guild.
- ///
- public class BotAddAuditLogData : IAuditLogData
+ private BotAddAuditLogData(IUser bot)
{
- private BotAddAuditLogData(IUser bot)
- {
- Target = bot;
- }
-
- internal static BotAddAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- return new BotAddAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null);
- }
-
- ///
- /// Gets the bot that was added.
- ///
- ///
- /// Will be if the bot is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user object representing the bot.
- ///
- public IUser Target { get; }
+ Target = bot;
}
+
+ internal static BotAddAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ return new BotAddAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null);
+ }
+
+ ///
+ /// Gets the bot that was added.
+ ///
+ ///
+ /// Will be if the bot is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user object representing the bot.
+ ///
+ public IUser Target { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs
index 07e90bce..6cd2d4ea 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelCreateAuditLogData.cs
@@ -1,104 +1,176 @@
+using Discord.API.AuditLogs;
+
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a channel creation.
+///
+public class ChannelCreateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a channel creation.
- ///
- public class ChannelCreateAuditLogData : IAuditLogData
+ private ChannelCreateAuditLogData(ChannelInfoAuditLogModel model, EntryModel entry)
{
- private ChannelCreateAuditLogData(ulong id, string name, ChannelType type, int? rateLimit, bool? nsfw, int? bitrate, IReadOnlyCollection overwrites)
+ ChannelId = entry.TargetId!.Value;
+ ChannelName = model.Name;
+ ChannelType = model.Type!.Value;
+ SlowModeInterval = model.RateLimitPerUser;
+ IsNsfw = model.IsNsfw;
+ Bitrate = model.Bitrate;
+ Topic = model.Topic;
+ AutoArchiveDuration = model.AutoArchiveDuration;
+ DefaultSlowModeInterval = model.DefaultThreadRateLimitPerUser;
+ DefaultAutoArchiveDuration = model.DefaultArchiveDuration;
+
+ AvailableTags = model.AvailableTags?.Select(x => new ForumTag(x.Id,
+ x.Name,
+ x.EmojiId.GetValueOrDefault(null),
+ x.EmojiName.GetValueOrDefault(null),
+ x.Moderated)).ToImmutableArray();
+
+
+ if (model.DefaultEmoji is not null)
{
- ChannelId = id;
- ChannelName = name;
- ChannelType = type;
- SlowModeInterval = rateLimit;
- IsNsfw = nsfw;
- Bitrate = bitrate;
- Overwrites = overwrites;
+ if (model.DefaultEmoji.EmojiId.HasValue && model.DefaultEmoji.EmojiId.Value != 0)
+ DefaultReactionEmoji = new Emote(model.DefaultEmoji.EmojiId.GetValueOrDefault(), null, false);
+ else if (model.DefaultEmoji.EmojiName.IsSpecified)
+ DefaultReactionEmoji = new Emoji(model.DefaultEmoji.EmojiName.Value);
+ else
+ DefaultReactionEmoji = null;
}
+ else
+ DefaultReactionEmoji = null;
- internal static ChannelCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var overwritesModel = changes.FirstOrDefault(x => x.ChangedProperty == "permission_overwrites");
- var typeModel = changes.FirstOrDefault(x => x.ChangedProperty == "type");
- var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var rateLimitPerUserModel = changes.FirstOrDefault(x => x.ChangedProperty == "rate_limit_per_user");
- var nsfwModel = changes.FirstOrDefault(x => x.ChangedProperty == "nsfw");
- var bitrateModel = changes.FirstOrDefault(x => x.ChangedProperty == "bitrate");
-
- var overwrites = overwritesModel.NewValue.ToObject(discord.ApiClient.Serializer)
- .Select(x => new Overwrite(x.TargetId, x.TargetType, new OverwritePermissions(x.Allow, x.Deny)))
- .ToList();
- var type = typeModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var name = nameModel.NewValue.ToObject(discord.ApiClient.Serializer);
- int? rateLimitPerUser = rateLimitPerUserModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? nsfw = nsfwModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- int? bitrate = bitrateModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- var id = entry.TargetId.Value;
-
- return new ChannelCreateAuditLogData(id, name, type, rateLimitPerUser, nsfw, bitrate, overwrites.ToReadOnlyCollection());
- }
-
- ///
- /// Gets the snowflake ID of the created channel.
- ///
- ///
- /// A representing the snowflake identifier for the created channel.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the name of the created channel.
- ///
- ///
- /// A string containing the name of the created channel.
- ///
- public string ChannelName { get; }
- ///
- /// Gets the type of the created channel.
- ///
- ///
- /// The type of channel that was created.
- ///
- public ChannelType ChannelType { get; }
- ///
- /// Gets the current slow-mode delay of the created channel.
- ///
- ///
- /// An representing the time in seconds required before the user can send another
- /// message; 0 if disabled.
- /// null if this is not mentioned in this entry.
- ///
- public int? SlowModeInterval { get; }
- ///
- /// Gets the value that indicates whether the created channel is NSFW.
- ///
- ///
- /// true if the created channel has the NSFW flag enabled; otherwise false.
- /// null if this is not mentioned in this entry.
- ///
- public bool? IsNsfw { get; }
- ///
- /// Gets the bit-rate that the clients in the created voice channel are requested to use.
- ///
- ///
- /// An representing the bit-rate (bps) that the created voice channel defines and requests the
- /// client(s) to use.
- /// null if this is not mentioned in this entry.
- ///
- public int? Bitrate { get; }
- ///
- /// Gets a collection of permission overwrites that was assigned to the created channel.
- ///
- ///
- /// A collection of permission , containing the permission overwrites that were
- /// assigned to the created channel.
- ///
- public IReadOnlyCollection Overwrites { get; }
+ VideoQualityMode = model.VideoQualityMode;
+ RtcRegion = model.Region;
+ Flags = model.Flags;
+ UserLimit = model.UserLimit;
+ Overwrites = model.Overwrites?.Select(x => new Overwrite(x.TargetId, x.TargetType, new OverwritePermissions(x.Allow, x.Deny)))
+ .ToImmutableArray();
}
+
+ internal static ChannelCreateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var (_, data) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new ChannelCreateAuditLogData(data, entry);
+ }
+
+ ///
+ /// Gets the snowflake ID of the created channel.
+ ///
+ ///
+ /// A representing the snowflake identifier for the created channel.
+ ///
+ public ulong ChannelId { get; }
+
+ ///
+ /// Gets the name of the created channel.
+ ///
+ ///
+ /// A string containing the name of the created channel.
+ ///
+ public string ChannelName { get; }
+
+ ///
+ /// Gets the type of the created channel.
+ ///
+ ///
+ /// The type of channel that was created.
+ ///
+ public ChannelType ChannelType { get; }
+
+ ///
+ /// Gets the current slow-mode delay of the created channel.
+ ///
+ ///
+ /// An representing the time in seconds required before the user can send another
+ /// message; 0 if disabled.
+ /// null if this is not mentioned in this entry.
+ ///
+ public int? SlowModeInterval { get; }
+
+ ///
+ /// Gets the value that indicates whether the created channel is NSFW.
+ ///
+ ///
+ /// true if the created channel has the NSFW flag enabled; otherwise false.
+ /// null if this is not mentioned in this entry.
+ ///
+ public bool? IsNsfw { get; }
+
+ ///
+ /// Gets the bit-rate that the clients in the created voice channel are requested to use.
+ ///
+ ///
+ /// An representing the bit-rate (bps) that the created voice channel defines and requests the
+ /// client(s) to use.
+ /// null if this is not mentioned in this entry.
+ ///
+ public int? Bitrate { get; }
+
+ ///
+ /// Gets a collection of permission overwrites that was assigned to the created channel.
+ ///
+ ///
+ /// A collection of permission , containing the permission overwrites that were
+ /// assigned to the created channel.
+ ///
+ public IReadOnlyCollection Overwrites { get; }
+
+ ///
+ /// Gets the thread archive duration that was set in the created channel.
+ ///
+ public ThreadArchiveDuration? AutoArchiveDuration { get; }
+
+ ///
+ /// Gets the default thread archive duration that was set in the created channel.
+ ///
+ public ThreadArchiveDuration? DefaultAutoArchiveDuration { get; }
+
+ ///
+ /// Gets the default slow mode interval that will be set in child threads in the channel.
+ ///
+ public int? DefaultSlowModeInterval { get; }
+
+ ///
+ /// Gets the topic that was set in the created channel.
+ ///
+ public string Topic { get; }
+
+ ///
+ /// Gets tags available in the created forum channel.
+ ///
+ public IReadOnlyCollection AvailableTags { get; }
+
+ ///
+ /// Gets the default reaction added to posts in the created forum channel.
+ ///
+ public IEmote DefaultReactionEmoji { get; }
+
+ ///
+ /// Gets the user limit configured in the created voice channel.
+ ///
+ public int? UserLimit { get; }
+
+ ///
+ /// Gets the video quality mode configured in the created voice channel.
+ ///
+ public VideoQualityMode? VideoQualityMode { get; }
+
+ ///
+ /// Gets the region configured in the created voice channel.
+ ///
+ public string RtcRegion { get; }
+
+ ///
+ /// Gets channel flags configured for the created channel.
+ ///
+ public ChannelFlags? Flags { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs
index d70b48ce..5ba1da50 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelDeleteAuditLogData.cs
@@ -1,102 +1,175 @@
+using Discord.API.AuditLogs;
+
using System.Collections.Generic;
+using System.Collections.Immutable;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a channel deletion.
+///
+public class ChannelDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a channel deletion.
- ///
- public class ChannelDeleteAuditLogData : IAuditLogData
+ private ChannelDeleteAuditLogData(ChannelInfoAuditLogModel model, EntryModel entry)
{
- private ChannelDeleteAuditLogData(ulong id, string name, ChannelType type, int? rateLimit, bool? nsfw, int? bitrate, IReadOnlyCollection overwrites)
+ ChannelId = entry.TargetId!.Value;
+ ChannelType = model.Type!.Value;
+ ChannelName = model.Name;
+
+ Topic = model.Topic;
+ IsNsfw = model.IsNsfw;
+ Bitrate = model.Bitrate;
+ DefaultArchiveDuration = model.DefaultArchiveDuration;
+ SlowModeInterval = model.RateLimitPerUser;
+
+ ForumTags = model.AvailableTags?.Select(
+ x => new ForumTag(x.Id,
+ x.Name,
+ x.EmojiId.GetValueOrDefault(null),
+ x.EmojiName.GetValueOrDefault(null),
+ x.Moderated)).ToImmutableArray();
+
+ if (model.DefaultEmoji is not null)
{
- ChannelId = id;
- ChannelName = name;
- ChannelType = type;
- SlowModeInterval = rateLimit;
- IsNsfw = nsfw;
- Bitrate = bitrate;
- Overwrites = overwrites;
+ if (model.DefaultEmoji.EmojiId.HasValue && model.DefaultEmoji.EmojiId.Value != 0)
+ DefaultReactionEmoji = new Emote(model.DefaultEmoji.EmojiId.GetValueOrDefault(), null, false);
+ else if (model.DefaultEmoji.EmojiName.IsSpecified)
+ DefaultReactionEmoji = new Emoji(model.DefaultEmoji.EmojiName.Value);
+ else
+ DefaultReactionEmoji = null;
}
+ else
+ DefaultReactionEmoji = null;
+ AutoArchiveDuration = model.AutoArchiveDuration;
+ DefaultSlowModeInterval = model.DefaultThreadRateLimitPerUser;
- internal static ChannelDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
+ VideoQualityMode = model.VideoQualityMode;
+ RtcRegion = model.Region;
+ Flags = model.Flags;
+ UserLimit = model.UserLimit;
- var overwritesModel = changes.FirstOrDefault(x => x.ChangedProperty == "permission_overwrites");
- var typeModel = changes.FirstOrDefault(x => x.ChangedProperty == "type");
- var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var rateLimitPerUserModel = changes.FirstOrDefault(x => x.ChangedProperty == "rate_limit_per_user");
- var nsfwModel = changes.FirstOrDefault(x => x.ChangedProperty == "nsfw");
- var bitrateModel = changes.FirstOrDefault(x => x.ChangedProperty == "bitrate");
-
- var overwrites = overwritesModel.OldValue.ToObject(discord.ApiClient.Serializer)
- .Select(x => new Overwrite(x.TargetId, x.TargetType, new OverwritePermissions(x.Allow, x.Deny)))
- .ToList();
- var type = typeModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var name = nameModel.OldValue.ToObject(discord.ApiClient.Serializer);
- int? rateLimitPerUser = rateLimitPerUserModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- bool? nsfw = nsfwModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- int? bitrate = bitrateModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- var id = entry.TargetId.Value;
-
- return new ChannelDeleteAuditLogData(id, name, type, rateLimitPerUser, nsfw, bitrate, overwrites.ToReadOnlyCollection());
- }
-
- ///
- /// Gets the snowflake ID of the deleted channel.
- ///
- ///
- /// A representing the snowflake identifier for the deleted channel.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the name of the deleted channel.
- ///
- ///
- /// A string containing the name of the deleted channel.
- ///
- public string ChannelName { get; }
- ///
- /// Gets the type of the deleted channel.
- ///
- ///
- /// The type of channel that was deleted.
- ///
- public ChannelType ChannelType { get; }
- ///
- /// Gets the slow-mode delay of the deleted channel.
- ///
- ///
- /// An representing the time in seconds required before the user can send another
- /// message; 0 if disabled.
- /// null if this is not mentioned in this entry.
- ///
- public int? SlowModeInterval { get; }
- ///
- /// Gets the value that indicates whether the deleted channel was NSFW.
- ///
- ///
- /// true if this channel had the NSFW flag enabled; otherwise false.
- /// null if this is not mentioned in this entry.
- ///
- public bool? IsNsfw { get; }
- ///
- /// Gets the bit-rate of this channel if applicable.
- ///
- ///
- /// An representing the bit-rate set of the voice channel.
- /// null if this is not mentioned in this entry.
- ///
- public int? Bitrate { get; }
- ///
- /// Gets a collection of permission overwrites that was assigned to the deleted channel.
- ///
- ///
- /// A collection of permission .
- ///
- public IReadOnlyCollection Overwrites { get; }
+ Overwrites = model.Overwrites?.Select(x
+ => new Overwrite(x.TargetId,
+ x.TargetType,
+ new OverwritePermissions(x.Allow, x.Deny))).ToImmutableArray();
}
+
+ internal static ChannelDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var (data, _) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new ChannelDeleteAuditLogData(data, entry);
+ }
+
+ ///
+ /// Gets the snowflake ID of the deleted channel.
+ ///
+ ///
+ /// A representing the snowflake identifier for the deleted channel.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the name of the deleted channel.
+ ///
+ ///
+ /// A string containing the name of the deleted channel.
+ ///
+ public string ChannelName { get; }
+ ///
+ /// Gets the type of the deleted channel.
+ ///
+ ///
+ /// The type of channel that was deleted.
+ ///
+ public ChannelType ChannelType { get; }
+ ///
+ /// Gets the slow-mode delay of the deleted channel.
+ ///
+ ///
+ /// An representing the time in seconds required before the user can send another
+ /// message; 0 if disabled.
+ /// null if this is not mentioned in this entry.
+ ///
+ public int? SlowModeInterval { get; }
+ ///
+ /// Gets the value that indicates whether the deleted channel was NSFW.
+ ///
+ ///
+ /// true if this channel had the NSFW flag enabled; otherwise false.
+ /// null if this is not mentioned in this entry.
+ ///
+ public bool? IsNsfw { get; }
+ ///
+ /// Gets the bit-rate of this channel if applicable.
+ ///
+ ///
+ /// An representing the bit-rate set of the voice channel.
+ /// null if this is not mentioned in this entry.
+ ///
+ public int? Bitrate { get; }
+ ///
+ /// Gets a collection of permission overwrites that was assigned to the deleted channel.
+ ///
+ ///
+ /// A collection of permission .
+ ///
+ public IReadOnlyCollection Overwrites { get; }
+ ///
+ /// Gets the user limit configured in the created voice channel.
+ ///
+ public int? UserLimit { get; }
+
+ ///
+ /// Gets the video quality mode configured in the created voice channel.
+ ///
+ public VideoQualityMode? VideoQualityMode { get; }
+
+ ///
+ /// Gets the region configured in the created voice channel.
+ ///
+ public string RtcRegion { get; }
+
+ ///
+ /// Gets channel flags configured for the created channel.
+ ///
+ public ChannelFlags? Flags { get; }
+
+ ///
+ /// Gets the thread archive duration that was configured for the created channel.
+ ///
+ public ThreadArchiveDuration? AutoArchiveDuration { get; }
+
+ ///
+ /// Gets the default slow mode interval that was configured for the channel.
+ ///
+ public int? DefaultSlowModeInterval { get; }
+
+ ///
+ ///
+ /// if the value was not specified in this entry..
+ ///
+ public ThreadArchiveDuration? DefaultArchiveDuration { get; }
+
+ ///
+ ///
+ /// if the value was not specified in this entry..
+ ///
+ public IReadOnlyCollection ForumTags { get; }
+
+ ///
+ ///
+ /// if the value was not specified in this entry..
+ ///
+ public string Topic { get; }
+
+ ///
+ ///
+ /// if the value was not specified in this entry..
+ ///
+ public IEmote DefaultReactionEmoji { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs
index f50d9eeb..dce7534f 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelInfo.cs
@@ -1,3 +1,8 @@
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+using Model = Discord.API.AuditLogs.ChannelInfoAuditLogModel;
+
namespace Discord.Rest
{
///
@@ -5,14 +10,41 @@ namespace Discord.Rest
///
public struct ChannelInfo
{
- internal ChannelInfo(string name, string topic, int? rateLimit, bool? nsfw, int? bitrate, ChannelType? type)
+ internal ChannelInfo(Model model)
{
- Name = name;
- Topic = topic;
- SlowModeInterval = rateLimit;
- IsNsfw = nsfw;
- Bitrate = bitrate;
- ChannelType = type;
+ Name = model.Name;
+ Topic = model.Topic;
+ IsNsfw = model.IsNsfw;
+ Bitrate = model.Bitrate;
+ DefaultArchiveDuration = model.DefaultArchiveDuration;
+ ChannelType = model.Type;
+ SlowModeInterval = model.RateLimitPerUser;
+
+ ForumTags = model.AvailableTags?.Select(
+ x => new ForumTag(x.Id,
+ x.Name,
+ x.EmojiId.GetValueOrDefault(null),
+ x.EmojiName.GetValueOrDefault(null),
+ x.Moderated)).ToImmutableArray();
+
+ if (model.DefaultEmoji is not null)
+ {
+ if (model.DefaultEmoji.EmojiId.HasValue && model.DefaultEmoji.EmojiId.Value != 0)
+ DefaultReactionEmoji = new Emote(model.DefaultEmoji.EmojiId.GetValueOrDefault(), null, false);
+ else if (model.DefaultEmoji.EmojiName.IsSpecified)
+ DefaultReactionEmoji = new Emoji(model.DefaultEmoji.EmojiName.Value);
+ else
+ DefaultReactionEmoji = null;
+ }
+ else
+ DefaultReactionEmoji = null;
+ AutoArchiveDuration = model.AutoArchiveDuration;
+ DefaultSlowModeInterval = model.DefaultThreadRateLimitPerUser;
+
+ VideoQualityMode = model.VideoQualityMode;
+ RtcRegion = model.Region;
+ Flags = model.Flags;
+ UserLimit = model.UserLimit;
}
///
@@ -61,5 +93,53 @@ namespace Discord.Rest
/// The channel type of this channel; null if not applicable.
///
public ChannelType? ChannelType { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public ThreadArchiveDuration? DefaultArchiveDuration { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public IReadOnlyCollection ForumTags { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public IEmote DefaultReactionEmoji { get; }
+
+ ///
+ /// Gets the user limit configured in the created voice channel.
+ ///
+ public int? UserLimit { get; }
+
+ ///
+ /// Gets the video quality mode configured in the created voice channel.
+ ///
+ public VideoQualityMode? VideoQualityMode { get; }
+
+ ///
+ /// Gets the region configured in the created voice channel.
+ ///
+ public string RtcRegion { get; }
+
+ ///
+ /// Gets channel flags configured for the created channel.
+ ///
+ public ChannelFlags? Flags { get; }
+
+ ///
+ /// Gets the thread archive duration that was set in the created channel.
+ ///
+ public ThreadArchiveDuration? AutoArchiveDuration { get; }
+
+ ///
+ /// Gets the default slow mode interval that will be set in child threads in the channel.
+ ///
+ public int? DefaultSlowModeInterval { get; }
}
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs
index 90b69c4f..e97b7582 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ChannelUpdateAuditLogData.cs
@@ -1,3 +1,4 @@
+using Discord.API.AuditLogs;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
@@ -16,34 +17,13 @@ namespace Discord.Rest
After = after;
}
- internal static ChannelUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
+ internal static ChannelUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
{
var changes = entry.Changes;
- var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var topicModel = changes.FirstOrDefault(x => x.ChangedProperty == "topic");
- var rateLimitPerUserModel = changes.FirstOrDefault(x => x.ChangedProperty == "rate_limit_per_user");
- var nsfwModel = changes.FirstOrDefault(x => x.ChangedProperty == "nsfw");
- var bitrateModel = changes.FirstOrDefault(x => x.ChangedProperty == "bitrate");
- var typeModel = changes.FirstOrDefault(x => x.ChangedProperty == "type");
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
- string oldName = nameModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newName = nameModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- string oldTopic = topicModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newTopic = topicModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- int? oldRateLimitPerUser = rateLimitPerUserModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newRateLimitPerUser = rateLimitPerUserModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? oldNsfw = nsfwModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newNsfw = nsfwModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- int? oldBitrate = bitrateModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newBitrate = bitrateModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ChannelType? oldType = typeModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newType = typeModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
-
- var before = new ChannelInfo(oldName, oldTopic, oldRateLimitPerUser, oldNsfw, oldBitrate, oldType);
- var after = new ChannelInfo(newName, newTopic, newRateLimitPerUser, newNsfw, newBitrate, newType);
-
- return new ChannelUpdateAuditLogData(entry.TargetId.Value, before, after);
+ return new ChannelUpdateAuditLogData(entry.TargetId!.Value, new ChannelInfo(before), new ChannelInfo(after));
}
///
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/CommandPermissionUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/CommandPermissionUpdateAuditLogData.cs
new file mode 100644
index 00000000..614235dc
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/CommandPermissionUpdateAuditLogData.cs
@@ -0,0 +1,69 @@
+using Discord.API;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an application command permission update.
+///
+public class CommandPermissionUpdateAuditLogData : IAuditLogData
+{
+ internal CommandPermissionUpdateAuditLogData(IReadOnlyCollection before, IReadOnlyCollection after,
+ IApplicationCommand command, ulong appId)
+ {
+ Before = before;
+ After = after;
+ ApplicationCommand = command;
+ ApplicationId = appId;
+ }
+
+ internal static CommandPermissionUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var before = new List();
+ var after = new List();
+
+ foreach (var change in changes)
+ {
+ var oldValue = change.OldValue?.ToObject();
+ var newValue = change.NewValue?.ToObject();
+
+ if (oldValue is not null)
+ before.Add(new ApplicationCommandPermission(oldValue.Id, oldValue.Type, oldValue.Permission));
+
+ if (newValue is not null)
+ after.Add(new ApplicationCommandPermission(newValue.Id, newValue.Type, newValue.Permission));
+ }
+
+ var command = log.Commands.FirstOrDefault(x => x.Id == entry.TargetId);
+ var appCommand = RestApplicationCommand.Create(discord, command, command?.GuildId.IsSpecified ?? false ? command.GuildId.Value : null);
+
+ return new(before.ToImmutableArray(), after.ToImmutableArray(), appCommand, entry.Options.ApplicationId!.Value);
+ }
+
+ ///
+ /// Gets the ID of the app whose permissions were targeted.
+ ///
+ public ulong ApplicationId { get; set; }
+
+ ///
+ /// Gets the application command which permissions were updated.
+ ///
+ public IApplicationCommand ApplicationCommand { get; }
+
+ ///
+ /// Gets values of the permissions before the change if available.
+ ///
+ public IReadOnlyCollection Before { get; }
+
+ ///
+ /// Gets values of the permissions after the change if available.
+ ///
+ public IReadOnlyCollection After { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs
index 4a0716de..7f73b6ea 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteCreateAuditLogData.cs
@@ -1,41 +1,42 @@
using System.Linq;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an emoji creation.
+///
+public class EmoteCreateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to an emoji creation.
- ///
- public class EmoteCreateAuditLogData : IAuditLogData
+ private EmoteCreateAuditLogData(ulong id, string name)
{
- private EmoteCreateAuditLogData(ulong id, string name)
- {
- EmoteId = id;
- Name = name;
- }
-
- internal static EmoteCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var change = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name");
-
- var emoteName = change.NewValue?.ToObject(discord.ApiClient.Serializer);
- return new EmoteCreateAuditLogData(entry.TargetId.Value, emoteName);
- }
-
- ///
- /// Gets the snowflake ID of the created emoji.
- ///
- ///
- /// A representing the snowflake identifier for the created emoji.
- ///
- public ulong EmoteId { get; }
- ///
- /// Gets the name of the created emoji.
- ///
- ///
- /// A string containing the name of the created emoji.
- ///
- public string Name { get; }
+ EmoteId = id;
+ Name = name;
}
+
+ internal static EmoteCreateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var change = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name");
+
+ var emoteName = change.NewValue?.ToObject(discord.ApiClient.Serializer);
+ return new EmoteCreateAuditLogData(entry.TargetId.Value, emoteName);
+ }
+
+ ///
+ /// Gets the snowflake ID of the created emoji.
+ ///
+ ///
+ /// A representing the snowflake identifier for the created emoji.
+ ///
+ public ulong EmoteId { get; }
+
+ ///
+ /// Gets the name of the created emoji.
+ ///
+ ///
+ /// A string containing the name of the created emoji.
+ ///
+ public string Name { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs
index 3e58f3c1..2051586c 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteDeleteAuditLogData.cs
@@ -2,41 +2,41 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an emoji deletion.
+///
+public class EmoteDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to an emoji deletion.
- ///
- public class EmoteDeleteAuditLogData : IAuditLogData
+ private EmoteDeleteAuditLogData(ulong id, string name)
{
- private EmoteDeleteAuditLogData(ulong id, string name)
- {
- EmoteId = id;
- Name = name;
- }
-
- internal static EmoteDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var change = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name");
-
- var emoteName = change.OldValue?.ToObject(discord.ApiClient.Serializer);
-
- return new EmoteDeleteAuditLogData(entry.TargetId.Value, emoteName);
- }
-
- ///
- /// Gets the snowflake ID of the deleted emoji.
- ///
- ///
- /// A representing the snowflake identifier for the deleted emoji.
- ///
- public ulong EmoteId { get; }
- ///
- /// Gets the name of the deleted emoji.
- ///
- ///
- /// A string containing the name of the deleted emoji.
- ///
- public string Name { get; }
+ EmoteId = id;
+ Name = name;
}
+
+ internal static EmoteDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var change = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name");
+
+ var emoteName = change.OldValue?.ToObject(discord.ApiClient.Serializer);
+
+ return new EmoteDeleteAuditLogData(entry.TargetId.Value, emoteName);
+ }
+
+ ///
+ /// Gets the snowflake ID of the deleted emoji.
+ ///
+ ///
+ /// A representing the snowflake identifier for the deleted emoji.
+ ///
+ public ulong EmoteId { get; }
+
+ ///
+ /// Gets the name of the deleted emoji.
+ ///
+ ///
+ /// A string containing the name of the deleted emoji.
+ ///
+ public string Name { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs
index 0603e4b3..9e626ed6 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/EmoteUpdateAuditLogData.cs
@@ -1,51 +1,53 @@
using System.Linq;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an emoji update.
+///
+public class EmoteUpdateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to an emoji update.
- ///
- public class EmoteUpdateAuditLogData : IAuditLogData
+ private EmoteUpdateAuditLogData(ulong id, string oldName, string newName)
{
- private EmoteUpdateAuditLogData(ulong id, string oldName, string newName)
- {
- EmoteId = id;
- OldName = oldName;
- NewName = newName;
- }
-
- internal static EmoteUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var change = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name");
-
- var newName = change.NewValue?.ToObject(discord.ApiClient.Serializer);
- var oldName = change.OldValue?.ToObject(discord.ApiClient.Serializer);
-
- return new EmoteUpdateAuditLogData(entry.TargetId.Value, oldName, newName);
- }
-
- ///
- /// Gets the snowflake ID of the updated emoji.
- ///
- ///
- /// A representing the snowflake identifier of the updated emoji.
- ///
- public ulong EmoteId { get; }
- ///
- /// Gets the new name of the updated emoji.
- ///
- ///
- /// A string containing the new name of the updated emoji.
- ///
- public string NewName { get; }
- ///
- /// Gets the old name of the updated emoji.
- ///
- ///
- /// A string containing the old name of the updated emoji.
- ///
- public string OldName { get; }
+ EmoteId = id;
+ OldName = oldName;
+ NewName = newName;
}
+
+ internal static EmoteUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var change = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name");
+
+ var newName = change.NewValue?.ToObject(discord.ApiClient.Serializer);
+ var oldName = change.OldValue?.ToObject(discord.ApiClient.Serializer);
+
+ return new EmoteUpdateAuditLogData(entry.TargetId.Value, oldName, newName);
+ }
+
+ ///
+ /// Gets the snowflake ID of the updated emoji.
+ ///
+ ///
+ /// A representing the snowflake identifier of the updated emoji.
+ ///
+ public ulong EmoteId { get; }
+
+ ///
+ /// Gets the new name of the updated emoji.
+ ///
+ ///
+ /// A string containing the new name of the updated emoji.
+ ///
+ public string NewName { get; }
+
+ ///
+ /// Gets the old name of the updated emoji.
+ ///
+ ///
+ /// A string containing the old name of the updated emoji.
+ ///
+ public string OldName { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildInfo.cs
index 85c7ac43..099da3ef 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildInfo.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildInfo.cs
@@ -1,128 +1,218 @@
-namespace Discord.Rest
-{
- ///
- /// Represents information for a guild.
- ///
- public struct GuildInfo
- {
- internal GuildInfo(int? afkTimeout, DefaultMessageNotifications? defaultNotifs,
- ulong? afkChannel, string name, string region, string icon,
- VerificationLevel? verification, IUser owner, MfaLevel? mfa, ExplicitContentFilterLevel? filter,
- ulong? systemChannel, ulong? widgetChannel, bool? widget)
- {
- AfkTimeout = afkTimeout;
- DefaultMessageNotifications = defaultNotifs;
- AfkChannelId = afkChannel;
- Name = name;
- RegionId = region;
- IconHash = icon;
- VerificationLevel = verification;
- Owner = owner;
- MfaLevel = mfa;
- ExplicitContentFilter = filter;
- SystemChannelId = systemChannel;
- EmbedChannelId = widgetChannel;
- IsEmbeddable = widget;
- }
+using Model = Discord.API.AuditLogs.GuildInfoAuditLogModel;
- ///
- /// Gets the amount of time (in seconds) a user must be inactive in a voice channel for until they are
- /// automatically moved to the AFK voice channel.
- ///
- ///
- /// An representing the amount of time in seconds for a user to be marked as inactive
- /// and moved into the AFK voice channel.
- /// null if this is not mentioned in this entry.
- ///
- public int? AfkTimeout { get; }
- ///
- /// Gets the default message notifications for users who haven't explicitly set their notification settings.
- ///
- ///
- /// The default message notifications setting of this guild.
- /// null if this is not mentioned in this entry.
- ///
- public DefaultMessageNotifications? DefaultMessageNotifications { get; }
- ///
- /// Gets the ID of the AFK voice channel for this guild.
- ///
- ///
- /// A representing the snowflake identifier of the AFK voice channel; null if
- /// none is set.
- ///
- public ulong? AfkChannelId { get; }
- ///
- /// Gets the name of this guild.
- ///
- ///
- /// A string containing the name of this guild.
- ///
- public string Name { get; }
- ///
- /// Gets the ID of the region hosting this guild's voice channels.
- ///
- public string RegionId { get; }
- ///
- /// Gets the ID of this guild's icon.
- ///
- ///
- /// A string containing the identifier for the splash image; null if none is set.
- ///
- public string IconHash { get; }
- ///
- /// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild.
- ///
- ///
- /// The level of requirements.
- /// null if this is not mentioned in this entry.
- ///
- public VerificationLevel? VerificationLevel { get; }
- ///
- /// Gets the owner of this guild.
- ///
- ///
- /// A user object representing the owner of this guild.
- ///
- public IUser Owner { get; }
- ///
- /// Gets the level of Multi-Factor Authentication requirements a user must fulfill before being allowed to
- /// perform administrative actions in this guild.
- ///
- ///
- /// The level of MFA requirement.
- /// null if this is not mentioned in this entry.
- ///
- public MfaLevel? MfaLevel { get; }
- ///
- /// Gets the level of content filtering applied to user's content in a Guild.
- ///
- ///
- /// The level of explicit content filtering.
- ///
- public ExplicitContentFilterLevel? ExplicitContentFilter { get; }
- ///
- /// Gets the ID of the channel where system messages are sent.
- ///
- ///
- /// A representing the snowflake identifier of the channel where system
- /// messages are sent; null if none is set.
- ///
- public ulong? SystemChannelId { get; }
- ///
- /// Gets the ID of the widget embed channel of this guild.
- ///
- ///
- /// A representing the snowflake identifier of the embedded channel found within the
- /// widget settings of this guild; null if none is set.
- ///
- public ulong? EmbedChannelId { get; }
- ///
- /// Gets a value that indicates whether this guild is embeddable (i.e. can use widget).
- ///
- ///
- /// true if this guild can be embedded via widgets; otherwise false.
- /// null if this is not mentioned in this entry.
- ///
- public bool? IsEmbeddable { get; }
+namespace Discord.Rest;
+
+///
+/// Represents information for a guild.
+///
+public struct GuildInfo
+{
+ internal GuildInfo(Model model, IUser owner)
+ {
+ Owner = owner;
+
+ Name = model.Name;
+ AfkTimeout = model.AfkTimeout.GetValueOrDefault();
+ IsEmbeddable = model.IsEmbeddable;
+ DefaultMessageNotifications = model.DefaultMessageNotifications;
+ MfaLevel = model.MfaLevel;
+ Description = model.Description;
+ PreferredLocale = model.PreferredLocale;
+ IconHash = model.IconHash;
+ OwnerId = model.OwnerId;
+ AfkChannelId = model.AfkChannelId;
+ ApplicationId = model.ApplicationId;
+ BannerId = model.Banner;
+ DiscoverySplashId = model.DiscoverySplash;
+ EmbedChannelId = model.EmbeddedChannelId;
+ ExplicitContentFilter = model.ExplicitContentFilterLevel;
+ IsBoostProgressBarEnabled = model.ProgressBarEnabled;
+ NsfwLevel = model.NsfwLevel;
+ PublicUpdatesChannelId = model.PublicUpdatesChannelId;
+ RegionId = model.RegionId;
+ RulesChannelId = model.RulesChannelId;
+ SplashId = model.Splash;
+ SystemChannelFlags = model.SystemChannelFlags;
+ SystemChannelId = model.SystemChannelId;
+ VanityURLCode = model.VanityUrl;
+ VerificationLevel = model.VerificationLevel;
}
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public string DiscoverySplashId { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public string SplashId { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public ulong? RulesChannelId { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public ulong? PublicUpdatesChannelId { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public ulong? OwnerId { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public ulong? ApplicationId { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public string BannerId { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public string VanityURLCode { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public SystemChannelMessageDeny? SystemChannelFlags { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public string Description { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public string PreferredLocale { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public NsfwLevel? NsfwLevel { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public bool? IsBoostProgressBarEnabled { get; }
+
+ ///
+ /// Gets the amount of time (in seconds) a user must be inactive in a voice channel for until they are
+ /// automatically moved to the AFK voice channel.
+ ///
+ ///
+ /// An representing the amount of time in seconds for a user to be marked as inactive
+ /// and moved into the AFK voice channel.
+ /// null if this is not mentioned in this entry.
+ ///
+ public int? AfkTimeout { get; }
+ ///
+ /// Gets the default message notifications for users who haven't explicitly set their notification settings.
+ ///
+ ///
+ /// The default message notifications setting of this guild.
+ /// null if this is not mentioned in this entry.
+ ///
+ public DefaultMessageNotifications? DefaultMessageNotifications { get; }
+ ///
+ /// Gets the ID of the AFK voice channel for this guild.
+ ///
+ ///
+ /// A representing the snowflake identifier of the AFK voice channel; null if
+ /// none is set.
+ ///
+ public ulong? AfkChannelId { get; }
+ ///
+ /// Gets the name of this guild.
+ ///
+ ///
+ /// A string containing the name of this guild.
+ ///
+ public string Name { get; }
+ ///
+ /// Gets the ID of the region hosting this guild's voice channels.
+ ///
+ public string RegionId { get; }
+ ///
+ /// Gets the ID of this guild's icon.
+ ///
+ ///
+ /// A string containing the identifier for the splash image; null if none is set.
+ ///
+ public string IconHash { get; }
+ ///
+ /// Gets the level of requirements a user must fulfill before being allowed to post messages in this guild.
+ ///
+ ///
+ /// The level of requirements.
+ /// null if this is not mentioned in this entry.
+ ///
+ public VerificationLevel? VerificationLevel { get; }
+ ///
+ /// Gets the owner of this guild.
+ ///
+ ///
+ /// A user object representing the owner of this guild.
+ ///
+ public IUser Owner { get; }
+ ///
+ /// Gets the level of Multi-Factor Authentication requirements a user must fulfill before being allowed to
+ /// perform administrative actions in this guild.
+ ///
+ ///
+ /// The level of MFA requirement.
+ /// null if this is not mentioned in this entry.
+ ///
+ public MfaLevel? MfaLevel { get; }
+ ///
+ /// Gets the level of content filtering applied to user's content in a Guild.
+ ///
+ ///
+ /// The level of explicit content filtering.
+ ///
+ public ExplicitContentFilterLevel? ExplicitContentFilter { get; }
+ ///
+ /// Gets the ID of the channel where system messages are sent.
+ ///
+ ///
+ /// A representing the snowflake identifier of the channel where system
+ /// messages are sent; null if none is set.
+ ///
+ public ulong? SystemChannelId { get; }
+ ///
+ /// Gets the ID of the widget embed channel of this guild.
+ ///
+ ///
+ /// A representing the snowflake identifier of the embedded channel found within the
+ /// widget settings of this guild; null if none is set.
+ ///
+ public ulong? EmbedChannelId { get; }
+ ///
+ /// Gets a value that indicates whether this guild is embeddable (i.e. can use widget).
+ ///
+ ///
+ /// true if this guild can be embedded via widgets; otherwise false.
+ /// null if this is not mentioned in this entry.
+ ///
+ public bool? IsEmbeddable { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs
index 45673e97..008b2e7f 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/GuildUpdateAuditLogData.cs
@@ -1,3 +1,4 @@
+using Discord.API.AuditLogs;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
@@ -15,50 +16,14 @@ namespace Discord.Rest
After = after;
}
- internal static GuildUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
+ internal static GuildUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
{
var changes = entry.Changes;
-
- var afkTimeoutModel = changes.FirstOrDefault(x => x.ChangedProperty == "afk_timeout");
- var defaultMessageNotificationsModel = changes.FirstOrDefault(x => x.ChangedProperty == "default_message_notifications");
- var afkChannelModel = changes.FirstOrDefault(x => x.ChangedProperty == "afk_channel_id");
- var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var regionIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "region");
- var iconHashModel = changes.FirstOrDefault(x => x.ChangedProperty == "icon_hash");
- var verificationLevelModel = changes.FirstOrDefault(x => x.ChangedProperty == "verification_level");
+
var ownerIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "owner_id");
- var mfaLevelModel = changes.FirstOrDefault(x => x.ChangedProperty == "mfa_level");
- var contentFilterModel = changes.FirstOrDefault(x => x.ChangedProperty == "explicit_content_filter");
- var systemChannelIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "system_channel_id");
- var widgetChannelIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "widget_channel_id");
- var widgetEnabledModel = changes.FirstOrDefault(x => x.ChangedProperty == "widget_enabled");
- int? oldAfkTimeout = afkTimeoutModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newAfkTimeout = afkTimeoutModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- DefaultMessageNotifications? oldDefaultMessageNotifications = defaultMessageNotificationsModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newDefaultMessageNotifications = defaultMessageNotificationsModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ulong? oldAfkChannelId = afkChannelModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newAfkChannelId = afkChannelModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- string oldName = nameModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newName = nameModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- string oldRegionId = regionIdModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newRegionId = regionIdModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- string oldIconHash = iconHashModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newIconHash = iconHashModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- VerificationLevel? oldVerificationLevel = verificationLevelModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newVerificationLevel = verificationLevelModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
ulong? oldOwnerId = ownerIdModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
newOwnerId = ownerIdModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- MfaLevel? oldMfaLevel = mfaLevelModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newMfaLevel = mfaLevelModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ExplicitContentFilterLevel? oldContentFilter = contentFilterModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newContentFilter = contentFilterModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ulong? oldSystemChannelId = systemChannelIdModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newSystemChannelId = systemChannelIdModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ulong? oldWidgetChannelId = widgetChannelIdModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newWidgetChannelId = widgetChannelIdModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? oldWidgetEnabled = widgetEnabledModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newWidgetEnabled = widgetEnabledModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
IUser oldOwner = null;
if (oldOwnerId != null)
@@ -74,14 +39,9 @@ namespace Discord.Rest
newOwner = RestUser.Create(discord, newOwnerInfo);
}
- var before = new GuildInfo(oldAfkTimeout, oldDefaultMessageNotifications,
- oldAfkChannelId, oldName, oldRegionId, oldIconHash, oldVerificationLevel, oldOwner,
- oldMfaLevel, oldContentFilter, oldSystemChannelId, oldWidgetChannelId, oldWidgetEnabled);
- var after = new GuildInfo(newAfkTimeout, newDefaultMessageNotifications,
- newAfkChannelId, newName, newRegionId, newIconHash, newVerificationLevel, newOwner,
- newMfaLevel, newContentFilter, newSystemChannelId, newWidgetChannelId, newWidgetEnabled);
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
- return new GuildUpdateAuditLogData(before, after);
+ return new GuildUpdateAuditLogData(new(before, oldOwner), new(after, newOwner));
}
///
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationCreatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationCreatedAuditLogData.cs
new file mode 100644
index 00000000..0f575814
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationCreatedAuditLogData.cs
@@ -0,0 +1,39 @@
+using Discord.API.AuditLogs;
+using System.Linq;
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an integration authorization.
+///
+public class IntegrationCreatedAuditLogData : IAuditLogData
+{
+ internal IntegrationCreatedAuditLogData(IntegrationInfo info, IIntegration integration)
+ {
+ Integration = integration;
+ Data = info;
+ }
+
+ internal static IntegrationCreatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (_, data) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ var integration = RestIntegration.Create(discord, null, log.Integrations.FirstOrDefault(x => x.Id == entry.TargetId));
+
+ return new(new IntegrationInfo(data), integration);
+ }
+
+ ///
+ /// Gets the partial integration the changes correspond to.
+ ///
+ public IIntegration Integration { get; }
+
+ ///
+ /// Gets the integration information after the changes.
+ ///
+ public IntegrationInfo Data { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationDeletedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationDeletedAuditLogData.cs
new file mode 100644
index 00000000..894c32fa
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationDeletedAuditLogData.cs
@@ -0,0 +1,31 @@
+using Discord.API.AuditLogs;
+using System.Linq;
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an integration removal.
+///
+public class IntegrationDeletedAuditLogData : IAuditLogData
+{
+ internal IntegrationDeletedAuditLogData(IntegrationInfo info)
+ {
+ Data = info;
+ }
+
+ internal static IntegrationDeletedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (data, _) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new(new IntegrationInfo(data));
+ }
+
+ ///
+ /// Gets the integration information before the changes.
+ ///
+ public IntegrationInfo Data { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationInfo.cs
new file mode 100644
index 00000000..55f3f64a
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationInfo.cs
@@ -0,0 +1,69 @@
+using Discord.API.AuditLogs;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+
+namespace Discord.Rest;
+
+///
+/// Represents information for an integration.
+///
+public class IntegrationInfo
+{
+ internal IntegrationInfo(IntegrationInfoAuditLogModel model)
+ {
+ Name = model.Name;
+ Type = model.Type;
+ EnableEmojis = model.EnableEmojis;
+ Enabled = model.Enabled;
+ Scopes = model.Scopes?.ToImmutableArray();
+ ExpireBehavior = model.ExpireBehavior;
+ ExpireGracePeriod = model.ExpireGracePeriod;
+ Syncing = model.Syncing;
+ RoleId = model.RoleId;
+ }
+
+ ///
+ /// Gets the name of the integration. if the property was not mentioned in this audit log.
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// Gets the type of the integration. if the property was not mentioned in this audit log.
+ ///
+ public string Type { get; set; }
+
+ ///
+ /// Gets if the integration is enabled. if the property was not mentioned in this audit log.
+ ///
+ public bool? Enabled { get; set; }
+
+ ///
+ /// Gets if syncing is enabled for this integration. if the property was not mentioned in this audit log.
+ ///
+ public bool? Syncing { get; set; }
+
+ ///
+ /// Gets the id of the role that this integration uses for subscribers. if the property was not mentioned in this audit log.
+ ///
+ public ulong? RoleId { get; set; }
+
+ ///
+ /// Gets whether emoticons should be synced for this integration. if the property was not mentioned in this audit log.
+ ///
+ public bool? EnableEmojis { get; set; }
+
+ ///
+ /// Gets the behavior of expiring subscribers. if the property was not mentioned in this audit log.
+ ///
+ public IntegrationExpireBehavior? ExpireBehavior { get; set; }
+
+ ///
+ /// Gets the grace period (in days) before expiring subscribers. if the property was not mentioned in this audit log.
+ ///
+ public int? ExpireGracePeriod { get; set; }
+
+ ///
+ /// Gets the scopes the application has been authorized for. if the property was not mentioned in this audit log.
+ ///
+ public IReadOnlyCollection Scopes { get; set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationUpdatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationUpdatedAuditLogData.cs
new file mode 100644
index 00000000..9f4665ab
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/IntegrationUpdatedAuditLogData.cs
@@ -0,0 +1,45 @@
+using Discord.API.AuditLogs;
+using System.Linq;
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an integration update.
+///
+public class IntegrationUpdatedAuditLogData : IAuditLogData
+{
+ internal IntegrationUpdatedAuditLogData(IntegrationInfo before, IntegrationInfo after, IIntegration integration)
+ {
+ Before = before;
+ After = after;
+ Integration = integration;
+ }
+
+ internal static IntegrationUpdatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ var integration = RestIntegration.Create(discord, null, log.Integrations.FirstOrDefault(x => x.Id == entry.TargetId));
+
+ return new(new IntegrationInfo(before), new IntegrationInfo(after), integration);
+ }
+
+ ///
+ /// Gets the partial integration the changes correspond to.
+ ///
+ public IIntegration Integration { get; }
+
+ ///
+ /// Gets the integration information before the changes.
+ ///
+ public IntegrationInfo Before { get; }
+
+ ///
+ /// Gets the integration information after the changes.
+ ///
+ public IntegrationInfo After { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs
index 21b8410c..bce9e916 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteCreateAuditLogData.cs
@@ -1,108 +1,102 @@
+using Discord.API.AuditLogs;
using System.Linq;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an invite creation.
+///
+public class InviteCreateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to an invite creation.
- ///
- public class InviteCreateAuditLogData : IAuditLogData
+ private InviteCreateAuditLogData(InviteInfoAuditLogModel model, IUser inviter)
{
- private InviteCreateAuditLogData(int maxAge, string code, bool temporary, IUser inviter, ulong channelId, int uses, int maxUses)
- {
- MaxAge = maxAge;
- Code = code;
- Temporary = temporary;
- Creator = inviter;
- ChannelId = channelId;
- Uses = uses;
- MaxUses = maxUses;
- }
-
- internal static InviteCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var maxAgeModel = changes.FirstOrDefault(x => x.ChangedProperty == "max_age");
- var codeModel = changes.FirstOrDefault(x => x.ChangedProperty == "code");
- var temporaryModel = changes.FirstOrDefault(x => x.ChangedProperty == "temporary");
- var inviterIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "inviter_id");
- var channelIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "channel_id");
- var usesModel = changes.FirstOrDefault(x => x.ChangedProperty == "uses");
- var maxUsesModel = changes.FirstOrDefault(x => x.ChangedProperty == "max_uses");
-
- var maxAge = maxAgeModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var code = codeModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var temporary = temporaryModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var channelId = channelIdModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var uses = usesModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var maxUses = maxUsesModel.NewValue.ToObject(discord.ApiClient.Serializer);
-
- RestUser inviter = null;
- if (inviterIdModel != null)
- {
- var inviterId = inviterIdModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var inviterInfo = log.Users.FirstOrDefault(x => x.Id == inviterId);
- inviter = (inviterInfo != null) ? RestUser.Create(discord, inviterInfo) : null;
- }
-
- return new InviteCreateAuditLogData(maxAge, code, temporary, inviter, channelId, uses, maxUses);
- }
-
- ///
- /// Gets the time (in seconds) until the invite expires.
- ///
- ///
- /// An representing the time in seconds until this invite expires.
- ///
- public int MaxAge { get; }
- ///
- /// Gets the unique identifier for this invite.
- ///
- ///
- /// A string containing the invite code (e.g. FTqNnyS).
- ///
- public string Code { get; }
- ///
- /// Gets a value that determines whether the invite is a temporary one.
- ///
- ///
- /// true if users accepting this invite will be removed from the guild when they log off; otherwise
- /// false.
- ///
- public bool Temporary { get; }
- ///
- /// Gets the user that created this invite if available.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user that created this invite or .
- ///
- public IUser Creator { get; }
- ///
- /// Gets the ID of the channel this invite is linked to.
- ///
- ///
- /// A representing the channel snowflake identifier that the invite points to.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the number of times this invite has been used.
- ///
- ///
- /// An representing the number of times this invite was used.
- ///
- public int Uses { get; }
- ///
- /// Gets the max number of uses this invite may have.
- ///
- ///
- /// An representing the number of uses this invite may be accepted until it is removed
- /// from the guild; null if none is set.
- ///
- public int MaxUses { get; }
+ MaxAge = model.MaxAge!.Value;
+ Code = model.Code;
+ Temporary = model.Temporary!.Value;
+ Creator = inviter;
+ ChannelId = model.ChannelId!.Value;
+ Uses = model.Uses!.Value;
+ MaxUses = model.MaxUses!.Value;
}
+
+ internal static InviteCreateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (_, data) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ RestUser inviter = null;
+
+ if (data.InviterId is not null)
+ {
+ var inviterInfo = log.Users.FirstOrDefault(x => x.Id == data.InviterId);
+ inviter = (inviterInfo != null) ? RestUser.Create(discord, inviterInfo) : null;
+ }
+
+ return new InviteCreateAuditLogData(data, inviter);
+ }
+
+ ///
+ /// Gets the time (in seconds) until the invite expires.
+ ///
+ ///
+ /// An representing the time in seconds until this invite expires.
+ ///
+ public int MaxAge { get; }
+
+ ///
+ /// Gets the unique identifier for this invite.
+ ///
+ ///
+ /// A string containing the invite code (e.g. FTqNnyS).
+ ///
+ public string Code { get; }
+
+ ///
+ /// Gets a value that determines whether the invite is a temporary one.
+ ///
+ ///
+ /// true if users accepting this invite will be removed from the guild when they log off; otherwise
+ /// false.
+ ///
+ public bool Temporary { get; }
+
+ ///
+ /// Gets the user that created this invite if available.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user that created this invite or .
+ ///
+ public IUser Creator { get; }
+
+ ///
+ /// Gets the ID of the channel this invite is linked to.
+ ///
+ ///
+ /// A representing the channel snowflake identifier that the invite points to.
+ ///
+ public ulong ChannelId { get; }
+
+ ///
+ /// Gets the number of times this invite has been used.
+ ///
+ ///
+ /// An representing the number of times this invite was used.
+ ///
+ public int Uses { get; }
+
+ ///
+ /// Gets the max number of uses this invite may have.
+ ///
+ ///
+ /// An representing the number of uses this invite may be accepted until it is removed
+ /// from the guild; null if none is set.
+ ///
+ public int MaxUses { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs
index af5c929d..9698bdab 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteDeleteAuditLogData.cs
@@ -1,108 +1,102 @@
+using Discord.API.AuditLogs;
using System.Linq;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an invite removal.
+///
+public class InviteDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to an invite removal.
- ///
- public class InviteDeleteAuditLogData : IAuditLogData
+ private InviteDeleteAuditLogData(InviteInfoAuditLogModel model, IUser inviter)
{
- private InviteDeleteAuditLogData(int maxAge, string code, bool temporary, IUser inviter, ulong channelId, int uses, int maxUses)
- {
- MaxAge = maxAge;
- Code = code;
- Temporary = temporary;
- Creator = inviter;
- ChannelId = channelId;
- Uses = uses;
- MaxUses = maxUses;
- }
-
- internal static InviteDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var maxAgeModel = changes.FirstOrDefault(x => x.ChangedProperty == "max_age");
- var codeModel = changes.FirstOrDefault(x => x.ChangedProperty == "code");
- var temporaryModel = changes.FirstOrDefault(x => x.ChangedProperty == "temporary");
- var inviterIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "inviter_id");
- var channelIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "channel_id");
- var usesModel = changes.FirstOrDefault(x => x.ChangedProperty == "uses");
- var maxUsesModel = changes.FirstOrDefault(x => x.ChangedProperty == "max_uses");
-
- var maxAge = maxAgeModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var code = codeModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var temporary = temporaryModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var channelId = channelIdModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var uses = usesModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var maxUses = maxUsesModel.OldValue.ToObject(discord.ApiClient.Serializer);
-
- RestUser inviter = null;
- if (inviterIdModel != null)
- {
- var inviterId = inviterIdModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var inviterInfo = log.Users.FirstOrDefault(x => x.Id == inviterId);
- inviter = (inviterInfo != null) ? RestUser.Create(discord, inviterInfo) : null;
- }
-
- return new InviteDeleteAuditLogData(maxAge, code, temporary, inviter, channelId, uses, maxUses);
- }
-
- ///
- /// Gets the time (in seconds) until the invite expires.
- ///
- ///
- /// An representing the time in seconds until this invite expires.
- ///
- public int MaxAge { get; }
- ///
- /// Gets the unique identifier for this invite.
- ///
- ///
- /// A string containing the invite code (e.g. FTqNnyS).
- ///
- public string Code { get; }
- ///
- /// Gets a value that indicates whether the invite is a temporary one.
- ///
- ///
- /// true if users accepting this invite will be removed from the guild when they log off; otherwise
- /// false.
- ///
- public bool Temporary { get; }
- ///
- /// Gets the user that created this invite if available.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user that created this invite or .
- ///
- public IUser Creator { get; }
- ///
- /// Gets the ID of the channel this invite is linked to.
- ///
- ///
- /// A representing the channel snowflake identifier that the invite points to.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the number of times this invite has been used.
- ///
- ///
- /// An representing the number of times this invite has been used.
- ///
- public int Uses { get; }
- ///
- /// Gets the max number of uses this invite may have.
- ///
- ///
- /// An representing the number of uses this invite may be accepted until it is removed
- /// from the guild; null if none is set.
- ///
- public int MaxUses { get; }
+ MaxAge = model.MaxAge!.Value;
+ Code = model.Code;
+ Temporary = model.Temporary!.Value;
+ Creator = inviter;
+ ChannelId = model.ChannelId!.Value;
+ Uses = model.Uses!.Value;
+ MaxUses = model.MaxUses!.Value;
}
+
+ internal static InviteDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (data, _) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ RestUser inviter = null;
+
+ if (data.InviterId != null)
+ {
+ var inviterInfo = log.Users.FirstOrDefault(x => x.Id == data.InviterId);
+ inviter = (inviterInfo != null) ? RestUser.Create(discord, inviterInfo) : null;
+ }
+
+ return new InviteDeleteAuditLogData(data, inviter);
+ }
+
+ ///
+ /// Gets the time (in seconds) until the invite expires.
+ ///
+ ///
+ /// An representing the time in seconds until this invite expires.
+ ///
+ public int MaxAge { get; }
+
+ ///
+ /// Gets the unique identifier for this invite.
+ ///
+ ///
+ /// A string containing the invite code (e.g. FTqNnyS).
+ ///
+ public string Code { get; }
+
+ ///
+ /// Gets a value that indicates whether the invite is a temporary one.
+ ///
+ ///
+ /// true if users accepting this invite will be removed from the guild when they log off; otherwise
+ /// false.
+ ///
+ public bool Temporary { get; }
+
+ ///
+ /// Gets the user that created this invite if available.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user that created this invite or .
+ ///
+ public IUser Creator { get; }
+
+ ///
+ /// Gets the ID of the channel this invite is linked to.
+ ///
+ ///
+ /// A representing the channel snowflake identifier that the invite points to.
+ ///
+ public ulong ChannelId { get; }
+
+ ///
+ /// Gets the number of times this invite has been used.
+ ///
+ ///
+ /// An representing the number of times this invite has been used.
+ ///
+ public int Uses { get; }
+
+ ///
+ /// Gets the max number of uses this invite may have.
+ ///
+ ///
+ /// An representing the number of uses this invite may be accepted until it is removed
+ /// from the guild; null if none is set.
+ ///
+ public int MaxUses { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteInfo.cs
index aaad362d..1a3a7c56 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteInfo.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteInfo.cs
@@ -1,57 +1,68 @@
-namespace Discord.Rest
-{
- ///
- /// Represents information for an invite.
- ///
- public struct InviteInfo
- {
- internal InviteInfo(int? maxAge, string code, bool? temporary, ulong? channelId, int? maxUses)
- {
- MaxAge = maxAge;
- Code = code;
- Temporary = temporary;
- ChannelId = channelId;
- MaxUses = maxUses;
- }
+using Model = Discord.API.AuditLogs.InviteInfoAuditLogModel;
- ///
- /// Gets the time (in seconds) until the invite expires.
- ///
- ///
- /// An representing the time in seconds until this invite expires; null if this
- /// invite never expires or not specified.
- ///
- public int? MaxAge { get; }
- ///
- /// Gets the unique identifier for this invite.
- ///
- ///
- /// A string containing the invite code (e.g. FTqNnyS).
- ///
- public string Code { get; }
- ///
- /// Gets a value that indicates whether the invite is a temporary one.
- ///
- ///
- /// true if users accepting this invite will be removed from the guild when they log off,
- /// false if not; null if not specified.
- ///
- public bool? Temporary { get; }
- ///
- /// Gets the ID of the channel this invite is linked to.
- ///
- ///
- /// A representing the channel snowflake identifier that the invite points to;
- /// null if not specified.
- ///
- public ulong? ChannelId { get; }
- ///
- /// Gets the max number of uses this invite may have.
- ///
- ///
- /// An representing the number of uses this invite may be accepted until it is removed
- /// from the guild; null if none is specified.
- ///
- public int? MaxUses { get; }
+namespace Discord.Rest;
+
+///
+/// Represents information for an invite.
+///
+public struct InviteInfo
+{
+ internal InviteInfo(Model model)
+ {
+ MaxAge = model.MaxAge;
+ Code = model.Code;
+ Temporary = model.Temporary;
+ ChannelId = model.ChannelId;
+ MaxUses = model.MaxUses;
+ CreatorId = model.InviterId;
}
+
+ ///
+ /// Gets the time (in seconds) until the invite expires.
+ ///
+ ///
+ /// An representing the time in seconds until this invite expires; null if this
+ /// invite never expires or not specified.
+ ///
+ public int? MaxAge { get; }
+
+ ///
+ /// Gets the unique identifier for this invite.
+ ///
+ ///
+ /// A string containing the invite code (e.g. FTqNnyS).
+ ///
+ public string Code { get; }
+
+ ///
+ /// Gets a value that indicates whether the invite is a temporary one.
+ ///
+ ///
+ /// true if users accepting this invite will be removed from the guild when they log off,
+ /// false if not; null if not specified.
+ ///
+ public bool? Temporary { get; }
+
+ ///
+ /// Gets the ID of the channel this invite is linked to.
+ ///
+ ///
+ /// A representing the channel snowflake identifier that the invite points to;
+ /// null if not specified.
+ ///
+ public ulong? ChannelId { get; }
+
+ ///
+ /// Gets the max number of uses this invite may have.
+ ///
+ ///
+ /// An representing the number of uses this invite may be accepted until it is removed
+ /// from the guild; null if none is specified.
+ ///
+ public int? MaxUses { get; }
+
+ ///
+ /// Gets the id of the user created this invite.
+ ///
+ public ulong? CreatorId { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs
index 5d282666..766a35bd 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/InviteUpdateAuditLogData.cs
@@ -1,60 +1,44 @@
+using Discord.API.AuditLogs;
+
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data relating to an invite update.
+///
+public class InviteUpdateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data relating to an invite update.
- ///
- public class InviteUpdateAuditLogData : IAuditLogData
+ private InviteUpdateAuditLogData(InviteInfo before, InviteInfo after)
{
- private InviteUpdateAuditLogData(InviteInfo before, InviteInfo after)
- {
- Before = before;
- After = after;
- }
-
- internal static InviteUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var maxAgeModel = changes.FirstOrDefault(x => x.ChangedProperty == "max_age");
- var codeModel = changes.FirstOrDefault(x => x.ChangedProperty == "code");
- var temporaryModel = changes.FirstOrDefault(x => x.ChangedProperty == "temporary");
- var channelIdModel = changes.FirstOrDefault(x => x.ChangedProperty == "channel_id");
- var maxUsesModel = changes.FirstOrDefault(x => x.ChangedProperty == "max_uses");
-
- int? oldMaxAge = maxAgeModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newMaxAge = maxAgeModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- string oldCode = codeModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newCode = codeModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? oldTemporary = temporaryModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newTemporary = temporaryModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ulong? oldChannelId = channelIdModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newChannelId = channelIdModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- int? oldMaxUses = maxUsesModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newMaxUses = maxUsesModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
-
- var before = new InviteInfo(oldMaxAge, oldCode, oldTemporary, oldChannelId, oldMaxUses);
- var after = new InviteInfo(newMaxAge, newCode, newTemporary, newChannelId, newMaxUses);
-
- return new InviteUpdateAuditLogData(before, after);
- }
-
- ///
- /// Gets the invite information before the changes.
- ///
- ///
- /// An information object containing the original invite information before the changes were made.
- ///
- public InviteInfo Before { get; }
- ///
- /// Gets the invite information after the changes.
- ///
- ///
- /// An information object containing the invite information after the changes were made.
- ///
- public InviteInfo After { get; }
+ Before = before;
+ After = after;
}
+
+ internal static InviteUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new InviteUpdateAuditLogData(new(before), new(after));
+ }
+
+ ///
+ /// Gets the invite information before the changes.
+ ///
+ ///
+ /// An information object containing the original invite information before the changes were made.
+ ///
+ public InviteInfo Before { get; }
+
+ ///
+ /// Gets the invite information after the changes.
+ ///
+ ///
+ /// An information object containing the invite information after the changes were made.
+ ///
+ public InviteInfo After { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs
index 02ec8a10..99b385d8 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/KickAuditLogData.cs
@@ -2,33 +2,32 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a kick.
+///
+public class KickAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a kick.
- ///
- public class KickAuditLogData : IAuditLogData
+ private KickAuditLogData(RestUser user)
{
- private KickAuditLogData(RestUser user)
- {
- Target = user;
- }
-
- internal static KickAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- return new KickAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null);
- }
-
- ///
- /// Gets the user that was kicked.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user object representing the kicked user.
- ///
- public IUser Target { get; }
+ Target = user;
}
+
+ internal static KickAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ return new KickAuditLogData((userInfo != null) ? RestUser.Create(discord, userInfo) : null);
+ }
+
+ ///
+ /// Gets the user that was kicked.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user object representing the kicked user.
+ ///
+ public IUser Target { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs
index 4181d9e9..a04c1af9 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberDisconnectAuditLogData.cs
@@ -1,29 +1,28 @@
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to disconnecting members from voice channels.
+///
+public class MemberDisconnectAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to disconnecting members from voice channels.
- ///
- public class MemberDisconnectAuditLogData : IAuditLogData
+ private MemberDisconnectAuditLogData(int count)
{
- private MemberDisconnectAuditLogData(int count)
- {
- MemberCount = count;
- }
-
- internal static MemberDisconnectAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- return new MemberDisconnectAuditLogData(entry.Options.Count.Value);
- }
-
- ///
- /// Gets the number of members that were disconnected.
- ///
- ///
- /// An representing the number of members that were disconnected from a voice channel.
- ///
- public int MemberCount { get; }
+ MemberCount = count;
}
+
+ internal static MemberDisconnectAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ return new MemberDisconnectAuditLogData(entry.Options.Count.Value);
+ }
+
+ ///
+ /// Gets the number of members that were disconnected.
+ ///
+ ///
+ /// An representing the number of members that were disconnected from a voice channel.
+ ///
+ public int MemberCount { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberInfo.cs
index ffa316fa..58c4e7b8 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberInfo.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberInfo.cs
@@ -1,41 +1,57 @@
-namespace Discord.Rest
-{
- ///
- /// Represents information for a member.
- ///
- public struct MemberInfo
- {
- internal MemberInfo(string nick, bool? deaf, bool? mute)
- {
- Nickname = nick;
- Deaf = deaf;
- Mute = mute;
- }
+using Discord.API.AuditLogs;
+using System;
- ///
- /// Gets the nickname of the updated member.
- ///
- ///
- /// A string representing the nickname of the updated member; null if none is set.
- ///
- public string Nickname { get; }
- ///
- /// Gets a value that indicates whether the updated member is deafened by the guild.
- ///
- ///
- /// true if the updated member is deafened (i.e. not permitted to listen to or speak to others) by the guild;
- /// otherwise false.
- /// null if this is not mentioned in this entry.
- ///
- public bool? Deaf { get; }
- ///
- /// Gets a value that indicates whether the updated member is muted (i.e. not permitted to speak via voice) by the
- /// guild.
- ///
- ///
- /// true if the updated member is muted by the guild; otherwise false.
- /// null if this is not mentioned in this entry.
- ///
- public bool? Mute { get; }
+namespace Discord.Rest;
+
+///
+/// Represents information for a member.
+///
+public struct MemberInfo
+{
+ internal MemberInfo(MemberInfoAuditLogModel model)
+ {
+ Nickname = model.Nickname;
+ Deaf = model.IsDeafened;
+ Mute = model.IsMuted;
+ TimedOutUntil = model.TimeOutUntil;
}
+
+ ///
+ /// Gets the nickname of the updated member.
+ ///
+ ///
+ /// A string representing the nickname of the updated member; if none is set.
+ ///
+ public string Nickname { get; }
+
+ ///
+ /// Gets a value that indicates whether the updated member is deafened by the guild.
+ ///
+ ///
+ /// if the updated member is deafened (i.e. not permitted to listen to or speak to others) by the guild;
+ /// otherwise .
+ /// if this is not mentioned in this entry.
+ ///
+ public bool? Deaf { get; }
+
+ ///
+ /// Gets a value that indicates whether the updated member is muted (i.e. not permitted to speak via voice) by the
+ /// guild.
+ ///
+ ///
+ /// if the updated member is muted by the guild; otherwise .
+ /// if this is not mentioned in this entry.
+ ///
+ public bool? Mute { get; }
+
+ ///
+ /// Gets the date and time that indicates if and for how long the updated user has been timed out.
+ ///
+ ///
+ /// or a timestamp in the past if the user is not timed out.
+ ///
+ ///
+ /// A indicating how long the user will be timed out for.
+ ///
+ public DateTimeOffset? TimedOutUntil { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs
index cd60d0f2..c33019b0 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberMoveAuditLogData.cs
@@ -1,37 +1,36 @@
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to moving members between voice channels.
+///
+public class MemberMoveAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to moving members between voice channels.
- ///
- public class MemberMoveAuditLogData : IAuditLogData
+ private MemberMoveAuditLogData(ulong channelId, int count)
{
- private MemberMoveAuditLogData(ulong channelId, int count)
- {
- ChannelId = channelId;
- MemberCount = count;
- }
-
- internal static MemberMoveAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- return new MemberMoveAuditLogData(entry.Options.ChannelId.Value, entry.Options.Count.Value);
- }
-
- ///
- /// Gets the ID of the channel that the members were moved to.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the members were moved to.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the number of members that were moved.
- ///
- ///
- /// An representing the number of members that were moved to another voice channel.
- ///
- public int MemberCount { get; }
+ ChannelId = channelId;
+ MemberCount = count;
}
+
+ internal static MemberMoveAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ return new MemberMoveAuditLogData(entry.Options.ChannelId.Value, entry.Options.Count.Value);
+ }
+
+ ///
+ /// Gets the ID of the channel that the members were moved to.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the members were moved to.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the number of members that were moved.
+ ///
+ ///
+ /// An representing the number of members that were moved to another voice channel.
+ ///
+ public int MemberCount { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs
index 339c6150..27000f09 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleAuditLogData.cs
@@ -3,48 +3,48 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a change in a guild member's roles.
+///
+public class MemberRoleAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a change in a guild member's roles.
- ///
- public class MemberRoleAuditLogData : IAuditLogData
+ private MemberRoleAuditLogData(IReadOnlyCollection roles, IUser target)
{
- private MemberRoleAuditLogData(IReadOnlyCollection roles, IUser target)
- {
- Roles = roles;
- Target = target;
- }
-
- internal static MemberRoleAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var roleInfos = changes.SelectMany(x => x.NewValue.ToObject(discord.ApiClient.Serializer),
- (model, role) => new { model.ChangedProperty, Role = role })
- .Select(x => new MemberRoleEditInfo(x.Role.Name, x.Role.Id, x.ChangedProperty == "$add"))
- .ToList();
-
- var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- RestUser user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
-
- return new MemberRoleAuditLogData(roleInfos.ToReadOnlyCollection(), user);
- }
-
- ///
- /// Gets a collection of role changes that were performed on the member.
- ///
- ///
- /// A read-only collection of , containing the roles that were changed on
- /// the member.
- ///
- public IReadOnlyCollection Roles { get; }
- ///
- /// Gets the user that the roles changes were performed on.
- ///
- ///
- /// A user object representing the user that the role changes were performed on.
- ///
- public IUser Target { get; }
+ Roles = roles;
+ Target = target;
}
+
+ internal static MemberRoleAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var roleInfos = changes.SelectMany(x => x.NewValue.ToObject(discord.ApiClient.Serializer),
+ (model, role) => new { model.ChangedProperty, Role = role })
+ .Select(x => new MemberRoleEditInfo(x.Role.Name, x.Role.Id, x.ChangedProperty == "$add"))
+ .ToList();
+
+ var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ RestUser user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
+
+ return new MemberRoleAuditLogData(roleInfos.ToReadOnlyCollection(), user);
+ }
+
+ ///
+ /// Gets a collection of role changes that were performed on the member.
+ ///
+ ///
+ /// A read-only collection of , containing the roles that were changed on
+ /// the member.
+ ///
+ public IReadOnlyCollection Roles { get; }
+
+ ///
+ /// Gets the user that the roles changes were performed on.
+ ///
+ ///
+ /// A user object representing the user that the role changes were performed on.
+ ///
+ public IUser Target { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleEditInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleEditInfo.cs
index b0abf2d9..dd178d38 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleEditInfo.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberRoleEditInfo.cs
@@ -1,37 +1,38 @@
-namespace Discord.Rest
-{
- ///
- /// An information object representing a change in one of a guild member's roles.
- ///
- public struct MemberRoleEditInfo
- {
- internal MemberRoleEditInfo(string name, ulong roleId, bool added)
- {
- Name = name;
- RoleId = roleId;
- Added = added;
- }
+namespace Discord.Rest;
- ///
- /// Gets the name of the role that was changed.
- ///
- ///
- /// A string containing the name of the role that was changed.
- ///
- public string Name { get; }
- ///
- /// Gets the ID of the role that was changed.
- ///
- ///
- /// A representing the snowflake identifier of the role that was changed.
- ///
- public ulong RoleId { get; }
- ///
- /// Gets a value that indicates whether the role was added to the user.
- ///
- ///
- /// true if the role was added to the user; otherwise false.
- ///
- public bool Added { get; }
+///
+/// An information object representing a change in one of a guild member's roles.
+///
+public struct MemberRoleEditInfo
+{
+ internal MemberRoleEditInfo(string name, ulong roleId, bool added)
+ {
+ Name = name;
+ RoleId = roleId;
+ Added = added;
}
+
+ ///
+ /// Gets the name of the role that was changed.
+ ///
+ ///
+ /// A string containing the name of the role that was changed.
+ ///
+ public string Name { get; }
+
+ ///
+ /// Gets the ID of the role that was changed.
+ ///
+ ///
+ /// A representing the snowflake identifier of the role that was changed.
+ ///
+ public ulong RoleId { get; }
+
+ ///
+ /// Gets a value that indicates whether the role was added to the user.
+ ///
+ ///
+ /// true if the role was added to the user; otherwise false.
+ ///
+ public bool Added { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs
index 57dca0f4..b2da83e0 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MemberUpdateAuditLogData.cs
@@ -1,68 +1,56 @@
+using Discord.API.AuditLogs;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a change in a guild member.
+///
+public class MemberUpdateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a change in a guild member.
- ///
- public class MemberUpdateAuditLogData : IAuditLogData
+ private MemberUpdateAuditLogData(IUser target, MemberInfo before, MemberInfo after)
{
- private MemberUpdateAuditLogData(IUser target, MemberInfo before, MemberInfo after)
- {
- Target = target;
- Before = before;
- After = after;
- }
-
- internal static MemberUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var nickModel = changes.FirstOrDefault(x => x.ChangedProperty == "nick");
- var deafModel = changes.FirstOrDefault(x => x.ChangedProperty == "deaf");
- var muteModel = changes.FirstOrDefault(x => x.ChangedProperty == "mute");
-
- string oldNick = nickModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newNick = nickModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? oldDeaf = deafModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newDeaf = deafModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? oldMute = muteModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newMute = muteModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
-
- var targetInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- RestUser user = (targetInfo != null) ? RestUser.Create(discord, targetInfo) : null;
-
- var before = new MemberInfo(oldNick, oldDeaf, oldMute);
- var after = new MemberInfo(newNick, newDeaf, newMute);
-
- return new MemberUpdateAuditLogData(user, before, after);
- }
-
- ///
- /// Gets the user that the changes were performed on.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user object representing the user who the changes were performed on.
- ///
- public IUser Target { get; }
- ///
- /// Gets the member information before the changes.
- ///
- ///
- /// An information object containing the original member information before the changes were made.
- ///
- public MemberInfo Before { get; }
- ///
- /// Gets the member information after the changes.
- ///
- ///
- /// An information object containing the member information after the changes were made.
- ///
- public MemberInfo After { get; }
+ Target = target;
+ Before = before;
+ After = after;
}
+
+ internal static MemberUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ var targetInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ RestUser user = (targetInfo != null) ? RestUser.Create(discord, targetInfo) : null;
+
+ return new MemberUpdateAuditLogData(user, new MemberInfo(before), new MemberInfo(after));
+ }
+
+ ///
+ /// Gets the user that the changes were performed on.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user object representing the user who the changes were performed on.
+ ///
+ public IUser Target { get; }
+ ///
+ /// Gets the member information before the changes.
+ ///
+ ///
+ /// An information object containing the original member information before the changes were made.
+ ///
+ public MemberInfo Before { get; }
+ ///
+ /// Gets the member information after the changes.
+ ///
+ ///
+ /// An information object containing the member information after the changes were made.
+ ///
+ public MemberInfo After { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs
index ed6563d3..878cd252 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageBulkDeleteAuditLogData.cs
@@ -1,38 +1,37 @@
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to message deletion(s).
+///
+public class MessageBulkDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to message deletion(s).
- ///
- public class MessageBulkDeleteAuditLogData : IAuditLogData
+ private MessageBulkDeleteAuditLogData(ulong channelId, int count)
{
- private MessageBulkDeleteAuditLogData(ulong channelId, int count)
- {
- ChannelId = channelId;
- MessageCount = count;
- }
-
- internal static MessageBulkDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- return new MessageBulkDeleteAuditLogData(entry.TargetId.Value, entry.Options.Count.Value);
- }
-
- ///
- /// Gets the ID of the channel that the messages were deleted from.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the messages were
- /// deleted from.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the number of messages that were deleted.
- ///
- ///
- /// An representing the number of messages that were deleted from the channel.
- ///
- public int MessageCount { get; }
+ ChannelId = channelId;
+ MessageCount = count;
}
+
+ internal static MessageBulkDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ return new MessageBulkDeleteAuditLogData(entry.TargetId.Value, entry.Options.Count.Value);
+ }
+
+ ///
+ /// Gets the ID of the channel that the messages were deleted from.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the messages were
+ /// deleted from.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the number of messages that were deleted.
+ ///
+ ///
+ /// An representing the number of messages that were deleted from the channel.
+ ///
+ public int MessageCount { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs
index a4672326..7281afe9 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageDeleteAuditLogData.cs
@@ -3,50 +3,49 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to message deletion(s).
+///
+public class MessageDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to message deletion(s).
- ///
- public class MessageDeleteAuditLogData : IAuditLogData
+ private MessageDeleteAuditLogData(ulong channelId, int count, IUser user)
{
- private MessageDeleteAuditLogData(ulong channelId, int count, IUser user)
- {
- ChannelId = channelId;
- MessageCount = count;
- Target = user;
- }
-
- internal static MessageDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- return new MessageDeleteAuditLogData(entry.Options.ChannelId.Value, entry.Options.Count.Value, userInfo != null ? RestUser.Create(discord, userInfo) : null);
- }
-
- ///
- /// Gets the number of messages that were deleted.
- ///
- ///
- /// An representing the number of messages that were deleted from the channel.
- ///
- public int MessageCount { get; }
- ///
- /// Gets the ID of the channel that the messages were deleted from.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the messages were
- /// deleted from.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the user of the messages that were deleted.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user object representing the user that created the deleted messages.
- ///
- public IUser Target { get; }
+ ChannelId = channelId;
+ MessageCount = count;
+ Target = user;
}
+
+ internal static MessageDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ return new MessageDeleteAuditLogData(entry.Options.ChannelId.Value, entry.Options.Count.Value, userInfo != null ? RestUser.Create(discord, userInfo) : null);
+ }
+
+ ///
+ /// Gets the number of messages that were deleted.
+ ///
+ ///
+ /// An representing the number of messages that were deleted from the channel.
+ ///
+ public int MessageCount { get; }
+ ///
+ /// Gets the ID of the channel that the messages were deleted from.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the messages were
+ /// deleted from.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the user of the messages that were deleted.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user object representing the user that created the deleted messages.
+ ///
+ public IUser Target { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs
index b740af46..d8cadb93 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessagePinAuditLogData.cs
@@ -2,55 +2,56 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a pinned message.
+///
+public class MessagePinAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a pinned message.
- ///
- public class MessagePinAuditLogData : IAuditLogData
+ private MessagePinAuditLogData(ulong messageId, ulong channelId, IUser user)
{
- private MessagePinAuditLogData(ulong messageId, ulong channelId, IUser user)
- {
- MessageId = messageId;
- ChannelId = channelId;
- Target = user;
- }
-
- internal static MessagePinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- RestUser user = null;
- if (entry.TargetId.HasValue)
- {
- var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
- }
-
- return new MessagePinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, user);
- }
-
- ///
- /// Gets the ID of the messages that was pinned.
- ///
- ///
- /// A representing the snowflake identifier for the messages that was pinned.
- ///
- public ulong MessageId { get; }
- ///
- /// Gets the ID of the channel that the message was pinned from.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the message was pinned from.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the user of the message that was pinned if available.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user object representing the user that created the pinned message or .
- ///
- public IUser Target { get; }
+ MessageId = messageId;
+ ChannelId = channelId;
+ Target = user;
}
+
+ internal static MessagePinAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ RestUser user = null;
+ if (entry.TargetId.HasValue)
+ {
+ var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
+ }
+
+ return new MessagePinAuditLogData(entry.Options.MessageId!.Value, entry.Options.ChannelId!.Value, user);
+ }
+
+ ///
+ /// Gets the ID of the messages that was pinned.
+ ///
+ ///
+ /// A representing the snowflake identifier for the messages that was pinned.
+ ///
+ public ulong MessageId { get; }
+
+ ///
+ /// Gets the ID of the channel that the message was pinned from.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the message was pinned from.
+ ///
+ public ulong ChannelId { get; }
+
+ ///
+ /// Gets the user of the message that was pinned if available.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user object representing the user that created the pinned message or .
+ ///
+ public IUser Target { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs
index 654f3e02..3526980e 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/MessageUnpinAuditLogData.cs
@@ -2,55 +2,54 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an unpinned message.
+///
+public class MessageUnpinAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to an unpinned message.
- ///
- public class MessageUnpinAuditLogData : IAuditLogData
+ private MessageUnpinAuditLogData(ulong messageId, ulong channelId, IUser user)
{
- private MessageUnpinAuditLogData(ulong messageId, ulong channelId, IUser user)
- {
- MessageId = messageId;
- ChannelId = channelId;
- Target = user;
- }
-
- internal static MessageUnpinAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- RestUser user = null;
- if (entry.TargetId.HasValue)
- {
- var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
- user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
- }
-
- return new MessageUnpinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, user);
- }
-
- ///
- /// Gets the ID of the messages that was unpinned.
- ///
- ///
- /// A representing the snowflake identifier for the messages that was unpinned.
- ///
- public ulong MessageId { get; }
- ///
- /// Gets the ID of the channel that the message was unpinned from.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the message was unpinned from.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the user of the message that was unpinned if available.
- ///
- ///
- /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
- ///
- ///
- /// A user object representing the user that created the unpinned message or .
- ///
- public IUser Target { get; }
+ MessageId = messageId;
+ ChannelId = channelId;
+ Target = user;
}
+
+ internal static MessageUnpinAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ RestUser user = null;
+ if (entry.TargetId.HasValue)
+ {
+ var userInfo = log.Users.FirstOrDefault(x => x.Id == entry.TargetId);
+ user = (userInfo != null) ? RestUser.Create(discord, userInfo) : null;
+ }
+
+ return new MessageUnpinAuditLogData(entry.Options.MessageId.Value, entry.Options.ChannelId.Value, user);
+ }
+
+ ///
+ /// Gets the ID of the messages that was unpinned.
+ ///
+ ///
+ /// A representing the snowflake identifier for the messages that was unpinned.
+ ///
+ public ulong MessageId { get; }
+ ///
+ /// Gets the ID of the channel that the message was unpinned from.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the message was unpinned from.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the user of the message that was unpinned if available.
+ ///
+ ///
+ /// Will be if the user is a 'Deleted User#....' because Discord does send user data for deleted users.
+ ///
+ ///
+ /// A user object representing the user that created the unpinned message or .
+ ///
+ public IUser Target { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingInfo.cs
new file mode 100644
index 00000000..b7dc5db1
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingInfo.cs
@@ -0,0 +1,34 @@
+using Discord.API.AuditLogs;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+
+namespace Discord.Rest;
+
+public class OnboardingInfo
+{
+ internal OnboardingInfo(OnboardingAuditLogModel model, BaseDiscordClient discord)
+ {
+ Prompts = model.Prompts?.Select(x => new RestGuildOnboardingPrompt(discord, x.Id, x)).ToImmutableArray();
+ DefaultChannelIds = model.DefaultChannelIds;
+ IsEnabled = model.Enabled;
+ }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ IReadOnlyCollection Prompts { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ IReadOnlyCollection DefaultChannelIds { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ bool? IsEnabled { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptCreatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptCreatedAuditLogData.cs
new file mode 100644
index 00000000..a6167b91
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptCreatedAuditLogData.cs
@@ -0,0 +1,31 @@
+using Discord.API.AuditLogs;
+
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to an onboarding prompt creation.
+///
+public class OnboardingPromptCreatedAuditLogData : IAuditLogData
+{
+ internal OnboardingPromptCreatedAuditLogData(OnboardingPromptInfo data)
+ {
+ Data = data;
+ }
+
+ internal static OnboardingPromptCreatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var (_, data) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new OnboardingPromptCreatedAuditLogData(new(data, discord));
+ }
+
+ ///
+ /// Gets the onboarding prompt information after the changes.
+ ///
+ OnboardingPromptInfo Data { get; set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptInfo.cs
new file mode 100644
index 00000000..a28564c0
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptInfo.cs
@@ -0,0 +1,56 @@
+using Discord.API.AuditLogs;
+
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Linq;
+
+namespace Discord.Rest;
+
+public class OnboardingPromptInfo
+{
+ internal OnboardingPromptInfo(OnboardingPromptAuditLogModel model, BaseDiscordClient discord)
+ {
+ Title = model.Title;
+ IsSingleSelect = model.IsSingleSelect;
+ IsRequired = model.IsRequired;
+ IsInOnboarding = model.IsInOnboarding;
+ Type = model.Type;
+ Options = model.Options?.Select(x => new RestGuildOnboardingPromptOption(discord, x.Id, x)).ToImmutableArray();
+ }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ string Title { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ bool? IsSingleSelect { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ bool? IsRequired { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ bool? IsInOnboarding { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ GuildOnboardingPromptType? Type { get; }
+
+ ///
+ ///
+ /// if this property is not mentioned in this entry.
+ ///
+ IReadOnlyCollection Options { get; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptUpdatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptUpdatedAuditLogData.cs
new file mode 100644
index 00000000..899fb670
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingPromptUpdatedAuditLogData.cs
@@ -0,0 +1,38 @@
+using Discord.API.AuditLogs;
+
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+
+///
+/// Contains a piece of audit log data related to an onboarding prompt update.
+///
+public class OnboardingPromptUpdatedAuditLogData : IAuditLogData
+{
+ internal OnboardingPromptUpdatedAuditLogData(OnboardingPromptInfo before, OnboardingPromptInfo after)
+ {
+ Before = before;
+ After = after;
+ }
+
+ internal static OnboardingPromptUpdatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new OnboardingPromptUpdatedAuditLogData(new(before, discord), new(after, discord));
+ }
+
+ ///
+ /// Gets the onboarding prompt information after the changes.
+ ///
+ OnboardingPromptInfo After { get; set; }
+
+ ///
+ /// Gets the onboarding prompt information before the changes.
+ ///
+ OnboardingPromptInfo Before { get; set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingUpdatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingUpdatedAuditLogData.cs
new file mode 100644
index 00000000..3dbc3210
--- /dev/null
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OnboardingUpdatedAuditLogData.cs
@@ -0,0 +1,38 @@
+using Discord.API.AuditLogs;
+
+using EntryModel = Discord.API.AuditLogEntry;
+using Model = Discord.API.AuditLog;
+
+namespace Discord.Rest;
+
+
+///
+/// Contains a piece of audit log data related to a guild update.
+///
+public class OnboardingUpdatedAuditLogData : IAuditLogData
+{
+ internal OnboardingUpdatedAuditLogData(OnboardingInfo before, OnboardingInfo after)
+ {
+ Before = before;
+ After = after;
+ }
+
+ internal static OnboardingUpdatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new OnboardingUpdatedAuditLogData(new(before, discord), new(after, discord));
+ }
+
+ ///
+ /// Gets the onboarding information after the changes.
+ ///
+ OnboardingInfo After { get; set; }
+
+ ///
+ /// Gets the onboarding information before the changes.
+ ///
+ OnboardingInfo Before { get; set; }
+}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs
index 3990f643..67a6d6b1 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteCreateAuditLogData.cs
@@ -1,52 +1,52 @@
using System.Linq;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data for a permissions overwrite creation.
+///
+public class OverwriteCreateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data for a permissions overwrite creation.
- ///
- public class OverwriteCreateAuditLogData : IAuditLogData
+ private OverwriteCreateAuditLogData(ulong channelId, Overwrite overwrite)
{
- private OverwriteCreateAuditLogData(ulong channelId, Overwrite overwrite)
- {
- ChannelId = channelId;
- Overwrite = overwrite;
- }
-
- internal static OverwriteCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var denyModel = changes.FirstOrDefault(x => x.ChangedProperty == "deny");
- var allowModel = changes.FirstOrDefault(x => x.ChangedProperty == "allow");
-
- var deny = denyModel.NewValue.ToObject(discord.ApiClient.Serializer);
- var allow = allowModel.NewValue.ToObject(discord.ApiClient.Serializer);
-
- var permissions = new OverwritePermissions(allow, deny);
-
- var id = entry.Options.OverwriteTargetId.Value;
- var type = entry.Options.OverwriteType;
-
- return new OverwriteCreateAuditLogData(entry.TargetId.Value, new Overwrite(id, type, permissions));
- }
-
- ///
- /// Gets the ID of the channel that the overwrite was created from.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the overwrite was
- /// created from.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the permission overwrite object that was created.
- ///
- ///
- /// An object representing the overwrite that was created.
- ///
- public Overwrite Overwrite { get; }
+ ChannelId = channelId;
+ Overwrite = overwrite;
}
+
+ internal static OverwriteCreateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var denyModel = changes.FirstOrDefault(x => x.ChangedProperty == "deny");
+ var allowModel = changes.FirstOrDefault(x => x.ChangedProperty == "allow");
+
+ var deny = denyModel.NewValue.ToObject(discord.ApiClient.Serializer);
+ var allow = allowModel.NewValue.ToObject(discord.ApiClient.Serializer);
+
+ var permissions = new OverwritePermissions(allow, deny);
+
+ var id = entry.Options.OverwriteTargetId.Value;
+ var type = entry.Options.OverwriteType;
+
+ return new OverwriteCreateAuditLogData(entry.TargetId.Value, new Overwrite(id, type, permissions));
+ }
+
+ ///
+ /// Gets the ID of the channel that the overwrite was created from.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the overwrite was
+ /// created from.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the permission overwrite object that was created.
+ ///
+ ///
+ /// An object representing the overwrite that was created.
+ ///
+ public Overwrite Overwrite { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs
index a959c301..ba72c970 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteDeleteAuditLogData.cs
@@ -2,51 +2,50 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to the deletion of a permission overwrite.
+///
+public class OverwriteDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to the deletion of a permission overwrite.
- ///
- public class OverwriteDeleteAuditLogData : IAuditLogData
+ private OverwriteDeleteAuditLogData(ulong channelId, Overwrite deletedOverwrite)
{
- private OverwriteDeleteAuditLogData(ulong channelId, Overwrite deletedOverwrite)
- {
- ChannelId = channelId;
- Overwrite = deletedOverwrite;
- }
-
- internal static OverwriteDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var denyModel = changes.FirstOrDefault(x => x.ChangedProperty == "deny");
- var allowModel = changes.FirstOrDefault(x => x.ChangedProperty == "allow");
-
- var deny = denyModel.OldValue.ToObject(discord.ApiClient.Serializer);
- var allow = allowModel.OldValue.ToObject(discord.ApiClient.Serializer);
-
- var permissions = new OverwritePermissions(allow, deny);
-
- var id = entry.Options.OverwriteTargetId.Value;
- var type = entry.Options.OverwriteType;
-
- return new OverwriteDeleteAuditLogData(entry.TargetId.Value, new Overwrite(id, type, permissions));
- }
-
- ///
- /// Gets the ID of the channel that the overwrite was deleted from.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the overwrite was
- /// deleted from.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the permission overwrite object that was deleted.
- ///
- ///
- /// An object representing the overwrite that was deleted.
- ///
- public Overwrite Overwrite { get; }
+ ChannelId = channelId;
+ Overwrite = deletedOverwrite;
}
+
+ internal static OverwriteDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var denyModel = changes.FirstOrDefault(x => x.ChangedProperty == "deny");
+ var allowModel = changes.FirstOrDefault(x => x.ChangedProperty == "allow");
+
+ var deny = denyModel.OldValue.ToObject(discord.ApiClient.Serializer);
+ var allow = allowModel.OldValue.ToObject(discord.ApiClient.Serializer);
+
+ var permissions = new OverwritePermissions(allow, deny);
+
+ var id = entry.Options.OverwriteTargetId.Value;
+ var type = entry.Options.OverwriteType;
+
+ return new OverwriteDeleteAuditLogData(entry.TargetId.Value, new Overwrite(id, type, permissions));
+ }
+
+ ///
+ /// Gets the ID of the channel that the overwrite was deleted from.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the overwrite was
+ /// deleted from.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the permission overwrite object that was deleted.
+ ///
+ ///
+ /// An object representing the overwrite that was deleted.
+ ///
+ public Overwrite Overwrite { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs
index 9aee0813..a73b5283 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/OverwriteUpdateAuditLogData.cs
@@ -1,80 +1,80 @@
using System.Linq;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to the update of a permission overwrite.
+///
+public class OverwriteUpdateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to the update of a permission overwrite.
- ///
- public class OverwriteUpdateAuditLogData : IAuditLogData
+ private OverwriteUpdateAuditLogData(ulong channelId, OverwritePermissions before, OverwritePermissions after, ulong targetId, PermissionTarget targetType)
{
- private OverwriteUpdateAuditLogData(ulong channelId, OverwritePermissions before, OverwritePermissions after, ulong targetId, PermissionTarget targetType)
- {
- ChannelId = channelId;
- OldPermissions = before;
- NewPermissions = after;
- OverwriteTargetId = targetId;
- OverwriteType = targetType;
- }
-
- internal static OverwriteUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var denyModel = changes.FirstOrDefault(x => x.ChangedProperty == "deny");
- var allowModel = changes.FirstOrDefault(x => x.ChangedProperty == "allow");
-
- var beforeAllow = allowModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- var afterAllow = allowModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- var beforeDeny = denyModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- var afterDeny = denyModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
-
- var beforePermissions = new OverwritePermissions(beforeAllow ?? 0, beforeDeny ?? 0);
- var afterPermissions = new OverwritePermissions(afterAllow ?? 0, afterDeny ?? 0);
-
- var type = entry.Options.OverwriteType;
-
- return new OverwriteUpdateAuditLogData(entry.TargetId.Value, beforePermissions, afterPermissions, entry.Options.OverwriteTargetId.Value, type);
- }
-
- ///
- /// Gets the ID of the channel that the overwrite was updated from.
- ///
- ///
- /// A representing the snowflake identifier for the channel that the overwrite was
- /// updated from.
- ///
- public ulong ChannelId { get; }
- ///
- /// Gets the overwrite permissions before the changes.
- ///
- ///
- /// An overwrite permissions object representing the overwrite permissions that the overwrite had before
- /// the changes were made.
- ///
- public OverwritePermissions OldPermissions { get; }
- ///
- /// Gets the overwrite permissions after the changes.
- ///
- ///
- /// An overwrite permissions object representing the overwrite permissions that the overwrite had after the
- /// changes.
- ///
- public OverwritePermissions NewPermissions { get; }
- ///
- /// Gets the ID of the overwrite that was updated.
- ///
- ///
- /// A representing the snowflake identifier of the overwrite that was updated.
- ///
- public ulong OverwriteTargetId { get; }
- ///
- /// Gets the target of the updated permission overwrite.
- ///
- ///
- /// The target of the updated permission overwrite.
- ///
- public PermissionTarget OverwriteType { get; }
+ ChannelId = channelId;
+ OldPermissions = before;
+ NewPermissions = after;
+ OverwriteTargetId = targetId;
+ OverwriteType = targetType;
}
+
+ internal static OverwriteUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ var changes = entry.Changes;
+
+ var denyModel = changes.FirstOrDefault(x => x.ChangedProperty == "deny");
+ var allowModel = changes.FirstOrDefault(x => x.ChangedProperty == "allow");
+
+ var beforeAllow = allowModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
+ var afterAllow = allowModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
+ var beforeDeny = denyModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
+ var afterDeny = denyModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
+
+ var beforePermissions = new OverwritePermissions(beforeAllow ?? 0, beforeDeny ?? 0);
+ var afterPermissions = new OverwritePermissions(afterAllow ?? 0, afterDeny ?? 0);
+
+ var type = entry.Options.OverwriteType;
+
+ return new OverwriteUpdateAuditLogData(entry.TargetId.Value, beforePermissions, afterPermissions, entry.Options.OverwriteTargetId.Value, type);
+ }
+
+ ///
+ /// Gets the ID of the channel that the overwrite was updated from.
+ ///
+ ///
+ /// A representing the snowflake identifier for the channel that the overwrite was
+ /// updated from.
+ ///
+ public ulong ChannelId { get; }
+ ///
+ /// Gets the overwrite permissions before the changes.
+ ///
+ ///
+ /// An overwrite permissions object representing the overwrite permissions that the overwrite had before
+ /// the changes were made.
+ ///
+ public OverwritePermissions OldPermissions { get; }
+ ///
+ /// Gets the overwrite permissions after the changes.
+ ///
+ ///
+ /// An overwrite permissions object representing the overwrite permissions that the overwrite had after the
+ /// changes.
+ ///
+ public OverwritePermissions NewPermissions { get; }
+ ///
+ /// Gets the ID of the overwrite that was updated.
+ ///
+ ///
+ /// A representing the snowflake identifier of the overwrite that was updated.
+ ///
+ public ulong OverwriteTargetId { get; }
+ ///
+ /// Gets the target of the updated permission overwrite.
+ ///
+ ///
+ /// The target of the updated permission overwrite.
+ ///
+ public PermissionTarget OverwriteType { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs
index 1f08eab5..25476392 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/PruneAuditLogData.cs
@@ -1,40 +1,40 @@
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a guild prune.
+///
+public class PruneAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a guild prune.
- ///
- public class PruneAuditLogData : IAuditLogData
+ private PruneAuditLogData(int pruneDays, int membersRemoved)
{
- private PruneAuditLogData(int pruneDays, int membersRemoved)
- {
- PruneDays = pruneDays;
- MembersRemoved = membersRemoved;
- }
-
- internal static PruneAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- return new PruneAuditLogData(entry.Options.PruneDeleteMemberDays.Value, entry.Options.PruneMembersRemoved.Value);
- }
-
- ///
- /// Gets the threshold for a guild member to not be kicked.
- ///
- ///
- /// An representing the amount of days that a member must have been seen in the server,
- /// to avoid being kicked. (i.e. If a user has not been seen for more than , they will be
- /// kicked from the server)
- ///
- public int PruneDays { get; }
- ///
- /// Gets the number of members that were kicked during the purge.
- ///
- ///
- /// An representing the number of members that were removed from this guild for having
- /// not been seen within .
- ///
- public int MembersRemoved { get; }
+ PruneDays = pruneDays;
+ MembersRemoved = membersRemoved;
}
+
+ internal static PruneAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log = null)
+ {
+ return new PruneAuditLogData(entry.Options.PruneDeleteMemberDays.Value, entry.Options.PruneMembersRemoved.Value);
+ }
+
+ ///
+ /// Gets the threshold for a guild member to not be kicked.
+ ///
+ ///
+ /// An representing the amount of days that a member must have been seen in the server,
+ /// to avoid being kicked. (i.e. If a user has not been seen for more than , they will be
+ /// kicked from the server)
+ ///
+ public int PruneDays { get; }
+
+ ///
+ /// Gets the number of members that were kicked during the purge.
+ ///
+ ///
+ /// An representing the number of members that were removed from this guild for having
+ /// not been seen within .
+ ///
+ public int MembersRemoved { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs
index be635ecb..c5bc2e6d 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleCreateAuditLogData.cs
@@ -1,61 +1,46 @@
+using Discord.API.AuditLogs;
+
using System.Linq;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a role creation.
+///
+public class RoleCreateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a role creation.
- ///
- public class RoleCreateAuditLogData : IAuditLogData
+ private RoleCreateAuditLogData(ulong id, RoleEditInfo props)
{
- private RoleCreateAuditLogData(ulong id, RoleEditInfo props)
- {
- RoleId = id;
- Properties = props;
- }
-
- internal static RoleCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var colorModel = changes.FirstOrDefault(x => x.ChangedProperty == "color");
- var mentionableModel = changes.FirstOrDefault(x => x.ChangedProperty == "mentionable");
- var hoistModel = changes.FirstOrDefault(x => x.ChangedProperty == "hoist");
- var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var permissionsModel = changes.FirstOrDefault(x => x.ChangedProperty == "permissions");
-
- uint? colorRaw = colorModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? mentionable = mentionableModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? hoist = hoistModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- string name = nameModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ulong? permissionsRaw = permissionsModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
-
- Color? color = null;
- GuildPermissions? permissions = null;
-
- if (colorRaw.HasValue)
- color = new Color(colorRaw.Value);
- if (permissionsRaw.HasValue)
- permissions = new GuildPermissions(permissionsRaw.Value);
-
- return new RoleCreateAuditLogData(entry.TargetId.Value,
- new RoleEditInfo(color, mentionable, hoist, name, permissions));
- }
-
- ///
- /// Gets the ID of the role that was created.
- ///
- ///
- /// A representing the snowflake identifier to the role that was created.
- ///
- public ulong RoleId { get; }
- ///
- /// Gets the role information that was created.
- ///
- ///
- /// An information object representing the properties of the role that was created.
- ///
- public RoleEditInfo Properties { get; }
+ RoleId = id;
+ Properties = props;
}
+
+ internal static RoleCreateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (_, data) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new RoleCreateAuditLogData(entry.TargetId!.Value,
+ new RoleEditInfo(data));
+ }
+
+ ///
+ /// Gets the ID of the role that was created.
+ ///
+ ///
+ /// A representing the snowflake identifier to the role that was created.
+ ///
+ public ulong RoleId { get; }
+
+ ///
+ /// Gets the role information that was created.
+ ///
+ ///
+ /// An information object representing the properties of the role that was created.
+ ///
+ public RoleEditInfo Properties { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs
index feb8064b..8ba448dc 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleDeleteAuditLogData.cs
@@ -1,61 +1,43 @@
-using System.Linq;
+using Discord.API.AuditLogs;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data relating to a role deletion.
+///
+public class RoleDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data relating to a role deletion.
- ///
- public class RoleDeleteAuditLogData : IAuditLogData
+ private RoleDeleteAuditLogData(ulong id, RoleEditInfo props)
{
- private RoleDeleteAuditLogData(ulong id, RoleEditInfo props)
- {
- RoleId = id;
- Properties = props;
- }
-
- internal static RoleDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var colorModel = changes.FirstOrDefault(x => x.ChangedProperty == "color");
- var mentionableModel = changes.FirstOrDefault(x => x.ChangedProperty == "mentionable");
- var hoistModel = changes.FirstOrDefault(x => x.ChangedProperty == "hoist");
- var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var permissionsModel = changes.FirstOrDefault(x => x.ChangedProperty == "permissions");
-
- uint? colorRaw = colorModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- bool? mentionable = mentionableModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- bool? hoist = hoistModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- string name = nameModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
- ulong? permissionsRaw = permissionsModel?.OldValue?.ToObject(discord.ApiClient.Serializer);
-
- Color? color = null;
- GuildPermissions? permissions = null;
-
- if (colorRaw.HasValue)
- color = new Color(colorRaw.Value);
- if (permissionsRaw.HasValue)
- permissions = new GuildPermissions(permissionsRaw.Value);
-
- return new RoleDeleteAuditLogData(entry.TargetId.Value,
- new RoleEditInfo(color, mentionable, hoist, name, permissions));
- }
-
- ///
- /// Gets the ID of the role that was deleted.
- ///
- ///
- /// A representing the snowflake identifier to the role that was deleted.
- ///
- public ulong RoleId { get; }
- ///
- /// Gets the role information that was deleted.
- ///
- ///
- /// An information object representing the properties of the role that was deleted.
- ///
- public RoleEditInfo Properties { get; }
+ RoleId = id;
+ Properties = props;
}
+
+ internal static RoleDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (data, _) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new RoleDeleteAuditLogData(entry.TargetId!.Value, new RoleEditInfo(data));
+ }
+
+ ///
+ /// Gets the ID of the role that was deleted.
+ ///
+ ///
+ /// A representing the snowflake identifier to the role that was deleted.
+ ///
+ public ulong RoleId { get; }
+
+ ///
+ /// Gets the role information that was deleted.
+ ///
+ ///
+ /// An information object representing the properties of the role that was deleted.
+ ///
+ public RoleEditInfo Properties { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleEditInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleEditInfo.cs
index 6f3d8d38..7d4ad3c1 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleEditInfo.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleEditInfo.cs
@@ -1,59 +1,79 @@
-namespace Discord.Rest
-{
- ///
- /// Represents information for a role edit.
- ///
- public struct RoleEditInfo
- {
- internal RoleEditInfo(Color? color, bool? mentionable, bool? hoist, string name,
- GuildPermissions? permissions)
- {
- Color = color;
- Mentionable = mentionable;
- Hoist = hoist;
- Name = name;
- Permissions = permissions;
- }
+using Model = Discord.API.AuditLogs.RoleInfoAuditLogModel;
- ///
- /// Gets the color of this role.
- ///
- ///
- /// A color object representing the color assigned to this role; null if this role does not have a
- /// color.
- ///
- public Color? Color { get; }
- ///
- /// Gets a value that indicates whether this role is mentionable.
- ///
- ///
- /// true if other members can mention this role in a text channel; otherwise false;
- /// null if this is not mentioned in this entry.
- ///
- public bool? Mentionable { get; }
- ///
- /// Gets a value that indicates whether this role is hoisted (i.e. its members will appear in a separate
- /// section on the user list).
- ///
- ///
- /// true if this role's members will appear in a separate section in the user list; otherwise
- /// false; null if this is not mentioned in this entry.
- ///
- public bool? Hoist { get; }
- ///
- /// Gets the name of this role.
- ///
- ///
- /// A string containing the name of this role.
- ///
- public string Name { get; }
- ///
- /// Gets the permissions assigned to this role.
- ///
- ///
- /// A guild permissions object representing the permissions that have been assigned to this role; null
- /// if no permissions have been assigned.
- ///
- public GuildPermissions? Permissions { get; }
+namespace Discord.Rest;
+
+///
+/// Represents information for a role edit.
+///
+public struct RoleEditInfo
+{
+ internal RoleEditInfo(Model model)
+ {
+ if (model.Color is not null)
+ Color = new Color(model.Color.Value);
+ else
+ Color = null;
+
+ Mentionable = model.IsMentionable;
+ Hoist = model.Hoist;
+ Name = model.Name;
+
+ if (model.Permissions is not null)
+ Permissions = new GuildPermissions(model.Permissions.Value);
+ else
+ Permissions = null;
+
+ IconId = model.IconHash;
}
+
+ ///
+ /// Gets the color of this role.
+ ///
+ ///
+ /// A color object representing the color assigned to this role; null if this role does not have a
+ /// color.
+ ///
+ public Color? Color { get; }
+
+ ///
+ /// Gets a value that indicates whether this role is mentionable.
+ ///
+ ///
+ /// true if other members can mention this role in a text channel; otherwise false;
+ /// null if this is not mentioned in this entry.
+ ///
+ public bool? Mentionable { get; }
+
+ ///
+ /// Gets a value that indicates whether this role is hoisted (i.e. its members will appear in a separate
+ /// section on the user list).
+ ///
+ ///
+ /// true if this role's members will appear in a separate section in the user list; otherwise
+ /// false; null if this is not mentioned in this entry.
+ ///
+ public bool? Hoist { get; }
+
+ ///
+ /// Gets the name of this role.
+ ///
+ ///
+ /// A string containing the name of this role.
+ ///
+ public string Name { get; }
+
+ ///
+ /// Gets the permissions assigned to this role.
+ ///
+ ///
+ /// A guild permissions object representing the permissions that have been assigned to this role; null
+ /// if no permissions have been assigned.
+ ///
+ public GuildPermissions? Permissions { get; }
+
+ ///
+ ///
+ /// if the value was not updated in this entry.
+ ///
+ public string IconId { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs
index 89b2db3e..3b31931d 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/RoleUpdateAuditLogData.cs
@@ -1,82 +1,52 @@
-using System.Linq;
+using Discord.API.AuditLogs;
+
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a role update.
+///
+public class RoleUpdateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a role update.
- ///
- public class RoleUpdateAuditLogData : IAuditLogData
+ private RoleUpdateAuditLogData(ulong id, RoleEditInfo oldProps, RoleEditInfo newProps)
{
- private RoleUpdateAuditLogData(ulong id, RoleEditInfo oldProps, RoleEditInfo newProps)
- {
- RoleId = id;
- Before = oldProps;
- After = newProps;
- }
-
- internal static RoleUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var colorModel = changes.FirstOrDefault(x => x.ChangedProperty == "color");
- var mentionableModel = changes.FirstOrDefault(x => x.ChangedProperty == "mentionable");
- var hoistModel = changes.FirstOrDefault(x => x.ChangedProperty == "hoist");
- var nameModel = changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var permissionsModel = changes.FirstOrDefault(x => x.ChangedProperty == "permissions");
-
- uint? oldColorRaw = colorModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newColorRaw = colorModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? oldMentionable = mentionableModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newMentionable = mentionableModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- bool? oldHoist = hoistModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newHoist = hoistModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- string oldName = nameModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newName = nameModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
- ulong? oldPermissionsRaw = permissionsModel?.OldValue?.ToObject(discord.ApiClient.Serializer),
- newPermissionsRaw = permissionsModel?.NewValue?.ToObject(discord.ApiClient.Serializer);
-
- Color? oldColor = null,
- newColor = null;
- GuildPermissions? oldPermissions = null,
- newPermissions = null;
-
- if (oldColorRaw.HasValue)
- oldColor = new Color(oldColorRaw.Value);
- if (newColorRaw.HasValue)
- newColor = new Color(newColorRaw.Value);
- if (oldPermissionsRaw.HasValue)
- oldPermissions = new GuildPermissions(oldPermissionsRaw.Value);
- if (newPermissionsRaw.HasValue)
- newPermissions = new GuildPermissions(newPermissionsRaw.Value);
-
- var oldProps = new RoleEditInfo(oldColor, oldMentionable, oldHoist, oldName, oldPermissions);
- var newProps = new RoleEditInfo(newColor, newMentionable, newHoist, newName, newPermissions);
-
- return new RoleUpdateAuditLogData(entry.TargetId.Value, oldProps, newProps);
- }
-
- ///
- /// Gets the ID of the role that was changed.
- ///
- ///
- /// A representing the snowflake identifier of the role that was changed.
- ///
- public ulong RoleId { get; }
- ///
- /// Gets the role information before the changes.
- ///
- ///
- /// A role information object containing the role information before the changes were made.
- ///
- public RoleEditInfo Before { get; }
- ///
- /// Gets the role information after the changes.
- ///
- ///
- /// A role information object containing the role information after the changes were made.
- ///
- public RoleEditInfo After { get; }
+ RoleId = id;
+ Before = oldProps;
+ After = newProps;
}
+
+ internal static RoleUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new RoleUpdateAuditLogData(entry.TargetId!.Value, new(before), new(after));
+ }
+
+ ///
+ /// Gets the ID of the role that was changed.
+ ///
+ ///
+ /// A representing the snowflake identifier of the role that was changed.
+ ///
+ public ulong RoleId { get; }
+
+ ///
+ /// Gets the role information before the changes.
+ ///
+ ///
+ /// A role information object containing the role information before the changes were made.
+ ///
+ public RoleEditInfo Before { get; }
+
+ ///
+ /// Gets the role information after the changes.
+ ///
+ ///
+ /// A role information object containing the role information after the changes were made.
+ ///
+ public RoleEditInfo After { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs
index 823c60a7..b4e4d07d 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventCreateAuditLogData.cs
@@ -1,148 +1,97 @@
-using Discord.API;
+using Discord.API.AuditLogs;
using System;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a scheduled event creation.
+///
+public class ScheduledEventCreateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a scheduled event creation.
- ///
- public class ScheduledEventCreateAuditLogData : IAuditLogData
+ private ScheduledEventCreateAuditLogData(ulong id, ScheduledEventInfoAuditLogModel model, IGuildScheduledEvent scheduledEvent)
{
- private ScheduledEventCreateAuditLogData(ulong id, ulong guildId, ulong? channelId, ulong? creatorId, string name, string description, DateTimeOffset scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel privacyLevel, GuildScheduledEventStatus status, GuildScheduledEventType entityType, ulong? entityId, string location, RestUser creator, int userCount, string image)
- {
- Id = id;
- GuildId = guildId;
- ChannelId = channelId;
- CreatorId = creatorId;
- Name = name;
- Description = description;
- ScheduledStartTime = scheduledStartTime;
- ScheduledEndTime = scheduledEndTime;
- PrivacyLevel = privacyLevel;
- Status = status;
- EntityType = entityType;
- EntityId = entityId;
- Location = location;
- Creator = creator;
- UserCount = userCount;
- Image = image;
- }
-
- internal static ScheduledEventCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var id = entry.TargetId.Value;
-
- var guildId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "guild_id")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var channelId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "channel_id")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var creatorId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "channel_id")
- .NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault();
- var name = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var description = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "description")
- .NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault();
- var scheduledStartTime = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "scheduled_start_time")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var scheduledEndTime = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "scheduled_end_time")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var status = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "status")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var entityType = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_type")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var entityId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_id")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var entityMetadata = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_metadata")
- .NewValue.ToObject(discord.ApiClient.Serializer);
- var creator = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "creator")
- .NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault();
- var userCount = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "user_count")
- .NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault();
- var image = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "image")
- .NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault();
-
- var creatorUser = creator == null ? null : RestUser.Create(discord, creator);
-
- return new ScheduledEventCreateAuditLogData(id, guildId, channelId, creatorId, name, description, scheduledStartTime, scheduledEndTime, privacyLevel, status, entityType, entityId, entityMetadata.Location.GetValueOrDefault(), creatorUser, userCount, image);
- }
-
- // Doc Note: Corresponds to the *current* data
-
- ///
- /// Gets the snowflake id of the event.
- ///
- public ulong Id { get; }
- ///
- /// Gets the snowflake id of the guild the event is associated with.
- ///
- public ulong GuildId { get; }
- ///
- /// Gets the snowflake id of the channel the event is associated with.
- ///
- public ulong? ChannelId { get; }
- ///
- /// Gets the snowflake id of the original creator of the event.
- ///
- public ulong? CreatorId { get; }
- ///
- /// Gets name of the event.
- ///
- public string Name { get; }
- ///
- /// Gets the description of the event. null if none is set.
- ///
- public string Description { get; }
- ///
- /// Gets the time the event was scheduled for.
- ///
- public DateTimeOffset ScheduledStartTime { get; }
- ///
- /// Gets the time the event was scheduled to end.
- ///
- public DateTimeOffset? ScheduledEndTime { get; }
- ///
- /// Gets the privacy level of the event.
- ///
- public GuildScheduledEventPrivacyLevel PrivacyLevel { get; }
- ///
- /// Gets the status of the event.
- ///
- public GuildScheduledEventStatus Status { get; }
- ///
- /// Gets the type of the entity associated with the event (stage / void / external).
- ///
- public GuildScheduledEventType EntityType { get; }
- ///
- /// Gets the snowflake id of the entity associated with the event (stage / void / external).
- ///
- public ulong? EntityId { get; }
- ///
- /// Gets the metadata for the entity associated with the event.
- ///
- public string Location { get; }
- ///
- /// Gets the user that originally created the event.
- ///
- public RestUser Creator { get; }
- ///
- /// Gets the count of users interested in this event.
- ///
- public int UserCount { get; }
- ///
- /// Gets the image hash of the image that was attached to the event. Null if not set.
- ///
- public string Image { get; }
+ Id = id;
+ ChannelId = model.ChannelId;
+ Name = model.Name;
+ Description = model.Description;
+ ScheduledStartTime = model.StartTime;
+ ScheduledEndTime = model.EndTime;
+ PrivacyLevel = model.PrivacyLevel!.Value;
+ Status = model.EventStatus!.Value;
+ EntityType = model.EventType!.Value;
+ EntityId = model.EntityId;
+ Location = model.Location;
+ Image = model.Image;
+ ScheduledEvent = scheduledEvent;
}
+
+ internal static ScheduledEventCreateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (_, data) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ var scheduledEvent = log.GuildScheduledEvents.FirstOrDefault(x => x.Id == entry.TargetId);
+
+ return new ScheduledEventCreateAuditLogData(entry.TargetId!.Value, data, RestGuildEvent.Create(discord, null, scheduledEvent));
+ }
+
+ ///
+ /// Gets the scheduled event this log corresponds to.
+ ///
+ public IGuildScheduledEvent ScheduledEvent { get; }
+
+ // Doc Note: Corresponds to the *current* data
+
+ ///
+ /// Gets the snowflake id of the event.
+ ///
+ public ulong Id { get; }
+ ///
+ /// Gets the snowflake id of the channel the event is associated with.
+ ///
+ public ulong? ChannelId { get; }
+ ///
+ /// Gets name of the event.
+ ///
+ public string Name { get; }
+ ///
+ /// Gets the description of the event. null if none is set.
+ ///
+ public string Description { get; }
+ ///
+ /// Gets the time the event was scheduled for.
+ ///
+ public DateTimeOffset? ScheduledStartTime { get; }
+ ///
+ /// Gets the time the event was scheduled to end.
+ ///
+ public DateTimeOffset? ScheduledEndTime { get; }
+ ///
+ /// Gets the privacy level of the event.
+ ///
+ public GuildScheduledEventPrivacyLevel PrivacyLevel { get; }
+ ///
+ /// Gets the status of the event.
+ ///
+ public GuildScheduledEventStatus Status { get; }
+ ///
+ /// Gets the type of the entity associated with the event (stage / void / external).
+ ///
+ public GuildScheduledEventType EntityType { get; }
+ ///
+ /// Gets the snowflake id of the entity associated with the event (stage / void / external).
+ ///
+ public ulong? EntityId { get; }
+ ///
+ /// Gets the metadata for the entity associated with the event.
+ ///
+ public string Location { get; }
+ ///
+ /// Gets the image hash of the image that was attached to the event. Null if not set.
+ ///
+ public string Image { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs
index 87502604..4fa3fa51 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventDeleteAuditLogData.cs
@@ -1,33 +1,97 @@
-using Discord.API;
+using Discord.API.AuditLogs;
using System;
-using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a scheduled event deletion.
+///
+public class ScheduledEventDeleteAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a scheduled event deletion.
- ///
- public class ScheduledEventDeleteAuditLogData : IAuditLogData
+ private ScheduledEventDeleteAuditLogData(ulong id, ScheduledEventInfoAuditLogModel model)
{
- private ScheduledEventDeleteAuditLogData(ulong id)
- {
- Id = id;
- }
-
- internal static ScheduledEventDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var id = entry.TargetId.Value;
-
- return new ScheduledEventDeleteAuditLogData(id);
- }
-
- // Doc Note: Corresponds to the *current* data
-
- ///
- /// Gets the snowflake id of the event.
- ///
- public ulong Id { get; }
+ Id = id;
+ ChannelId = model.ChannelId;
+ Name = model.Name;
+ Description = model.Description;
+ ScheduledStartTime = model.StartTime;
+ ScheduledEndTime = model.EndTime;
+ PrivacyLevel = model.PrivacyLevel;
+ Status = model.EventStatus;
+ EntityType = model.EventType;
+ EntityId = model.EntityId;
+ Location = model.Location;
+ Image = model.Image;
}
+
+ internal static ScheduledEventDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (data, _) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ return new ScheduledEventDeleteAuditLogData(entry.TargetId!.Value, data);
+ }
+
+ ///
+ /// Gets the snowflake id of the event.
+ ///
+ public ulong Id { get; }
+
+ ///
+ /// Gets the snowflake id of the channel the event is associated with.
+ ///
+ public ulong? ChannelId { get; }
+
+ ///
+ /// Gets name of the event.
+ ///
+ public string Name { get; }
+
+ ///
+ /// Gets the description of the event. null if none is set.
+ ///
+ public string Description { get; }
+
+ ///
+ /// Gets the time the event was scheduled for.
+ ///
+ public DateTimeOffset? ScheduledStartTime { get; }
+
+ ///
+ /// Gets the time the event was scheduled to end.
+ ///
+ public DateTimeOffset? ScheduledEndTime { get; }
+
+ ///
+ /// Gets the privacy level of the event.
+ ///
+ public GuildScheduledEventPrivacyLevel? PrivacyLevel { get; }
+
+ ///
+ /// Gets the status of the event.
+ ///
+ public GuildScheduledEventStatus? Status { get; }
+
+ ///
+ /// Gets the type of the entity associated with the event (stage / void / external).
+ ///
+ public GuildScheduledEventType? EntityType { get; }
+
+ ///
+ /// Gets the snowflake id of the entity associated with the event (stage / void / external).
+ ///
+ public ulong? EntityId { get; }
+
+ ///
+ /// Gets the metadata for the entity associated with the event.
+ ///
+ public string Location { get; }
+
+ ///
+ /// Gets the image hash of the image that was attached to the event. Null if not set.
+ ///
+ public string Image { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs
index 868c8e9d..c334a1d9 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventInfo.cs
@@ -1,80 +1,81 @@
+using Discord.API.AuditLogs;
+
using System;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Represents information for a scheduled event.
+///
+public class ScheduledEventInfo
{
///
- /// Represents information for a scheduled event.
+ /// Gets the snowflake id of the channel the event is associated with.
///
- public class ScheduledEventInfo
- {
- ///
- /// Gets the snowflake id of the guild the event is associated with.
- ///
- public ulong? GuildId { get; }
- ///
- /// Gets the snowflake id of the channel the event is associated with. 0 for events with external location.
- ///
- public ulong? ChannelId { get; }
- ///
- /// Gets name of the event.
- ///
- public string Name { get; }
- ///
- /// Gets the description of the event. null if none is set.
- ///
- public string Description { get; }
- ///
- /// Gets the time the event was scheduled for.
- ///
- public DateTimeOffset? ScheduledStartTime { get; }
- ///
- /// Gets the time the event was scheduled to end.
- ///
- public DateTimeOffset? ScheduledEndTime { get; }
- ///
- /// Gets the privacy level of the event.
- ///
- public GuildScheduledEventPrivacyLevel? PrivacyLevel { get; }
- ///
- /// Gets the status of the event.
- ///
- public GuildScheduledEventStatus? Status { get; }
- ///
- /// Gets the type of the entity associated with the event (stage / void / external).
- ///
- public GuildScheduledEventType? EntityType { get; }
- ///
- /// Gets the snowflake id of the entity associated with the event (stage / void / external).
- ///
- public ulong? EntityId { get; }
- ///
- /// Gets the metadata for the entity associated with the event. if there was no change.
- ///
- public Optional Location { get; }
- ///
- /// Gets the count of users interested in this event.
- ///
- public int? UserCount { get; }
- ///
- /// Gets the image hash of the image that was attached to the event. Null if not set.
- ///
- public string Image { get; }
+ public ulong? ChannelId { get; }
- internal ScheduledEventInfo(ulong? guildId, ulong? channelId, string name, string description, DateTimeOffset? scheduledStartTime, DateTimeOffset? scheduledEndTime, GuildScheduledEventPrivacyLevel? privacyLevel, GuildScheduledEventStatus? status, GuildScheduledEventType? entityType, ulong? entityId, Optional location, int? userCount, string image)
- {
- GuildId = guildId;
- ChannelId = channelId;
- Name = name;
- Description = description;
- ScheduledStartTime = scheduledStartTime;
- ScheduledEndTime = scheduledEndTime;
- PrivacyLevel = privacyLevel;
- Status = status;
- EntityType = entityType;
- EntityId = entityId;
- Location = location;
- UserCount = userCount;
- Image = image;
- }
+ ///
+ /// Gets name of the event.
+ ///
+ public string Name { get; }
+
+ ///
+ /// Gets the description of the event. null if none is set.
+ ///
+ public string Description { get; }
+
+ ///
+ /// Gets the time the event was scheduled for.
+ ///
+ public DateTimeOffset? ScheduledStartTime { get; }
+
+ ///
+ /// Gets the time the event was scheduled to end.
+ ///
+ public DateTimeOffset? ScheduledEndTime { get; }
+
+ ///
+ /// Gets the privacy level of the event.
+ ///
+ public GuildScheduledEventPrivacyLevel? PrivacyLevel { get; }
+
+ ///
+ /// Gets the status of the event.
+ ///
+ public GuildScheduledEventStatus? Status { get; }
+
+ ///
+ /// Gets the type of the entity associated with the event (stage / void / external).
+ ///
+ public GuildScheduledEventType? EntityType { get; }
+
+ ///
+ /// Gets the snowflake id of the entity associated with the event (stage / void / external).
+ ///
+ public ulong? EntityId { get; }
+
+ ///
+ /// Gets the metadata for the entity associated with the event.
+ ///
+ public string Location { get; }
+
+ ///
+ /// Gets the image hash of the image that was attached to the event. Null if not set.
+ ///
+ public string Image { get; }
+
+ internal ScheduledEventInfo(ScheduledEventInfoAuditLogModel model)
+ {
+ ChannelId = model.ChannelId;
+ Name = model.Name;
+ Description = model.Description;
+ ScheduledStartTime = model.StartTime;
+ ScheduledEndTime = model.EndTime;
+ PrivacyLevel = model.PrivacyLevel;
+ Status = model.EventStatus;
+ EntityType = model.EventType;
+ EntityId = model.EntityId;
+ Location = model.Location;
+ Image = model.Image;
}
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs
index e39759a4..d93e72c5 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/ScheduledEventUpdateAuditLogData.cs
@@ -1,95 +1,54 @@
-using System;
+using Discord.API.AuditLogs;
using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a scheduled event updates.
+///
+public class ScheduledEventUpdateAuditLogData : IAuditLogData
{
- ///
- /// Contains a piece of audit log data related to a scheduled event updates.
- ///
- public class ScheduledEventUpdateAuditLogData : IAuditLogData
+ private ScheduledEventUpdateAuditLogData(ulong id, ScheduledEventInfo before, ScheduledEventInfo after, IGuildScheduledEvent scheduledEvent)
{
- private ScheduledEventUpdateAuditLogData(ulong id, ScheduledEventInfo before, ScheduledEventInfo after)
- {
- Id = id;
- Before = before;
- After = after;
- }
+ Id = id;
+ Before = before;
+ After = after;
+ ScheduledEvent = scheduledEvent;
- internal static ScheduledEventUpdateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var changes = entry.Changes;
-
- var id = entry.TargetId.Value;
-
- var guildId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "guild_id");
- var channelId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "channel_id");
- var name = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "name");
- var description = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "description");
- var scheduledStartTime = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "scheduled_start_time");
- var scheduledEndTime = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "scheduled_end_time");
- var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level");
- var status = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "status");
- var entityType = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_type");
- var entityId = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "entity_id");
- var location = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "location");
- var userCount = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "user_count");
- var image = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "image");
-
- var before = new ScheduledEventInfo(
- guildId?.OldValue.ToObject(discord.ApiClient.Serializer),
- channelId == null ? null : channelId.OldValue?.ToObject(discord.ApiClient.Serializer) ?? 0,
- name?.OldValue.ToObject(discord.ApiClient.Serializer),
- description?.OldValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault(),
- scheduledStartTime?.OldValue.ToObject(discord.ApiClient.Serializer),
- scheduledEndTime?.OldValue.ToObject(discord.ApiClient.Serializer),
- privacyLevel?.OldValue.ToObject(discord.ApiClient.Serializer),
- status?.OldValue.ToObject(discord.ApiClient.Serializer),
- entityType?.OldValue.ToObject(discord.ApiClient.Serializer),
- entityId?.OldValue.ToObject(discord.ApiClient.Serializer),
- location == null ? Optional.Unspecified : new Optional(location.OldValue?.ToObject(discord.ApiClient.Serializer)),
- userCount?.OldValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault(),
- image?.OldValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault()
- );
- var after = new ScheduledEventInfo(
- guildId?.NewValue.ToObject(discord.ApiClient.Serializer),
- channelId == null ? null : channelId.NewValue?.ToObject(discord.ApiClient.Serializer) ?? 0,
- name?.NewValue.ToObject(discord.ApiClient.Serializer),
- description?.NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault(),
- scheduledStartTime?.NewValue.ToObject(discord.ApiClient.Serializer),
- scheduledEndTime?.NewValue.ToObject(discord.ApiClient.Serializer),
- privacyLevel?.NewValue.ToObject(discord.ApiClient.Serializer),
- status?.NewValue.ToObject(discord.ApiClient.Serializer),
- entityType?.NewValue.ToObject(discord.ApiClient.Serializer),
- entityId?.NewValue.ToObject(discord.ApiClient.Serializer),
- location == null ? Optional.Unspecified : new Optional(location.NewValue?.ToObject(discord.ApiClient.Serializer)),
- userCount?.NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault(),
- image?.NewValue.ToObject>(discord.ApiClient.Serializer)
- .GetValueOrDefault()
- );
-
- return new ScheduledEventUpdateAuditLogData(id, before, after);
- }
-
- // Doc Note: Corresponds to the *current* data
-
- ///
- /// Gets the snowflake id of the event.
- ///
- public ulong Id { get; }
- ///
- /// Gets the state before the change.
- ///
- public ScheduledEventInfo Before { get; }
- ///
- /// Gets the state after the change.
- ///
- public ScheduledEventInfo After { get; }
}
+
+ internal static ScheduledEventUpdateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var changes = entry.Changes;
+
+ var (before, after) = AuditLogHelper.CreateAuditLogEntityInfo(changes, discord);
+
+ var scheduledEvent = log.GuildScheduledEvents.FirstOrDefault(x => x.Id == entry.TargetId);
+
+ return new ScheduledEventUpdateAuditLogData(entry.TargetId!.Value, new(before), new(after), RestGuildEvent.Create(discord, null, scheduledEvent));
+ }
+
+ ///
+ /// Gets the scheduled event this log corresponds to.
+ ///
+ public IGuildScheduledEvent ScheduledEvent { get; }
+
+ // Doc Note: Corresponds to the *current* data
+
+ ///
+ /// Gets the snowflake id of the event.
+ ///
+ public ulong Id { get; }
+
+ ///
+ /// Gets the state before the change.
+ ///
+ public ScheduledEventInfo Before { get; }
+
+ ///
+ /// Gets the state after the change.
+ ///
+ public ScheduledEventInfo After { get; }
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs
index 778ecb1e..f73f71df 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceCreateAuditLogData.cs
@@ -2,49 +2,48 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a stage going live.
+///
+public class StageInstanceCreateAuditLogData : IAuditLogData
{
///
- /// Contains a piece of audit log data related to a stage going live.
+ /// Gets the topic of the stage channel.
///
- public class StageInstanceCreateAuditLogData : IAuditLogData
+ public string Topic { get; }
+
+ ///
+ /// Gets the privacy level of the stage channel.
+ ///
+ public StagePrivacyLevel PrivacyLevel { get; }
+
+ ///
+ /// Gets the user who started the stage channel.
+ ///
+ public IUser User { get; }
+
+ ///
+ /// Gets the Id of the stage channel.
+ ///
+ public ulong StageChannelId { get; }
+
+ internal StageInstanceCreateAuditLogData(string topic, StagePrivacyLevel privacyLevel, IUser user, ulong channelId)
{
- ///
- /// Gets the topic of the stage channel.
- ///
- public string Topic { get; }
+ Topic = topic;
+ PrivacyLevel = privacyLevel;
+ User = user;
+ StageChannelId = channelId;
+ }
- ///
- /// Gets the privacy level of the stage channel.
- ///
- public StagePrivacyLevel PrivacyLevel { get; }
+ internal static StageInstanceCreateAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic").NewValue.ToObject(discord.ApiClient.Serializer);
+ var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level").NewValue.ToObject(discord.ApiClient.Serializer);
+ var user = log.Users.FirstOrDefault(x => x.Id == entry.UserId);
+ var channelId = entry.Options.ChannelId;
- ///
- /// Gets the user who started the stage channel.
- ///
- public IUser User { get; }
-
- ///
- /// Gets the Id of the stage channel.
- ///
- public ulong StageChannelId { get; }
-
- internal StageInstanceCreateAuditLogData(string topic, StagePrivacyLevel privacyLevel, IUser user, ulong channelId)
- {
- Topic = topic;
- PrivacyLevel = privacyLevel;
- User = user;
- StageChannelId = channelId;
- }
-
- internal static StageInstanceCreateAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic").NewValue.ToObject(discord.ApiClient.Serializer);
- var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level").NewValue.ToObject(discord.ApiClient.Serializer);
- var user = log.Users.FirstOrDefault(x => x.Id == entry.UserId);
- var channelId = entry.Options.ChannelId;
-
- return new StageInstanceCreateAuditLogData(topic, privacyLevel, RestUser.Create(discord, user), channelId ?? 0);
- }
+ return new StageInstanceCreateAuditLogData(topic, privacyLevel, RestUser.Create(discord, user), channelId ?? 0);
}
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs
index becf0aa4..d5136a85 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceDeleteAuditLogData.cs
@@ -2,49 +2,48 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a stage instance deleted.
+///
+public class StageInstanceDeleteAuditLogData : IAuditLogData
{
///
- /// Contains a piece of audit log data related to a stage instance deleted.
+ /// Gets the topic of the stage channel.
///
- public class StageInstanceDeleteAuditLogData
+ public string Topic { get; }
+
+ ///
+ /// Gets the privacy level of the stage channel.
+ ///
+ public StagePrivacyLevel PrivacyLevel { get; }
+
+ ///
+ /// Gets the user who started the stage channel.
+ ///
+ public IUser User { get; }
+
+ ///
+ /// Gets the Id of the stage channel.
+ ///
+ public ulong StageChannelId { get; }
+
+ internal StageInstanceDeleteAuditLogData(string topic, StagePrivacyLevel privacyLevel, IUser user, ulong channelId)
{
- ///
- /// Gets the topic of the stage channel.
- ///
- public string Topic { get; }
+ Topic = topic;
+ PrivacyLevel = privacyLevel;
+ User = user;
+ StageChannelId = channelId;
+ }
- ///
- /// Gets the privacy level of the stage channel.
- ///
- public StagePrivacyLevel PrivacyLevel { get; }
+ internal static StageInstanceDeleteAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic").OldValue.ToObject(discord.ApiClient.Serializer);
+ var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level").OldValue.ToObject(discord.ApiClient.Serializer);
+ var user = log.Users.FirstOrDefault(x => x.Id == entry.UserId);
+ var channelId = entry.Options.ChannelId;
- ///
- /// Gets the user who started the stage channel.
- ///
- public IUser User { get; }
-
- ///
- /// Gets the Id of the stage channel.
- ///
- public ulong StageChannelId { get; }
-
- internal StageInstanceDeleteAuditLogData(string topic, StagePrivacyLevel privacyLevel, IUser user, ulong channelId)
- {
- Topic = topic;
- PrivacyLevel = privacyLevel;
- User = user;
- StageChannelId = channelId;
- }
-
- internal static StageInstanceDeleteAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic").OldValue.ToObject(discord.ApiClient.Serializer);
- var privacyLevel = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy_level").OldValue.ToObject(discord.ApiClient.Serializer);
- var user = log.Users.FirstOrDefault(x => x.Id == entry.UserId);
- var channelId = entry.Options.ChannelId;
-
- return new StageInstanceDeleteAuditLogData(topic, privacyLevel, RestUser.Create(discord, user), channelId ?? 0);
- }
+ return new StageInstanceDeleteAuditLogData(topic, privacyLevel, RestUser.Create(discord, user), channelId ?? 0);
}
}
diff --git a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs
index dfcf1386..d661a486 100644
--- a/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs
+++ b/src/Discord.Net.Rest/Entities/AuditLogs/DataTypes/StageInstanceUpdatedAuditLogData.cs
@@ -2,50 +2,49 @@ using System.Linq;
using EntryModel = Discord.API.AuditLogEntry;
using Model = Discord.API.AuditLog;
-namespace Discord.Rest
+namespace Discord.Rest;
+
+///
+/// Contains a piece of audit log data related to a stage instance update.
+///
+public class StageInstanceUpdatedAuditLogData : IAuditLogData
{
///
- /// Contains a piece of audit log data related to a stage instance update.
+ /// Gets the Id of the stage channel.
///
- public class StageInstanceUpdatedAuditLogData
+ public ulong StageChannelId { get; }
+
+ ///
+ /// Gets the stage information before the changes.
+ ///
+ public StageInfo Before { get; }
+
+ ///
+ /// Gets the stage information after the changes.
+ ///
+ public StageInfo After { get; }
+
+ internal StageInstanceUpdatedAuditLogData(ulong channelId, StageInfo before, StageInfo after)
{
- ///
- /// Gets the Id of the stage channel.
- ///
- public ulong StageChannelId { get; }
+ StageChannelId = channelId;
+ Before = before;
+ After = after;
+ }
- ///
- /// Gets the stage information before the changes.
- ///
- public StageInfo Before { get; }
+ internal static StageInstanceUpdatedAuditLogData Create(BaseDiscordClient discord, EntryModel entry, Model log)
+ {
+ var channelId = entry.Options.ChannelId.Value;
- ///
- /// Gets the stage information after the changes.
- ///
- public StageInfo After { get; }
+ var topic = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "topic");
+ var privacy = entry.Changes.FirstOrDefault(x => x.ChangedProperty == "privacy");
- internal StageInstanceUpdatedAuditLogData(ulong channelId, StageInfo before, StageInfo after)
- {
- StageChannelId = channelId;
- Before = before;
- After = after;
- }
+ var user = RestUser.Create(discord, log.Users.FirstOrDefault(x => x.Id == entry.UserId));
- internal static StageInstanceUpdatedAuditLogData Create(BaseDiscordClient discord, Model log, EntryModel entry)
- {
- var channelId = entry.Options.ChannelId.Value;
+ var oldTopic = topic?.OldValue.ToObject();
+ var newTopic = topic?.NewValue.ToObject();
+ var oldPrivacy = privacy?.OldValue.ToObject();
+ var newPrivacy = privacy?.NewValue.ToObject