diff --git a/mod.ts b/mod.ts index 2584e41..8c18c53 100644 --- a/mod.ts +++ b/mod.ts @@ -3,18 +3,7 @@ * * December 21, 2020 */ -import { - botId, - cache, - DiscordActivityTypes, - DiscordenoGuild, - DiscordenoMessage, - editBotNickname, - editBotStatus, - Intents, - sendMessage, - startBot, -} from '@discordeno'; +import { botId, cache, DiscordActivityTypes, DiscordenoGuild, DiscordenoMessage, editBotNickname, editBotStatus, Intents, sendMessage, startBot } from '@discordeno'; import { initLog, log, LogTypes as LT } from '@Log4Deno'; import config from '/config.ts'; @@ -81,12 +70,10 @@ startBot({ }, 30000); // Interval to update bot list stats every 24 hours - LOCALMODE - ? log(LT.INFO, 'updateListStatistics not running') - : setInterval(() => { - log(LT.LOG, 'Updating all bot lists statistics'); - intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size); - }, 86400000); + LOCALMODE ? log(LT.INFO, 'updateListStatistics not running') : setInterval(() => { + log(LT.LOG, 'Updating all bot lists statistics'); + intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size); + }, 86400000); // Interval to update hourlyRates every hour setInterval(() => { diff --git a/src/artigen/managers/queueManager.ts b/src/artigen/managers/queueManager.ts index 3253360..b0fa815 100644 --- a/src/artigen/managers/queueManager.ts +++ b/src/artigen/managers/queueManager.ts @@ -35,7 +35,7 @@ The results for this roll will replace this message when it is done.`, setInterval(() => { log( LT.LOG, - `Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${currentWorkers}, config.limits.maxWorkers: ${config.limits.maxWorkers}` + `Checking rollQueue for items, rollQueue length: ${rollQueue.length}, currentWorkers: ${currentWorkers}, config.limits.maxWorkers: ${config.limits.maxWorkers}`, ); if (rollQueue.length && currentWorkers < config.limits.maxWorkers) { const temp = rollQueue.shift(); diff --git a/src/artigen/managers/workerManager.ts b/src/artigen/managers/workerManager.ts index 38ed6ba..65de972 100644 --- a/src/artigen/managers/workerManager.ts +++ b/src/artigen/managers/workerManager.ts @@ -35,12 +35,12 @@ export const handleRollWorker = (rq: QueuedRoll) => { ( await generateRollEmbed( rq.dd.message.authorId, - { + { error: true, errorCode: 'TooComplex', errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts', }, - {} + {}, ) ).embed, ], @@ -166,14 +166,14 @@ export const handleRollWorker = (rq: QueuedRoll) => { JSON.stringify( rq.modifiers.count ? { - counts: countEmbed, - details: pubEmbedDetails, - } + counts: countEmbed, + details: pubEmbedDetails, + } : { - details: pubEmbedDetails, - } - ) - ) + details: pubEmbedDetails, + }, + ), + ), ); } } diff --git a/src/artigen/parser.ts b/src/artigen/parser.ts index d8a30a5..464f393 100644 --- a/src/artigen/parser.ts +++ b/src/artigen/parser.ts @@ -12,7 +12,7 @@ import { fullSolver } from 'artigen/solver.ts'; // parseRoll handles converting fullCmd into a computer readable format for processing, and finally executes the solving export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll => { const operators = ['(', ')', '^', '*', '/', '%', '+', '-']; - const returnMsg = { + const returnMsg = { error: false, errorCode: '', errorMsg: '', @@ -54,7 +54,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll const [tempConf, tempFormat] = sepRoll.split(config.postfix); // Remove all spaces from the operation config and split it by any operator (keeping the operator in mathConf for fullSolver to do math on) - const mathConf: (string | number | SolvedStep)[] = <(string | number | SolvedStep)[]>tempConf.replace(/ /g, '').split(/([-+()*/^]|(? tempConf.replace(/ /g, '').split(/([-+()*/^]|(? strMathConfI.endsWith(mathOp))) { @@ -173,10 +173,10 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll } else { // Handle normally, just set current item to negative if (typeof mathConf[i] === 'number') { - mathConf[i] = mathConf[i] * -1; + mathConf[i] = mathConf[i] * -1; } else { - (mathConf[i]).total = (mathConf[i]).total * -1; - (mathConf[i]).details = `-${(mathConf[i]).details}`; + ( mathConf[i]).total = ( mathConf[i]).total * -1; + ( mathConf[i]).details = `-${( mathConf[i]).details}`; } mathConf.splice(i - 1, 1); i--; @@ -255,10 +255,12 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll // Populate line2 (the results) and line3 (the details) with their data if (modifiers.order === '') { - line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${escapeCharacters( - e.rollPostFormat, - '|*_~`' - )} `; + line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${ + escapeCharacters( + e.rollPostFormat, + '|*_~`', + ) + } `; } else { // If order is on, turn rolls into csv without formatting line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}, `; diff --git a/src/artigen/rollUtils.ts b/src/artigen/rollUtils.ts index eab2cc0..986d848 100644 --- a/src/artigen/rollUtils.ts +++ b/src/artigen/rollUtils.ts @@ -36,7 +36,7 @@ export const genFateRoll = (modifiers: RollModifiers): number => { return 0; } else { const sides = [-1, -1, 0, 0, 1, 1]; - return sides[genRoll(6, modifiers, { on: false }) - 1]; + return sides[genRoll(6, modifiers, { on: false }) - 1]; } }; diff --git a/src/artigen/roller.ts b/src/artigen/roller.ts index 7a670dd..0fb3e43 100644 --- a/src/artigen/roller.ts +++ b/src/artigen/roller.ts @@ -64,22 +64,22 @@ export const roll = (rollStr: string, modifiers: RollModifiers): RollSet[] => { reroll: { on: false, once: false, - nums: [], + nums: [], }, critScore: { on: false, - range: [], + range: [], }, critFail: { on: false, - range: [], + range: [], }, exploding: { on: false, once: false, compounding: false, penetrating: false, - nums: [], + nums: [], }, }; diff --git a/src/artigen/solver.ts b/src/artigen/solver.ts index 553d071..1a12f16 100644 --- a/src/artigen/solver.ts +++ b/src/artigen/solver.ts @@ -186,10 +186,10 @@ export const fullSolver = (conf: (string | number | SolvedStep)[], wrapDetails: stepSolve.details = conf[0].toString(); } else { // Else fully populate the stepSolve with what was computed - stepSolve.total = (conf[0]).total; - stepSolve.details = (conf[0]).details; - stepSolve.containsCrit = (conf[0]).containsCrit; - stepSolve.containsFail = (conf[0]).containsFail; + stepSolve.total = ( conf[0]).total; + stepSolve.details = ( conf[0]).details; + stepSolve.containsCrit = ( conf[0]).containsCrit; + stepSolve.containsFail = ( conf[0]).containsFail; } // If this was a nested call, add on parens around the details to show what math we've done diff --git a/src/commandUtils.ts b/src/commandUtils.ts index 373019d..ac88b7c 100644 --- a/src/commandUtils.ts +++ b/src/commandUtils.ts @@ -49,7 +49,7 @@ export const generateStats = ( utilityCount: bigint, rollRate: number, utilityRate: number, - queryTimeMs: number + queryTimeMs: number, ) => ({ embeds: [ { diff --git a/src/commands/apiCmd/apiHelp.ts b/src/commands/apiCmd/apiHelp.ts index 9ab811d..2a5d57d 100644 --- a/src/commands/apiCmd/apiHelp.ts +++ b/src/commands/apiCmd/apiHelp.ts @@ -12,7 +12,8 @@ export const help = (message: DiscordenoMessage) => { { color: infoColor2, title: `${config.name}'s API Details:`, - description: `${config.name} has a built in API that allows user to roll dice into Discord using third party programs. By default, API rolls are blocked from being sent in your guild. The API warning is also enabled by default. These commands may only be used by the Owner or Admins of your guild. + description: + `${config.name} has a built in API that allows user to roll dice into Discord using third party programs. By default, API rolls are blocked from being sent in your guild. The API warning is also enabled by default. These commands may only be used by the Owner or Admins of your guild. For information on how to use the API, please check the GitHub README for more information [here](${config.links.sourceCode}). diff --git a/src/commands/auditCmd/auditGuilds.ts b/src/commands/auditCmd/auditGuilds.ts index 563febd..21ef192 100644 --- a/src/commands/auditCmd/auditGuilds.ts +++ b/src/commands/auditCmd/auditGuilds.ts @@ -119,25 +119,21 @@ Please see attached file for audit details on cached guilds and members.`, }, { name: 'Repeat Guild Owners:', - value: - repeatCounts - .map((ownerCnt, serverIdx) => `${ownerCnt} ${ownerCnt === 1 ? 'person has' : 'people have'} me in ${serverIdx + 1} of their guilds`) - .filter((str) => str) - .join('\n') || 'No Repeat Guild Owners', + value: repeatCounts + .map((ownerCnt, serverIdx) => `${ownerCnt} ${ownerCnt === 1 ? 'person has' : 'people have'} me in ${serverIdx + 1} of their guilds`) + .filter((str) => str) + .join('\n') || 'No Repeat Guild Owners', }, { name: 'Guild Size Dist:', - value: - Array.from(guildSizeDist) - .map( - ([size, count], idx) => - `${count} Guild${count === 1 ? ' has' : 's have'} ${ - guildSizeDist.has(sizeCats[idx - 1]) - ? `${size.toLocaleString()} - ${(sizeCats[idx - 1] - 1).toLocaleString()}` - : `at least ${size.toLocaleString()}` - } Member${size === 1 ? '' : 's'}` - ) - .join('\n') || 'Not available', + value: Array.from(guildSizeDist) + .map( + ([size, count], idx) => + `${count} Guild${count === 1 ? ' has' : 's have'} ${ + guildSizeDist.has(sizeCats[idx - 1]) ? `${size.toLocaleString()} - ${(sizeCats[idx - 1] - 1).toLocaleString()}` : `at least ${size.toLocaleString()}` + } Member${size === 1 ? '' : 's'}`, + ) + .join('\n') || 'Not available', }, ], }, diff --git a/src/commands/help.ts b/src/commands/help.ts index 9fe88da..290f5c6 100644 --- a/src/commands/help.ts +++ b/src/commands/help.ts @@ -91,7 +91,8 @@ export const help = (message: DiscordenoMessage) => { }, { name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`, - value: `Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`), run \`${config.prefix}??\` for more details`, + value: + `Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`), run \`${config.prefix}??\` for more details`, inline: true, }, ], diff --git a/src/commands/privacy.ts b/src/commands/privacy.ts index 98c7318..967f3d3 100644 --- a/src/commands/privacy.ts +++ b/src/commands/privacy.ts @@ -21,7 +21,8 @@ export const privacy = (message: DiscordenoMessage) => { fields: [ { name: `${config.name} does not track or collect user information via Discord.`, - value: `The only user submitted information that is stored is submitted via the \`${config.prefix}report\` command. This information is only stored for a short period of time in a location that only the Developer of ${config.name} can see. + value: + `The only user submitted information that is stored is submitted via the \`${config.prefix}report\` command. This information is only stored for a short period of time in a location that only the Developer of ${config.name} can see. For more details, please check out the Privacy Policy on the GitHub [here](${config.links.privacyPolicy}). diff --git a/src/commands/roll/getModifiers.ts b/src/commands/roll/getModifiers.ts index 425c1cb..38dab09 100644 --- a/src/commands/roll/getModifiers.ts +++ b/src/commands/roll/getModifiers.ts @@ -68,9 +68,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri } if (modifiers.gms.length < 1) { // If -gm is on and none were found, throw an error - m.edit(generateRollError(errorType, 'Must specify at least one GM by @mentioning them')).catch((e) => - utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e) - ); + m.edit(generateRollError(errorType, 'Must specify at least one GM by @mentioning them')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e)); if (DEVMODE && config.logRolls) { // If enabled, log rolls so we can verify the bots math @@ -87,9 +85,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri if (!args[i] || (args[i].toLowerCase()[0] !== 'd' && args[i].toLowerCase()[0] !== 'a')) { // If -o is on and asc or desc was not specified, error out - m.edit(generateRollError(errorType, 'Must specify `a` or `d` to order the rolls ascending or descending')).catch((e) => - utils.commonLoggers.messageEditError('getModifiers.ts:81', m, e) - ); + m.edit(generateRollError(errorType, 'Must specify `a` or `d` to order the rolls ascending or descending')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:81', m, e)); if (DEVMODE && config.logRolls) { // If enabled, log rolls so we can verify the bots math diff --git a/src/commands/rollDecorators.ts b/src/commands/rollDecorators.ts index f95b463..e4a60d3 100644 --- a/src/commands/rollDecorators.ts +++ b/src/commands/rollDecorators.ts @@ -54,8 +54,7 @@ Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${c }, { name: '`-gm @user1 @user2 @userN` - GM Roll', - value: - 'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs', + value: 'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs', inline: true, }, { diff --git a/src/commands/rollHelp.ts b/src/commands/rollHelp.ts index 22358c6..c3e9796 100644 --- a/src/commands/rollHelp.ts +++ b/src/commands/rollHelp.ts @@ -72,32 +72,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`, }, { name: '`rq` [Optional]', - value: - 'Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll every die that land on 3 or greater, throwing out old rolls, cannot be used with `ro`', + value: 'Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll every die that land on 3 or greater, throwing out old rolls, cannot be used with `ro`', inline: true, }, { name: '`roa` or `ro=q` [Optional]', - value: - 'Rerolls any rolls that match `a`, `ro3` will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`', + value: 'Rerolls any rolls that match `a`, `ro3` will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`', inline: true, }, { name: '`roq` [Optional]', - value: - 'Rerolls any rolls that are greater than or equal to `a`, `ro3` will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with `r`', + value: 'Rerolls any rolls that are greater than or equal to `a`, `ro3` will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with `r`', inline: true, }, { @@ -192,32 +187,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`, }, { name: '`!p>u` [Optional]', - value: - 'Penetrating Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but subtracts one from each resulting explosion', + value: 'Penetrating Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but subtracts one from each resulting explosion', inline: true, }, { name: '`!pu` [Optional]', - value: - 'Compounding Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but adds the resulting explosion to the die that caused this explosion', + value: 'Compounding Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but adds the resulting explosion to the die that caused this explosion', inline: true, }, { name: '`!! { total - rolls, rollRate, totalRate - rollRate, - endTime - startTime - ) + endTime - startTime, + ), ).catch((e: Error) => utils.commonLoggers.messageEditError('stats.ts:38', m, e)); } catch (e) { utils.commonLoggers.messageSendError('stats.ts:41', message, e as Error); diff --git a/src/endpoints/gets/apiRoll.ts b/src/endpoints/gets/apiRoll.ts index eba0b48..6093e32 100644 --- a/src/endpoints/gets/apiRoll.ts +++ b/src/endpoints/gets/apiRoll.ts @@ -115,7 +115,7 @@ export const apiRoll = async (query: Map, apiUserid: bigint): Pr } else { // Alert API user that they messed up return stdResp.Forbidden( - `Verify you are a member of the guild you are sending this roll to. If you are, the ${config.name} may not have that registered, please send a message in the guild so ${config.name} can register this. This registration is temporary, so if you see this error again, just poke your server again.` + `Verify you are a member of the guild you are sending this roll to. If you are, the ${config.name} may not have that registered, please send a message in the guild so ${config.name} can register this. This registration is temporary, so if you see this error again, just poke your server again.`, ); } } else { diff --git a/src/endpoints/stdResponses.ts b/src/endpoints/stdResponses.ts index fefd602..832d5d3 100644 --- a/src/endpoints/stdResponses.ts +++ b/src/endpoints/stdResponses.ts @@ -1,7 +1,6 @@ import { STATUS_CODE, STATUS_TEXT, StatusCode } from '@std/http'; -const genericResponse = (customText: string, status: StatusCode) => - new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] }); +const genericResponse = (customText: string, status: StatusCode) => new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] }); export default { BadRequest: (customText: string) => genericResponse(customText, STATUS_CODE.BadRequest), diff --git a/src/intervals.ts b/src/intervals.ts index 671b827..728cb17 100644 --- a/src/intervals.ts +++ b/src/intervals.ts @@ -4,7 +4,7 @@ * December 21, 2020 */ import { cache, cacheHandlers } from '@discordeno'; -import { Image, decode } from '@imagescript'; +import { decode, Image } from '@imagescript'; import { log, LogTypes as LT } from '@Log4Deno'; import config from '/config.ts'; @@ -193,7 +193,7 @@ const updateHeatmapPng = async () => { hourPixels[hour][0] + 1, dayPixels[day][1] - dayPixels[day][0] + 1, hourPixels[hour][1] - hourPixels[hour][0] + 1, - Image.rgbToColor(255 * (1 - percent), 255 * percent, 0) + Image.rgbToColor(255 * (1 - percent), 255 * percent, 0), ); } } diff --git a/src/utils.ts b/src/utils.ts index 8aa8dc4..af3532c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -15,7 +15,7 @@ const ask = async (question: string, stdin = Deno.stdin, stdout = Deno.stdout): await stdout.write(new TextEncoder().encode(question)); // Read console's input into answer - const n = await stdin.read(buf); + const n = await stdin.read(buf); const answer = new TextDecoder().decode(buf.subarray(0, n)); return answer.trim(); @@ -93,8 +93,7 @@ const messageSendError = (location: string, message: DiscordenoMessage | string, genericLogger(LT.ERROR, `${location} | Failed to send message: ${JSON.stringify(message)} | Error: ${err.name} - ${err.message}`); const messageDeleteError = (location: string, message: DiscordenoMessage | string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to delete message: ${JSON.stringify(message)} | Error: ${err.name} - ${err.message}`); -const dbError = (location: string, type: string, err: Error) => - genericLogger(LT.ERROR, `${location} | Failed to ${type} database | Error: ${err.name} - ${err.message}`); +const dbError = (location: string, type: string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to ${type} database | Error: ${err.name} - ${err.message}`); export default { commonLoggers: {