Remora.Discord
Remora.Discord copied to clipboard
[WIP] Auto Moderation
Implements the new Auto Moderation API.
REST
- [x] Write REST objects
- [x]
IDiscordAutoModerationAPI.ListAutoModerationRulesAsync
- [x]
IDiscordAutoModerationAPI.GetAutoModerationRuleAsync
- [x]
IDiscordAutoModerationAPI.CreateAutoModerationRuleAsync
- [x]
IDiscordAutoModerationAPI.ModifyAutoModerationRuleAsync
- [x]
IDiscordAutoModerationAPI.DeleteAutoModerationRuleAsync
- [x] Write JSON converters
- [x] Add API to
AddDiscordRest
- [X] Tests
- [x] https://github.com/discord/discord-api-docs/pull/5070
- [ ] https://github.com/discord/discord-api-docs/pull/5090
- [x] https://github.com/discord/discord-api-docs/pull/5116
Gateway
- [x]
IAutoModerationRuleCreate
- [x]
IAutoModerationRuleUpdate
- [x]
IAutoModerationRuleDelete
- [x]
IAutoModerationActionExecution
- [x] Write JSON converters
- [X] Tests
Audit Log
- [x]
AuditLogEvent.AutoModerationRuleCreate
- [x]
AuditLogEvent.AutoModerationRuleUpdate
- [x]
AuditLogEvent.AutoModerationRuleDelete
- [x]
AuditLogEvent.AutoModerationMessageBlock
- [x]
IAuditLog.AutoModerationRules
- [x] Tests
Messages
Guilds
Intents
- [x]
AutoModerationConfiguration
(1 << 20)
- [x]
AutoModerationExecution
(1 << 21)
Other Considerations (out of scope of this PR)
There is a weird, hacky pattern-matching thing Discord has made called keyword matching strategies. Someone might considering adding helper methods for this in Remora.Discord.Extensions
.
I think the endpoints should be under IDiscordAutoModerationAPI
.
As the API class is determined by the resource of the Discord docs, even if the base endpoint of Discord API is /guilds
.
In addition the methods should be named the same as in the documentation:
List Auto Moderation Rules for Guild
=> ListAutoModerationRulesForGuildAsync
.
I did not find any example in the current code that does not adhere to this.
I think the endpoints should be under
IDiscordAutoModerationAPI
. As the API class is determined by the resource of the Discord docs, even if the base endpoint of Discord API is/guilds
.
I also think this so thanks. I'll move those over.
In addition the methods should be named the same as in the documentation:
List Auto Moderation Rules for Guild
=>ListAutoModerationRulesForGuildAsync
. I did not find any example in the current code that does not adhere to this.
Nice catch! I didn't realise this.
Should tests be included in this PR?
Should tests be included in this PR?
I would say so
Just added the tests - would really appreciate a review!
As soon as Discord addresses the following pull requests, this should be good to merge after a couple of minor additions. https://github.com/discord/discord-api-docs/pull/5070 https://github.com/discord/discord-api-docs/pull/5090
I would rather rename IDiscordRestAutoModerationAPI
to IDiscordRestGuildAutoModerationAPI
since they are guild only anyways.
@AraHaan For conciseness, DiscordAutoMod
could be better.
Yes, but there still needs to have an interface that defines what goes into it and it must start with I
in it's interface name (because of C#'s interface naming rules).
The name should match the documentation category in Discord's docs.
While checking the docs I noticed that with AutoMod also a new messager type was added: https://discord.com/developers/docs/resources/channel#message-object-message-types
@MazeXP That is for the timeline indicators of the automod action, messages of that type can be ignored by bots.
@erkinalp If it is documented then it should also be part of the enum in Remora.Discord. That is one of its goals.
The AuditLog
object also has a new field related to AutoMod: https://discord.com/developers/docs/resources/audit-log#audit-log-object
GuildFeature
does also have a new element related to AutoMod: https://discord.com/developers/docs/resources/guild#guild-object-guild-features
@Hamsterland Discord merged 5070 into their docs.
And it looks like 5116 was merged recently as well.
As soon as discord/discord-api-docs#5090 goes in, I'm happy to merge. No need to stress things, @AraHaan.
@Nihlus AutoMod is already enabled in all guilds.
@Nihlus AutoMod is already enabled in all guilds.
And the aforementioned PR is yet to be merged.
@Nihlus AutoMod is already enabled in all guilds.
@Nihlus AutoMod is already enabled in all guilds.
And the aforementioned PR is yet to be merged.
Yeah, as it is, the documentation does not reflect the real behaviour of the API. Until that is corrected, I'd prefer not to merge this PR.
Opened PR to the docs that still wait to be merged so it can be merged (hopefully). https://github.com/Hamsterland/discord-api-docs/pull/1
This PR should also be taken into account: https://github.com/discord/discord-api-docs/pull/5242 The optionality is also already worded in this commit: https://github.com/discord/discord-api-docs/commit/a003d94dbd21af355703b4b3456e6fe09ff3e3dd
Is there is news about this recently?
@Hamsterland I think we can merge this now, even though Discord has bad docs. They have clarified and confirmed that the fields should be optional; now it's just a matter of fixing the documentation.