diff --git a/src/data/DefaultLogMessages.json b/src/data/DefaultLogMessages.json index b0291d5c..9aeb8081 100644 --- a/src/data/DefaultLogMessages.json +++ b/src/data/DefaultLogMessages.json @@ -57,5 +57,6 @@ "SCHEDULED_MESSAGE": "⏰ {userMention(author)} scheduled a message to be posted to {channelMention(channel)} on {date} at {time} (UTC)", "POSTED_SCHEDULED_MESSAGE": "\uD83D\uDCE8 Posted scheduled message (`{messageId}`) to {channelMention(channel)} as scheduled by {userMention(author)}", - "BOT_ALERT": "⚠ {tmplEval(body)}" + "BOT_ALERT": "⚠ {tmplEval(body)}", + "AUTOMOD_ALERT": "{text}" } diff --git a/src/data/LogType.ts b/src/data/LogType.ts index f08cc964..69a62bda 100644 --- a/src/data/LogType.ts +++ b/src/data/LogType.ts @@ -58,4 +58,5 @@ export enum LogType { POSTED_SCHEDULED_MESSAGE, BOT_ALERT, + AUTOMOD_ALERT, } diff --git a/src/plugins/Automod.ts b/src/plugins/Automod.ts index 5b90959f..0ed2dcc2 100644 --- a/src/plugins/Automod.ts +++ b/src/plugins/Automod.ts @@ -20,6 +20,8 @@ import { Queue } from "../Queue"; import Timeout = NodeJS.Timeout; import { ModActionsPlugin } from "./ModActions"; import { MutesPlugin } from "./Mutes"; +import { LogsPlugin } from "./Logs"; +import { LogType } from "../data/LogType"; type MessageInfo = { channelId: string; messageId: string }; @@ -310,7 +312,7 @@ const inviteCache = new SimpleCache(10 * MINUTES); export class AutomodPlugin extends ZeppelinPlugin { public static pluginName = "automod"; public static configSchema = ConfigSchema; - public static dependencies = ["mod_actions", "mutes"]; + public static dependencies = ["mod_actions", "mutes", "logs"]; protected unloaded = false; @@ -330,6 +332,7 @@ export class AutomodPlugin extends ZeppelinPlugin { protected modActions: ModActionsPlugin; protected mutes: MutesPlugin; + protected logs: LogsPlugin; protected static preprocessStaticConfig(config) { if (config.rules && typeof config.rules === "object") { @@ -371,6 +374,7 @@ export class AutomodPlugin extends ZeppelinPlugin { protected onLoad() { this.automodQueue = new Queue(); this.modActions = this.getPlugin("mod_actions"); + this.logs = this.getPlugin("logs"); } protected onUnload() { @@ -850,7 +854,10 @@ export class AutomodPlugin extends ZeppelinPlugin { } } - // TODO: Alert action (and AUTOMOD_ALERT log type) + if (rule.actions.alert) { + const text = rule.actions.alert.text; + this.logs.log(LogType.AUTOMOD_ALERT, { text }); + } } @d.event("messageCreate")