Sonar Cleanup - Phase 8

This commit is contained in:
Ean Milligan (Bastion) 2022-05-22 17:30:30 -04:00
parent 764b8c103b
commit bbba797dc3
3 changed files with 79 additions and 50 deletions

125
mod.ts
View File

@ -124,54 +124,83 @@ startBot({
// All commands below here // All commands below here
// [[ping switch (command) {
// Its a ping test, what else do you want. case 'ping':
if (command === 'ping') { // [[ping
commands.ping(message); // Its a ping test, what else do you want.
} // [[rip [[memory commands.ping(message);
// Displays a short message I wanted to include break;
else if (command === 'rip' || command === 'memory') { case 'rip':
commands.rip(message); case 'memory':
} // [[rollhelp or [[rh or [[hr or [[?? // [[rip [[memory
// Help command specifically for the roll command // Displays a short message I wanted to include
else if (command === 'rollhelp' || command === 'rh' || command === 'hr' || command === '??' || command?.startsWith('xdy')) { commands.rip(message);
commands.rollHelp(message); break;
} // [[help or [[h or [[? case 'rollhelp':
// Help command, prints from help file case 'rh':
else if (command === 'help' || command === 'h' || command === '?') { case 'hr':
commands.help(message); case '??':
} // [[info or [[i // [[rollhelp or [[rh or [[hr or [[??
// Info command, prints short desc on bot and some links // Help command specifically for the roll command
else if (command === 'info' || command === 'i') { commands.rollHelp(message);
commands.info(message); break;
} // [[privacy case 'help':
// Privacy command, prints short desc on bot's privacy policy case 'h':
else if (command === 'privacy') { case '?':
commands.privacy(message); // [[help or [[h or [[?
} // [[version or [[v // Help command, prints from help file
// Returns version of the bot commands.help(message);
else if (command === 'version' || command === 'v') { break;
commands.version(message); case 'info':
} // [[report or [[r (command that failed) case 'i':
// Manually report a failed roll // [[info or [[i
else if (command === 'report' || command === 'r') { // Info command, prints short desc on bot and some links
commands.report(message, args); commands.info(message);
} // [[stats or [[s break;
// Displays stats on the bot case 'privacy':
else if (command === 'stats' || command === 's') { // [[privacy
commands.stats(message); // Privacy command, prints short desc on bot's privacy policy
} // [[api arg commands.privacy(message);
// API sub commands break;
else if (command === 'api') { case 'version':
commands.api(message, args); case 'v':
} // [[roll]] // [[version or [[v
// Dice rolling commence! // Returns version of the bot
else if (command && (`${command}${args.join('')}`).indexOf(config.postfix) > -1) { commands.version(message);
commands.roll(message, args, command); break;
} // [[emoji or [[emojialias case 'report':
// Check if the unhandled command is an emoji request case 'r':
else if (command) { // [[report or [[r (command that failed)
commands.emoji(message, command); // Manually report a failed roll
commands.report(message, args);
break;
case 'stats':
case 's':
// [[stats or [[s
// Displays stats on the bot
commands.stats(message);
break;
case 'api':
// [[api arg
// API sub commands
commands.api(message, args);
break;
default:
// Non-standard commands
if (command?.startsWith('xdy')) {
// [[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) {
// [[roll]]
// Dice rolling commence!
commands.roll(message, args, command);
} else if (command) {
// [[emoji or [[emojialias
// Check if the unhandled command is an emoji request
commands.emoji(message, command);
}
break;
} }
}, },
}, },

View File

@ -537,7 +537,7 @@ export const generateApiStatus = (banned: boolean, active: boolean) => {
color: infoColor1, color: infoColor1,
title: `The Artificer's API is ${config.api.enable ? 'currently enabled' : 'currently disabled'}.`, title: `The Artificer's API is ${config.api.enable ? 'currently enabled' : 'currently disabled'}.`,
description: banned ? 'API rolls are banned from being used in this guild.\n\nThis will not be reversed.' : `API rolls are ${apiStatus} in this guild.`, description: banned ? 'API rolls are banned from being used in this guild.\n\nThis will not be reversed.' : `API rolls are ${apiStatus} in this guild.`,
}] }],
}; };
}; };

View File

@ -62,7 +62,7 @@ export const compareOrigidx = (a: RollSet, b: RollSet): number => {
// escapeCharacters escapes all characters listed in esc // escapeCharacters escapes all characters listed in esc
export const escapeCharacters = (str: string, esc: string): string => { export const escapeCharacters = (str: string, esc: string): string => {
// Loop thru each esc char one at a time // Loop thru each esc char one at a time
for (const e of esc) { for (const e of esc) {
log(LT.LOG, `Escaping character ${e} | ${str}, ${esc}`); log(LT.LOG, `Escaping character ${e} | ${str}, ${esc}`);
// Create a new regex to look for that char that needs replaced and escape it // Create a new regex to look for that char that needs replaced and escape it
const temprgx = new RegExp(`[${e}]`, 'g'); const temprgx = new RegExp(`[${e}]`, 'g');