@@ -12,23 +12,28 @@ namespace Discord | |||||
public enum AutoModTriggerType | public enum AutoModTriggerType | ||||
{ | { | ||||
/// <summary> | /// <summary> | ||||
/// Check if content contains words from a user defined list of keywords | |||||
/// Check if content contains words from a user defined list of keywords. | |||||
/// </summary> | /// </summary> | ||||
Keyword = 1, | Keyword = 1, | ||||
/// <summary> | /// <summary> | ||||
/// Check if content contains any harmful links | |||||
/// Check if content contains any harmful links. | |||||
/// </summary> | /// </summary> | ||||
HarmfulLink = 2, | HarmfulLink = 2, | ||||
/// <summary> | /// <summary> | ||||
/// Check if content represents generic spam | |||||
/// Check if content represents generic spam. | |||||
/// </summary> | /// </summary> | ||||
Spam = 3, | Spam = 3, | ||||
/// <summary> | /// <summary> | ||||
/// Check if content contains words from internal pre-defined wordsets | |||||
/// Check if content contains words from internal pre-defined wordsets. | |||||
/// </summary> | /// </summary> | ||||
KeywordPreset = 4, | KeywordPreset = 4, | ||||
/// <summary> | |||||
/// Check if content contains more unique mentions than allowed. | |||||
/// </summary> | |||||
MentionSpam = 5, | |||||
} | } | ||||
} | } |
@@ -45,6 +45,24 @@ namespace Discord | |||||
/// </remarks> | /// </remarks> | ||||
public IReadOnlyCollection<string> KeywordFilter { get; } | public IReadOnlyCollection<string> KeywordFilter { get; } | ||||
/// <summary> | |||||
/// Gets regex patterns for this rule. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// This collection will be empty if <see cref="TriggerType"/> is not | |||||
/// <see cref="AutoModTriggerType.Keyword"/>. | |||||
/// </remarks> | |||||
public IReadOnlyCollection<string> RegexPatterns { get; } | |||||
/// <summary> | |||||
/// Gets the allow list patterns for this rule. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// This collection will be empty if <see cref="TriggerType"/> is not | |||||
/// <see cref="AutoModTriggerType.Keyword"/>. | |||||
/// </remarks> | |||||
public IReadOnlyCollection<string> AllowList { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets the preset keyword types for this rule. | /// Gets the preset keyword types for this rule. | ||||
/// </summary> | /// </summary> | ||||
@@ -54,6 +72,15 @@ namespace Discord | |||||
/// </remarks> | /// </remarks> | ||||
public IReadOnlyCollection<KeywordPresetTypes> Presets { get; } | public IReadOnlyCollection<KeywordPresetTypes> Presets { get; } | ||||
/// <summary> | |||||
/// Gets the total mention limit for this rule. | |||||
/// </summary> | |||||
/// <remarks> | |||||
/// This collection will be empty if <see cref="TriggerType"/> is not | |||||
/// <see cref="AutoModTriggerType.MentionSpam"/>. | |||||
/// </remarks> | |||||
public int MentionTotalLimit { get; } | |||||
/// <summary> | /// <summary> | ||||
/// Gets a collection of actions that will be preformed if a user breaks this rule. | /// Gets a collection of actions that will be preformed if a user breaks this rule. | ||||
/// </summary> | /// </summary> | ||||
@@ -12,7 +12,16 @@ namespace Discord.API | |||||
[JsonProperty("keyword_filter")] | [JsonProperty("keyword_filter")] | ||||
public string[] KeywordFilter { get; set; } | public string[] KeywordFilter { get; set; } | ||||
[JsonProperty("regex_patterns")] | |||||
public string[] RegexPatterns { get; set; } | |||||
[JsonProperty("presets")] | [JsonProperty("presets")] | ||||
public KeywordPresetTypes[] Presets { get; set; } | public KeywordPresetTypes[] Presets { get; set; } | ||||
[JsonProperty("allow_list")] | |||||
public string[] AllowList { get; set; } | |||||
[JsonProperty("mention_total_limit")] | |||||
public int MentionLimit { get; set; } | |||||
} | } | ||||
} | } |
@@ -1062,7 +1062,7 @@ namespace Discord.Rest | |||||
#endregion | #endregion | ||||
#region Auto Mod | #region Auto Mod | ||||
public static Task ModifyRuleAsync(BaseDiscordClient client, IAutoModRule rule, Action<AutoModRuleProperties> func, RequestOptions options) | |||||
public static Task<AutoModerationRule> ModifyRuleAsync(BaseDiscordClient client, IAutoModRule rule, Action<AutoModRuleProperties> func, RequestOptions options) | |||||
{ | { | ||||
var args = new AutoModRuleProperties(); | var args = new AutoModRuleProperties(); | ||||
func(args); | func(args); | ||||
@@ -33,12 +33,21 @@ namespace Discord.WebSocket | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public IReadOnlyCollection<string> KeywordFilter { get; private set; } | public IReadOnlyCollection<string> KeywordFilter { get; private set; } | ||||
/// <inheritdoc/> | |||||
public IReadOnlyCollection<string> RegexPatterns { get; private set; } | |||||
/// <inheritdoc/> | |||||
public IReadOnlyCollection<string> AllowList { get; private set; } | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public IReadOnlyCollection<KeywordPresetTypes> Presets { get; private set; } | public IReadOnlyCollection<KeywordPresetTypes> Presets { get; private set; } | ||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public IReadOnlyCollection<AutoModRuleAction> Actions { get; private set; } | public IReadOnlyCollection<AutoModRuleAction> Actions { get; private set; } | ||||
/// <inheritdoc/> | |||||
public int MentionTotalLimit { get; private set; } | |||||
/// <inheritdoc/> | /// <inheritdoc/> | ||||
public bool Enabled { get; private set; } | public bool Enabled { get; private set; } | ||||
@@ -80,6 +89,9 @@ namespace Discord.WebSocket | |||||
TriggerType = model.TriggerType; | TriggerType = model.TriggerType; | ||||
KeywordFilter = model.TriggerMetadata.KeywordFilter.ToImmutableArray(); | KeywordFilter = model.TriggerMetadata.KeywordFilter.ToImmutableArray(); | ||||
Presets = model.TriggerMetadata.Presets.ToImmutableArray(); | Presets = model.TriggerMetadata.Presets.ToImmutableArray(); | ||||
RegexPatterns = model.TriggerMetadata.RegexPatterns.ToImmutableArray(); | |||||
AllowList = model.TriggerMetadata.AllowList.ToImmutableArray(); | |||||
MentionTotalLimit = model.TriggerMetadata.MentionLimit; | |||||
Actions = model.Actions.Select(x => new AutoModRuleAction(x.Type, x.Metadata.GetValueOrDefault()?.ChannelId.ToNullable(), x.Metadata.GetValueOrDefault()?.DurationSeconds.ToNullable())).ToImmutableArray(); | Actions = model.Actions.Select(x => new AutoModRuleAction(x.Type, x.Metadata.GetValueOrDefault()?.ChannelId.ToNullable(), x.Metadata.GetValueOrDefault()?.DurationSeconds.ToNullable())).ToImmutableArray(); | ||||
Enabled = model.Enabled; | Enabled = model.Enabled; | ||||
ExemptRoles = model.ExemptRoles.Select(x => Guild.GetRole(x)).ToImmutableArray(); | ExemptRoles = model.ExemptRoles.Select(x => Guild.GetRole(x)).ToImmutableArray(); | ||||