deno fmt
This commit is contained in:
parent
f3a6a36fb0
commit
a42b75aa51
20
mod.ts
20
mod.ts
|
@ -6,21 +6,7 @@
|
||||||
|
|
||||||
import config from './config.ts';
|
import config from './config.ts';
|
||||||
import { DEBUG, DEVMODE, LOCALMODE } from './flags.ts';
|
import { DEBUG, DEVMODE, LOCALMODE } from './flags.ts';
|
||||||
import {
|
import { botId, cache, DiscordActivityTypes, DiscordenoGuild, DiscordenoMessage, editBotNickname, editBotStatus, initLog, Intents, log, LT, sendMessage, startBot } from './deps.ts';
|
||||||
botId,
|
|
||||||
cache,
|
|
||||||
DiscordActivityTypes,
|
|
||||||
DiscordenoGuild,
|
|
||||||
DiscordenoMessage,
|
|
||||||
editBotNickname,
|
|
||||||
editBotStatus,
|
|
||||||
initLog,
|
|
||||||
Intents,
|
|
||||||
log,
|
|
||||||
LT,
|
|
||||||
sendMessage,
|
|
||||||
startBot,
|
|
||||||
} from './deps.ts';
|
|
||||||
import api from './src/api.ts';
|
import api from './src/api.ts';
|
||||||
import dbClient from './src/db/client.ts';
|
import dbClient from './src/db/client.ts';
|
||||||
import { ignoreList } from './src/db/common.ts';
|
import { ignoreList } from './src/db/common.ts';
|
||||||
|
@ -80,9 +66,7 @@ startBot({
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
||||||
// Interval to update bot list stats every 24 hours
|
// Interval to update bot list stats every 24 hours
|
||||||
LOCALMODE
|
LOCALMODE ? log(LT.INFO, 'updateListStatistics not running') : setInterval(() => {
|
||||||
? log(LT.INFO, 'updateListStatistics not running')
|
|
||||||
: setInterval(() => {
|
|
||||||
log(LT.LOG, 'Updating all bot lists statistics');
|
log(LT.LOG, 'Updating all bot lists statistics');
|
||||||
intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size);
|
intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size);
|
||||||
}, 86400000);
|
}, 86400000);
|
||||||
|
|
|
@ -45,7 +45,7 @@ export const generateStats = (
|
||||||
rollCount: bigint,
|
rollCount: bigint,
|
||||||
utilityCount: bigint,
|
utilityCount: bigint,
|
||||||
rollRate: number,
|
rollRate: number,
|
||||||
utilityRate: number
|
utilityRate: number,
|
||||||
) => ({
|
) => ({
|
||||||
embeds: [
|
embeds: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,8 @@ export const help = (message: DiscordenoMessage) => {
|
||||||
{
|
{
|
||||||
color: infoColor2,
|
color: infoColor2,
|
||||||
title: `${config.name}'s API Details:`,
|
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}).
|
For information on how to use the API, please check the GitHub README for more information [here](${config.links.sourceCode}).
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,8 @@ export const help = (message: DiscordenoMessage) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -21,7 +21,8 @@ export const privacy = (message: DiscordenoMessage) => {
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: `${config.name} does not track or collect user information via Discord.`,
|
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}).
|
For more details, please check out the Privacy Policy on the GitHub [here](${config.links.privacyPolicy}).
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
||||||
}
|
}
|
||||||
if (modifiers.gms.length < 1) {
|
if (modifiers.gms.length < 1) {
|
||||||
// If -gm is on and none were found, throw an error
|
// 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) =>
|
m.edit(generateRollError(errorType, 'Must specify at least one GM by @mentioning them')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e));
|
||||||
utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DEVMODE && config.logRolls) {
|
if (DEVMODE && config.logRolls) {
|
||||||
// If enabled, log rolls so we can verify the bots math
|
// If enabled, log rolls so we can verify the bots math
|
||||||
|
@ -83,9 +81,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
||||||
|
|
||||||
if (!args[i] || (args[i].toLowerCase()[0] !== 'd' && args[i].toLowerCase()[0] !== 'a')) {
|
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
|
// 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) =>
|
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));
|
||||||
utils.commonLoggers.messageEditError('getModifiers.ts:81', m, e)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DEVMODE && config.logRolls) {
|
if (DEVMODE && config.logRolls) {
|
||||||
// If enabled, log rolls so we can verify the bots math
|
// If enabled, log rolls so we can verify the bots math
|
||||||
|
@ -112,9 +108,7 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
||||||
|
|
||||||
// maxRoll and nominalRoll cannot both be on, throw an error
|
// maxRoll and nominalRoll cannot both be on, throw an error
|
||||||
if (modifiers.maxRoll && modifiers.nominalRoll) {
|
if (modifiers.maxRoll && modifiers.nominalRoll) {
|
||||||
m.edit(generateRollError(errorType, 'Cannot maximize and nominize the roll at the same time')).catch((e) =>
|
m.edit(generateRollError(errorType, 'Cannot maximize and nominize the roll at the same time')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:106', m, e));
|
||||||
utils.commonLoggers.messageEditError('getModifiers.ts:106', m, e)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DEVMODE && config.logRolls) {
|
if (DEVMODE && config.logRolls) {
|
||||||
// If enabled, log rolls so we can verify the bots math
|
// If enabled, log rolls so we can verify the bots math
|
||||||
|
|
|
@ -49,8 +49,7 @@ Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${c
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`-gm @user1 @user2 @userN` - GM Roll',
|
name: '`-gm @user1 @user2 @userN` - GM Roll',
|
||||||
value:
|
value: 'Rolls the requested roll in GM mode, suppressing all publicly shown results and details and sending the results directly to the specified GMs',
|
||||||
'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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -72,32 +72,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`r<q` [Optional]',
|
name: '`r<q` [Optional]',
|
||||||
value:
|
value: 'Rerolls any rolls that are less than or equal to `a`, `r3` will reroll every die that land on 3, 2, or 1, throwing out old rolls, cannot be used with `ro`',
|
||||||
'Rerolls any rolls that are less than or equal to `a`, `r3` will reroll every die that land on 3, 2, or 1, throwing out old rolls, cannot be used with `ro`',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`r>q` [Optional]',
|
name: '`r>q` [Optional]',
|
||||||
value:
|
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`',
|
||||||
'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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`roa` or `ro=q` [Optional]',
|
name: '`roa` or `ro=q` [Optional]',
|
||||||
value:
|
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`',
|
||||||
'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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`ro<q` [Optional]',
|
name: '`ro<q` [Optional]',
|
||||||
value:
|
value: 'Rerolls any rolls that are less than or equal to `a`, `ro3` will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||||
'Rerolls any rolls that are less than or equal to `a`, `ro3` will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`ro>q` [Optional]',
|
name: '`ro>q` [Optional]',
|
||||||
value:
|
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`',
|
||||||
'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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -192,32 +187,27 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!p>u` [Optional]',
|
name: '`!p>u` [Optional]',
|
||||||
value:
|
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',
|
||||||
'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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!p<u` [Optional]',
|
name: '`!p<u` [Optional]',
|
||||||
value:
|
value: 'Penetrating Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but subtracts one from each resulting explosion',
|
||||||
'Penetrating Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but subtracts one from each resulting explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!=u` [Optional]',
|
name: '`!!=u` [Optional]',
|
||||||
value:
|
value: 'Compounding Explosion on `u`, rolls one `dy` for each die that lands on `u`, but adds the resulting explosion to the die that caused this explosion',
|
||||||
'Compounding Explosion on `u`, rolls one `dy` for each die that lands on `u`, but adds the resulting explosion to the die that caused this explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!>u` [Optional]',
|
name: '`!!>u` [Optional]',
|
||||||
value:
|
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',
|
||||||
'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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!<u` [Optional]',
|
name: '`!!<u` [Optional]',
|
||||||
value:
|
value: 'Compounding Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but adds the resulting explosion to the die that caused this explosion',
|
||||||
'Compounding Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but adds the resulting explosion to the die that caused this explosion',
|
|
||||||
inline: true,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -40,8 +40,8 @@ export const stats = async (message: DiscordenoMessage) => {
|
||||||
rolls,
|
rolls,
|
||||||
total - rolls,
|
total - rolls,
|
||||||
rollRate,
|
rollRate,
|
||||||
totalRate - rollRate
|
totalRate - rollRate,
|
||||||
)
|
),
|
||||||
).catch((e: Error) => utils.commonLoggers.messageEditError('stats.ts:38', m, e));
|
).catch((e: Error) => utils.commonLoggers.messageEditError('stats.ts:38', m, e));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
utils.commonLoggers.messageSendError('stats.ts:41', message, e as Error);
|
utils.commonLoggers.messageSendError('stats.ts:41', message, e as Error);
|
||||||
|
|
|
@ -113,7 +113,7 @@ export const apiRoll = async (query: Map<string, string>, apiUserid: bigint): Pr
|
||||||
} else {
|
} else {
|
||||||
// Alert API user that they messed up
|
// Alert API user that they messed up
|
||||||
return stdResp.Forbidden(
|
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 {
|
} else {
|
||||||
|
|
|
@ -5,8 +5,7 @@ import {
|
||||||
StatusCode,
|
StatusCode,
|
||||||
} from '../../deps.ts';
|
} from '../../deps.ts';
|
||||||
|
|
||||||
const genericResponse = (customText: string, status: StatusCode) =>
|
const genericResponse = (customText: string, status: StatusCode) => new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] });
|
||||||
new Response(customText || STATUS_TEXT[status], { status: status, statusText: STATUS_TEXT[status] });
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
BadRequest: (customText: string) => genericResponse(customText, STATUS_CODE.BadRequest),
|
BadRequest: (customText: string) => genericResponse(customText, STATUS_CODE.BadRequest),
|
||||||
|
|
|
@ -198,7 +198,7 @@ const updateHeatmapPng = async () => {
|
||||||
hourPixels[hour][0] + 1,
|
hourPixels[hour][0] + 1,
|
||||||
dayPixels[day][1] - dayPixels[day][0] + 1,
|
dayPixels[day][1] - dayPixels[day][0] + 1,
|
||||||
hourPixels[hour][1] - hourPixels[hour][0] + 1,
|
hourPixels[hour][1] - hourPixels[hour][0] + 1,
|
||||||
is.Image.rgbToColor(255 * (1 - percent), 255 * percent, 0)
|
is.Image.rgbToColor(255 * (1 - percent), 255 * percent, 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import { fullSolver } from './solver.ts';
|
||||||
// parseRoll handles converting fullCmd into a computer readable format for processing, and finally executes the solving
|
// parseRoll handles converting fullCmd into a computer readable format for processing, and finally executes the solving
|
||||||
export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll => {
|
export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll => {
|
||||||
const operators = ['^', '*', '/', '%', '+', '-', '(', ')'];
|
const operators = ['^', '*', '/', '%', '+', '-', '(', ')'];
|
||||||
const returnMsg = <SolvedRoll>{
|
const returnMsg = <SolvedRoll> {
|
||||||
error: false,
|
error: false,
|
||||||
errorCode: '',
|
errorCode: '',
|
||||||
errorMsg: '',
|
errorMsg: '',
|
||||||
|
@ -57,7 +57,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
||||||
const [tempConf, tempFormat] = sepRoll.split(config.postfix);
|
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)
|
// 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(/([-+()*/%^])/g);
|
const mathConf: (string | number | SolvedStep)[] = <(string | number | SolvedStep)[]> tempConf.replace(/ /g, '').split(/([-+()*/%^])/g);
|
||||||
|
|
||||||
// Verify there are equal numbers of opening and closing parenthesis by adding 1 for opening parens and subtracting 1 for closing parens
|
// Verify there are equal numbers of opening and closing parenthesis by adding 1 for opening parens and subtracting 1 for closing parens
|
||||||
let parenCnt = 0;
|
let parenCnt = 0;
|
||||||
|
@ -139,7 +139,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
||||||
containsCrit: false,
|
containsCrit: false,
|
||||||
containsFail: false,
|
containsFail: false,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
} else if (!operators.includes(mathConf[i].toString())) {
|
} else if (!operators.includes(mathConf[i].toString())) {
|
||||||
// If nothing else has handled it by now, try it as a roll
|
// If nothing else has handled it by now, try it as a roll
|
||||||
|
@ -150,10 +150,10 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
||||||
|
|
||||||
if (mathConf[i - 1] === '-' && ((!mathConf[i - 2] && mathConf[i - 2] !== 0) || mathConf[i - 2] === '(')) {
|
if (mathConf[i - 1] === '-' && ((!mathConf[i - 2] && mathConf[i - 2] !== 0) || mathConf[i - 2] === '(')) {
|
||||||
if (typeof mathConf[i] === 'number') {
|
if (typeof mathConf[i] === 'number') {
|
||||||
mathConf[i] = <number>mathConf[i] * -1;
|
mathConf[i] = <number> mathConf[i] * -1;
|
||||||
} else {
|
} else {
|
||||||
(<SolvedStep>mathConf[i]).total = (<SolvedStep>mathConf[i]).total * -1;
|
(<SolvedStep> mathConf[i]).total = (<SolvedStep> mathConf[i]).total * -1;
|
||||||
(<SolvedStep>mathConf[i]).details = `-${(<SolvedStep>mathConf[i]).details}`;
|
(<SolvedStep> mathConf[i]).details = `-${(<SolvedStep> mathConf[i]).details}`;
|
||||||
}
|
}
|
||||||
mathConf.splice(i - 1, 1);
|
mathConf.splice(i - 1, 1);
|
||||||
i--;
|
i--;
|
||||||
|
|
|
@ -44,12 +44,12 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
||||||
(
|
(
|
||||||
await generateRollEmbed(
|
await generateRollEmbed(
|
||||||
rq.dd.message.authorId,
|
rq.dd.message.authorId,
|
||||||
<SolvedRoll>{
|
<SolvedRoll> {
|
||||||
error: true,
|
error: true,
|
||||||
errorCode: 'TooComplex',
|
errorCode: 'TooComplex',
|
||||||
errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts',
|
errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts',
|
||||||
},
|
},
|
||||||
<RollModifiers>{}
|
<RollModifiers> {},
|
||||||
)
|
)
|
||||||
).embed,
|
).embed,
|
||||||
],
|
],
|
||||||
|
@ -180,9 +180,9 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
details: pubEmbedDetails,
|
details: pubEmbedDetails,
|
||||||
}
|
},
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ The results for this roll will replace this message when it is done.`,
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
log(
|
log(
|
||||||
LT.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) {
|
if (rollQueue.length && currentWorkers < config.limits.maxWorkers) {
|
||||||
const temp = rollQueue.shift();
|
const temp = rollQueue.shift();
|
||||||
|
|
|
@ -47,22 +47,22 @@ export const roll = (rollStr: string, maximizeRoll: boolean, nominalRoll: boolea
|
||||||
reroll: {
|
reroll: {
|
||||||
on: false,
|
on: false,
|
||||||
once: false,
|
once: false,
|
||||||
nums: <number[]>[],
|
nums: <number[]> [],
|
||||||
},
|
},
|
||||||
critScore: {
|
critScore: {
|
||||||
on: false,
|
on: false,
|
||||||
range: <number[]>[],
|
range: <number[]> [],
|
||||||
},
|
},
|
||||||
critFail: {
|
critFail: {
|
||||||
on: false,
|
on: false,
|
||||||
range: <number[]>[],
|
range: <number[]> [],
|
||||||
},
|
},
|
||||||
exploding: {
|
exploding: {
|
||||||
on: false,
|
on: false,
|
||||||
once: false,
|
once: false,
|
||||||
compounding: false,
|
compounding: false,
|
||||||
penetrating: false,
|
penetrating: false,
|
||||||
nums: <number[]>[],
|
nums: <number[]> [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -183,10 +183,10 @@ export const fullSolver = (conf: (string | number | SolvedStep)[], wrapDetails:
|
||||||
stepSolve.details = conf[0].toString();
|
stepSolve.details = conf[0].toString();
|
||||||
} else {
|
} else {
|
||||||
// Else fully populate the stepSolve with what was computed
|
// Else fully populate the stepSolve with what was computed
|
||||||
stepSolve.total = (<SolvedStep>conf[0]).total;
|
stepSolve.total = (<SolvedStep> conf[0]).total;
|
||||||
stepSolve.details = (<SolvedStep>conf[0]).details;
|
stepSolve.details = (<SolvedStep> conf[0]).details;
|
||||||
stepSolve.containsCrit = (<SolvedStep>conf[0]).containsCrit;
|
stepSolve.containsCrit = (<SolvedStep> conf[0]).containsCrit;
|
||||||
stepSolve.containsFail = (<SolvedStep>conf[0]).containsFail;
|
stepSolve.containsFail = (<SolvedStep> conf[0]).containsFail;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this was a nested call, add on parens around the details to show what math we've done
|
// If this was a nested call, add on parens around the details to show what math we've done
|
||||||
|
|
|
@ -23,7 +23,7 @@ const ask = async (question: string, stdin = Deno.stdin, stdout = Deno.stdout):
|
||||||
await stdout.write(new TextEncoder().encode(question));
|
await stdout.write(new TextEncoder().encode(question));
|
||||||
|
|
||||||
// Read console's input into answer
|
// Read console's input into answer
|
||||||
const n = <number>await stdin.read(buf);
|
const n = <number> await stdin.read(buf);
|
||||||
const answer = new TextDecoder().decode(buf.subarray(0, n));
|
const answer = new TextDecoder().decode(buf.subarray(0, n));
|
||||||
|
|
||||||
return answer.trim();
|
return answer.trim();
|
||||||
|
@ -101,8 +101,7 @@ const messageSendError = (location: string, message: DiscordenoMessage | string,
|
||||||
genericLogger(LT.ERROR, `${location} | Failed to send message: ${JSON.stringify(message)} | Error: ${err.name} - ${err.message}`);
|
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) =>
|
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}`);
|
genericLogger(LT.ERROR, `${location} | Failed to delete message: ${JSON.stringify(message)} | Error: ${err.name} - ${err.message}`);
|
||||||
const dbError = (location: string, type: string, err: Error) =>
|
const dbError = (location: string, type: string, err: Error) => genericLogger(LT.ERROR, `${location} | Failed to ${type} database | Error: ${err.name} - ${err.message}`);
|
||||||
genericLogger(LT.ERROR, `${location} | Failed to ${type} database | Error: ${err.name} - ${err.message}`);
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
commonLoggers: {
|
commonLoggers: {
|
||||||
|
|
Loading…
Reference in New Issue