diff --git a/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleProperties.cs b/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleProperties.cs index e91276947..0e45b6625 100644 --- a/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleProperties.cs +++ b/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleProperties.cs @@ -31,6 +31,21 @@ namespace Discord /// public Optional KeywordFilter { get; set; } + /// + /// Gets or sets regex patterns for the rule. + /// + public Optional RegexPatterns { get; set; } + + /// + /// Gets or sets the allow list for the rule. + /// + public Optional AllowList { get; set; } + + /// + /// Gets or sets total mention limit for the rule. + /// + public Optional MentionLimit { get; set; } + /// /// Gets or sets the presets for the rule. /// diff --git a/src/Discord.Net.Core/Entities/Guilds/AutoModeration/IAutoModRule.cs b/src/Discord.Net.Core/Entities/Guilds/AutoModeration/IAutoModRule.cs index cf51bab3f..5e09496a9 100644 --- a/src/Discord.Net.Core/Entities/Guilds/AutoModeration/IAutoModRule.cs +++ b/src/Discord.Net.Core/Entities/Guilds/AutoModeration/IAutoModRule.cs @@ -76,10 +76,10 @@ namespace Discord /// Gets the total mention limit for this rule. /// /// - /// This collection will be empty if is not + /// This property will be if is not /// . /// - public int MentionTotalLimit { get; } + public int? MentionTotalLimit { get; } /// /// Gets a collection of actions that will be preformed if a user breaks this rule. diff --git a/src/Discord.Net.Rest/API/Common/TriggerMetadata.cs b/src/Discord.Net.Rest/API/Common/TriggerMetadata.cs index 6b4aa0a66..214e464c9 100644 --- a/src/Discord.Net.Rest/API/Common/TriggerMetadata.cs +++ b/src/Discord.Net.Rest/API/Common/TriggerMetadata.cs @@ -10,18 +10,18 @@ namespace Discord.API internal class TriggerMetadata { [JsonProperty("keyword_filter")] - public string[] KeywordFilter { get; set; } + public Optional KeywordFilter { get; set; } [JsonProperty("regex_patterns")] - public string[] RegexPatterns { get; set; } + public Optional RegexPatterns { get; set; } [JsonProperty("presets")] - public KeywordPresetTypes[] Presets { get; set; } + public Optional Presets { get; set; } [JsonProperty("allow_list")] - public string[] AllowList { get; set; } + public Optional AllowList { get; set; } [JsonProperty("mention_total_limit")] - public int MentionLimit { get; set; } + public Optional MentionLimit { get; set; } } } diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index 3a01adc95..32f12537d 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -1087,6 +1087,9 @@ namespace Discord.Rest TriggerMetadata = args.KeywordFilter.IsSpecified || args.Presets.IsSpecified ? new API.TriggerMetadata { KeywordFilter = args.KeywordFilter.GetValueOrDefault(Array.Empty()), + RegexPatterns = args.RegexPatterns.GetValueOrDefault(Array.Empty()), + AllowList = args.AllowList.GetValueOrDefault(Array.Empty()), + MentionLimit = args.MentionLimit, Presets = args.Presets.GetValueOrDefault(Array.Empty()) } : Optional.Unspecified }; diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketAutoModRule.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketAutoModRule.cs index 78b0572ae..7dcd1f050 100644 --- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketAutoModRule.cs +++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketAutoModRule.cs @@ -46,7 +46,7 @@ namespace Discord.WebSocket public IReadOnlyCollection Actions { get; private set; } /// - public int MentionTotalLimit { get; private set; } + public int? MentionTotalLimit { get; private set; } /// public bool Enabled { get; private set; } @@ -87,11 +87,13 @@ namespace Discord.WebSocket Creator ??= Guild.GetUser(_creatorId); EventType = model.EventType; TriggerType = model.TriggerType; - KeywordFilter = model.TriggerMetadata.KeywordFilter.ToImmutableArray(); - Presets = model.TriggerMetadata.Presets.ToImmutableArray(); - RegexPatterns = model.TriggerMetadata.RegexPatterns.ToImmutableArray(); - AllowList = model.TriggerMetadata.AllowList.ToImmutableArray(); - MentionTotalLimit = model.TriggerMetadata.MentionLimit; + 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 + ? model.TriggerMetadata.MentionLimit.Value + : null; Actions = model.Actions.Select(x => new AutoModRuleAction(x.Type, x.Metadata.GetValueOrDefault()?.ChannelId.ToNullable(), x.Metadata.GetValueOrDefault()?.DurationSeconds.ToNullable())).ToImmutableArray(); Enabled = model.Enabled; ExemptRoles = model.ExemptRoles.Select(x => Guild.GetRole(x)).ToImmutableArray();