[untested] - start reorganizing the solver folder (renamed to artigen here), organize imports better since deno has support for it now
This commit is contained in:
parent
b9c7fac984
commit
6e1c6e8db3
|
@ -9,6 +9,7 @@
|
|||
],
|
||||
"spellright.documentTypes": [],
|
||||
"cSpell.words": [
|
||||
"artigen",
|
||||
"channelid",
|
||||
"CWOD",
|
||||
"DEVMODE",
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
## Imports
|
||||
- Should be grouped the following order:
|
||||
- `@` (third party)
|
||||
- `/` (root directory)
|
||||
- `artigen`
|
||||
- `commands`
|
||||
- `db`
|
||||
- `endpoints`
|
||||
- `src`
|
||||
- Should be alphabetical by import source file name
|
|
@ -10,7 +10,7 @@ pidfile="/var/dbots/TheArtificer/artificer.pid"
|
|||
|
||||
artificer_root="/var/dbots/TheArtificer"
|
||||
artificer_write="./logs/,./src/endpoints/gets/heatmap.png"
|
||||
artificer_read="./src/solver/,./src/endpoints/gets/heatmap-base.png,./src/endpoints/gets/heatmap.png,./config.ts,./deps.ts,./flags.ts,./src/mod.d.ts"
|
||||
artificer_read="./src/artigen/,./src/endpoints/gets/heatmap-base.png,./src/endpoints/gets/heatmap.png,./config.ts,./deps.ts,./flags.ts,./src/mod.d.ts"
|
||||
artificer_log="/var/log/artificer.log"
|
||||
|
||||
artificer_chdir="${artificer_root}"
|
||||
|
|
|
@ -6,7 +6,7 @@ After=network.target
|
|||
[Service]
|
||||
Type=simple
|
||||
PIDFile=/run/deno.pid
|
||||
ExecStart=/root/.deno/bin/deno run --allow-write=./logs/,./src/endpoints/gets/heatmap.png --allow-read=./src/solver/,./src/endpoints/gets/heatmap-base.png,./src/endpoints/gets/heatmap.png,./config.ts,./deps.ts,./flags.ts,./src/mod.d.ts --allow-net --allow-import .\mod.ts
|
||||
ExecStart=/root/.deno/bin/deno run --allow-write=./logs/,./src/endpoints/gets/heatmap.png --allow-read=./src/artigen/,./src/endpoints/gets/heatmap-base.png,./src/endpoints/gets/heatmap.png,./config.ts,./deps.ts,./flags.ts,./src/mod.d.ts --allow-net --allow-import .\mod.ts
|
||||
RestartSec=60
|
||||
Restart=on-failure
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// This file will create all tables for the artificer schema
|
||||
// DATA WILL BE LOST IF DB ALREADY EXISTS, RUN AT OWN RISK
|
||||
|
||||
import config from '../config.ts';
|
||||
import dbClient from '../src/db/client.ts';
|
||||
import config from '/config.ts';
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
console.log('Attempting to create DB');
|
||||
await dbClient.execute(`CREATE SCHEMA IF NOT EXISTS ${config.db.name};`);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// This file will populate the tables with default values
|
||||
|
||||
import config from '../config.ts';
|
||||
import dbClient from '../src/db/client.ts';
|
||||
import dbClient from 'src/db/client.ts';
|
||||
|
||||
console.log('Attempting to populate DB Admin API key');
|
||||
await dbClient.execute('INSERT INTO all_keys(userid,apiKey) values(?,?)', [config.api.admin, config.api.adminKey]).catch((e) => {
|
||||
|
|
14
deno.json
14
deno.json
|
@ -19,5 +19,19 @@
|
|||
"indentWidth": 2,
|
||||
"singleQuote": true,
|
||||
"proseWrap": "preserve"
|
||||
},
|
||||
"imports": {
|
||||
"@discordeno": "https://deno.land/x/discordeno@12.0.1/mod.ts",
|
||||
"@Log4Deno": "https://raw.githubusercontent.com/Burn-E99/Log4Deno/V2.1.1/mod.ts",
|
||||
"@mysql": "https://deno.land/x/mysql@v2.12.1/mod.ts",
|
||||
"@std/http": "jsr:@std/http@1.0.15",
|
||||
"@nanoid": "https://deno.land/x/nanoid@v3.0.0/mod.ts",
|
||||
"@imagescript": "https://deno.land/x/imagescript@1.3.0/mod.ts",
|
||||
"/": "./",
|
||||
"artigen/": "./src/artigen/",
|
||||
"commands/": "./src/commands/",
|
||||
"endpoints/": "./src/endpoints/",
|
||||
"db/": "./src/db/",
|
||||
"src/": "./src/"
|
||||
}
|
||||
}
|
29
deps.ts
29
deps.ts
|
@ -1,29 +0,0 @@
|
|||
// All external dependencies are to be loaded here to make updating dependency versions much easier
|
||||
export {
|
||||
botId,
|
||||
cache,
|
||||
cacheHandlers,
|
||||
DiscordActivityTypes,
|
||||
editBotNickname,
|
||||
editBotStatus,
|
||||
getMessage,
|
||||
hasGuildPermissions,
|
||||
Intents,
|
||||
sendDirectMessage,
|
||||
sendMessage,
|
||||
startBot,
|
||||
} from 'https://deno.land/x/discordeno@12.0.1/mod.ts';
|
||||
|
||||
export type { CreateMessage, DiscordenoGuild, DiscordenoMessage, EmbedField } from 'https://deno.land/x/discordeno@12.0.1/mod.ts';
|
||||
|
||||
export { Client } from 'https://deno.land/x/mysql@v2.12.1/mod.ts';
|
||||
|
||||
export { STATUS_CODE, STATUS_TEXT } from 'jsr:@std/http@1.0.15';
|
||||
|
||||
export type { StatusCode } from 'jsr:@std/http@1.0.15';
|
||||
|
||||
export { nanoid } from 'https://deno.land/x/nanoid@v3.0.0/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';
|
2
flags.ts
2
flags.ts
|
@ -3,4 +3,4 @@ export const DEVMODE = false;
|
|||
// DEBUG is used to toggle the cmdPrompt and show debug log messages
|
||||
export const DEBUG = false;
|
||||
// LOCALMODE is used to run a different bot token for local testing
|
||||
export const LOCALMODE = false;
|
||||
export const LOCALMODE = true;
|
||||
|
|
39
mod.ts
39
mod.ts
|
@ -3,17 +3,32 @@
|
|||
*
|
||||
* December 21, 2020
|
||||
*/
|
||||
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';
|
||||
import { DEBUG, DEVMODE, LOCALMODE } from './flags.ts';
|
||||
import { botId, cache, DiscordActivityTypes, DiscordenoGuild, DiscordenoMessage, editBotNickname, editBotStatus, initLog, Intents, log, LT, sendMessage, startBot } from './deps.ts';
|
||||
import api from './src/api.ts';
|
||||
import dbClient from './src/db/client.ts';
|
||||
import { ignoreList } from './src/db/common.ts';
|
||||
import commands from './src/commands/_index.ts';
|
||||
import intervals from './src/intervals.ts';
|
||||
import { successColor, warnColor } from './src/commandUtils.ts';
|
||||
import utils from './src/utils.ts';
|
||||
import config from '/config.ts';
|
||||
import { DEBUG, DEVMODE, LOCALMODE } from '/flags.ts';
|
||||
|
||||
import commands from 'commands/_index.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { ignoreList } from 'db/common.ts';
|
||||
|
||||
import api from 'src/api.ts';
|
||||
import { successColor, warnColor } from 'src/commandUtils.ts';
|
||||
import intervals from 'src/intervals.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
// Extend the BigInt prototype to support JSON.stringify
|
||||
interface BigIntX extends BigInt {
|
||||
|
@ -66,7 +81,9 @@ startBot({
|
|||
}, 30000);
|
||||
|
||||
// Interval to update bot list stats every 24 hours
|
||||
LOCALMODE ? log(LT.INFO, 'updateListStatistics not running') : setInterval(() => {
|
||||
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);
|
||||
|
|
16
src/api.ts
16
src/api.ts
|
@ -3,16 +3,14 @@
|
|||
*
|
||||
* December 21, 2020
|
||||
*/
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '../config.ts';
|
||||
import {
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../deps.ts';
|
||||
import dbClient from './db/client.ts';
|
||||
import endpoints from './endpoints/_index.ts';
|
||||
import stdResp from './endpoints/stdResponses.ts';
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import endpoints from 'endpoints/_index.ts';
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
|
||||
// start() returns nothing
|
||||
// start initializes and runs the entire API for the bot
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
# artigen - The Artificer's Dice and Math Engine
|
||||
artigen is the core engine powering The Artificer.
|
|
@ -1,4 +1,4 @@
|
|||
import { CountDetails, RollSet } from './solver.d.ts';
|
||||
import { CountDetails, RollSet } from 'artigen/solver.d.ts';
|
||||
|
||||
export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
||||
const countDetails = {
|
|
@ -0,0 +1,49 @@
|
|||
import config from '/config.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
import { infoColor2, rollingEmbed } from 'src/commandUtils.ts';
|
||||
import { QueuedRoll } from 'src/mod.d.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
import { currentWorkers, handleRollWorker } from 'artigen/managers/workerManager.ts';
|
||||
|
||||
const rollQueue: Array<QueuedRoll> = [];
|
||||
|
||||
// Runs the roll or queues it depending on how many workers are currently running
|
||||
export const queueRoll = (rq: QueuedRoll) => {
|
||||
if (rq.apiRoll) {
|
||||
handleRollWorker(rq);
|
||||
} else if (!rollQueue.length && currentWorkers < config.limits.maxWorkers) {
|
||||
handleRollWorker(rq);
|
||||
} else {
|
||||
rollQueue.push(rq);
|
||||
rq.dd.m
|
||||
.edit({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: `${config.name} currently has its hands full and has queued your roll.`,
|
||||
description: `There are currently ${currentWorkers + rollQueue.length} rolls ahead of this roll.
|
||||
|
||||
The results for this roll will replace this message when it is done.`,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageEditError('rollQueue.ts:197', rq.dd.m, e));
|
||||
}
|
||||
};
|
||||
|
||||
// Checks the queue constantly to make sure the queue stays empty
|
||||
setInterval(() => {
|
||||
log(
|
||||
LT.LOG,
|
||||
`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();
|
||||
if (temp && !temp.apiRoll) {
|
||||
temp.dd.m.edit(rollingEmbed).catch((e: Error) => utils.commonLoggers.messageEditError('rollQueue.ts:208', temp.dd.m, e));
|
||||
handleRollWorker(temp);
|
||||
} else if (temp && temp.apiRoll) {
|
||||
handleRollWorker(temp);
|
||||
}
|
||||
}
|
||||
}, 1000);
|
|
@ -1,36 +1,27 @@
|
|||
import config from '../../config.ts';
|
||||
import { DEVMODE } from '../../flags.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
// Discordeno deps
|
||||
sendDirectMessage,
|
||||
sendMessage,
|
||||
} from '../../deps.ts';
|
||||
import { SolvedRoll } from '../solver/solver.d.ts';
|
||||
import { ApiQueuedRoll, DDQueuedRoll, RollModifiers } from '../mod.d.ts';
|
||||
import { generateCountDetailsEmbed, generateDMFailed, generateRollEmbed, infoColor2, rollingEmbed } from '../commandUtils.ts';
|
||||
import stdResp from '../endpoints/stdResponses.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { loggingEnabled } from './rollUtils.ts';
|
||||
import config from '/config.ts';
|
||||
import { generateCountDetailsEmbed, generateDMFailed, generateRollEmbed } from 'src/commandUtils.ts';
|
||||
import { QueuedRoll, RollModifiers } from 'src/mod.d.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
import { SolvedRoll } from 'src/artigen/solver.d.ts';
|
||||
import { loggingEnabled } from 'src/artigen/rollUtils.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
import { DEVMODE } from '/flags.ts';
|
||||
import dbClient from 'src/db/client.ts';
|
||||
import stdResp from 'src/endpoints/stdResponses.ts';
|
||||
import { DiscordenoMessage, sendDirectMessage, sendMessage } from '@discordeno';
|
||||
import { queries } from 'src/db/common.ts';
|
||||
|
||||
let currentWorkers = 0;
|
||||
const rollQueue: Array<ApiQueuedRoll | DDQueuedRoll> = [];
|
||||
export let currentWorkers = 0;
|
||||
|
||||
// Handle setting up and calling the rollWorker
|
||||
const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
||||
export const handleRollWorker = (rq: QueuedRoll) => {
|
||||
currentWorkers++;
|
||||
|
||||
// gmModifiers used to create gmEmbed (basically just turn off the gmRoll)
|
||||
const gmModifiers = JSON.parse(JSON.stringify(rq.modifiers));
|
||||
gmModifiers.gmRoll = false;
|
||||
|
||||
const rollWorker = new Worker(new URL('../solver/rollWorker.ts', import.meta.url).href, { type: 'module' });
|
||||
const rollWorker = new Worker(new URL('../artigen/rollWorker.ts', import.meta.url).href, { type: 'module' });
|
||||
|
||||
const workerTimeout = setTimeout(async () => {
|
||||
rollWorker.terminate();
|
||||
|
@ -49,7 +40,7 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
|||
errorCode: 'TooComplex',
|
||||
errorMsg: 'Error: Roll took too long to process, try breaking roll down into simpler parts',
|
||||
},
|
||||
<RollModifiers> {},
|
||||
<RollModifiers>{}
|
||||
)
|
||||
).embed,
|
||||
],
|
||||
|
@ -180,9 +171,9 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
|||
}
|
||||
: {
|
||||
details: pubEmbedDetails,
|
||||
},
|
||||
),
|
||||
),
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -194,44 +185,3 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
|||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Runs the roll or queues it depending on how many workers are currently running
|
||||
export const queueRoll = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
||||
if (rq.apiRoll) {
|
||||
handleRollWorker(rq);
|
||||
} else if (!rollQueue.length && currentWorkers < config.limits.maxWorkers) {
|
||||
handleRollWorker(rq);
|
||||
} else {
|
||||
rq.dd.m
|
||||
.edit({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: `${config.name} currently has its hands full and has queued your roll.`,
|
||||
description: `There are currently ${currentWorkers + rollQueue.length} rolls ahead of this roll.
|
||||
|
||||
The results for this roll will replace this message when it is done.`,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageEditError('rollQueue.ts:197', rq.dd.m, e));
|
||||
rollQueue.push(rq);
|
||||
}
|
||||
};
|
||||
|
||||
// Checks the queue constantly to make sure the queue stays empty
|
||||
setInterval(() => {
|
||||
log(
|
||||
LT.LOG,
|
||||
`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();
|
||||
if (temp && !temp.apiRoll) {
|
||||
temp.dd.m.edit(rollingEmbed).catch((e: Error) => utils.commonLoggers.messageEditError('rollQueue.ts:208', temp.dd.m, e));
|
||||
handleRollWorker(temp);
|
||||
} else if (temp && temp.apiRoll) {
|
||||
handleRollWorker(temp);
|
||||
}
|
||||
}
|
||||
}, 1000);
|
|
@ -1,16 +1,12 @@
|
|||
import {
|
||||
log,
|
||||
// Log4Deno deps
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '../../config.ts';
|
||||
import config from '/config.ts';
|
||||
|
||||
import { RollModifiers } from '../mod.d.ts';
|
||||
import { CountDetails, ReturnData, SolvedRoll, SolvedStep } from './solver.d.ts';
|
||||
import { compareTotalRolls, compareTotalRollsReverse, escapeCharacters, legalMathOperators, loggingEnabled } from './rollUtils.ts';
|
||||
import { formatRoll } from './rollFormatter.ts';
|
||||
import { fullSolver } from './solver.ts';
|
||||
import { RollModifiers } from 'src/mod.d.ts';
|
||||
import { CountDetails, ReturnData, SolvedRoll, SolvedStep } from 'artigen/solver.d.ts';
|
||||
import { compareTotalRolls, compareTotalRollsReverse, escapeCharacters, legalMathOperators, loggingEnabled } from 'artigen/rollUtils.ts';
|
||||
import { formatRoll } from 'artigen/rollFormatter.ts';
|
||||
import { fullSolver } from 'artigen/solver.ts';
|
||||
|
||||
// parseRoll(fullCmd, modifiers)
|
||||
// parseRoll handles converting fullCmd into a computer readable format for processing, and finally executes the solving
|
||||
|
@ -37,6 +33,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
|||
try {
|
||||
// Split the fullCmd by the command prefix to allow every roll/math op to be handled individually
|
||||
const sepRolls = fullCmd.split(config.prefix);
|
||||
// TODO: HERE for the [[ ]] nesting stuff
|
||||
|
||||
const tempReturnData: ReturnData[] = [];
|
||||
const tempCountDetails: CountDetails[] = [
|
||||
|
@ -150,7 +147,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
|||
containsCrit: false,
|
||||
containsFail: false,
|
||||
},
|
||||
],
|
||||
]
|
||||
);
|
||||
i += 2;
|
||||
} else if (!legalMathOperators.includes(strMathConfI) && legalMathOperators.some((mathOp) => strMathConfI.endsWith(mathOp))) {
|
||||
|
@ -258,12 +255,10 @@ 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(
|
||||
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}, `;
|
|
@ -1,14 +1,10 @@
|
|||
import {
|
||||
log,
|
||||
// Log4Deno deps
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import { roll } from './roller.ts';
|
||||
import { rollCounter } from './counter.ts';
|
||||
import { RollFormat } from './solver.d.ts';
|
||||
import { loggingEnabled } from './rollUtils.ts';
|
||||
import { RollModifiers } from '../mod.d.ts';
|
||||
import { roll } from 'artigen/roller.ts';
|
||||
import { rollCounter } from 'artigen/counter.ts';
|
||||
import { RollFormat } from 'artigen/solver.d.ts';
|
||||
import { loggingEnabled } from 'artigen/rollUtils.ts';
|
||||
import { RollModifiers } from 'src/mod.d.ts';
|
||||
|
||||
// formatRoll(rollConf, modifiers) returns one SolvedStep
|
||||
// formatRoll handles creating and formatting the completed rolls into the SolvedStep format
|
|
@ -1,11 +1,7 @@
|
|||
import {
|
||||
log,
|
||||
// Log4Deno deps
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { RollModifiers } from '../mod.d.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
import { RollModifiers } from 'src/mod.d.ts';
|
||||
|
||||
import { DPercentConf, ReturnData, RollSet } from './solver.d.ts';
|
||||
import { DPercentConf, ReturnData, RollSet } from 'artigen/solver.d.ts';
|
||||
|
||||
type MathFunction = (arg: number) => number;
|
||||
export const loggingEnabled = false;
|
|
@ -1,7 +1,7 @@
|
|||
import { closeLog, initLog } from '../../deps.ts';
|
||||
import { DEBUG } from '../../flags.ts';
|
||||
import { parseRoll } from './parser.ts';
|
||||
import { loggingEnabled } from './rollUtils.ts';
|
||||
import { closeLog, initLog } from '@Log4Deno';
|
||||
import { DEBUG } from '/flags.ts';
|
||||
import { parseRoll } from 'artigen/parser.ts';
|
||||
import { loggingEnabled } from 'artigen/rollUtils.ts';
|
||||
|
||||
loggingEnabled && initLog('logs/worker', DEBUG);
|
||||
|
|
@ -1,13 +1,9 @@
|
|||
import config from '../../config.ts';
|
||||
import {
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import config from '/config.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import { RollConf, RollSet, RollType } from './solver.d.ts';
|
||||
import { compareOrigIdx, compareRolls, genFateRoll, genRoll, loggingEnabled } from './rollUtils.ts';
|
||||
import { RollModifiers } from '../mod.d.ts';
|
||||
import { RollConf, RollSet, RollType } from 'artigen/solver.d.ts';
|
||||
import { compareOrigIdx, compareRolls, genFateRoll, genRoll, loggingEnabled } from 'artigen/rollUtils.ts';
|
||||
import { RollModifiers } from 'src/mod.d.ts';
|
||||
|
||||
// Call with loopCountCheck(++loopCount);
|
||||
// Will ensure if maxLoops is 10, 10 loops will be allowed, 11 will not.
|
|
@ -1,5 +1,4 @@
|
|||
// solver.ts custom types
|
||||
|
||||
// Available Roll Types
|
||||
export type RollType = '' | 'roll20' | 'fate' | 'cwod' | 'ova';
|
||||
|
||||
// RollSet is used to preserve all information about a calculated roll
|
|
@ -3,15 +3,10 @@
|
|||
*
|
||||
* December 21, 2020
|
||||
*/
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import {
|
||||
log,
|
||||
// Log4Deno deps
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
|
||||
import { SolvedStep } from './solver.d.ts';
|
||||
import { legalMath, legalMathOperators, loggingEnabled } from './rollUtils.ts';
|
||||
import { SolvedStep } from 'artigen/solver.d.ts';
|
||||
import { legalMath, legalMathOperators, loggingEnabled } from 'artigen/rollUtils.ts';
|
||||
|
||||
// fullSolver(conf, wrapDetails) returns one condensed SolvedStep
|
||||
// fullSolver is a function that recursively solves the full roll and math
|
|
@ -1,8 +1,11 @@
|
|||
import config from '../config.ts';
|
||||
import { CountDetails, SolvedRoll } from './solver/solver.d.ts';
|
||||
import { RollModifiers } from './mod.d.ts';
|
||||
import { loggingEnabled } from './solver/rollUtils.ts';
|
||||
import { log, LT } from '../deps.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import { loggingEnabled } from 'artigen/rollUtils.ts';
|
||||
import { CountDetails, SolvedRoll } from 'artigen/solver.d.ts';
|
||||
|
||||
import { RollModifiers } from 'src/mod.d.ts';
|
||||
|
||||
export const failColor = 0xe71212;
|
||||
export const warnColor = 0xe38f28;
|
||||
|
@ -46,7 +49,7 @@ export const generateStats = (
|
|||
utilityCount: bigint,
|
||||
rollRate: number,
|
||||
utilityRate: number,
|
||||
queryTimeMs: number,
|
||||
queryTimeMs: number
|
||||
) => ({
|
||||
embeds: [
|
||||
{
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
import { ping } from './ping.ts';
|
||||
import { rip } from './rip.ts';
|
||||
import { rollHelp } from './rollHelp.ts';
|
||||
import { rollDecorators } from './rollDecorators.ts';
|
||||
import { help } from './help.ts';
|
||||
import { info } from './info.ts';
|
||||
import { privacy } from './privacy.ts';
|
||||
import { version } from './version.ts';
|
||||
import { report } from './report.ts';
|
||||
import { stats } from './stats.ts';
|
||||
import { api } from './apiCmd.ts';
|
||||
import { emoji } from './emoji.ts';
|
||||
import { roll } from './roll.ts';
|
||||
import { handleMentions } from './handleMentions.ts';
|
||||
import { audit } from './audit.ts';
|
||||
import { heatmap } from './heatmap.ts';
|
||||
import { optOut } from './optOut.ts';
|
||||
import { optIn } from './optIn.ts';
|
||||
import { api } from 'commands/apiCmd.ts';
|
||||
import { audit } from 'commands/audit.ts';
|
||||
import { emoji } from 'commands/emoji.ts';
|
||||
import { handleMentions } from 'commands/handleMentions.ts';
|
||||
import { heatmap } from 'commands/heatmap.ts';
|
||||
import { help } from 'commands/help.ts';
|
||||
import { info } from 'commands/info.ts';
|
||||
import { optIn } from 'commands/optIn.ts';
|
||||
import { optOut } from 'commands/optOut.ts';
|
||||
import { ping } from 'commands/ping.ts';
|
||||
import { privacy } from 'commands/privacy.ts';
|
||||
import { rip } from 'commands/rip.ts';
|
||||
import { report } from 'commands/report.ts';
|
||||
import { roll } from 'commands/roll.ts';
|
||||
import { rollDecorators } from 'commands/rollDecorators.ts';
|
||||
import { rollHelp } from 'commands/rollHelp.ts';
|
||||
import { stats } from 'commands/stats.ts';
|
||||
import { version } from 'commands/version.ts';
|
||||
|
||||
export default {
|
||||
ping,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
hasGuildPermissions,
|
||||
} from '../../deps.ts';
|
||||
import apiCommands from './apiCmd/_index.ts';
|
||||
import { failColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import config from '../../config.ts';
|
||||
import { DiscordenoMessage, hasGuildPermissions } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import apiCommands from 'commands/apiCmd/_index.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { failColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const api = async (message: DiscordenoMessage, args: string[]) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { help } from './apiHelp.ts';
|
||||
import { allowBlock } from './allowBlock.ts';
|
||||
import { deleteGuild } from './deleteGuild.ts';
|
||||
import { status } from './status.ts';
|
||||
import { showHideWarn } from './showHideWarn.ts';
|
||||
import { allowBlock } from 'commands/apiCmd/allowBlock.ts';
|
||||
import { help } from 'commands/apiCmd/apiHelp.ts';
|
||||
import { deleteGuild } from 'commands/apiCmd/deleteGuild.ts';
|
||||
import { showHideWarn } from 'commands/apiCmd/showHideWarn.ts';
|
||||
import { status } from 'commands/apiCmd/status.ts';
|
||||
|
||||
export default {
|
||||
help,
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import { generateApiFailed, generateApiSuccess } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const allowBlock = async (message: DiscordenoMessage, apiArg: string) => {
|
||||
let errorOutInitial = false;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import config from '../../../config.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { infoColor1, infoColor2 } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import { infoColor1, infoColor2 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const help = (message: DiscordenoMessage) => {
|
||||
message
|
||||
|
@ -13,8 +12,7 @@ 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}).
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { failColor, successColor } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import config from '../../../config.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import { failColor, successColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const deleteGuild = async (message: DiscordenoMessage) => {
|
||||
let errorOut = false;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import { generateApiFailed, generateApiSuccess } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const showHideWarn = async (message: DiscordenoMessage, apiArg: string) => {
|
||||
let errorOutInitial = false;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { failColor, generateApiStatus } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import { failColor, generateApiStatus } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const status = async (message: DiscordenoMessage) => {
|
||||
// Get status of guild from the db
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import auditCommands from './auditCmd/_index.ts';
|
||||
import { failColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import auditCommands from 'commands/auditCmd/_index.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { failColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const audit = (message: DiscordenoMessage, args: string[]) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { auditHelp } from './auditHelp.ts';
|
||||
import { auditDB } from './auditDB.ts';
|
||||
import { auditGuilds } from './auditGuilds.ts';
|
||||
import { auditDB } from 'commands/auditCmd/auditDB.ts';
|
||||
import { auditGuilds } from 'commands/auditCmd/auditGuilds.ts';
|
||||
import { auditHelp } from 'commands/auditCmd/auditHelp.ts';
|
||||
|
||||
export default {
|
||||
auditHelp,
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
EmbedField,
|
||||
} from '../../../deps.ts';
|
||||
import { infoColor2 } from '../../commandUtils.ts';
|
||||
import { compilingStats } from '../../commonEmbeds.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { DiscordenoMessage, EmbedField } from '@discordeno';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import { compilingStats } from 'src/commonEmbeds.ts';
|
||||
import { infoColor2 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
interface DBSizeData {
|
||||
table: string;
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
import config from '../../../config.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
cache,
|
||||
cacheHandlers,
|
||||
DiscordenoGuild,
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { infoColor2 } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { cache, cacheHandlers, DiscordenoGuild, DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import { infoColor2 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
const sortGuildByMemberCount = (a: DiscordenoGuild, b: DiscordenoGuild) => {
|
||||
if (a.memberCount < b.memberCount) {
|
||||
|
@ -123,19 +119,23 @@ Please see attached file for audit details on cached guilds and members.`,
|
|||
},
|
||||
{
|
||||
name: 'Repeat Guild Owners:',
|
||||
value: repeatCounts
|
||||
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)
|
||||
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'}`,
|
||||
guildSizeDist.has(sizeCats[idx - 1])
|
||||
? `${size.toLocaleString()} - ${(sizeCats[idx - 1] - 1).toLocaleString()}`
|
||||
: `at least ${size.toLocaleString()}`
|
||||
} Member${size === 1 ? '' : 's'}`
|
||||
)
|
||||
.join('\n') || 'Not available',
|
||||
},
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import config from '../../../config.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { infoColor1 } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import { infoColor1 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const auditHelp = (message: DiscordenoMessage) => {
|
||||
message
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { EmojiConf } from '../mod.d.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { EmojiConf } from 'src/mod.d.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
const allEmojiAliases: string[] = [];
|
||||
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor1 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const handleMentions = (message: DiscordenoMessage) => {
|
||||
log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import config from '../../config.ts';
|
||||
import { failColor, infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import intervals from '../intervals.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { failColor, infoColor2 } from 'src/commandUtils.ts';
|
||||
import intervals from 'src/intervals.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const heatmap = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor2 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const help = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
@ -91,8 +91,7 @@ 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,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor2 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const info = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { ignoreList, queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { failColor, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { ignoreList, queries } from 'db/common.ts';
|
||||
|
||||
import { failColor, successColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const optIn = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { ignoreList, queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { failColor, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { ignoreList, queries } from 'db/common.ts';
|
||||
|
||||
import { failColor, successColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const optOut = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { generatePing } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { generatePing } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const ping = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor1 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const privacy = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
@ -21,8 +21,7 @@ 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}).
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
sendMessage,
|
||||
} from '../../deps.ts';
|
||||
import { failColor, generateReport, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage, sendMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { failColor, generateReport, successColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const report = (message: DiscordenoMessage, args: string[]) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import config from '../../config.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor2 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const rip = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import config from '../../config.ts';
|
||||
import { DEVMODE } from '../../flags.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { rollingEmbed, warnColor } from '../commandUtils.ts';
|
||||
import rollFuncs from './roll/_index.ts';
|
||||
import { queueRoll } from '../solver/rollQueue.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '/config.ts';
|
||||
import { DEVMODE } from '/flags.ts';
|
||||
|
||||
import { queueRoll } from 'artigen/managers/queueManager.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import rollFuncs from 'commands/roll/_index.ts';
|
||||
|
||||
import { rollingEmbed, warnColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { getModifiers } from './getModifiers.ts';
|
||||
import { getModifiers } from 'commands/roll/getModifiers.ts';
|
||||
|
||||
export default {
|
||||
getModifiers,
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
import config from '../../../config.ts';
|
||||
import { DEVMODE } from '../../../flags.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import { queries } from '../../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../../deps.ts';
|
||||
import { generateRollError } from '../../commandUtils.ts';
|
||||
import { RollModifiers } from '../../mod.d.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '/config.ts';
|
||||
import { DEVMODE } from '/flags.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { generateRollError } from 'src/commandUtils.ts';
|
||||
import { RollModifiers } from 'src/mod.d.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const getModifiers = (m: DiscordenoMessage, args: string[], command: string, originalCommand: string): RollModifiers => {
|
||||
const errorType = 'Modifiers invalid:';
|
||||
|
@ -70,7 +68,9 @@ 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,7 +87,9 @@ 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
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor2 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const rollDecorators = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
@ -54,7 +54,8 @@ 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,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1, infoColor2, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor1, infoColor2, successColor } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const rollHelp = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
@ -72,27 +72,32 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
|||
},
|
||||
{
|
||||
name: '`r<q` [Optional]',
|
||||
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`',
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`r>q` [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: '`ro<q` [Optional]',
|
||||
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`',
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ro>q` [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,
|
||||
},
|
||||
{
|
||||
|
@ -187,27 +192,32 @@ 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: '`!p<u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!=u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!>u` [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: '`!!<u` [Optional]',
|
||||
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',
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
cache,
|
||||
cacheHandlers,
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { generateStats } from '../commandUtils.ts';
|
||||
import { compilingStats } from '../commonEmbeds.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { cache, cacheHandlers, DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { compilingStats } from 'src/commonEmbeds.ts';
|
||||
import { generateStats } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const stats = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
@ -45,8 +42,8 @@ export const stats = async (message: DiscordenoMessage) => {
|
|||
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);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import config from '../../config.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import { infoColor1 } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const version = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { warnColor } from './commandUtils.ts';
|
||||
import { warnColor } from 'src/commandUtils.ts';
|
||||
|
||||
export const compilingStats = {
|
||||
embeds: [
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import config from '../../config.ts';
|
||||
import { Client } from '../../deps.ts';
|
||||
import { LOCALMODE } from '../../flags.ts';
|
||||
import { Client } from '@mysql';
|
||||
|
||||
import config from '/config.ts';
|
||||
import { LOCALMODE } from '/flags.ts';
|
||||
|
||||
const dbClient = await new Client().connect({
|
||||
hostname: LOCALMODE ? config.db.localhost : config.db.host,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import dbClient from './client.ts';
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
type UserIdObj = {
|
||||
userid: bigint;
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import { apiKeyDelete } from './deletes/apiKeyDelete.ts';
|
||||
import { apiKey } from './gets/apiKey.ts';
|
||||
import { apiRoll } from './gets/apiRoll.ts';
|
||||
import { apiKeyAdmin } from './gets/apiKeyAdmin.ts';
|
||||
import { apiChannel } from './gets/apiChannel.ts';
|
||||
import { heatmapPng } from './gets/heatmapPng.ts';
|
||||
import { apiChannelAdd } from './posts/apiChannelAdd.ts';
|
||||
import { apiKeyManage } from './puts/apiKeyManage.ts';
|
||||
import { apiChannelManageBan } from './puts/apiChannelManageBan.ts';
|
||||
import { apiChannelManageActive } from './puts/apiChannelManageActive.ts';
|
||||
import { apiKeyDelete } from 'endpoints/deletes/apiKeyDelete.ts';
|
||||
|
||||
import { apiChannel } from 'endpoints/gets/apiChannel.ts';
|
||||
import { apiKey } from 'endpoints/gets/apiKey.ts';
|
||||
import { apiKeyAdmin } from 'endpoints/gets/apiKeyAdmin.ts';
|
||||
import { apiRoll } from 'endpoints/gets/apiRoll.ts';
|
||||
import { heatmapPng } from 'endpoints/gets/heatmapPng.ts';
|
||||
|
||||
import { apiChannelAdd } from 'endpoints/posts/apiChannelAdd.ts';
|
||||
|
||||
import { apiChannelManageActive } from 'endpoints/puts/apiChannelManageActive.ts';
|
||||
import { apiChannelManageBan } from 'endpoints/puts/apiChannelManageBan.ts';
|
||||
import { apiKeyManage } from 'endpoints/puts/apiKeyManage.ts';
|
||||
|
||||
export default {
|
||||
delete: {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import config from '../../../config.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// nanoid deps
|
||||
nanoid,
|
||||
// Discordeno deps
|
||||
sendMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { generateApiDeleteEmail } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import { sendMessage } from '@discordeno';
|
||||
import { nanoid } from '@nanoid';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import { generateApiDeleteEmail } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiKeyDelete = async (query: Map<string, string>, apiUserid: bigint, apiUserEmail: string, apiUserDelCode: string): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user', 'email'])) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiChannel = async (query: Map<string, string>, apiUserid: bigint): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user'])) {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import config from '../../../config.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// nanoid deps
|
||||
nanoid,
|
||||
// Discordeno deps
|
||||
sendMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { generateApiKeyEmail } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import { sendMessage } from '@discordeno';
|
||||
import { nanoid } from '@nanoid';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import { generateApiKeyEmail } from 'src/commandUtils.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiKey = async (query: Map<string, string>): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user', 'email'])) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
import config from '../../../config.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// nanoid deps
|
||||
nanoid,
|
||||
} from '../../../deps.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import { nanoid } from '@nanoid';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiKeyAdmin = async (query: Map<string, string>, apiUserid: bigint): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user', 'a'])) {
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import config from '../../../config.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import { queries } from '../../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
cache,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../../deps.ts';
|
||||
import { RollModifiers } from '../../mod.d.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { queueRoll } from '../../solver/rollQueue.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import { cache } from '@discordeno';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import config from '/config.ts';
|
||||
|
||||
import { queueRoll } from 'artigen/managers/queueManager.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { queries } from 'db/common.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import { RollModifiers } from 'src/mod.d.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
const apiWarning = `The following roll was conducted using my built in API. If someone in this channel did not request this roll, please report API abuse here: <${config.api.supportURL}>`;
|
||||
|
||||
|
@ -115,7 +115,7 @@ export const apiRoll = async (query: Map<string, string>, 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 {
|
||||
|
|
|
@ -1,8 +1,4 @@
|
|||
import {
|
||||
// httpd deps
|
||||
STATUS_CODE,
|
||||
STATUS_TEXT,
|
||||
} from '../../../deps.ts';
|
||||
import { STATUS_CODE, STATUS_TEXT } from '@std/http';
|
||||
|
||||
export const heatmapPng = (): Response => {
|
||||
const file = Deno.readFileSync('./src/endpoints/gets/heatmap.png');
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiChannelAdd = async (query: Map<string, string>, apiUserid: bigint): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user', 'channel'])) {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import dbClient from '../../db/client.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiChannelManageActive = async (query: Map<string, string>, apiUserid: bigint, path: string): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user', 'channel'])) {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import config from '../../../config.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiChannelManageBan = async (query: Map<string, string>, apiUserid: bigint, path: string): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user', 'channel', 'a'])) {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
import config from '../../../config.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import stdResp from '../stdResponses.ts';
|
||||
import utils from '../../utils.ts';
|
||||
import { verifyQueryHasParams } from '../utils.ts';
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
|
||||
import stdResp from 'endpoints/stdResponses.ts';
|
||||
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
export const apiKeyManage = async (query: Map<string, string>, apiUserid: bigint, path: string): Promise<Response> => {
|
||||
if (verifyQueryHasParams(query, ['user', 'a'])) {
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
import {
|
||||
STATUS_CODE,
|
||||
STATUS_TEXT,
|
||||
// httpd deps
|
||||
StatusCode,
|
||||
} from '../../deps.ts';
|
||||
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),
|
||||
|
|
|
@ -3,22 +3,17 @@
|
|||
*
|
||||
* December 21, 2020
|
||||
*/
|
||||
import { cache, cacheHandlers } from '@discordeno';
|
||||
import { Image, decode } from '@imagescript';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
|
||||
import {
|
||||
// Discordeno deps
|
||||
cache,
|
||||
cacheHandlers,
|
||||
// imagescript dep
|
||||
is,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../deps.ts';
|
||||
import { PastCommandCount } from './mod.d.ts';
|
||||
import dbClient from './db/client.ts';
|
||||
import { weekDays } from './db/common.ts';
|
||||
import utils from './utils.ts';
|
||||
import config from '../config.ts';
|
||||
import config from '/config.ts';
|
||||
|
||||
import dbClient from 'db/client.ts';
|
||||
import { weekDays } from 'db/common.ts';
|
||||
|
||||
import { PastCommandCount } from 'src/mod.d.ts';
|
||||
import utils from 'src/utils.ts';
|
||||
|
||||
// getRandomStatus() returns status as string
|
||||
// Gets a new random status for the bot
|
||||
|
@ -163,8 +158,8 @@ let minRollCnt: number;
|
|||
let maxRollCnt: number;
|
||||
const updateHeatmapPng = async () => {
|
||||
const baseHeatmap = Deno.readFileSync('./src/endpoints/gets/heatmap-base.png');
|
||||
const heatmap = await is.decode(baseHeatmap);
|
||||
if (!(heatmap instanceof is.Image)) {
|
||||
const heatmap = await decode(baseHeatmap);
|
||||
if (!(heatmap instanceof Image)) {
|
||||
return;
|
||||
}
|
||||
// Get latest data from DB
|
||||
|
@ -198,7 +193,7 @@ const updateHeatmapPng = async () => {
|
|||
hourPixels[hour][0] + 1,
|
||||
dayPixels[day][1] - dayPixels[day][0] + 1,
|
||||
hourPixels[hour][1] - hourPixels[hour][0] + 1,
|
||||
is.Image.rgbToColor(255 * (1 - percent), 255 * percent, 0),
|
||||
Image.rgbToColor(255 * (1 - percent), 255 * percent, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
// mod.d.ts custom types
|
||||
import { DiscordenoMessage } from '../deps.ts';
|
||||
import { DiscordenoMessage } from '@discordeno';
|
||||
|
||||
// EmojiConf is used as a structure for the emojis stored in config.ts
|
||||
export type EmojiConf = {
|
||||
|
@ -28,12 +27,12 @@ export type RollModifiers = {
|
|||
};
|
||||
|
||||
// QueuedRoll is the structure to track rolls we could not immediately handle
|
||||
interface QueuedRoll {
|
||||
interface BaseQueuedRoll {
|
||||
rollCmd: string;
|
||||
modifiers: RollModifiers;
|
||||
originalCommand: string;
|
||||
}
|
||||
export interface ApiQueuedRoll extends QueuedRoll {
|
||||
export interface ApiQueuedRoll extends BaseQueuedRoll {
|
||||
apiRoll: true;
|
||||
api: {
|
||||
resolve: (value: Response | PromiseLike<Response>) => void;
|
||||
|
@ -41,13 +40,14 @@ export interface ApiQueuedRoll extends QueuedRoll {
|
|||
userId: bigint;
|
||||
};
|
||||
}
|
||||
export interface DDQueuedRoll extends QueuedRoll {
|
||||
export interface DDQueuedRoll extends BaseQueuedRoll {
|
||||
apiRoll: false;
|
||||
dd: {
|
||||
m: DiscordenoMessage;
|
||||
message: DiscordenoMessage;
|
||||
};
|
||||
}
|
||||
export type QueuedRoll = ApiQueuedRoll | DDQueuedRoll;
|
||||
|
||||
export type PastCommandCount = {
|
||||
command: string;
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
import { parseRoll } from './parser.ts';
|
||||
|
||||
export default {
|
||||
parseRoll,
|
||||
};
|
15
src/utils.ts
15
src/utils.ts
|
@ -3,16 +3,8 @@
|
|||
*
|
||||
* December 21, 2020
|
||||
*/
|
||||
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
// Discordeno deps
|
||||
sendMessage,
|
||||
} from '../deps.ts';
|
||||
import { log, LogTypes as LT } from '@Log4Deno';
|
||||
import { DiscordenoMessage, sendMessage } from '@discordeno';
|
||||
|
||||
// ask(prompt) returns string
|
||||
// ask prompts the user at command line for message
|
||||
|
@ -101,7 +93,8 @@ 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: {
|
||||
|
|
|
@ -1 +1 @@
|
|||
deno run --allow-write=./logs/,./src/endpoints/gets/heatmap.png --allow-read=./src/solver/,./src/endpoints/gets/heatmap-base.png,./src/endpoints/gets/heatmap.png,./config.ts,./deps.ts,./flags.ts,./src/mod.d.ts --allow-net --allow-import mod.ts
|
||||
deno run --allow-write=./logs/,./src/endpoints/gets/heatmap.png --allow-read=./src/artigen/,./src/endpoints/gets/heatmap-base.png,./src/endpoints/gets/heatmap.png,./config.ts,./deps.ts,./flags.ts,./src/mod.d.ts --allow-net --allow-import mod.ts
|
||||
|
|
Loading…
Reference in New Issue