Swap indexOf to includes when indexOf was just being used to check if an item was in an array
This commit is contained in:
parent
2e2e08f48a
commit
73e4ca94b7
2
mod.ts
2
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);
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ export const apiChannelManageActive = async (query: Map<string, string>, apiUser
|
|||
erroredOut = false;
|
||||
|
||||
// Determine value to set
|
||||
if (path.toLowerCase().indexOf('de') > 0) {
|
||||
if (path.toLowerCase().includes('de')) {
|
||||
value = 0;
|
||||
} else {
|
||||
value = 1;
|
||||
|
|
|
@ -12,7 +12,7 @@ export const apiChannelManageBan = async (query: Map<string, string>, apiUserid:
|
|||
erroredOut = false;
|
||||
|
||||
// Determine value to set
|
||||
if (path.toLowerCase().indexOf('un') > 0) {
|
||||
if (path.toLowerCase().includes('un')) {
|
||||
value = 0;
|
||||
} else {
|
||||
value = 1;
|
||||
|
|
|
@ -13,14 +13,14 @@ export const apiKeyManage = async (query: Map<string, string>, 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue