diff --git a/mod.ts b/mod.ts index ce73caf..69c3d75 100644 --- a/mod.ts +++ b/mod.ts @@ -303,7 +303,7 @@ startBot({ // [[xdydz (aka someone copy pasted the template as a roll) // Help command specifically for the roll command commands.rollHelp(message); - } else if (command && `${command}${args.join('')}`.indexOf(config.postfix) > -1) { + } else if (command && `${command}${args.join('')}`.includes(config.postfix)) { // [[roll]] // Dice rolling commence! commands.roll(message, args, command); diff --git a/src/commands/emoji.ts b/src/commands/emoji.ts index 5b0c854..5ac4599 100644 --- a/src/commands/emoji.ts +++ b/src/commands/emoji.ts @@ -23,7 +23,7 @@ export const emoji = (message: DiscordenoMessage, command: string) => { config.emojis.some((curEmoji: EmojiConf) => { log(LT.LOG, `Checking if command was emoji ${JSON.stringify(curEmoji)}`); // If a match gets found - if (curEmoji.aliases.indexOf(command || '') > -1) { + if (curEmoji.aliases.includes(command || '')) { // Light telemetry to see how many times a command is being run dbClient.execute(queries.callIncCnt('emojis')).catch((e) => utils.commonLoggers.dbError('emojis.ts:28', 'call sproc INC_CNT on', e)); diff --git a/src/endpoints/puts/apiChannelManageActive.ts b/src/endpoints/puts/apiChannelManageActive.ts index cd08572..140bee9 100644 --- a/src/endpoints/puts/apiChannelManageActive.ts +++ b/src/endpoints/puts/apiChannelManageActive.ts @@ -11,7 +11,7 @@ export const apiChannelManageActive = async (query: Map, apiUser erroredOut = false; // Determine value to set - if (path.toLowerCase().indexOf('de') > 0) { + if (path.toLowerCase().includes('de')) { value = 0; } else { value = 1; diff --git a/src/endpoints/puts/apiChannelManageBan.ts b/src/endpoints/puts/apiChannelManageBan.ts index 282a052..0878734 100644 --- a/src/endpoints/puts/apiChannelManageBan.ts +++ b/src/endpoints/puts/apiChannelManageBan.ts @@ -12,7 +12,7 @@ export const apiChannelManageBan = async (query: Map, apiUserid: erroredOut = false; // Determine value to set - if (path.toLowerCase().indexOf('un') > 0) { + if (path.toLowerCase().includes('un')) { value = 0; } else { value = 1; diff --git a/src/endpoints/puts/apiKeyManage.ts b/src/endpoints/puts/apiKeyManage.ts index 9e30244..0a4d49a 100644 --- a/src/endpoints/puts/apiKeyManage.ts +++ b/src/endpoints/puts/apiKeyManage.ts @@ -13,14 +13,14 @@ export const apiKeyManage = async (query: Map, apiUserid: bigint erroredOut = false; // Determine key to edit - if (path.toLowerCase().indexOf('ban') > 0) { + if (path.toLowerCase().includes('ban')) { key = 'banned'; } else { key = 'active'; } // Determine value to set - if (path.toLowerCase().indexOf('de') > 0 || path.toLowerCase().indexOf('un') > 0) { + if (path.toLowerCase().includes('de') || path.toLowerCase().includes('un')) { value = 0; } else { value = 1; diff --git a/src/solver/roller.ts b/src/solver/roller.ts index 345b0d7..e8ed3e0 100644 --- a/src/solver/roller.ts +++ b/src/solver/roller.ts @@ -411,7 +411,7 @@ export const roll = (rollStr: string, maximizeRoll: boolean, nominalRoll: boolea if (rollConf.keepLow.on && rollConf.keepLow.count === 0) { throw new Error('NoZerosAllowed_keepLow'); } - if (rollConf.reroll.on && rollConf.reroll.nums.indexOf(0) >= 0) { + if (rollConf.reroll.on && rollConf.reroll.nums.includes(0)) { throw new Error('NoZerosAllowed_reroll'); } @@ -466,13 +466,13 @@ export const roll = (rollStr: string, maximizeRoll: boolean, nominalRoll: boolea rolling.origIdx = i; // If critScore arg is on, check if the roll should be a crit, if its off, check if the roll matches the die size - if (rollConf.critScore.on && rollConf.critScore.range.indexOf(rolling.roll) >= 0) { + if (rollConf.critScore.on && rollConf.critScore.range.includes(rolling.roll)) { rolling.critHit = true; } else if (!rollConf.critScore.on) { rolling.critHit = rolling.roll === rollConf.dieSize; } // If critFail arg is on, check if the roll should be a fail, if its off, check if the roll matches 1 - if (rollConf.critFail.on && rollConf.critFail.range.indexOf(rolling.roll) >= 0) { + if (rollConf.critFail.on && rollConf.critFail.range.includes(rolling.roll)) { rolling.critFail = true; } else if (!rollConf.critFail.on) { if (rollType === 'fate') { @@ -535,7 +535,7 @@ export const roll = (rollStr: string, maximizeRoll: boolean, nominalRoll: boolea } else if ( rollConf.exploding.on && !rollSet[i].rerolled && - (rollConf.exploding.nums.length ? rollConf.exploding.nums.indexOf(rollSet[i].roll) >= 0 : rollSet[i].critHit) && + (rollConf.exploding.nums.length ? rollConf.exploding.nums.includes(rollSet[i].roll) : rollSet[i].critHit) && (!rollConf.exploding.once || !rollSet[i].exploding) ) { // If we have exploding.nums set, use those to determine the exploding range, and make sure if !o is on, make sure we don't repeatedly explode @@ -549,13 +549,13 @@ export const roll = (rollStr: string, maximizeRoll: boolean, nominalRoll: boolea newExplodingRoll.exploding = true; // If critScore arg is on, check if the roll should be a crit, if its off, check if the roll matches the die size - if (rollConf.critScore.on && rollConf.critScore.range.indexOf(newExplodingRoll.roll) >= 0) { + if (rollConf.critScore.on && rollConf.critScore.range.includes(newExplodingRoll.roll)) { newExplodingRoll.critHit = true; } else if (!rollConf.critScore.on) { newExplodingRoll.critHit = newExplodingRoll.roll === rollConf.dieSize; } // If critFail arg is on, check if the roll should be a fail, if its off, check if the roll matches 1 - if (rollConf.critFail.on && rollConf.critFail.range.indexOf(newExplodingRoll.roll) >= 0) { + if (rollConf.critFail.on && rollConf.critFail.range.includes(newExplodingRoll.roll)) { newExplodingRoll.critFail = true; } else if (!rollConf.critFail.on) { newExplodingRoll.critFail = newExplodingRoll.roll === 1; diff --git a/src/solver/solver.ts b/src/solver/solver.ts index c1bf3d5..bfd9bb3 100644 --- a/src/solver/solver.ts +++ b/src/solver/solver.ts @@ -32,7 +32,7 @@ export const fullSolver = (conf: (string | number | SolvedStep)[], wrapDetails: } // Evaluate all parenthesis - while (conf.indexOf('(') > -1) { + while (conf.includes('(')) { loggingEnabled && log(LT.LOG, `Evaluating roll ${JSON.stringify(conf)} | Looking for (`); // Get first open parenthesis const openParen = conf.indexOf('('); @@ -91,7 +91,7 @@ export const fullSolver = (conf: (string | number | SolvedStep)[], wrapDetails: for (let i = 0; i < conf.length; i++) { loggingEnabled && log(LT.LOG, `Evaluating roll ${JSON.stringify(conf)} | Evaluating ${JSON.stringify(curOps)} | Checking ${JSON.stringify(conf[i])}`); // Check if the current index is in the active tier of operators - if (curOps.indexOf(conf[i].toString()) > -1) { + if (curOps.includes(conf[i].toString())) { // Grab the operands from before and after the operator const operand1 = conf[i - 1]; const operand2 = conf[i + 1];