From 647c2eb85a47ceabb4971cd802b119829778861f Mon Sep 17 00:00:00 2001 From: Dragory <2606411+Dragory@users.noreply.github.com> Date: Mon, 3 May 2021 20:41:39 +0300 Subject: [PATCH] Fix !counters reset_all not also removing triggers --- backend/src/data/GuildCounters.ts | 4 ++++ .../src/plugins/Counters/commands/ResetAllCounterValuesCmd.ts | 3 +++ 2 files changed, 7 insertions(+) diff --git a/backend/src/data/GuildCounters.ts b/backend/src/data/GuildCounters.ts index 92395e0f..2d689295 100644 --- a/backend/src/data/GuildCounters.ts +++ b/backend/src/data/GuildCounters.ts @@ -532,5 +532,9 @@ export class GuildCounters extends BaseGuildRepository { await this.counterValues.delete({ counter_id: counterId, }); + + await this.counterTriggers.delete({ + counter_id: counterId, + }); } } diff --git a/backend/src/plugins/Counters/commands/ResetAllCounterValuesCmd.ts b/backend/src/plugins/Counters/commands/ResetAllCounterValuesCmd.ts index 25ff5ec4..c6f518b2 100644 --- a/backend/src/plugins/Counters/commands/ResetAllCounterValuesCmd.ts +++ b/backend/src/plugins/Counters/commands/ResetAllCounterValuesCmd.ts @@ -8,6 +8,7 @@ import { confirm, resolveUser, trimMultilineString, UnknownUser } from "../../.. import { changeCounterValue } from "../functions/changeCounterValue"; import { setCounterValue } from "../functions/setCounterValue"; import { resetAllCounterValues } from "../functions/resetAllCounterValues"; +import { counterIdLock } from "../../../utils/lockNameHelpers"; export const ResetAllCounterValuesCmd = guildCommand()({ trigger: ["counters reset_all"], @@ -47,7 +48,9 @@ export const ResetAllCounterValuesCmd = guildCommand()({ return; } + const lock = await pluginData.locks.acquire(counterIdLock(counterId)); await resetAllCounterValues(pluginData, args.counterName); + lock.unlock(); sendSuccessMessage(pluginData, message.channel, `All counter values for **${counterName}** have been reset`); },