deno fmt
This commit is contained in:
parent
09e97eabc1
commit
103ad8a8f5
2
deps.ts
2
deps.ts
|
@ -24,6 +24,6 @@ export type { StatusCode } from 'jsr:@std/http@1.0.15';
|
||||||
|
|
||||||
export { nanoid } from 'https://deno.land/x/nanoid@v3.0.0/mod.ts';
|
export { nanoid } from 'https://deno.land/x/nanoid@v3.0.0/mod.ts';
|
||||||
|
|
||||||
export { initLog, closeLog, log, LogTypes as LT } from 'https://raw.githubusercontent.com/Burn-E99/Log4Deno/V2.1.1/mod.ts';
|
export { closeLog, initLog, log, LogTypes as LT } from 'https://raw.githubusercontent.com/Burn-E99/Log4Deno/V2.1.1/mod.ts';
|
||||||
|
|
||||||
export * as is from 'https://deno.land/x/imagescript@1.3.0/mod.ts';
|
export * as is from 'https://deno.land/x/imagescript@1.3.0/mod.ts';
|
||||||
|
|
26
mod.ts
26
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,12 +66,10 @@ 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')
|
log(LT.LOG, 'Updating all bot lists statistics');
|
||||||
: setInterval(() => {
|
intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size);
|
||||||
log(LT.LOG, 'Updating all bot lists statistics');
|
}, 86400000);
|
||||||
intervals.updateListStatistics(botId, cache.guilds.size + cache.dispatchedGuildIds.size);
|
|
||||||
}, 86400000);
|
|
||||||
|
|
||||||
// Interval to update hourlyRates every hour
|
// Interval to update hourlyRates every hour
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|
|
@ -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: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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,
|
||||||
],
|
],
|
||||||
|
@ -175,14 +175,14 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
rq.modifiers.count
|
rq.modifiers.count
|
||||||
? {
|
? {
|
||||||
counts: countEmbed,
|
counts: countEmbed,
|
||||||
details: pubEmbedDetails,
|
details: pubEmbedDetails,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
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();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { initLog, closeLog } from '../../deps.ts';
|
import { closeLog, initLog } from '../../deps.ts';
|
||||||
import { DEBUG } from '../../flags.ts';
|
import { DEBUG } from '../../flags.ts';
|
||||||
import { parseRoll } from './parser.ts';
|
import { parseRoll } from './parser.ts';
|
||||||
import { loggingEnabled } from './rollUtils.ts';
|
import { loggingEnabled } from './rollUtils.ts';
|
||||||
|
|
|
@ -47,22 +47,22 @@ export const roll = (rollStr: string, maximiseRoll: 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[]> [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue