3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 04:25:01 +00:00

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:
Dragory 2021-04-02 17:44:21 +03:00
parent ab8ea2e7e5
commit 4147298120
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1
9 changed files with 347 additions and 16 deletions

View file

@ -0,0 +1,22 @@
import * as t from "io-ts";
import { automodAction } from "../helpers";
import { CountersPlugin } from "../../Counters/CountersPlugin";
export const AddToCounterAction = automodAction({
configType: t.type({
counter: t.string,
amount: t.number,
}),
defaultConfig: {},
async apply({ pluginData, contexts, actionConfig, matchResult }) {
const countersPlugin = pluginData.getPlugin(CountersPlugin);
countersPlugin.changeCounterValue(
actionConfig.counter,
contexts[0].message?.channel_id || null,
contexts[0].user?.id || null,
actionConfig.amount,
);
},
});