Skip to content

Commit fd7fb66

Browse files
Run AutoMod-blocked messages through autowarn filters (#217)
* Run AutoMod-blocked messages through autowarn filters * Apply suggestions from code review Co-authored-by: Erisa A <[email protected]> * Rephrase too many emoji/lines warning msgs for AutoMod-blocked msgs * Hide button to show content for automodded msgs w/ too many lines * Avoid unnecessary code --------- Co-authored-by: Erisa A <[email protected]>
1 parent 44c0cbd commit fd7fb66

6 files changed

+432
-255
lines changed

Events/AutoModEvents.cs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace Cliptok.Events
2+
{
3+
public class AutoModEvents
4+
{
5+
public static async Task AutoModerationRuleExecuted(DiscordClient client, AutoModerationRuleExecutedEventArgs e)
6+
{
7+
if (e.Rule.Action.Type == DiscordRuleActionType.BlockMessage)
8+
{
9+
// AutoMod blocked a message. Pass it to the message handler to run it through some filters anyway.
10+
11+
var author = await client.GetUserAsync(e.Rule.UserId);
12+
var channel = await client.GetChannelAsync(e.Rule.ChannelId!.Value);
13+
14+
// Create a "mock" message object to pass to the message handler, since we don't have the actual message object
15+
var message = new MockDiscordMessage(author: author, channel: channel, channelId: channel.Id, content: e.Rule.Content);
16+
17+
// Pass to the message handler
18+
await MessageEvent.MessageHandlerAsync(client, message, channel, false, true, true);
19+
}
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)