From bff208d560328e4599f1e6f40bd58c68806e2a64 Mon Sep 17 00:00:00 2001 From: "Ean Milligan (Bastion)" Date: Wed, 22 Jun 2022 02:06:50 -0400 Subject: [PATCH] add catches to all messages --- src/commands/roll/getModifiers.ts | 12 +++++++++--- src/solver/rollQueue.ts | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/commands/roll/getModifiers.ts b/src/commands/roll/getModifiers.ts index db165ae..2be1016 100644 --- a/src/commands/roll/getModifiers.ts +++ b/src/commands/roll/getModifiers.ts @@ -62,7 +62,9 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri } if (modifiers.gms.length < 1) { // If -gm is on and none were found, throw an error - m.edit(generateRollError(errorType, 'Must specifiy at least one GM by @mentioning them')); + m.edit(generateRollError(errorType, 'Must specifiy at least one GM by @mentioning them')).catch((e) => { + log(LT.ERROR, `Failed to edit message: ${JSON.stringify(m)} | ${JSON.stringify(e)}`); + }); if (DEVMODE && config.logRolls) { // If enabled, log rolls so we can verify the bots math @@ -79,7 +81,9 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri if (!args[i] || args[i].toLowerCase()[0] !== 'd' && args[i].toLowerCase()[0] !== 'a') { // If -o is on and asc or desc was not specified, error out - m.edit(generateRollError(errorType, 'Must specifiy `a` or `d` to order the rolls ascending or descending')); + m.edit(generateRollError(errorType, 'Must specifiy `a` or `d` to order the rolls ascending or descending')).catch((e) => { + log(LT.ERROR, `Failed to edit message: ${JSON.stringify(m)} | ${JSON.stringify(e)}`); + }); if (DEVMODE && config.logRolls) { // If enabled, log rolls so we can verify the bots math @@ -106,7 +110,9 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri // maxRoll and nominalRoll cannot both be on, throw an error if (modifiers.maxRoll && modifiers.nominalRoll) { - m.edit(generateRollError(errorType, 'Cannot maximise and nominise the roll at the same time')); + m.edit(generateRollError(errorType, 'Cannot maximise and nominise the roll at the same time')).catch((e) => { + log(LT.ERROR, `Failed to edit message: ${JSON.stringify(m)} | ${JSON.stringify(e)}`); + }); if (DEVMODE && config.logRolls) { // If enabled, log rolls so we can verify the bots math diff --git a/src/solver/rollQueue.ts b/src/solver/rollQueue.ts index 479b898..b334752 100644 --- a/src/solver/rollQueue.ts +++ b/src/solver/rollQueue.ts @@ -47,6 +47,8 @@ const handleRollWorker = async (rq: QueuedRoll) => { {}, )).embed, ], + }).catch((e) => { + log(LT.ERROR, `Failed to edit message: ${JSON.stringify(rq.dd.m)} | ${JSON.stringify(e)}`); }); } }, config.limits.workerTimeout);