mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 04:25:01 +00:00
Fix error when using an unknown counter from Automod
This commit is contained in:
parent
8763a06ef1
commit
ad8aab3937
4 changed files with 28 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
import * as t from "io-ts";
|
||||
import { automodAction } from "../helpers";
|
||||
import { CountersPlugin } from "../../Counters/CountersPlugin";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
|
||||
export const AddToCounterAction = automodAction({
|
||||
configType: t.type({
|
||||
|
@ -10,8 +11,15 @@ export const AddToCounterAction = automodAction({
|
|||
|
||||
defaultConfig: {},
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult }) {
|
||||
async apply({ pluginData, contexts, actionConfig, matchResult, ruleName }) {
|
||||
const countersPlugin = pluginData.getPlugin(CountersPlugin);
|
||||
if (!countersPlugin.counterExists(actionConfig.counter)) {
|
||||
pluginData.state.logs.log(LogType.BOT_ALERT, {
|
||||
body: `Unknown counter \`${actionConfig.counter}\` in \`add_to_counter\` action of Automod rule \`${ruleName}\``,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
countersPlugin.changeCounterValue(
|
||||
actionConfig.counter,
|
||||
contexts[0].message?.channel_id || null,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue