Skip to content

Commit

Permalink
feat: AutoModerationRuleCreateChangeSet
Browse files Browse the repository at this point in the history
  • Loading branch information
TheXorog committed Oct 17, 2023
1 parent a69633e commit 98340af
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
namespace DisCatSharp.Entities;
using System.Collections.Generic;
using System.Linq;

using DisCatSharp.Enums;

namespace DisCatSharp.Entities;

/// <summary>
/// Represents a change set for creating an Auto Moderation rule.
/// </summary>
public class AutoModerationRuleCreateChangeSet : DiscordAuditLogEntry
{ }
{
internal AutoModerationRuleCreateChangeSet()
{
this.ValidFor = AuditLogActionType.AutoModerationRuleCreate;
}

public bool Enabled => (bool)this.Changes.FirstOrDefault(x => x.Key == "enabled")?.NewValue;
public string RuleName => (string)this.Changes.FirstOrDefault(x => x.Key == "name")?.NewValue;
public AutomodTriggerType TriggerType => (AutomodTriggerType)this.Changes.FirstOrDefault(x => x.Key == "trigger_type")?.NewValue;
public AutomodEventType EventType => (AutomodEventType)this.Changes.FirstOrDefault(x => x.Key == "event_type")?.NewValue;
public AutomodAction[] Actions => (AutomodAction[])this.Changes.FirstOrDefault(x => x.Key == "actions")?.NewValue;
public AutomodTriggerMetadata TriggerMetadata => (AutomodTriggerMetadata)this.Changes.FirstOrDefault(x => x.Key == "trigger_metadata")?.NewValue;

public IReadOnlyList<ulong>? ExemptRoleIds => ((IReadOnlyList<string>?)this.Changes.FirstOrDefault(x => x.Key == "exempt_roles")?.NewValue)?.Select(x => ConvertToUlong(x)!.Value).ToList();
public IEnumerable<DiscordRole> ExemptRoles => this.ExemptRoles.Select(x => this.Discord.Guilds[this.GuildId].Roles[x.Id]);

public IReadOnlyList<ulong>? ExemptChannelIds => ((IReadOnlyList<string>?)this.Changes.FirstOrDefault(x => x.Key == "exempt_channels")?.NewValue)?.Select(x => ConvertToUlong(x)!.Value).ToList();
public IEnumerable<DiscordChannel> ExemptChannels => this.ExemptChannels.Select(x => this.Discord.Guilds[this.GuildId].Channels[x.Id]);
}

0 comments on commit 98340af

Please sign in to comment.