Counters v0.9
Includes automod trigger/action. No user-facing commands yet.
This commit is contained in:
parent
ec37cf27a2
commit
c3407e2d5d
29 changed files with 1387 additions and 3 deletions
46
backend/src/plugins/Automod/triggers/counter.ts
Normal file
46
backend/src/plugins/Automod/triggers/counter.ts
Normal file
|
@ -0,0 +1,46 @@
|
|||
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({
|
||||
name: t.string,
|
||||
condition: t.string,
|
||||
reverse: tNullable(t.boolean),
|
||||
}),
|
||||
|
||||
defaultConfig: {},
|
||||
|
||||
async match({ triggerConfig, context, pluginData }) {
|
||||
if (!context.counterTrigger) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.counterTrigger.name !== triggerConfig.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (context.counterTrigger.condition !== triggerConfig.condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
const reverse = triggerConfig.reverse ?? false;
|
||||
if (context.counterTrigger.reverse !== reverse) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
extra: {},
|
||||
};
|
||||
},
|
||||
|
||||
renderMatchInformation({ matchResult, pluginData, contexts, triggerConfig }) {
|
||||
// TODO: Show user, channel, reverse
|
||||
return `Matched counter \`${triggerConfig.name} ${triggerConfig.condition}\``;
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue