diff --git a/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleBuilder.cs b/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleBuilder.cs
index dd5e5faa0..506e3bc63 100644
--- a/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleBuilder.cs
+++ b/src/Discord.Net.Core/Entities/Guilds/AutoModeration/AutoModRuleBuilder.cs
@@ -12,20 +12,55 @@ namespace Discord;
///
public class AutoModRuleBuilder
{
- private const int MaxKeywordCount = 1000;
- private const int MaxKeywordLength = 30;
+ ///
+ /// Returns the max keyword count for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxKeywordCount = 1000;
+
+ ///
+ /// Returns the max keyword length for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxKeywordLength = 30;
+
+ ///
+ /// Returns the max regex pattern count for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxRegexPatternCount = 10;
+
+ ///
+ /// Returns the max regex pattern length for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxRegexPatternLength = 260;
- private const int MaxRegexPatternCount = 10;
- private const int MaxRegexPatternLength = 260;
+ ///
+ /// Returns the max allowlist keyword count for a AutoMod rule allowed by Discord.
+ ///
+ public const int MaxAllowListCountKeyword = 100;
- private const int MaxAllowListCountKeyword = 100;
- private const int MaxAllowListCountKeywordPreset = 1000;
- private const int MaxAllowListEntryLength = 30;
+ ///
+ /// Returns the max allowlist keyword count for a AutoMod rule allowed by Discord.
+ ///
+ public const int MaxAllowListCountKeywordPreset = 1000;
- private const int MaxMentionLimit = 50;
+ ///
+ /// Returns the max allowlist keyword length for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxAllowListEntryLength = 30;
- private const int MaxExemptRoles = 20;
- private const int MaxExemptChannels = 50;
+ ///
+ /// Returns the max mention limit for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxMentionLimit = 50;
+
+ ///
+ /// Returns the max exempt role count for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxExemptRoles = 20;
+
+ ///
+ /// Returns the max exempt channel count for an AutoMod rule allowed by Discord.
+ ///
+ public const int MaxExemptChannels = 50;
private List _keywordFilter = new();
private List _regexPatterns = new();
@@ -33,11 +68,12 @@ public class AutoModRuleBuilder
private List _exemptRoles = new();
private List _exemptChannels = new();
+ private HashSet _presets = new();
private int? _mentionLimit;
///
- ///
+ /// Gets or sets the list of of an .
///
public List KeywordFilter
{
@@ -58,7 +94,7 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Gets or sets the list of of an .
///
public List RegexPatterns
{
@@ -79,7 +115,7 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Gets or sets the list of of an .
///
public List AllowList
{
@@ -103,7 +139,7 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Gets or sets the list of of an .
///
public List ExemptRoles
{
@@ -118,7 +154,7 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Gets or sets the list of of an .
///
public List ExemptChannels
{
@@ -133,7 +169,7 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Gets or sets the hashset of of an .
///
public HashSet Presets
{
@@ -148,22 +184,22 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Gets or sets the name of an .
///
public string Name { get; set; }
///
- ///
+ /// Gets or sets the event type of an .
///
public AutoModEventType EventType { get; set; } = AutoModEventType.MessageSend;
///
- ///
+ /// Gets the trigger type of an .
///
- public AutoModTriggerType TriggerType { get; }
+ public AutoModTriggerType TriggerType { get; }
///
- ///
+ /// Gets or sets the mention limit of an .
///
public int? MentionLimit
{
@@ -180,30 +216,28 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Gets or sets the list of of an .
///
public List Actions = new();
- private HashSet _presets = new();
-
///
- ///
+ /// Gets or sets the enabled status of an .
///
public bool Enabled { get; set; } = false;
///
- ///
+ /// Initializes a new instance of used to create a new .
///
- ///
+ /// The trigger type of an
public AutoModRuleBuilder(AutoModTriggerType type)
{
TriggerType = type;
}
///
- ///
+ /// Sets the name of an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder WithName(string name)
{
Name = name;
@@ -211,9 +245,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Sets the enabled status of an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder WithEnabled(bool enabled)
{
Enabled = enabled;
@@ -221,9 +255,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Sets the event type of an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder WithEventType(AutoModEventType eventType)
{
EventType = eventType;
@@ -231,9 +265,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Sets the mention limit of an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder WithMentionLimit(int limit)
{
MentionLimit = limit;
@@ -241,10 +275,10 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds a keyword to an .
///
- ///
- public AutoModRuleBuilder AddKeywordFilter(string keyword)
+ /// The current builder.
+ public AutoModRuleBuilder AddKeyword(string keyword)
{
if (TriggerType != AutoModTriggerType.Keyword)
throw new ArgumentException(message: $"Keyword filter can only be used with 'Keyword' trigger type.");
@@ -261,10 +295,10 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds a allow list keyword to an .
///
- ///
- public AutoModRuleBuilder AddAllowList(string keyword)
+ /// The current builder.
+ public AutoModRuleBuilder AddAllowListKeyword(string keyword)
{
if (TriggerType is not AutoModTriggerType.Keyword or AutoModTriggerType.KeywordPreset)
throw new ArgumentException(message: $"Allow list can only be used with 'Keyword' or 'KeywordPreset' trigger type.");
@@ -284,9 +318,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds a to an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder AddKeywordPreset(KeywordPresetTypes type)
{
if (TriggerType != AutoModTriggerType.KeywordPreset)
@@ -297,9 +331,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds a regex pattern to an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder AddRegexPattern(string regex)
{
if (TriggerType != AutoModTriggerType.Keyword)
@@ -317,9 +351,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds an exempt to an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder AddExemptRole(IRole role)
{
AddExemptRole(role.Id);
@@ -327,9 +361,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds a exempt role with id keyword to an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder AddExemptRole(ulong roleId)
{
ExemptRoles.Add(roleId);
@@ -337,9 +371,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds an exempt keyword to an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder AddExemptChannel(IMessageChannel channel)
{
AddExemptChannel(channel.Id);
@@ -347,9 +381,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds an exempt channel with id keyword to an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder AddExemptChannel(ulong channelId)
{
ExemptChannels.Add(channelId);
@@ -357,9 +391,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Adds an to an .
///
- ///
+ /// The current builder.
public AutoModRuleBuilder AddAction(AutoModRuleActionBuilder builder)
{
Actions.Add(builder);
@@ -367,9 +401,9 @@ public class AutoModRuleBuilder
}
///
- ///
+ /// Creates a new instance of with data from a .
///
- ///
+ /// The new builder.
public static AutoModRuleBuilder FromAutoModRule(IAutoModRule rule)
=> new(rule.TriggerType)
{
@@ -385,9 +419,9 @@ public class AutoModRuleBuilder
Enabled = rule.Enabled,
EventType = rule.EventType
};
-
+
///
- ///
+ /// Builds the into ready to be sent.
///
///
public AutoModRule Build()
@@ -460,7 +494,7 @@ public class AutoModRuleActionBuilder
}
///
- ///
+ /// Creates a new instance of used to define actions of an .
///
public AutoModRuleActionBuilder(AutoModActionType type, ulong? channelId = null, TimeSpan? duration = null)
{
diff --git a/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs b/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
index 82e677300..bc97139e9 100644
--- a/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
+++ b/src/Discord.Net.WebSocket/BaseSocketClient.Events.cs
@@ -895,6 +895,9 @@ namespace Discord.WebSocket
#region AutoModeration
+ ///
+ /// Fired when an auto moderation rule is created.
+ ///
public event Func AutoModRuleCreated
{
add => _autoModRuleCreated.Add(value);
@@ -902,6 +905,9 @@ namespace Discord.WebSocket
}
internal readonly AsyncEvent> _autoModRuleCreated = new ();
+ ///
+ /// Fired when an auto moderation rule is modified.
+ ///
public event Func, SocketAutoModRule, Task> AutoModRuleUpdated
{
add => _autoModRuleUpdated.Add(value);
@@ -909,6 +915,9 @@ namespace Discord.WebSocket
}
internal readonly AsyncEvent, SocketAutoModRule, Task>> _autoModRuleUpdated = new ();
+ ///
+ /// Fired when an auto moderation rule is deleted.
+ ///
public event Func AutoModRuleDeleted
{
add => _autoModRuleDeleted.Add(value);
@@ -916,6 +925,9 @@ namespace Discord.WebSocket
}
internal readonly AsyncEvent> _autoModRuleDeleted = new ();
+ ///
+ /// Fired when an auto moderation rule is triggered by a user.
+ ///
public event Func AutoModActionExecuted
{
add => _autoModActionExecuted.Add(value);
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/AutoModActionExecutedData.cs b/src/Discord.Net.WebSocket/Entities/Guilds/AutoModActionExecutedData.cs
index 611b39441..d6b3204f9 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/AutoModActionExecutedData.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/AutoModActionExecutedData.cs
@@ -28,7 +28,7 @@ public class AutoModActionExecutedData
/// Gets the message that triggered the action.
///
///
- /// This property will be if the message was blocked byt automod.
+ /// This property will be if the message was blocked by the automod.
///
public Cacheable Message { get; }
diff --git a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
index 1496c101f..3ea7ff41d 100644
--- a/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
+++ b/src/Discord.Net.WebSocket/Entities/Guilds/SocketGuild.cs
@@ -1847,7 +1847,7 @@ namespace Discord.WebSocket
rule.Update(model);
}
- return rule is null ? SocketAutoModRule.Create(Discord, this, model) : rule;
+ return rule ?? SocketAutoModRule.Create(Discord, this, model);
}
///