This repository has been archived by the owner on Oct 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47fc679
commit 2694c16
Showing
5 changed files
with
47 additions
and
1 deletion.
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
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,35 @@ | ||
import { AutoModerationActionType } from "discord.js"; | ||
import { GuildFeatures, ModerationAction } from "@prisma/client"; | ||
import type { MeteoriumEvent } from "./eventsEntry.js"; | ||
|
||
export const Event: MeteoriumEvent<"autoModerationActionExecution"> = { | ||
event: "autoModerationActionExecution", | ||
async callback(client, exec) { | ||
const guildSettings = await client.db.guild.findUnique({ where: { GuildId: exec.guild.id } }); | ||
if (!guildSettings) throw new Error("could not get settings from database"); | ||
if (!guildSettings.CreateCaseFromAutoMod) return; | ||
if (!client.guildFeatures.hasFeatureEnabled(exec.guild.id, GuildFeatures.Moderation)) return; | ||
|
||
const rule = | ||
exec.autoModerationRule || (await exec.guild.autoModerationRules.fetch(exec.ruleId).catch(() => null)); | ||
if (!rule) return; | ||
|
||
await client.dbUtils.createModerationCase({ | ||
Action: | ||
exec.action.type == AutoModerationActionType.Timeout ? ModerationAction.Mute : ModerationAction.Warn, | ||
GuildId: exec.guild.id, | ||
TargetUserId: exec.userId, | ||
ModeratorUserId: rule.creatorId, | ||
Reason: `Automatically generated case from Auto Moderation (automod) trigger:\n${rule.name}`, | ||
Duration: | ||
exec.action.type == AutoModerationActionType.Timeout | ||
? exec.action.metadata.durationSeconds | ||
? (exec.action.metadata.durationSeconds * 1000).toString() | ||
: "0" | ||
: undefined, | ||
}); | ||
|
||
return; | ||
}, | ||
once: false, | ||
}; |
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
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
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