From 7825487b010866bb79890c3fc32eca6bb442185b Mon Sep 17 00:00:00 2001 From: Peter-MJ-Parker <34216187+Peter-MJ-Parker@users.noreply.github.com> Date: Sun, 25 Feb 2024 07:27:48 -0600 Subject: [PATCH] Update CommandHandler.ts This change fixes a bug with the cooldowns map. I have only ran into it once but I tried to throw the error where the cooldown type is used outside of a guild with the user attached. It threw the error and tried to attach the expiry time of 7 minutes. When I have the dbRequired set to 5 minutes, it will try to input the info to mongo. Since it sent "ERROR" to the db, it also tried to input the time but it failed and sent a mongo error stating it could not insert a string to Date property. --- src/command-handler/CommandHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command-handler/CommandHandler.ts b/src/command-handler/CommandHandler.ts index 2a2f8f8..7d6c363 100644 --- a/src/command-handler/CommandHandler.ts +++ b/src/command-handler/CommandHandler.ts @@ -219,7 +219,7 @@ class CommandHandler { const result = this._instance.cooldowns?.canRunAction(cooldownUsage) - if (typeof result === 'string') { + if (typeof result === 'string' && result !== "ERROR") { return result }