diff --git a/src/api.ts b/src/api.ts index f9f25e4..4d666a4 100644 --- a/src/api.ts +++ b/src/api.ts @@ -233,7 +233,7 @@ const start = async (): Promise => { } // Clip off the leading prefix. API calls must be formatted with a prefix at the start to match how commands are sent in Discord - rollCmd = rollCmd.substr(rollCmd.indexOf(config.prefix) + 2).replace(/%20/g, " "); + rollCmd = rollCmd.substring(rollCmd.indexOf(config.prefix) + 2).replace(/%20/g, " "); // Parse the roll and get the return text const returnmsg = solver.parseRoll(rollCmd, config.prefix, config.postfix, query.has("m"), query.has("n"), query.has("o") ? (query.get("o")?.toLowerCase() || "") : ""); diff --git a/src/commands/roll.ts b/src/commands/roll.ts index d876533..31c1af4 100644 --- a/src/commands/roll.ts +++ b/src/commands/roll.ts @@ -82,7 +82,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command: returnText = `<@${message.authorId}>${returnmsg.line1}\n${returnmsg.line2}\nFull details could not be attached to this messaged as a \`.txt\` file as the file would be too large for Discord to handle. If you would like to see the details of rolls, please send the rolls in multiple messages instead of bundled into one.`; // Attempt to DM the GMs and send a warning if it could not DM a GM - await sendDirectMessage(BigInt(e.substr(2, (e.length - 3))), returnText).catch(() => { + await sendDirectMessage(BigInt(e.substring(2, (e.length - 1))), returnText).catch(() => { message.send(generateDMFailed(e)); }); } else { @@ -91,7 +91,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command: returnText = `<@${message.authorId}>${returnmsg.line1}\n${returnmsg.line2}\nFull details have been attached to this messaged as a \`.txt\` file for verification purposes.`; // Attempt to DM the GMs and send a warning if it could not DM a GM - await sendDirectMessage(BigInt(e.substr(2, (e.length - 3))), { "content": returnText, "file": { "blob": b, "name": "rollDetails.txt" } }).catch(() => { + await sendDirectMessage(BigInt(e.substring(2, (e.length - 1))), { "content": returnText, "file": { "blob": b, "name": "rollDetails.txt" } }).catch(() => { message.send(generateDMFailed(e)); }); } diff --git a/src/solver.ts b/src/solver.ts index 379a24b..07e52fd 100644 --- a/src/solver.ts +++ b/src/solver.ts @@ -556,7 +556,7 @@ const formatRoll = (rollConf: string, maximiseRoll: boolean, nominalRoll: boolea tempDetails += `${preFormat}${e.roll}${postFormat} + `; }); // After the looping is done, remove the extra " + " from the details and cap it with the closing ] - tempDetails = tempDetails.substr(0, (tempDetails.length - 3)); + tempDetails = tempDetails.substring(0, (tempDetails.length - 1)); tempDetails += "]"; return { @@ -859,7 +859,7 @@ const parseRoll = (fullCmd: string, localPrefix: string, localPostfix: string, m // Remove any floating spaces from fullCmd if (fullCmd[fullCmd.length - 1] === " ") { - fullCmd = fullCmd.substr(0, (fullCmd.length - 1)); + fullCmd = fullCmd.substring(0, (fullCmd.length - 1)); } // Escape any | and ` chars in fullCmd to prevent spoilers and code blocks from acting up @@ -922,7 +922,7 @@ const parseRoll = (fullCmd: string, localPrefix: string, localPostfix: string, m // If order is on, remove trailing ", " if (order !== "") { - line2 = line2.substr(0, (line2.length - 2)); + line2 = line2.substring(0, (line2.length - 2)); } // Fill in the return block