Remora.Discord icon indicating copy to clipboard operation
Remora.Discord copied to clipboard

[WIP] Auto Moderation

Open Hamsterland opened this issue 2 years ago • 25 comments

Implements the new Auto Moderation API.

REST

Gateway

Audit Log

Messages

Guilds

Intents

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.

Hamsterland avatar Jun 16 '22 21:06 Hamsterland

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.

MazeXP avatar Jun 17 '22 11:06 MazeXP

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.

MazeXP avatar Jun 17 '22 11:06 MazeXP

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.

Hamsterland avatar Jun 17 '22 14:06 Hamsterland

Should tests be included in this PR?

Hamsterland avatar Jun 18 '22 17:06 Hamsterland

Should tests be included in this PR?

I would say so

MazeXP avatar Jun 18 '22 17:06 MazeXP

Just added the tests - would really appreciate a review!

Hamsterland avatar Jun 19 '22 21:06 Hamsterland

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

Hamsterland avatar Jun 20 '22 21:06 Hamsterland

I would rather rename IDiscordRestAutoModerationAPI to IDiscordRestGuildAutoModerationAPI since they are guild only anyways.

AraHaan avatar Jun 20 '22 22:06 AraHaan

@AraHaan For conciseness, DiscordAutoMod could be better.

erkinalp avatar Jun 24 '22 16:06 erkinalp

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).

AraHaan avatar Jun 24 '22 16:06 AraHaan

The name should match the documentation category in Discord's docs.

Nihlus avatar Jun 24 '22 18:06 Nihlus

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 image

MazeXP avatar Jun 26 '22 13:06 MazeXP

@MazeXP That is for the timeline indicators of the automod action, messages of that type can be ignored by bots.

erkinalp avatar Jun 26 '22 13:06 erkinalp

@erkinalp If it is documented then it should also be part of the enum in Remora.Discord. That is one of its goals.

MazeXP avatar Jun 26 '22 13:06 MazeXP

The AuditLog object also has a new field related to AutoMod: https://discord.com/developers/docs/resources/audit-log#audit-log-object image

MazeXP avatar Jun 26 '22 13:06 MazeXP

GuildFeature does also have a new element related to AutoMod: https://discord.com/developers/docs/resources/guild#guild-object-guild-features image

MazeXP avatar Jun 26 '22 14:06 MazeXP

@Hamsterland Discord merged 5070 into their docs.

AraHaan avatar Jul 03 '22 19:07 AraHaan

And it looks like 5116 was merged recently as well.

AraHaan avatar Jul 18 '22 06:07 AraHaan

As soon as discord/discord-api-docs#5090 goes in, I'm happy to merge. No need to stress things, @AraHaan.

Nihlus avatar Jul 20 '22 21:07 Nihlus

@Nihlus AutoMod is already enabled in all guilds.

erkinalp avatar Jul 21 '22 10:07 erkinalp

@Nihlus AutoMod is already enabled in all guilds.

And the aforementioned PR is yet to be merged.

VelvetToroyashi avatar Jul 21 '22 10:07 VelvetToroyashi

@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.

Nihlus avatar Jul 21 '22 10:07 Nihlus

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

AraHaan avatar Jul 23 '22 06:07 AraHaan

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

MazeXP avatar Jul 25 '22 08:07 MazeXP

Is there is news about this recently?

AraHaan avatar Sep 01 '22 22:09 AraHaan

@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.

Nihlus avatar Oct 08 '22 12:10 Nihlus