mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 20:35:02 +00:00
Add commands to list and reset counters
This commit is contained in:
parent
25a3350196
commit
a568e86d78
8 changed files with 258 additions and 2 deletions
|
@ -0,0 +1,18 @@
|
|||
import { GuildPluginData } from "knub";
|
||||
import { counterIdLock } from "../../../utils/lockNameHelpers";
|
||||
import { CountersPluginType } from "../types";
|
||||
|
||||
export async function resetAllCounterValues(pluginData: GuildPluginData<CountersPluginType>, counterName: string) {
|
||||
const config = pluginData.config.get();
|
||||
const counter = config.counters[counterName];
|
||||
if (!counter) {
|
||||
throw new Error(`Unknown counter: ${counterName}`);
|
||||
}
|
||||
|
||||
const counterId = pluginData.state.counterIds[counterName];
|
||||
const lock = await pluginData.locks.acquire(counterIdLock(counterId));
|
||||
|
||||
await pluginData.state.counters.resetAllCounterValues(counterId);
|
||||
|
||||
lock.unlock();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue