2021-02-13 17:29:10 +02:00
|
|
|
import * as t from "io-ts";
|
|
|
|
import { automodAction } from "../helpers";
|
|
|
|
import { CountersPlugin } from "../../Counters/CountersPlugin";
|
|
|
|
|
2021-04-02 17:44:21 +03:00
|
|
|
export const SetCounterAction = automodAction({
|
2021-02-13 17:29:10 +02:00
|
|
|
configType: t.type({
|
2021-04-02 17:44:21 +03:00
|
|
|
counter: t.string,
|
|
|
|
value: t.number,
|
2021-02-13 17:29:10 +02:00
|
|
|
}),
|
|
|
|
|
|
|
|
defaultConfig: {},
|
|
|
|
|
|
|
|
async apply({ pluginData, contexts, actionConfig, matchResult }) {
|
|
|
|
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
2021-04-02 17:44:21 +03:00
|
|
|
countersPlugin.setCounterValue(
|
|
|
|
actionConfig.counter,
|
2021-02-13 17:29:10 +02:00
|
|
|
contexts[0].message?.channel_id || null,
|
|
|
|
contexts[0].user?.id || null,
|
2021-04-02 17:44:21 +03:00
|
|
|
actionConfig.value,
|
2021-02-13 17:29:10 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|