Skip to content

Commit

Permalink
Run AutoMod-blocked messages through autowarn filters (#217)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
FloatingMilkshake and Erisa authored Aug 19, 2024
1 parent 44c0cbd commit fd7fb66
Show file tree
Hide file tree
Showing 6 changed files with 432 additions and 255 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 fd7fb66

Please sign in to comment.