3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00
zeppelin/backend/src/plugins/Automod/triggers/antiraidLevel.ts

34 lines
813 B
TypeScript
Raw Normal View History

2021-04-02 17:53:16 +03:00
import * as t from "io-ts";
import { tNullable } from "../../../utils";
import { automodTrigger } from "../helpers";
2021-04-02 17:53:16 +03:00
// tslint:disable-next-line
interface AntiraidLevelTriggerResult {}
export const AntiraidLevelTrigger = automodTrigger<AntiraidLevelTriggerResult>()({
configType: t.type({
level: tNullable(t.string),
}),
defaultConfig: {},
async match({ triggerConfig, context, pluginData }) {
if (!context.antiraid) {
return;
}
if (context.antiraid.level !== triggerConfig.level) {
return;
}
return {
extra: {},
};
},
renderMatchInformation({ matchResult, pluginData, contexts, triggerConfig }) {
2021-04-02 19:50:37 +03:00
const newLevel = contexts[0].antiraid!.level;
return newLevel ? `Antiraid level was set to ${newLevel}` : `Antiraid was turned off`;
2021-04-02 17:53:16 +03:00
},
});