Add MentionRaidProtectionEnabled (#3056)
This commit is contained in:
@@ -131,6 +131,11 @@ namespace Discord
|
||||
/// Gets or sets the exempt channels for the rule. Empty if the rule has no exempt channels.
|
||||
/// </summary>
|
||||
public Optional<ulong[]> ExemptChannels { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to automatically detect mention raids.
|
||||
/// </summary>
|
||||
public Optional<bool> MentionRaidProtectionEnabled { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Discord
|
||||
/// This collection will be empty if <see cref="TriggerType"/> is not
|
||||
/// <see cref="AutoModTriggerType.Keyword"/>.
|
||||
/// </remarks>
|
||||
public IReadOnlyCollection<string> KeywordFilter { get; }
|
||||
IReadOnlyCollection<string> KeywordFilter { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets regex patterns for this rule. Empty if the rule has no regexes.
|
||||
@@ -52,7 +52,7 @@ namespace Discord
|
||||
/// This collection will be empty if <see cref="TriggerType"/> is not
|
||||
/// <see cref="AutoModTriggerType.Keyword"/>.
|
||||
/// </remarks>
|
||||
public IReadOnlyCollection<string> RegexPatterns { get; }
|
||||
IReadOnlyCollection<string> RegexPatterns { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the allow list patterns for this rule. Empty if the rule has no allowed terms.
|
||||
@@ -61,7 +61,7 @@ namespace Discord
|
||||
/// This collection will be empty if <see cref="TriggerType"/> is not
|
||||
/// <see cref="AutoModTriggerType.Keyword"/>.
|
||||
/// </remarks>
|
||||
public IReadOnlyCollection<string> AllowList { get; }
|
||||
IReadOnlyCollection<string> AllowList { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the preset keyword types for this rule. Empty if the rule has no presets.
|
||||
@@ -70,7 +70,7 @@ namespace Discord
|
||||
/// This collection will be empty if <see cref="TriggerType"/> is not
|
||||
/// <see cref="AutoModTriggerType.KeywordPreset"/>.
|
||||
/// </remarks>
|
||||
public IReadOnlyCollection<KeywordPresetTypes> Presets { get; }
|
||||
IReadOnlyCollection<KeywordPresetTypes> Presets { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the total mention limit for this rule.
|
||||
@@ -79,7 +79,7 @@ namespace Discord
|
||||
/// This property will be <see langword="null"/> if <see cref="TriggerType"/> is not
|
||||
/// <see cref="AutoModTriggerType.MentionSpam"/>.
|
||||
/// </remarks>
|
||||
public int? MentionTotalLimit { get; }
|
||||
int? MentionTotalLimit { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of actions that will be preformed if a user breaks this rule.
|
||||
@@ -101,6 +101,15 @@ namespace Discord
|
||||
/// </summary>
|
||||
IReadOnlyCollection<ulong> ExemptChannels { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether to automatically detect mention raids.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This property will be <see langword="null"/> if <see cref="TriggerType"/> is not
|
||||
/// <see cref="AutoModTriggerType.MentionSpam"/>.
|
||||
/// </remarks>
|
||||
bool? MentionRaidProtectionEnabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Modifies this rule.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,45 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.API
|
||||
namespace Discord.API;
|
||||
|
||||
internal class AutoModerationRule
|
||||
{
|
||||
internal class AutoModerationRule
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
[JsonProperty("guild_id")]
|
||||
public ulong GuildId { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("creator_id")]
|
||||
public ulong CreatorId { get; set; }
|
||||
[JsonProperty("creator_id")]
|
||||
public ulong CreatorId { get; set; }
|
||||
|
||||
[JsonProperty("event_type")]
|
||||
public AutoModEventType EventType { get; set; }
|
||||
[JsonProperty("event_type")]
|
||||
public AutoModEventType EventType { get; set; }
|
||||
|
||||
[JsonProperty("trigger_type")]
|
||||
public AutoModTriggerType TriggerType { get; set; }
|
||||
[JsonProperty("trigger_type")]
|
||||
public AutoModTriggerType TriggerType { get; set; }
|
||||
|
||||
[JsonProperty("trigger_metadata")]
|
||||
public TriggerMetadata TriggerMetadata { get; set; }
|
||||
[JsonProperty("trigger_metadata")]
|
||||
public TriggerMetadata TriggerMetadata { get; set; }
|
||||
|
||||
[JsonProperty("actions")]
|
||||
public AutoModAction[] Actions { get; set; }
|
||||
[JsonProperty("actions")]
|
||||
public AutoModAction[] Actions { get; set; }
|
||||
|
||||
[JsonProperty("enabled")]
|
||||
public bool Enabled { get; set; }
|
||||
[JsonProperty("enabled")]
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
[JsonProperty("exempt_roles")]
|
||||
public ulong[] ExemptRoles { get; set; }
|
||||
[JsonProperty("exempt_roles")]
|
||||
public ulong[] ExemptRoles { get; set; }
|
||||
|
||||
[JsonProperty("exempt_channels")]
|
||||
public ulong[] ExemptChannels { get; set; }
|
||||
}
|
||||
[JsonProperty("exempt_channels")]
|
||||
public ulong[] ExemptChannels { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,27 +1,24 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Discord.API
|
||||
namespace Discord.API;
|
||||
|
||||
internal class TriggerMetadata
|
||||
{
|
||||
internal class TriggerMetadata
|
||||
{
|
||||
[JsonProperty("keyword_filter")]
|
||||
public Optional<string[]> KeywordFilter { get; set; }
|
||||
[JsonProperty("keyword_filter")]
|
||||
public Optional<string[]> KeywordFilter { get; set; }
|
||||
|
||||
[JsonProperty("regex_patterns")]
|
||||
public Optional<string[]> RegexPatterns { get; set; }
|
||||
[JsonProperty("regex_patterns")]
|
||||
public Optional<string[]> RegexPatterns { get; set; }
|
||||
|
||||
[JsonProperty("presets")]
|
||||
public Optional<KeywordPresetTypes[]> Presets { get; set; }
|
||||
[JsonProperty("presets")]
|
||||
public Optional<KeywordPresetTypes[]> Presets { get; set; }
|
||||
|
||||
[JsonProperty("allow_list")]
|
||||
public Optional<string[]> AllowList { get; set; }
|
||||
[JsonProperty("allow_list")]
|
||||
public Optional<string[]> AllowList { get; set; }
|
||||
|
||||
[JsonProperty("mention_total_limit")]
|
||||
public Optional<int> MentionLimit { get; set; }
|
||||
}
|
||||
[JsonProperty("mention_total_limit")]
|
||||
public Optional<int> MentionLimit { get; set; }
|
||||
|
||||
[JsonProperty("mention_raid_protection_enabled")]
|
||||
public Optional<bool> MentionRaidProtectionEnabled { get; set; }
|
||||
}
|
||||
|
||||
@@ -1538,6 +1538,7 @@ namespace Discord.Rest
|
||||
AllowList = args.AllowList.IsSpecified ? args.AllowList : rule.AllowList.ToArray(),
|
||||
MentionLimit = args.MentionLimit.IsSpecified ? args.MentionLimit : rule.MentionTotalLimit ?? Optional<int>.Unspecified,
|
||||
Presets = args.Presets.IsSpecified ? args.Presets : rule.Presets.ToArray(),
|
||||
MentionRaidProtectionEnabled = args.MentionRaidProtectionEnabled.IsSpecified ? args.MentionRaidProtectionEnabled : rule.MentionRaidProtectionEnabled ?? Optional<bool>.Unspecified,
|
||||
} : Optional<API.TriggerMetadata>.Unspecified
|
||||
};
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@ public class RestAutoModRule : RestEntity<ulong>, IAutoModRule
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyCollection<ulong> ExemptChannels { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool? MentionRaidProtectionEnabled { get; private set; }
|
||||
|
||||
internal RestAutoModRule(BaseDiscordClient discord, ulong id) : base(discord, id)
|
||||
{
|
||||
|
||||
@@ -95,6 +98,7 @@ public class RestAutoModRule : RestEntity<ulong>, IAutoModRule
|
||||
Enabled = model.Enabled;
|
||||
ExemptRoles = model.ExemptRoles.ToImmutableArray();
|
||||
ExemptChannels = model.ExemptChannels.ToImmutableArray();
|
||||
MentionRaidProtectionEnabled = model.TriggerMetadata.MentionRaidProtectionEnabled.ToNullable();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -60,6 +60,9 @@ namespace Discord.WebSocket
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<SocketGuildChannel> ExemptChannels { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool? MentionRaidProtectionEnabled { get; private set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DateTimeOffset CreatedAt
|
||||
=> SnowflakeUtils.FromSnowflake(Id);
|
||||
@@ -106,6 +109,7 @@ namespace Discord.WebSocket
|
||||
Enabled = model.Enabled;
|
||||
ExemptRoles = model.ExemptRoles.Select(x => Guild.GetRole(x)).ToImmutableArray();
|
||||
ExemptChannels = model.ExemptChannels.Select(x => Guild.GetChannel(x)).ToImmutableArray();
|
||||
MentionRaidProtectionEnabled = model.TriggerMetadata.MentionRaidProtectionEnabled.ToNullable();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
Reference in New Issue
Block a user