[Feature] AutoMod support (#2578)

* initial implementation

* update models

* somewhat working auto mod action executed event

* made some properties optional

* comments, rest entity, guild methods

* add placeholder methods

* started working on rule cache

* working events

* started working on rule builder

* working state

* fix null issue

* commentsssss

* public automod rules collection in a socketgulild

* forgot nullability

* update limits

* add Download func to cacheable user

* Apply suggestions from code review

* Update src/Discord.Net.Rest/DiscordRestApiClient.cs

* missing xml doc

* reworkkkk

* fix the `;` lol

---------

Co-authored-by: Quin Lynch <lynchquin@gmail.com>
Co-authored-by: Casmir <68127614+csmir@users.noreply.github.com>
This commit is contained in:
Misha133
2023-02-16 19:08:47 +03:00
committed by GitHub
parent 0c27395efd
commit 673b02dd36
26 changed files with 1478 additions and 1 deletions

View File

@@ -1197,6 +1197,34 @@ namespace Discord.Rest
RequestOptions options = null)
=> GuildHelper.CreateGuildEventAsync(Discord, this, name, privacyLevel, startTime, type, description, endTime, channelId, location, coverImage, options);
#endregion
#region AutoMod
/// <inheritdoc cref="IGuild.GetAutoModRuleAsync"/>
public async Task<RestAutoModRule> GetAutoModRuleAsync(ulong ruleId, RequestOptions options = null)
{
var rule = await GuildHelper.GetAutoModRuleAsync(ruleId, this, Discord, options);
return RestAutoModRule.Create(Discord, rule);
}
/// <inheritdoc cref="IGuild.GetAutoModRulesAsync"/>
public async Task<RestAutoModRule[]> GetAutoModRulesAsync(RequestOptions options = null)
{
var rules = await GuildHelper.GetAutoModRulesAsync(this, Discord, options);
return rules.Select(x => RestAutoModRule.Create(Discord, x)).ToArray();
}
/// <inheritdoc cref="IGuild.CreateAutoModRuleAsync"/>
public async Task<RestAutoModRule> CreateAutoModRuleAsync(Action<AutoModRuleProperties> props, RequestOptions options = null)
{
var rule = await GuildHelper.CreateAutoModRuleAsync(this, props, Discord, options);
return RestAutoModRule.Create(Discord, rule);
}
#endregion
#region IGuild
@@ -1543,6 +1571,19 @@ namespace Discord.Rest
public Task<WelcomeScreen> ModifyWelcomeScreenAsync(bool enabled, WelcomeScreenChannelProperties[] channels, string description = null, RequestOptions options = null)
=> GuildHelper.ModifyWelcomeScreenAsync(enabled, description, channels, this, Discord, options);
/// <inheritdoc/>
async Task<IAutoModRule> IGuild.GetAutoModRuleAsync(ulong ruleId, RequestOptions options)
=> await GetAutoModRuleAsync(ruleId, options).ConfigureAwait(false);
/// <inheritdoc/>
async Task<IAutoModRule[]> IGuild.GetAutoModRulesAsync(RequestOptions options)
=> await GetAutoModRulesAsync(options).ConfigureAwait(false);
/// <inheritdoc/>
async Task<IAutoModRule> IGuild.CreateAutoModRuleAsync(Action<AutoModRuleProperties> props, RequestOptions options)
=> await CreateAutoModRuleAsync(props, options).ConfigureAwait(false);
#endregion
}
}