converted all substr to substring

This commit is contained in:
Ean Milligan (Bastion) 2022-05-05 01:51:05 -04:00
parent 541747285f
commit d2083bea53
3 changed files with 6 additions and 6 deletions

View File

@ -233,7 +233,7 @@ const start = async (): Promise<void> => {
}
// 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() || "") : "");

View File

@ -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));
});
}

View File

@ -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