Add counter documentation/examples. Tweak counter triggers/actions in automod.
Rename change_counter automod action to add_to_counter, add set_counter action, rename counter trigger to counter_trigger.
This commit is contained in:
parent
ab8ea2e7e5
commit
4147298120
9 changed files with 347 additions and 16 deletions
52
backend/src/plugins/Automod/triggers/counterTrigger.ts
Normal file
52
backend/src/plugins/Automod/triggers/counterTrigger.ts
Normal file
|
@ -0,0 +1,52 @@
|
|||
import * as t from "io-ts";
|
||||
import { automodTrigger } from "../helpers";
|
||||
import { consumeIgnoredRoleChange } from "../functions/ignoredRoleChanges";
|
||||
import { CountersPlugin } from "../../Counters/CountersPlugin";
|
||||
import { tNullable } from "../../../utils";
|
||||
|
||||
// tslint:disable-next-line
|
||||
interface CounterTriggerResult {}
|
||||
|
||||
export const CounterTrigger = automodTrigger<CounterTriggerResult>()({
|
||||
configType: t.type({
|
||||
counter: t.string,
|
||||
trigger: t.string,
|
||||
reverse: tNullable(t.boolean),
|
||||
}),
|
||||
|
||||
defaultConfig: {},
|
||||
|
||||
async match({ triggerConfig, context, pluginData }) {
|
||||
if (!context.counterTrigger) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.counterTrigger.counter !== triggerConfig.counter) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.counterTrigger.trigger !== triggerConfig.trigger) {
|
||||
return;
|
||||
}
|
||||
|
||||
const reverse = triggerConfig.reverse ?? false;
|
||||
if (context.counterTrigger.reverse !== reverse) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
extra: {},
|
||||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult, pluginData, contexts, triggerConfig }) {
|
||||
let str = `Matched counter trigger \`${contexts[0].counterTrigger!.prettyCounter} / ${
|
||||
contexts[0].counterTrigger!.prettyTrigger
|
||||
}\``;
|
||||
if (contexts[0].counterTrigger!.reverse) {
|
||||
str += " (reverse)";
|
||||
}
|
||||
|
||||
return str;
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue