-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: AutoModerationRuleCreateChangeSet
- Loading branch information
Showing
1 changed file
with
25 additions
and
2 deletions.
There are no files selected for viewing
27 changes: 25 additions & 2 deletions
27
DisCatSharp/Entities/Guild/AuditLog/ChangeSet/AutoModerationRuleCreateChangeSet.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
} |