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