Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run AutoMod-blocked messages through autowarn filters #217

Merged
merged 7 commits into from
Aug 19, 2024
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
Loading