throw new ArgumentException("Name of the rule must not be empty", paramName: nameof(Name));
Preconditions.AtLeast(1, Actions.Count, nameof(Actions), "Auto moderation rule must have at least 1 action");
if(TriggerType is AutoModTriggerType.Keyword)
Preconditions.AtLeast(1, KeywordFilter.Count + RegexPatterns.Count, nameof(KeywordFilter), "Auto moderation rule must have at least 1 keyword or regex pattern");
if(TriggerType is AutoModTriggerType.MentionSpam && MentionLimit is null)
throw new ArgumentException("Mention limit must not be empty", paramName: nameof(MentionLimit));
return new(Name,
EventType,
TriggerType,
KeywordFilter.ToArray(),
RegexPatterns.ToArray(),
AllowList.ToArray(),
MentionLimit,
Presets.ToArray(),
Actions.Select(x => new AutoModRuleAction(x.Type, x.ChannelId, (int?)x.TimeoutDuration?.TotalSeconds)).ToArray(),
Enabled,
ExemptRoles.ToArray(),
ExemptChannels.ToArray());
}
}
/// <summary>
@@ -205,17 +436,23 @@ public class AutoModRuleActionBuilder
/// <summary>
/// Get or sets the channel id on which to post alerts.
/// </summary>
/// <remarks>
/// This property will be <see langword="null"/> if <see cref="Type"/> is not <see cref="AutoModActionType.SendAlertMessage"/>
/// </remarks>
public ulong? ChannelId { get; set; }
/// <summary>
/// Gets or sets the duration of which a user will be timed out for breaking this rule.
/// </summary>
/// <remarks>
/// This property will be <see langword="null"/> if <see cref="Type"/> is not <see cref="AutoModActionType.Timeout"/>
/// </remarks>
public TimeSpan? TimeoutDuration
{
get => _timeoutDuration;
set
{
if(value is { TotalSeconds: > MaxTimeoutSeconds })
if(value is { TotalSeconds: > MaxTimeoutSeconds })
throw new ArgumentException(message: $"Field count must be less than or equal to {MaxTimeoutSeconds}.", paramName: nameof(TimeoutDuration));
_timeoutDuration = value;
@@ -225,18 +462,13 @@ public class AutoModRuleActionBuilder
/// <summary>
///
/// </summary>
public AutoModRuleActionBuilder()
{
}
/// <summary>
///
/// </summary>
public AutoModRuleActionBuilder(AutoModActionType type, ulong? channelId, TimeSpan? duration)
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.