3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-11 04:45:02 +00:00
zeppelin/backend/src/plugins/Counters/functions/checkCounterTrigger.ts

17 lines
656 B
TypeScript

import { GuildPluginData } from "knub";
import { CounterTrigger } from "../../../data/entities/CounterTrigger";
import { CountersPluginType } from "../types";
import { emitCounterEvent } from "./emitCounterEvent";
export async function checkCounterTrigger(
pluginData: GuildPluginData<CountersPluginType>,
counterName: string,
counterTrigger: CounterTrigger,
channelId: string | null,
userId: string | null,
) {
const triggered = await pluginData.state.counters.checkForTrigger(counterTrigger, channelId, userId);
if (triggered) {
await emitCounterEvent(pluginData, "trigger", counterName, counterTrigger.name, channelId, userId);
}
}