automod: add alert action support
This commit is contained in:
parent
6e67ff8292
commit
85136c11e3
3 changed files with 12 additions and 3 deletions
|
@ -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}"
|
||||
}
|
||||
|
|
|
@ -58,4 +58,5 @@ export enum LogType {
|
|||
POSTED_SCHEDULED_MESSAGE,
|
||||
|
||||
BOT_ALERT,
|
||||
AUTOMOD_ALERT,
|
||||
}
|
||||
|
|
|
@ -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<TConfigSchema> {
|
||||
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<TConfigSchema> {
|
|||
|
||||
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<TConfigSchema> {
|
|||
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<TConfigSchema> {
|
|||
}
|
||||
}
|
||||
|
||||
// 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")
|
||||
|
|
Loading…
Add table
Reference in a new issue