Skip to content

Commit

Permalink
Run AutoMod-blocked messages through autowarn filters
Browse files Browse the repository at this point in the history
  • Loading branch information
FloatingMilkshake committed Aug 15, 2024
1 parent 39674f3 commit d5c6de3
Show file tree
Hide file tree
Showing 6 changed files with 396 additions and 243 deletions.
22 changes: 22 additions & 0 deletions Events/AutoModEvents.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Cliptok.Events
{
public class AutoModEvents
{
public static async Task AutoModerationRuleExecuted(DiscordClient client, AutoModerationRuleExecutedEventArgs e)
{
if (e.Rule.Action.Type == DiscordRuleActionType.BlockMessage)
{
// AutoMod blocked a message. Pass it to the message handler to run it through some filters anyway.

var author = await client.GetUserAsync(e.Rule.UserId);
var channel = await client.GetChannelAsync(e.Rule.ChannelId!.Value);

// Create a "mock" message object to pass to the message handler, since we don't have the actual message object
var message = new MockDiscordMessage(author: author, channel: channel, channelId: channel.Id, content: e.Rule.Content);

// Pass to the message handler
await MessageEvent.MessageHandlerAsync(client, message, channel, false, true, true);
}
}
}
}
Loading

0 comments on commit d5c6de3

Please sign in to comment.