-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run AutoMod-blocked messages through autowarn filters
- Loading branch information
1 parent
39674f3
commit d5c6de3
Showing
6 changed files
with
396 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.