Author | SHA1 | Message | Date |
---|---|---|---|
|
ae7b8574fb | initial implementation | 3 years ago |
@@ -0,0 +1,26 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
public enum AutoModActionType | |||
{ | |||
/// <summary> | |||
/// Blocks the content of a message according to the rule. | |||
/// </summary> | |||
BlockMessage = 1, | |||
/// <summary> | |||
/// Logs user content to a specified channel. | |||
/// </summary> | |||
SendAlertMessage = 2, | |||
/// <summary> | |||
/// Timeout user for a specified duration. | |||
/// </summary> | |||
Timeout = 3, | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// An enum indecating in what event context a rule should be checked. | |||
/// </summary> | |||
public enum AutoModEventType | |||
{ | |||
/// <summary> | |||
/// When a member sends or edits a message in the guild | |||
/// </summary> | |||
MessageSend = 1 | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represents an action that will be preformed if a user breaks an <see cref="IAutoModRule"/>. | |||
/// </summary> | |||
public class AutoModRuleAction | |||
{ | |||
/// <summary> | |||
/// Gets the type for this action. | |||
/// </summary> | |||
public AutoModActionType Type { get; } | |||
/// <summary> | |||
/// Get the channel id on which to post alerts. | |||
/// </summary> | |||
public ulong? ChannelId { get; } | |||
/// <summary> | |||
/// Gets the duration of which a user will be timed out for breaking this rule. | |||
/// </summary> | |||
public TimeSpan? TimeoutDuration { get; } | |||
internal AutoModRuleAction(AutoModActionType type, ulong? channelId, int? duration) | |||
{ | |||
Type = type; | |||
ChannelId = channelId; | |||
TimeoutDuration = duration.HasValue ? TimeSpan.FromSeconds(duration.Value) : null; | |||
} | |||
} | |||
} |
@@ -0,0 +1,78 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Provides properties used to modify a <see cref="IAutoModRule"/>. | |||
/// </summary> | |||
public class AutoModRuleProperties | |||
{ | |||
/// <summary> | |||
/// Gets or sets the name for the rule. | |||
/// </summary> | |||
public Optional<string> Name { get; set; } | |||
/// <summary> | |||
/// Gets or sets the event type for the rule. | |||
/// </summary> | |||
public Optional<AutoModEventType> EventType { get; set; } | |||
/// <summary> | |||
/// Gets or sets the trigger type for the rule. | |||
/// </summary> | |||
public Optional<AutoModTriggerType> TriggerType { get; set; } | |||
/// <summary> | |||
/// Gets or sets the keyword filter for the rule. | |||
/// </summary> | |||
public Optional<string[]> KeywordFilter { get; set; } | |||
/// <summary> | |||
/// Gets or sets the presets for the rule. | |||
/// </summary> | |||
public Optional<KeywordPresetTypes[]> Presets { get; set; } | |||
/// <summary> | |||
/// Gets or sets the actions for the rule. | |||
/// </summary> | |||
public Optional<AutoModRuleActionProperties[]> Actions { get; set; } | |||
/// <summary> | |||
/// Gets or sets whether or not the rule is enabled. | |||
/// </summary> | |||
public Optional<bool> Enabled { get; set; } | |||
/// <summary> | |||
/// Gets or sets the exempt roles for the rule. | |||
/// </summary> | |||
public Optional<ulong[]> ExemptRoles { get; set; } | |||
/// <summary> | |||
/// Gets or sets the exempt channels for the rule. | |||
/// </summary> | |||
public Optional<ulong[]> ExemptChannels { get; set; } | |||
} | |||
public class AutoModRuleActionProperties | |||
{ | |||
/// <summary> | |||
/// Gets or sets the type for this action. | |||
/// </summary> | |||
public AutoModActionType Type { get; set; } | |||
/// <summary> | |||
/// Get or sets the channel id on which to post alerts. | |||
/// </summary> | |||
public ulong? ChannelId { get; set; } | |||
/// <summary> | |||
/// Gets or sets the duration of which a user will be timed out for breaking this rule. | |||
/// </summary> | |||
public TimeSpan? TimeoutDuration { get; set; } | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// An enum representing the type of content which can trigger the rule. | |||
/// </summary> | |||
public enum AutoModTriggerType | |||
{ | |||
/// <summary> | |||
/// Check if content contains words from a user defined list of keywords | |||
/// </summary> | |||
Keyword = 1, | |||
/// <summary> | |||
/// Check if content contains any harmful links | |||
/// </summary> | |||
HarmfulLink = 2, | |||
/// <summary> | |||
/// Check if content represents generic spam | |||
/// </summary> | |||
Spam = 3, | |||
/// <summary> | |||
/// Check if content contains words from internal pre-defined wordsets | |||
/// </summary> | |||
KeywordPreset = 4, | |||
} | |||
} |
@@ -0,0 +1,84 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// Represents a auto mod rule within a guild. | |||
/// </summary> | |||
public interface IAutoModRule : ISnowflakeEntity, IDeletable | |||
{ | |||
/// <summary> | |||
/// Gets the guild id on which this rule exists. | |||
/// </summary> | |||
ulong GuildId { get; } | |||
/// <summary> | |||
/// Get the name of this rule. | |||
/// </summary> | |||
string Name { get; } | |||
/// <summary> | |||
/// Gets the id of the user who created this use. | |||
/// </summary> | |||
ulong CreatorId { get; } | |||
/// <summary> | |||
/// Gets the event type on which this rule is triggered. | |||
/// </summary> | |||
AutoModEventType EventType { get; } | |||
/// <summary> | |||
/// Gets the trigger type on which this rule executes. | |||
/// </summary> | |||
AutoModTriggerType TriggerType { get; } | |||
/// <summary> | |||
/// Gets the keyword filter for this rule. | |||
/// </summary> | |||
/// <remarks> | |||
/// This collection will be empty if <see cref="TriggerType"/> is not | |||
/// <see cref="AutoModTriggerType.Keyword"/>. | |||
/// </remarks> | |||
public IReadOnlyCollection<string> KeywordFilter { get; } | |||
/// <summary> | |||
/// Gets the preset keyword types for this rule. | |||
/// </summary> | |||
/// <remarks> | |||
/// This collection will be empty if <see cref="TriggerType"/> is not | |||
/// <see cref="AutoModTriggerType.KeywordPreset"/>. | |||
/// </remarks> | |||
public IReadOnlyCollection<KeywordPresetTypes> Presets { get; } | |||
/// <summary> | |||
/// Gets a collection of actions that will be preformed if a user breaks this rule. | |||
/// </summary> | |||
IReadOnlyCollection<AutoModRuleAction> Actions { get; } | |||
/// <summary> | |||
/// Gets whether or not this rule is enabled. | |||
/// </summary> | |||
bool Enabled { get; } | |||
/// <summary> | |||
/// Gets a collection of role ids that are exempt from this rule. | |||
/// </summary> | |||
IReadOnlyCollection<ulong> ExemptRoles { get; } | |||
/// <summary> | |||
/// Gets a collection of channel ids that are exempt from this rule. | |||
/// </summary> | |||
IReadOnlyCollection<ulong> ExemptChannels { get; } | |||
/// <summary> | |||
/// Modifies this rule. | |||
/// </summary> | |||
/// <param name="func">The delegate containing the properties to modify the rule with.</param> | |||
/// <param name="options">The options to be used when sending the request.</param> | |||
Task ModifyAsync(Action<AutoModRuleProperties> func, RequestOptions options = null); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord | |||
{ | |||
/// <summary> | |||
/// An enum representing preset filter types. | |||
/// </summary> | |||
public enum KeywordPresetTypes | |||
{ | |||
/// <summary> | |||
/// Words that may be considered forms of swearing or cursing. | |||
/// </summary> | |||
Profanity = 1, | |||
/// <summary> | |||
/// Words that refer to sexually explicit behavior or activity. | |||
/// </summary> | |||
SexualContent = 2, | |||
/// <summary> | |||
/// Personal insults or words that may be considered hate speech. | |||
/// </summary> | |||
Slurs = 3, | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.API | |||
{ | |||
internal class ActionMetadata | |||
{ | |||
[JsonProperty("channel_id")] | |||
public Optional<ulong> ChannelId { get; set; } | |||
[JsonProperty("duration_seconds")] | |||
public Optional<int> DurationSeconds { get; set; } | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.API | |||
{ | |||
internal class AutoModAction | |||
{ | |||
[JsonProperty("type")] | |||
public AutoModActionType Type { get; set; } | |||
[JsonProperty("metadata")] | |||
public Optional<ActionMetadata> Metadata { get; set; } | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.API | |||
{ | |||
internal class AutoModerationRule | |||
{ | |||
[JsonProperty("id")] | |||
public ulong Id { get; set; } | |||
[JsonProperty("guild_id")] | |||
public ulong GuildId { get; set; } | |||
[JsonProperty("name")] | |||
public string Name { get; set; } | |||
[JsonProperty("creator_id")] | |||
public ulong CreatorId { get; set; } | |||
[JsonProperty("event_type")] | |||
public AutoModEventType EventType { get; set; } | |||
[JsonProperty("trigger_type")] | |||
public AutoModTriggerType TriggerType { get; set; } | |||
[JsonProperty("trigger_metadata")] | |||
public TriggerMetadata TriggerMetadata { get; set; } | |||
[JsonProperty("actions")] | |||
public AutoModAction[] Actions { get; set; } | |||
[JsonProperty("enabled")] | |||
public bool Enabled { get; set; } | |||
[JsonProperty("exempt_roles")] | |||
public ulong[] ExemptRoles { get; set; } | |||
[JsonProperty("exempt_channels")] | |||
public ulong[] ExemptChannels { get; set; } | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
using Newtonsoft.Json; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.API | |||
{ | |||
internal class TriggerMetadata | |||
{ | |||
[JsonProperty("keyword_filter")] | |||
public string[] KeywordFilter { get; set; } | |||
[JsonProperty("presets")] | |||
public KeywordPresetTypes[] Presets { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.API.Rest | |||
{ | |||
internal class CreateAutoModRuleParams | |||
{ | |||
public string Name { get; set; } | |||
public AutoModEventType EventType { get; set; } | |||
public AutoModTriggerType TriggerType { get; set; } | |||
public Optional<TriggerMetadata> TriggerMetadata { get; set; } | |||
public AutoModAction[] Actions { get; set; } | |||
public Optional<bool> Enabled { get; set; } | |||
public Optional<ulong[]> ExemptRoles { get; set; } | |||
public Optional<ulong[]> ExemptChannels { get; set; } | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Discord.API.Rest | |||
{ | |||
internal class ModifyAutoModRuleParams | |||
{ | |||
public Optional<string> Name { get; set; } | |||
public Optional<AutoModEventType> EventType { get; set; } | |||
public Optional<AutoModTriggerType> TriggerType { get; set; } | |||
public Optional<TriggerMetadata> TriggerMetadata { get; set; } | |||
public Optional<AutoModAction[]> Actions { get; set; } | |||
public Optional<bool> Enabled { get; set; } | |||
public Optional<ulong[]> ExemptRoles { get; set; } | |||
public Optional<ulong[]> ExemptChannels { get; set; } | |||
} | |||
} |
@@ -2074,6 +2074,58 @@ namespace Discord.API | |||
#endregion | |||
#region Guild AutoMod | |||
public async Task<AutoModerationRule[]> GetGuildAutoModRulesAsync(ulong guildId, RequestOptions options) | |||
{ | |||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
options = RequestOptions.CreateOrClone(options); | |||
return await SendAsync<AutoModerationRule[]>("GET", () => $"guilds/{guildId}/auto-moderation/rules", new BucketIds(guildId), options: options); | |||
} | |||
public async Task<AutoModerationRule> GetGuildAutoModRuleAsync(ulong guildId, ulong ruleId, RequestOptions options) | |||
{ | |||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
Preconditions.NotEqual(ruleId, 0, nameof(ruleId)); | |||
options = RequestOptions.CreateOrClone(options); | |||
return await SendAsync<AutoModerationRule>("GET", () => $"guilds/{guildId}/auto-moderation/rules/{ruleId}", new BucketIds(guildId), options: options); | |||
} | |||
public async Task<AutoModerationRule> CreateGuildAutoModRuleAsync(ulong guildId, CreateAutoModRuleParams args, RequestOptions options) | |||
{ | |||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
options = RequestOptions.CreateOrClone(options); | |||
return await SendJsonAsync<AutoModerationRule>("POST", () => $"guilds/{guildId}/auto-moderation", args, new BucketIds(guildId), options: options); | |||
} | |||
public async Task<AutoModerationRule> ModifyGuildAutoModRuleAsync(ulong guildId, ulong ruleId, ModifyAutoModRuleParams args, RequestOptions options) | |||
{ | |||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
Preconditions.NotEqual(ruleId, 0, nameof(ruleId)); | |||
options = RequestOptions.CreateOrClone(options); | |||
return await SendJsonAsync<AutoModerationRule>("PATCH", () => $"guilds/{guildId}/auto-moderation/{ruleId}", args, new BucketIds(guildId), options: options); | |||
} | |||
public async Task DeleteGuildAutoModRuleAsync(ulong guildId, ulong ruleId, RequestOptions options) | |||
{ | |||
Preconditions.NotEqual(guildId, 0, nameof(guildId)); | |||
Preconditions.NotEqual(ruleId, 0, nameof(ruleId)); | |||
options = RequestOptions.CreateOrClone(options); | |||
await SendAsync("DELETE", () => $"guilds/{guildId}/auto-moderation/rules/{ruleId}", new BucketIds(guildId), options: options); | |||
} | |||
#endregion | |||
#region Users | |||
public async Task<User> GetUserAsync(ulong userId, RequestOptions options = null) | |||
{ | |||
@@ -943,5 +943,42 @@ namespace Discord.Rest | |||
} | |||
#endregion | |||
#region Auto Mod | |||
public static Task ModifyRuleAsync(BaseDiscordClient client, IAutoModRule rule, Action<AutoModRuleProperties> func, RequestOptions options) | |||
{ | |||
var args = new AutoModRuleProperties(); | |||
func(args); | |||
var apiArgs = new API.Rest.ModifyAutoModRuleParams | |||
{ | |||
Actions = args.Actions.IsSpecified ? args.Actions.Value.Select(x => new API.AutoModAction() | |||
{ | |||
Type = x.Type, | |||
Metadata = x.ChannelId.HasValue || x.TimeoutDuration.HasValue ? new API.ActionMetadata | |||
{ | |||
ChannelId = x.ChannelId ?? Optional<ulong>.Unspecified, | |||
DurationSeconds = x.TimeoutDuration.HasValue ? (int)Math.Floor(x.TimeoutDuration.Value.TotalSeconds) : Optional<int>.Unspecified | |||
} : Optional<API.ActionMetadata>.Unspecified | |||
}).ToArray() : Optional<API.AutoModAction[]>.Unspecified, | |||
Enabled = args.Enabled, | |||
EventType = args.EventType, | |||
ExemptChannels = args.ExemptChannels, | |||
ExemptRoles = args.ExemptRoles, | |||
Name = args.Name, | |||
TriggerType = args.TriggerType, | |||
TriggerMetadata = args.KeywordFilter.IsSpecified || args.Presets.IsSpecified ? new API.TriggerMetadata | |||
{ | |||
KeywordFilter = args.KeywordFilter.GetValueOrDefault(Array.Empty<string>()), | |||
Presets = args.Presets.GetValueOrDefault(Array.Empty<KeywordPresetTypes>()) | |||
} : Optional<API.TriggerMetadata>.Unspecified | |||
}; | |||
return client.ApiClient.ModifyGuildAutoModRuleAsync(rule.GuildId, rule.Id, apiArgs, options); | |||
} | |||
public static Task DeleteRuleAsync(BaseDiscordClient client, IAutoModRule rule, RequestOptions options) | |||
=> client.ApiClient.DeleteGuildAutoModRuleAsync(rule.GuildId, rule.Id, options); | |||
#endregion | |||
} | |||
} |
@@ -877,5 +877,24 @@ namespace Discord.WebSocket | |||
} | |||
internal readonly AsyncEvent<Func<SocketCustomSticker, Task>> _guildStickerDeleted = new AsyncEvent<Func<SocketCustomSticker, Task>>(); | |||
#endregion | |||
#region AutoModeration | |||
public event Func<SocketAutoModRule, Task> AutoModRuleCreated | |||
{ | |||
add => _autoModRuleCreated.Add(value); | |||
remove => _autoModRuleCreated.Remove(value); | |||
} | |||
internal readonly AsyncEvent<Func<SocketAutoModRule, Task>> _autoModRuleCreated = new AsyncEvent<Func<SocketAutoModRule, Task>>(); | |||
public event Func<SocketAutoModRule, Task> AutoModRuleDelted | |||
{ | |||
add => _autoModRuleDeleted.Add(value); | |||
remove => _autoModRuleDeleted.Remove(value); | |||
} | |||
internal readonly AsyncEvent<Func<SocketAutoModRule, Task>> _autoModRuleDeleted = new AsyncEvent<Func<SocketAutoModRule, Task>>(); | |||
//public event Func<SocketAutoModRule> | |||
#endregion | |||
} | |||
} |
@@ -2839,6 +2839,34 @@ namespace Discord.WebSocket | |||
#endregion | |||
#region Auto Moderation | |||
case "AUTO_MODERATION_RULE_CREATE": | |||
{ | |||
} | |||
break; | |||
case "AUTO_MODERATION_RULE_UPDATE": | |||
{ | |||
} | |||
break; | |||
case "AUTO_MODERATION_RULE_DELETE": | |||
{ | |||
} | |||
break; | |||
case "AUTO_MODERATION_RULE_EXECUTE": | |||
{ | |||
} | |||
break; | |||
#endregion | |||
#region Ignored (User only) | |||
case "CHANNEL_PINS_ACK": | |||
await _gatewayLogger.DebugAsync("Ignored Dispatch (CHANNEL_PINS_ACK)").ConfigureAwait(false); | |||
@@ -0,0 +1,104 @@ | |||
using Discord.Rest; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.Immutable; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using Model = Discord.API.AutoModerationRule; | |||
namespace Discord.WebSocket | |||
{ | |||
public class SocketAutoModRule : SocketEntity<ulong>, IAutoModRule | |||
{ | |||
/// <summary> | |||
/// Gets the guild that this rule is in. | |||
/// </summary> | |||
public SocketGuild Guild { get; } | |||
/// <inheritdoc/> | |||
public string Name { get; private set; } | |||
/// <summary> | |||
/// Gets the creator of this rule. | |||
/// </summary> | |||
public SocketGuildUser Creator { get; private set; } | |||
/// <inheritdoc/> | |||
public AutoModEventType EventType { get; private set; } | |||
/// <inheritdoc/> | |||
public AutoModTriggerType TriggerType { get; private set; } | |||
/// <inheritdoc/> | |||
public IReadOnlyCollection<string> KeywordFilter { get; private set; } | |||
/// <inheritdoc/> | |||
public IReadOnlyCollection<KeywordPresetTypes> Presets { get; private set; } | |||
/// <inheritdoc/> | |||
public IReadOnlyCollection<AutoModRuleAction> Actions { get; private set; } | |||
/// <inheritdoc/> | |||
public bool Enabled { get; private set; } | |||
/// <summary> | |||
/// Gets the roles that are exempt from this rule. | |||
/// </summary> | |||
public IReadOnlyCollection<SocketRole> ExemptRoles { get; private set; } | |||
/// <summary> | |||
/// Gets the channels that are exempt from this rule. | |||
/// </summary> | |||
public IReadOnlyCollection<SocketGuildChannel> ExemptChannels { get; private set; } | |||
/// <inheritdoc/> | |||
public DateTimeOffset CreatedAt | |||
=> SnowflakeUtils.FromSnowflake(Id); | |||
private ulong _creatorId; | |||
internal SocketAutoModRule(DiscordSocketClient discord, ulong id, SocketGuild guild) | |||
: base(discord, id) | |||
{ | |||
Guild = guild; | |||
} | |||
internal static SocketAutoModRule Create(DiscordSocketClient discord, SocketGuild guild, Model model) | |||
{ | |||
var entity = new SocketAutoModRule(discord, model.Id, guild); | |||
entity.Update(model); | |||
return entity; | |||
} | |||
internal void Update(Model model) | |||
{ | |||
Name = model.Name; | |||
_creatorId = model.CreatorId; | |||
Creator ??= Guild.GetUser(_creatorId); | |||
EventType = model.EventType; | |||
TriggerType = model.TriggerType; | |||
KeywordFilter = model.TriggerMetadata.KeywordFilter.ToImmutableArray(); | |||
Presets = model.TriggerMetadata.Presets.ToImmutableArray(); | |||
Actions = model.Actions.Select(x => new AutoModRuleAction(x.Type, x.Metadata.GetValueOrDefault()?.ChannelId.ToNullable(), x.Metadata.GetValueOrDefault()?.DurationSeconds.ToNullable())).ToImmutableArray(); | |||
Enabled = model.Enabled; | |||
ExemptRoles = model.ExemptRoles.Select(x => Guild.GetRole(x)).ToImmutableArray(); | |||
ExemptChannels = model.ExemptChannels.Select(x => Guild.GetChannel(x)).ToImmutableArray(); | |||
} | |||
/// <inheritdoc/> | |||
public Task ModifyAsync(Action<AutoModRuleProperties> func, RequestOptions options = null) | |||
=> GuildHelper.ModifyRuleAsync(Discord, this, func, options); | |||
/// <inheritdoc/> | |||
public Task DeleteAsync(RequestOptions options = null) | |||
=> GuildHelper.DeleteRuleAsync(Discord, this, options); | |||
#region IAutoModRule | |||
IReadOnlyCollection<ulong> IAutoModRule.ExemptRoles => ExemptRoles.Select(x => x.Id).ToImmutableArray(); | |||
IReadOnlyCollection<ulong> IAutoModRule.ExemptChannels => ExemptChannels.Select(x => x.Id).ToImmutableArray(); | |||
ulong IAutoModRule.GuildId => Guild.Id; | |||
ulong IAutoModRule.CreatorId => _creatorId; | |||
#endregion | |||
} | |||
} |
@@ -43,6 +43,7 @@ namespace Discord.WebSocket | |||
private ConcurrentDictionary<ulong, SocketVoiceState> _voiceStates; | |||
private ConcurrentDictionary<ulong, SocketCustomSticker> _stickers; | |||
private ConcurrentDictionary<ulong, SocketGuildEvent> _events; | |||
//private ConcurrentDictionary<ulong, SocketAutoModRule> _automodRules; | |||
private ImmutableArray<GuildEmote> _emotes; | |||
private AudioClient _audioClient; | |||