From e553042e8834fa7f780581d37203913af15ea4fe Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Wed, 30 Jul 2025 00:42:06 -0400 Subject: [PATCH] Fixed !>5 not working correctly (was misidentified as a numberless option) and added some additional debug to help id issues with tsep parsing in the future --- config.example.ts | 2 +- src/artigen/dice/getRollConf.ts | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/config.example.ts b/config.example.ts index 109b96f..6dcb702 100644 --- a/config.example.ts +++ b/config.example.ts @@ -1,7 +1,7 @@ export const config = { name: 'The Artificer', // Name of the bot maxFileSize: 8_388_290, // Max file size bot can send - version: '4.0.0', // Version of the bot + version: '4.0.1', // Version of the bot token: 'the_bot_token', // Discord API Token for this bot localtoken: 'local_testing_token', // Discord API Token for a secondary OPTIONAL testing bot, THIS MUST BE DIFFERENT FROM "token" prefix: '[[', // Prefix for all commands diff --git a/src/artigen/dice/getRollConf.ts b/src/artigen/dice/getRollConf.ts index f78dbae..a9534ec 100644 --- a/src/artigen/dice/getRollConf.ts +++ b/src/artigen/dice/getRollConf.ts @@ -227,20 +227,27 @@ export const getRollConf = (rollStr: string, customTypes: CustomDiceShapes = new // Determine if afterSepIdx needs to be moved up (cases like mt! or !mt) const tempSep = remains.slice(0, afterSepIdx); + loggingEnabled && log(LT.LOG, `tempSep: ${tempSep}`); + let noNumberAfter = false; - NumberlessDiceOptions.some((opt) => { - loopCountCheck(); - if (tempSep.startsWith(opt) && tempSep !== opt) { - afterSepIdx = opt.length; - noNumberAfter = true; - return true; - } - return tempSep === opt; - }); + if (!(Object.values(DiceOptions) as string[]).includes(tempSep)) { + NumberlessDiceOptions.some((opt) => { + loopCountCheck(); + loggingEnabled && log(LT.LOG, `In NumberlessDiceOptions ${opt} ${tempSep.startsWith(opt) && tempSep !== opt}`); + if (tempSep.startsWith(opt) && tempSep !== opt) { + afterSepIdx = opt.length; + noNumberAfter = true; + return true; + } + return tempSep === opt; + }); + } // Save the rule name to tSep and remove it from remains const tSep = remains.slice(0, afterSepIdx); remains = remains.slice(afterSepIdx); + loggingEnabled && log(LT.LOG, `tSep: ${tSep}, remains: ${remains}`); + // Find the next non-number in the remains to be able to cut out the count/num let afterNumIdx = noNumberAfter ? 0 : remains.search(/(?![-\d])/); if (afterNumIdx < 0) {