2021-04-02 17:53:16 +03:00
|
|
|
import * as t from "io-ts";
|
|
|
|
import { tNullable } from "../../../utils";
|
2021-06-06 23:51:32 +02:00
|
|
|
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
|
|
|
},
|
|
|
|
});
|