[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": [],
|
"spellright.documentTypes": [],
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"artigen",
|
||||||
"channelid",
|
"channelid",
|
||||||
"CWOD",
|
"CWOD",
|
||||||
"DEVMODE",
|
"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_root="/var/dbots/TheArtificer"
|
||||||
artificer_write="./logs/,./src/endpoints/gets/heatmap.png"
|
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_log="/var/log/artificer.log"
|
||||||
|
|
||||||
artificer_chdir="${artificer_root}"
|
artificer_chdir="${artificer_root}"
|
||||||
|
|
|
@ -6,7 +6,7 @@ After=network.target
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
PIDFile=/run/deno.pid
|
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
|
RestartSec=60
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// This file will create all tables for the artificer schema
|
// This file will create all tables for the artificer schema
|
||||||
// DATA WILL BE LOST IF DB ALREADY EXISTS, RUN AT OWN RISK
|
// DATA WILL BE LOST IF DB ALREADY EXISTS, RUN AT OWN RISK
|
||||||
|
|
||||||
import config from '../config.ts';
|
import config from '/config.ts';
|
||||||
import dbClient from '../src/db/client.ts';
|
import dbClient from 'db/client.ts';
|
||||||
|
|
||||||
console.log('Attempting to create DB');
|
console.log('Attempting to create DB');
|
||||||
await dbClient.execute(`CREATE SCHEMA IF NOT EXISTS ${config.db.name};`);
|
await dbClient.execute(`CREATE SCHEMA IF NOT EXISTS ${config.db.name};`);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// This file will populate the tables with default values
|
// This file will populate the tables with default values
|
||||||
|
|
||||||
import config from '../config.ts';
|
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');
|
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) => {
|
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,
|
"indentWidth": 2,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"proseWrap": "preserve"
|
"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
|
// DEBUG is used to toggle the cmdPrompt and show debug log messages
|
||||||
export const DEBUG = false;
|
export const DEBUG = false;
|
||||||
// LOCALMODE is used to run a different bot token for local testing
|
// 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
|
* 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 config from '/config.ts';
|
||||||
import { DEBUG, DEVMODE, LOCALMODE } from './flags.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 commands from 'commands/_index.ts';
|
||||||
import dbClient from './src/db/client.ts';
|
|
||||||
import { ignoreList } from './src/db/common.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import commands from './src/commands/_index.ts';
|
import { ignoreList } from 'db/common.ts';
|
||||||
import intervals from './src/intervals.ts';
|
|
||||||
import { successColor, warnColor } from './src/commandUtils.ts';
|
import api from 'src/api.ts';
|
||||||
import utils from './src/utils.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
|
// Extend the BigInt prototype to support JSON.stringify
|
||||||
interface BigIntX extends BigInt {
|
interface BigIntX extends BigInt {
|
||||||
|
@ -66,7 +81,9 @@ startBot({
|
||||||
}, 30000);
|
}, 30000);
|
||||||
|
|
||||||
// Interval to update bot list stats every 24 hours
|
// 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');
|
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);
|
||||||
|
|
16
src/api.ts
16
src/api.ts
|
@ -3,16 +3,14 @@
|
||||||
*
|
*
|
||||||
* December 21, 2020
|
* December 21, 2020
|
||||||
*/
|
*/
|
||||||
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import config from '../config.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Log4Deno deps
|
import dbClient from 'db/client.ts';
|
||||||
log,
|
|
||||||
LT,
|
import endpoints from 'endpoints/_index.ts';
|
||||||
} from '../deps.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import dbClient from './db/client.ts';
|
|
||||||
import endpoints from './endpoints/_index.ts';
|
|
||||||
import stdResp from './endpoints/stdResponses.ts';
|
|
||||||
|
|
||||||
// start() returns nothing
|
// start() returns nothing
|
||||||
// start initializes and runs the entire API for the bot
|
// 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 => {
|
export const rollCounter = (rollSet: RollSet[]): CountDetails => {
|
||||||
const 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 config from '/config.ts';
|
||||||
import { DEVMODE } from '../../flags.ts';
|
import { generateCountDetailsEmbed, generateDMFailed, generateRollEmbed } from 'src/commandUtils.ts';
|
||||||
import dbClient from '../db/client.ts';
|
import { QueuedRoll, RollModifiers } from 'src/mod.d.ts';
|
||||||
import { queries } from '../db/common.ts';
|
import utils from 'src/utils.ts';
|
||||||
import {
|
import { SolvedRoll } from 'src/artigen/solver.d.ts';
|
||||||
// Discordeno deps
|
import { loggingEnabled } from 'src/artigen/rollUtils.ts';
|
||||||
DiscordenoMessage,
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
// Log4Deno deps
|
import { DEVMODE } from '/flags.ts';
|
||||||
log,
|
import dbClient from 'src/db/client.ts';
|
||||||
LT,
|
import stdResp from 'src/endpoints/stdResponses.ts';
|
||||||
// Discordeno deps
|
import { DiscordenoMessage, sendDirectMessage, sendMessage } from '@discordeno';
|
||||||
sendDirectMessage,
|
import { queries } from 'src/db/common.ts';
|
||||||
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';
|
|
||||||
|
|
||||||
let currentWorkers = 0;
|
export let currentWorkers = 0;
|
||||||
const rollQueue: Array<ApiQueuedRoll | DDQueuedRoll> = [];
|
|
||||||
|
|
||||||
// Handle setting up and calling the rollWorker
|
// Handle setting up and calling the rollWorker
|
||||||
const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
export const handleRollWorker = (rq: QueuedRoll) => {
|
||||||
currentWorkers++;
|
currentWorkers++;
|
||||||
|
|
||||||
// gmModifiers used to create gmEmbed (basically just turn off the gmRoll)
|
// gmModifiers used to create gmEmbed (basically just turn off the gmRoll)
|
||||||
const gmModifiers = JSON.parse(JSON.stringify(rq.modifiers));
|
const gmModifiers = JSON.parse(JSON.stringify(rq.modifiers));
|
||||||
gmModifiers.gmRoll = false;
|
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 () => {
|
const workerTimeout = setTimeout(async () => {
|
||||||
rollWorker.terminate();
|
rollWorker.terminate();
|
||||||
|
@ -49,7 +40,7 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
||||||
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 +171,9 @@ const handleRollWorker = (rq: ApiQueuedRoll | DDQueuedRoll) => {
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
details: pubEmbedDetails,
|
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 {
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
log,
|
|
||||||
// Log4Deno deps
|
|
||||||
LT,
|
|
||||||
} from '../../deps.ts';
|
|
||||||
|
|
||||||
import config from '../../config.ts';
|
import config from '/config.ts';
|
||||||
|
|
||||||
import { RollModifiers } from '../mod.d.ts';
|
import { RollModifiers } from 'src/mod.d.ts';
|
||||||
import { CountDetails, ReturnData, SolvedRoll, SolvedStep } from './solver.d.ts';
|
import { CountDetails, ReturnData, SolvedRoll, SolvedStep } from 'artigen/solver.d.ts';
|
||||||
import { compareTotalRolls, compareTotalRollsReverse, escapeCharacters, legalMathOperators, loggingEnabled } from './rollUtils.ts';
|
import { compareTotalRolls, compareTotalRollsReverse, escapeCharacters, legalMathOperators, loggingEnabled } from 'artigen/rollUtils.ts';
|
||||||
import { formatRoll } from './rollFormatter.ts';
|
import { formatRoll } from 'artigen/rollFormatter.ts';
|
||||||
import { fullSolver } from './solver.ts';
|
import { fullSolver } from 'artigen/solver.ts';
|
||||||
|
|
||||||
// parseRoll(fullCmd, modifiers)
|
// parseRoll(fullCmd, modifiers)
|
||||||
// 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
|
||||||
|
@ -37,6 +33,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
||||||
try {
|
try {
|
||||||
// Split the fullCmd by the command prefix to allow every roll/math op to be handled individually
|
// Split the fullCmd by the command prefix to allow every roll/math op to be handled individually
|
||||||
const sepRolls = fullCmd.split(config.prefix);
|
const sepRolls = fullCmd.split(config.prefix);
|
||||||
|
// TODO: HERE for the [[ ]] nesting stuff
|
||||||
|
|
||||||
const tempReturnData: ReturnData[] = [];
|
const tempReturnData: ReturnData[] = [];
|
||||||
const tempCountDetails: CountDetails[] = [
|
const tempCountDetails: CountDetails[] = [
|
||||||
|
@ -150,7 +147,7 @@ export const parseRoll = (fullCmd: string, modifiers: RollModifiers): SolvedRoll
|
||||||
containsCrit: false,
|
containsCrit: false,
|
||||||
containsFail: false,
|
containsFail: false,
|
||||||
},
|
},
|
||||||
],
|
]
|
||||||
);
|
);
|
||||||
i += 2;
|
i += 2;
|
||||||
} else if (!legalMathOperators.includes(strMathConfI) && legalMathOperators.some((mathOp) => strMathConfI.endsWith(mathOp))) {
|
} 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
|
// Populate line2 (the results) and line3 (the details) with their data
|
||||||
if (modifiers.order === '') {
|
if (modifiers.order === '') {
|
||||||
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${
|
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}${escapeCharacters(
|
||||||
escapeCharacters(
|
|
||||||
e.rollPostFormat,
|
e.rollPostFormat,
|
||||||
'|*_~`',
|
'|*_~`'
|
||||||
)
|
)} `;
|
||||||
} `;
|
|
||||||
} else {
|
} else {
|
||||||
// If order is on, turn rolls into csv without formatting
|
// If order is on, turn rolls into csv without formatting
|
||||||
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}, `;
|
line2 += `${preFormat}${modifiers.commaTotals ? e.rollTotal.toLocaleString() : e.rollTotal}${postFormat}, `;
|
|
@ -1,14 +1,10 @@
|
||||||
import {
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
log,
|
|
||||||
// Log4Deno deps
|
|
||||||
LT,
|
|
||||||
} from '../../deps.ts';
|
|
||||||
|
|
||||||
import { roll } from './roller.ts';
|
import { roll } from 'artigen/roller.ts';
|
||||||
import { rollCounter } from './counter.ts';
|
import { rollCounter } from 'artigen/counter.ts';
|
||||||
import { RollFormat } from './solver.d.ts';
|
import { RollFormat } from 'artigen/solver.d.ts';
|
||||||
import { loggingEnabled } from './rollUtils.ts';
|
import { loggingEnabled } from 'artigen/rollUtils.ts';
|
||||||
import { RollModifiers } from '../mod.d.ts';
|
import { RollModifiers } from 'src/mod.d.ts';
|
||||||
|
|
||||||
// formatRoll(rollConf, modifiers) returns one SolvedStep
|
// formatRoll(rollConf, modifiers) returns one SolvedStep
|
||||||
// formatRoll handles creating and formatting the completed rolls into the SolvedStep format
|
// formatRoll handles creating and formatting the completed rolls into the SolvedStep format
|
|
@ -1,11 +1,7 @@
|
||||||
import {
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
log,
|
import { RollModifiers } from 'src/mod.d.ts';
|
||||||
// Log4Deno deps
|
|
||||||
LT,
|
|
||||||
} from '../../deps.ts';
|
|
||||||
import { RollModifiers } from '../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;
|
type MathFunction = (arg: number) => number;
|
||||||
export const loggingEnabled = false;
|
export const loggingEnabled = false;
|
|
@ -1,7 +1,7 @@
|
||||||
import { closeLog, initLog } from '../../deps.ts';
|
import { closeLog, initLog } from '@Log4Deno';
|
||||||
import { DEBUG } from '../../flags.ts';
|
import { DEBUG } from '/flags.ts';
|
||||||
import { parseRoll } from './parser.ts';
|
import { parseRoll } from 'artigen/parser.ts';
|
||||||
import { loggingEnabled } from './rollUtils.ts';
|
import { loggingEnabled } from 'artigen/rollUtils.ts';
|
||||||
|
|
||||||
loggingEnabled && initLog('logs/worker', DEBUG);
|
loggingEnabled && initLog('logs/worker', DEBUG);
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
import config from '../../config.ts';
|
import config from '/config.ts';
|
||||||
import {
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
// Log4Deno deps
|
|
||||||
log,
|
|
||||||
LT,
|
|
||||||
} from '../../deps.ts';
|
|
||||||
|
|
||||||
import { RollConf, RollSet, RollType } from './solver.d.ts';
|
import { RollConf, RollSet, RollType } from 'artigen/solver.d.ts';
|
||||||
import { compareOrigIdx, compareRolls, genFateRoll, genRoll, loggingEnabled } from './rollUtils.ts';
|
import { compareOrigIdx, compareRolls, genFateRoll, genRoll, loggingEnabled } from 'artigen/rollUtils.ts';
|
||||||
import { RollModifiers } from '../mod.d.ts';
|
import { RollModifiers } from 'src/mod.d.ts';
|
||||||
|
|
||||||
// Call with loopCountCheck(++loopCount);
|
// Call with loopCountCheck(++loopCount);
|
||||||
// Will ensure if maxLoops is 10, 10 loops will be allowed, 11 will not.
|
// 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';
|
export type RollType = '' | 'roll20' | 'fate' | 'cwod' | 'ova';
|
||||||
|
|
||||||
// RollSet is used to preserve all information about a calculated roll
|
// RollSet is used to preserve all information about a calculated roll
|
|
@ -3,15 +3,10 @@
|
||||||
*
|
*
|
||||||
* December 21, 2020
|
* December 21, 2020
|
||||||
*/
|
*/
|
||||||
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import {
|
import { SolvedStep } from 'artigen/solver.d.ts';
|
||||||
log,
|
import { legalMath, legalMathOperators, loggingEnabled } from 'artigen/rollUtils.ts';
|
||||||
// Log4Deno deps
|
|
||||||
LT,
|
|
||||||
} from '../../deps.ts';
|
|
||||||
|
|
||||||
import { SolvedStep } from './solver.d.ts';
|
|
||||||
import { legalMath, legalMathOperators, loggingEnabled } from './rollUtils.ts';
|
|
||||||
|
|
||||||
// fullSolver(conf, wrapDetails) returns one condensed SolvedStep
|
// fullSolver(conf, wrapDetails) returns one condensed SolvedStep
|
||||||
// fullSolver is a function that recursively solves the full roll and math
|
// fullSolver is a function that recursively solves the full roll and math
|
|
@ -1,8 +1,11 @@
|
||||||
import config from '../config.ts';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import { CountDetails, SolvedRoll } from './solver/solver.d.ts';
|
|
||||||
import { RollModifiers } from './mod.d.ts';
|
import config from '/config.ts';
|
||||||
import { loggingEnabled } from './solver/rollUtils.ts';
|
|
||||||
import { log, LT } from '../deps.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 failColor = 0xe71212;
|
||||||
export const warnColor = 0xe38f28;
|
export const warnColor = 0xe38f28;
|
||||||
|
@ -46,7 +49,7 @@ export const generateStats = (
|
||||||
utilityCount: bigint,
|
utilityCount: bigint,
|
||||||
rollRate: number,
|
rollRate: number,
|
||||||
utilityRate: number,
|
utilityRate: number,
|
||||||
queryTimeMs: number,
|
queryTimeMs: number
|
||||||
) => ({
|
) => ({
|
||||||
embeds: [
|
embeds: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
import { ping } from './ping.ts';
|
import { api } from 'commands/apiCmd.ts';
|
||||||
import { rip } from './rip.ts';
|
import { audit } from 'commands/audit.ts';
|
||||||
import { rollHelp } from './rollHelp.ts';
|
import { emoji } from 'commands/emoji.ts';
|
||||||
import { rollDecorators } from './rollDecorators.ts';
|
import { handleMentions } from 'commands/handleMentions.ts';
|
||||||
import { help } from './help.ts';
|
import { heatmap } from 'commands/heatmap.ts';
|
||||||
import { info } from './info.ts';
|
import { help } from 'commands/help.ts';
|
||||||
import { privacy } from './privacy.ts';
|
import { info } from 'commands/info.ts';
|
||||||
import { version } from './version.ts';
|
import { optIn } from 'commands/optIn.ts';
|
||||||
import { report } from './report.ts';
|
import { optOut } from 'commands/optOut.ts';
|
||||||
import { stats } from './stats.ts';
|
import { ping } from 'commands/ping.ts';
|
||||||
import { api } from './apiCmd.ts';
|
import { privacy } from 'commands/privacy.ts';
|
||||||
import { emoji } from './emoji.ts';
|
import { rip } from 'commands/rip.ts';
|
||||||
import { roll } from './roll.ts';
|
import { report } from 'commands/report.ts';
|
||||||
import { handleMentions } from './handleMentions.ts';
|
import { roll } from 'commands/roll.ts';
|
||||||
import { audit } from './audit.ts';
|
import { rollDecorators } from 'commands/rollDecorators.ts';
|
||||||
import { heatmap } from './heatmap.ts';
|
import { rollHelp } from 'commands/rollHelp.ts';
|
||||||
import { optOut } from './optOut.ts';
|
import { stats } from 'commands/stats.ts';
|
||||||
import { optIn } from './optIn.ts';
|
import { version } from 'commands/version.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
ping,
|
ping,
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import dbClient from '../db/client.ts';
|
import { DiscordenoMessage, hasGuildPermissions } from '@discordeno';
|
||||||
import { queries } from '../db/common.ts';
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
import apiCommands from 'commands/apiCmd/_index.ts';
|
||||||
hasGuildPermissions,
|
|
||||||
} from '../../deps.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import apiCommands from './apiCmd/_index.ts';
|
import { queries } from 'db/common.ts';
|
||||||
import { failColor } from '../commandUtils.ts';
|
|
||||||
import utils from '../utils.ts';
|
import { failColor } from 'src/commandUtils.ts';
|
||||||
import config from '../../config.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const api = async (message: DiscordenoMessage, args: string[]) => {
|
export const api = async (message: DiscordenoMessage, args: string[]) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { help } from './apiHelp.ts';
|
import { allowBlock } from 'commands/apiCmd/allowBlock.ts';
|
||||||
import { allowBlock } from './allowBlock.ts';
|
import { help } from 'commands/apiCmd/apiHelp.ts';
|
||||||
import { deleteGuild } from './deleteGuild.ts';
|
import { deleteGuild } from 'commands/apiCmd/deleteGuild.ts';
|
||||||
import { status } from './status.ts';
|
import { showHideWarn } from 'commands/apiCmd/showHideWarn.ts';
|
||||||
import { showHideWarn } from './showHideWarn.ts';
|
import { status } from 'commands/apiCmd/status.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
help,
|
help,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../../deps.ts';
|
import { generateApiFailed, generateApiSuccess } from 'src/commandUtils.ts';
|
||||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
export const allowBlock = async (message: DiscordenoMessage, apiArg: string) => {
|
export const allowBlock = async (message: DiscordenoMessage, apiArg: string) => {
|
||||||
let errorOutInitial = false;
|
let errorOutInitial = false;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import config from '../../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import config from '/config.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../../deps.ts';
|
import { infoColor1, infoColor2 } from 'src/commandUtils.ts';
|
||||||
import { infoColor1, infoColor2 } from '../../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
export const help = (message: DiscordenoMessage) => {
|
export const help = (message: DiscordenoMessage) => {
|
||||||
message
|
message
|
||||||
|
@ -13,8 +12,7 @@ export const help = (message: DiscordenoMessage) => {
|
||||||
{
|
{
|
||||||
color: infoColor2,
|
color: infoColor2,
|
||||||
title: `${config.name}'s API Details:`,
|
title: `${config.name}'s API Details:`,
|
||||||
description:
|
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.
|
||||||
`${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}).
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import config from '/config.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../../deps.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import { failColor, successColor } from '../../commandUtils.ts';
|
|
||||||
import utils from '../../utils.ts';
|
import { failColor, successColor } from 'src/commandUtils.ts';
|
||||||
import config from '../../../config.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const deleteGuild = async (message: DiscordenoMessage) => {
|
export const deleteGuild = async (message: DiscordenoMessage) => {
|
||||||
let errorOut = false;
|
let errorOut = false;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../../deps.ts';
|
import { generateApiFailed, generateApiSuccess } from 'src/commandUtils.ts';
|
||||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
export const showHideWarn = async (message: DiscordenoMessage, apiArg: string) => {
|
export const showHideWarn = async (message: DiscordenoMessage, apiArg: string) => {
|
||||||
let errorOutInitial = false;
|
let errorOutInitial = false;
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../../deps.ts';
|
import { failColor, generateApiStatus } from 'src/commandUtils.ts';
|
||||||
import { failColor, generateApiStatus } from '../../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
export const status = async (message: DiscordenoMessage) => {
|
export const status = async (message: DiscordenoMessage) => {
|
||||||
// Get status of guild from the db
|
// Get status of guild from the db
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import auditCommands from 'commands/auditCmd/_index.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../deps.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import auditCommands from './auditCmd/_index.ts';
|
import { queries } from 'db/common.ts';
|
||||||
import { failColor } from '../commandUtils.ts';
|
|
||||||
import utils from '../utils.ts';
|
import { failColor } from 'src/commandUtils.ts';
|
||||||
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const audit = (message: DiscordenoMessage, args: string[]) => {
|
export const audit = (message: DiscordenoMessage, args: string[]) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { auditHelp } from './auditHelp.ts';
|
import { auditDB } from 'commands/auditCmd/auditDB.ts';
|
||||||
import { auditDB } from './auditDB.ts';
|
import { auditGuilds } from 'commands/auditCmd/auditGuilds.ts';
|
||||||
import { auditGuilds } from './auditGuilds.ts';
|
import { auditHelp } from 'commands/auditCmd/auditHelp.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
auditHelp,
|
auditHelp,
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import { DiscordenoMessage, EmbedField } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
EmbedField,
|
import { compilingStats } from 'src/commonEmbeds.ts';
|
||||||
} from '../../../deps.ts';
|
import { infoColor2 } from 'src/commandUtils.ts';
|
||||||
import { infoColor2 } from '../../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import { compilingStats } from '../../commonEmbeds.ts';
|
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
interface DBSizeData {
|
interface DBSizeData {
|
||||||
table: string;
|
table: string;
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
import config from '../../../config.ts';
|
import { cache, cacheHandlers, DiscordenoGuild, DiscordenoMessage } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import config from '/config.ts';
|
||||||
cache,
|
|
||||||
cacheHandlers,
|
import { infoColor2 } from 'src/commandUtils.ts';
|
||||||
DiscordenoGuild,
|
import utils from 'src/utils.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../../deps.ts';
|
|
||||||
import { infoColor2 } from '../../commandUtils.ts';
|
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
const sortGuildByMemberCount = (a: DiscordenoGuild, b: DiscordenoGuild) => {
|
const sortGuildByMemberCount = (a: DiscordenoGuild, b: DiscordenoGuild) => {
|
||||||
if (a.memberCount < b.memberCount) {
|
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:',
|
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`)
|
.map((ownerCnt, serverIdx) => `${ownerCnt} ${ownerCnt === 1 ? 'person has' : 'people have'} me in ${serverIdx + 1} of their guilds`)
|
||||||
.filter((str) => str)
|
.filter((str) => str)
|
||||||
.join('\n') || 'No Repeat Guild Owners',
|
.join('\n') || 'No Repeat Guild Owners',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Guild Size Dist:',
|
name: 'Guild Size Dist:',
|
||||||
value: Array.from(guildSizeDist)
|
value:
|
||||||
|
Array.from(guildSizeDist)
|
||||||
.map(
|
.map(
|
||||||
([size, count], idx) =>
|
([size, count], idx) =>
|
||||||
`${count} Guild${count === 1 ? ' has' : 's have'} ${
|
`${count} Guild${count === 1 ? ' has' : 's have'} ${
|
||||||
guildSizeDist.has(sizeCats[idx - 1]) ? `${size.toLocaleString()} - ${(sizeCats[idx - 1] - 1).toLocaleString()}` : `at least ${size.toLocaleString()}`
|
guildSizeDist.has(sizeCats[idx - 1])
|
||||||
} Member${size === 1 ? '' : 's'}`,
|
? `${size.toLocaleString()} - ${(sizeCats[idx - 1] - 1).toLocaleString()}`
|
||||||
|
: `at least ${size.toLocaleString()}`
|
||||||
|
} Member${size === 1 ? '' : 's'}`
|
||||||
)
|
)
|
||||||
.join('\n') || 'Not available',
|
.join('\n') || 'Not available',
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import config from '../../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import config from '/config.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../../deps.ts';
|
import { infoColor1 } from 'src/commandUtils.ts';
|
||||||
import { infoColor1 } from '../../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
export const auditHelp = (message: DiscordenoMessage) => {
|
export const auditHelp = (message: DiscordenoMessage) => {
|
||||||
message
|
message
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import { queries } from '../db/common.ts';
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
import dbClient from 'db/client.ts';
|
||||||
// Log4Deno deps
|
import { queries } from 'db/common.ts';
|
||||||
log,
|
|
||||||
LT,
|
import { EmojiConf } from 'src/mod.d.ts';
|
||||||
} from '../../deps.ts';
|
import utils from 'src/utils.ts';
|
||||||
import { EmojiConf } from '../mod.d.ts';
|
|
||||||
import utils from '../utils.ts';
|
|
||||||
|
|
||||||
const allEmojiAliases: string[] = [];
|
const allEmojiAliases: string[] = [];
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,13 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import { queries } from '../db/common.ts';
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
import dbClient from 'db/client.ts';
|
||||||
// Log4Deno deps
|
import { queries } from 'db/common.ts';
|
||||||
log,
|
|
||||||
LT,
|
import { infoColor1 } from 'src/commandUtils.ts';
|
||||||
} from '../../deps.ts';
|
import utils from 'src/utils.ts';
|
||||||
import { infoColor1 } from '../commandUtils.ts';
|
|
||||||
import utils from '../utils.ts';
|
|
||||||
|
|
||||||
export const handleMentions = (message: DiscordenoMessage) => {
|
export const handleMentions = (message: DiscordenoMessage) => {
|
||||||
log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
|
log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import dbClient from '../db/client.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import { queries } from '../db/common.ts';
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
import dbClient from 'db/client.ts';
|
||||||
} from '../../deps.ts';
|
import { queries } from 'db/common.ts';
|
||||||
import config from '../../config.ts';
|
|
||||||
import { failColor, infoColor2 } from '../commandUtils.ts';
|
import { failColor, infoColor2 } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import intervals from 'src/intervals.ts';
|
||||||
import intervals from '../intervals.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const heatmap = (message: DiscordenoMessage) => {
|
export const heatmap = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { infoColor2 } from '../commandUtils.ts';
|
import { infoColor2 } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const help = (message: DiscordenoMessage) => {
|
export const help = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// 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}\` ...`,
|
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
||||||
value:
|
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`,
|
||||||
`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,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { infoColor2 } from '../commandUtils.ts';
|
import { infoColor2 } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const info = (message: DiscordenoMessage) => {
|
export const info = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { ignoreList, queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { ignoreList, queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { failColor, successColor } from '../commandUtils.ts';
|
import { failColor, successColor } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const optIn = async (message: DiscordenoMessage) => {
|
export const optIn = async (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { ignoreList, queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { ignoreList, queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { failColor, successColor } from '../commandUtils.ts';
|
import { failColor, successColor } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const optOut = async (message: DiscordenoMessage) => {
|
export const optOut = async (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import dbClient from '../db/client.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import { queries } from '../db/common.ts';
|
|
||||||
import {
|
import dbClient from 'db/client.ts';
|
||||||
// Discordeno deps
|
import { queries } from 'db/common.ts';
|
||||||
DiscordenoMessage,
|
|
||||||
} from '../../deps.ts';
|
import { generatePing } from 'src/commandUtils.ts';
|
||||||
import { generatePing } from '../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import utils from '../utils.ts';
|
|
||||||
|
|
||||||
export const ping = async (message: DiscordenoMessage) => {
|
export const ping = async (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { infoColor1 } from '../commandUtils.ts';
|
import { infoColor1 } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const privacy = (message: DiscordenoMessage) => {
|
export const privacy = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
@ -21,8 +21,7 @@ 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:
|
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.
|
||||||
`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}).
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage, sendMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { queries } from 'db/common.ts';
|
||||||
// Discordeno deps
|
|
||||||
sendMessage,
|
import { failColor, generateReport, successColor } from 'src/commandUtils.ts';
|
||||||
} from '../../deps.ts';
|
import utils from 'src/utils.ts';
|
||||||
import { failColor, generateReport, successColor } from '../commandUtils.ts';
|
|
||||||
import utils from '../utils.ts';
|
|
||||||
|
|
||||||
export const report = (message: DiscordenoMessage, args: string[]) => {
|
export const report = (message: DiscordenoMessage, args: string[]) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import dbClient from '../db/client.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import { queries } from '../db/common.ts';
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
import dbClient from 'db/client.ts';
|
||||||
} from '../../deps.ts';
|
import { queries } from 'db/common.ts';
|
||||||
import { infoColor2 } from '../commandUtils.ts';
|
|
||||||
import utils from '../utils.ts';
|
import { infoColor2 } from 'src/commandUtils.ts';
|
||||||
import config from '../../config.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const rip = (message: DiscordenoMessage) => {
|
export const rip = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import { DEVMODE } from '../../flags.ts';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
import { DEVMODE } from '/flags.ts';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
import { queueRoll } from 'artigen/managers/queueManager.ts';
|
||||||
// Log4Deno deps
|
|
||||||
log,
|
import dbClient from 'db/client.ts';
|
||||||
LT,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { rollingEmbed, warnColor } from '../commandUtils.ts';
|
import rollFuncs from 'commands/roll/_index.ts';
|
||||||
import rollFuncs from './roll/_index.ts';
|
|
||||||
import { queueRoll } from '../solver/rollQueue.ts';
|
import { rollingEmbed, warnColor } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
|
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// 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 {
|
export default {
|
||||||
getModifiers,
|
getModifiers,
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
import config from '../../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import { DEVMODE } from '../../../flags.ts';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import dbClient from '../../db/client.ts';
|
|
||||||
import { queries } from '../../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
import { DEVMODE } from '/flags.ts';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
import dbClient from 'db/client.ts';
|
||||||
// Log4Deno deps
|
import { queries } from 'db/common.ts';
|
||||||
log,
|
|
||||||
LT,
|
import { generateRollError } from 'src/commandUtils.ts';
|
||||||
} from '../../../deps.ts';
|
import { RollModifiers } from 'src/mod.d.ts';
|
||||||
import { generateRollError } from '../../commandUtils.ts';
|
import utils from 'src/utils.ts';
|
||||||
import { RollModifiers } from '../../mod.d.ts';
|
|
||||||
import utils from '../../utils.ts';
|
|
||||||
|
|
||||||
export const getModifiers = (m: DiscordenoMessage, args: string[], command: string, originalCommand: string): RollModifiers => {
|
export const getModifiers = (m: DiscordenoMessage, args: string[], command: string, originalCommand: string): RollModifiers => {
|
||||||
const errorType = 'Modifiers invalid:';
|
const errorType = 'Modifiers invalid:';
|
||||||
|
@ -70,7 +68,9 @@ 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) => 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 (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
|
||||||
|
@ -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 (!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) => 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 (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
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { infoColor2 } from '../commandUtils.ts';
|
import { infoColor2 } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const rollDecorators = (message: DiscordenoMessage) => {
|
export const rollDecorators = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// 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',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { infoColor1, infoColor2, successColor } from '../commandUtils.ts';
|
import { infoColor1, infoColor2, successColor } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const rollHelp = (message: DiscordenoMessage) => {
|
export const rollHelp = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// 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]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`r>q` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`roa` or `ro=q` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`ro<q` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`ro>q` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -187,27 +192,32 @@ Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!p>u` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!p<u` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!=u` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!>u` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: '`!!<u` [Optional]',
|
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,
|
inline: true,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
import dbClient from '../db/client.ts';
|
import { cache, cacheHandlers, DiscordenoMessage } from '@discordeno';
|
||||||
import { queries } from '../db/common.ts';
|
|
||||||
import {
|
import dbClient from 'db/client.ts';
|
||||||
// Discordeno deps
|
import { queries } from 'db/common.ts';
|
||||||
cache,
|
|
||||||
cacheHandlers,
|
import { compilingStats } from 'src/commonEmbeds.ts';
|
||||||
DiscordenoMessage,
|
import { generateStats } from 'src/commandUtils.ts';
|
||||||
} from '../../deps.ts';
|
import utils from 'src/utils.ts';
|
||||||
import { generateStats } from '../commandUtils.ts';
|
|
||||||
import { compilingStats } from '../commonEmbeds.ts';
|
|
||||||
import utils from '../utils.ts';
|
|
||||||
|
|
||||||
export const stats = async (message: DiscordenoMessage) => {
|
export const stats = async (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// Light telemetry to see how many times a command is being run
|
||||||
|
@ -45,8 +42,8 @@ export const stats = async (message: DiscordenoMessage) => {
|
||||||
total - rolls,
|
total - rolls,
|
||||||
rollRate,
|
rollRate,
|
||||||
totalRate - rollRate,
|
totalRate - rollRate,
|
||||||
endTime - startTime,
|
endTime - startTime
|
||||||
),
|
)
|
||||||
).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);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import config from '../../config.ts';
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import dbClient from '../db/client.ts';
|
|
||||||
import { queries } from '../db/common.ts';
|
import config from '/config.ts';
|
||||||
import {
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
DiscordenoMessage,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../deps.ts';
|
|
||||||
import { infoColor1 } from '../commandUtils.ts';
|
import { infoColor1 } from 'src/commandUtils.ts';
|
||||||
import utils from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const version = (message: DiscordenoMessage) => {
|
export const version = (message: DiscordenoMessage) => {
|
||||||
// Light telemetry to see how many times a command is being run
|
// 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 = {
|
export const compilingStats = {
|
||||||
embeds: [
|
embeds: [
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import config from '../../config.ts';
|
import { Client } from '@mysql';
|
||||||
import { Client } from '../../deps.ts';
|
|
||||||
import { LOCALMODE } from '../../flags.ts';
|
import config from '/config.ts';
|
||||||
|
import { LOCALMODE } from '/flags.ts';
|
||||||
|
|
||||||
const dbClient = await new Client().connect({
|
const dbClient = await new Client().connect({
|
||||||
hostname: LOCALMODE ? config.db.localhost : config.db.host,
|
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 = {
|
type UserIdObj = {
|
||||||
userid: bigint;
|
userid: bigint;
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
import { apiKeyDelete } from './deletes/apiKeyDelete.ts';
|
import { apiKeyDelete } from 'endpoints/deletes/apiKeyDelete.ts';
|
||||||
import { apiKey } from './gets/apiKey.ts';
|
|
||||||
import { apiRoll } from './gets/apiRoll.ts';
|
import { apiChannel } from 'endpoints/gets/apiChannel.ts';
|
||||||
import { apiKeyAdmin } from './gets/apiKeyAdmin.ts';
|
import { apiKey } from 'endpoints/gets/apiKey.ts';
|
||||||
import { apiChannel } from './gets/apiChannel.ts';
|
import { apiKeyAdmin } from 'endpoints/gets/apiKeyAdmin.ts';
|
||||||
import { heatmapPng } from './gets/heatmapPng.ts';
|
import { apiRoll } from 'endpoints/gets/apiRoll.ts';
|
||||||
import { apiChannelAdd } from './posts/apiChannelAdd.ts';
|
import { heatmapPng } from 'endpoints/gets/heatmapPng.ts';
|
||||||
import { apiKeyManage } from './puts/apiKeyManage.ts';
|
|
||||||
import { apiChannelManageBan } from './puts/apiChannelManageBan.ts';
|
import { apiChannelAdd } from 'endpoints/posts/apiChannelAdd.ts';
|
||||||
import { apiChannelManageActive } from './puts/apiChannelManageActive.ts';
|
|
||||||
|
import { apiChannelManageActive } from 'endpoints/puts/apiChannelManageActive.ts';
|
||||||
|
import { apiChannelManageBan } from 'endpoints/puts/apiChannelManageBan.ts';
|
||||||
|
import { apiKeyManage } from 'endpoints/puts/apiKeyManage.ts';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
delete: {
|
delete: {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import config from '../../../config.ts';
|
import { sendMessage } from '@discordeno';
|
||||||
import dbClient from '../../db/client.ts';
|
import { nanoid } from '@nanoid';
|
||||||
import {
|
|
||||||
// nanoid deps
|
import config from '/config.ts';
|
||||||
nanoid,
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
sendMessage,
|
|
||||||
} from '../../../deps.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import { generateApiDeleteEmail } from '../../commandUtils.ts';
|
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
import stdResp from '../stdResponses.ts';
|
import { generateApiDeleteEmail } from 'src/commandUtils.ts';
|
||||||
import { verifyQueryHasParams } from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const apiKeyDelete = async (query: Map<string, string>, apiUserid: bigint, apiUserEmail: string, apiUserDelCode: string): Promise<Response> => {
|
export const apiKeyDelete = async (query: Map<string, string>, apiUserid: bigint, apiUserEmail: string, apiUserDelCode: string): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user', 'email'])) {
|
if (verifyQueryHasParams(query, ['user', 'email'])) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import stdResp from '../stdResponses.ts';
|
|
||||||
import utils from '../../utils.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import { verifyQueryHasParams } from '../utils.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> => {
|
export const apiChannel = async (query: Map<string, string>, apiUserid: bigint): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user'])) {
|
if (verifyQueryHasParams(query, ['user'])) {
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import config from '../../../config.ts';
|
import { sendMessage } from '@discordeno';
|
||||||
import dbClient from '../../db/client.ts';
|
import { nanoid } from '@nanoid';
|
||||||
import {
|
|
||||||
// nanoid deps
|
import config from '/config.ts';
|
||||||
nanoid,
|
|
||||||
// Discordeno deps
|
import dbClient from 'db/client.ts';
|
||||||
sendMessage,
|
|
||||||
} from '../../../deps.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import { generateApiKeyEmail } from '../../commandUtils.ts';
|
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
import stdResp from '../stdResponses.ts';
|
import { generateApiKeyEmail } from 'src/commandUtils.ts';
|
||||||
import { verifyQueryHasParams } from '../utils.ts';
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const apiKey = async (query: Map<string, string>): Promise<Response> => {
|
export const apiKey = async (query: Map<string, string>): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user', 'email'])) {
|
if (verifyQueryHasParams(query, ['user', 'email'])) {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
import config from '../../../config.ts';
|
import { nanoid } from '@nanoid';
|
||||||
import dbClient from '../../db/client.ts';
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// nanoid deps
|
|
||||||
nanoid,
|
import dbClient from 'db/client.ts';
|
||||||
} from '../../../deps.ts';
|
|
||||||
import stdResp from '../stdResponses.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import utils from '../../utils.ts';
|
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||||
import { verifyQueryHasParams } from '../utils.ts';
|
|
||||||
|
import utils from 'src/utils.ts';
|
||||||
|
|
||||||
export const apiKeyAdmin = async (query: Map<string, string>, apiUserid: bigint): Promise<Response> => {
|
export const apiKeyAdmin = async (query: Map<string, string>, apiUserid: bigint): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user', 'a'])) {
|
if (verifyQueryHasParams(query, ['user', 'a'])) {
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import config from '../../../config.ts';
|
import { cache } from '@discordeno';
|
||||||
import dbClient from '../../db/client.ts';
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import { queries } from '../../db/common.ts';
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// Discordeno deps
|
|
||||||
cache,
|
import { queueRoll } from 'artigen/managers/queueManager.ts';
|
||||||
// Log4Deno deps
|
|
||||||
log,
|
import dbClient from 'db/client.ts';
|
||||||
LT,
|
import { queries } from 'db/common.ts';
|
||||||
} from '../../../deps.ts';
|
|
||||||
import { RollModifiers } from '../../mod.d.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import utils from '../../utils.ts';
|
import { verifyQueryHasParams } from 'endpoints/utils.ts';
|
||||||
import { queueRoll } from '../../solver/rollQueue.ts';
|
|
||||||
import stdResp from '../stdResponses.ts';
|
import { RollModifiers } from 'src/mod.d.ts';
|
||||||
import { verifyQueryHasParams } from '../utils.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}>`;
|
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 {
|
} 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 {
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import {
|
import { STATUS_CODE, STATUS_TEXT } from '@std/http';
|
||||||
// httpd deps
|
|
||||||
STATUS_CODE,
|
|
||||||
STATUS_TEXT,
|
|
||||||
} from '../../../deps.ts';
|
|
||||||
|
|
||||||
export const heatmapPng = (): Response => {
|
export const heatmapPng = (): Response => {
|
||||||
const file = Deno.readFileSync('./src/endpoints/gets/heatmap.png');
|
const file = Deno.readFileSync('./src/endpoints/gets/heatmap.png');
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import stdResp from '../stdResponses.ts';
|
|
||||||
import utils from '../../utils.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import { verifyQueryHasParams } from '../utils.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> => {
|
export const apiChannelAdd = async (query: Map<string, string>, apiUserid: bigint): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user', 'channel'])) {
|
if (verifyQueryHasParams(query, ['user', 'channel'])) {
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
import dbClient from '../../db/client.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import stdResp from '../stdResponses.ts';
|
|
||||||
import utils from '../../utils.ts';
|
import stdResp from 'endpoints/stdResponses.ts';
|
||||||
import { verifyQueryHasParams } from '../utils.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> => {
|
export const apiChannelManageActive = async (query: Map<string, string>, apiUserid: bigint, path: string): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user', 'channel'])) {
|
if (verifyQueryHasParams(query, ['user', 'channel'])) {
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import config from '../../../config.ts';
|
import config from '/config.ts';
|
||||||
import dbClient from '../../db/client.ts';
|
|
||||||
import stdResp from '../stdResponses.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
import { verifyQueryHasParams } from '../utils.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> => {
|
export const apiChannelManageBan = async (query: Map<string, string>, apiUserid: bigint, path: string): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user', 'channel', 'a'])) {
|
if (verifyQueryHasParams(query, ['user', 'channel', 'a'])) {
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
import config from '../../../config.ts';
|
import config from '/config.ts';
|
||||||
import dbClient from '../../db/client.ts';
|
|
||||||
import stdResp from '../stdResponses.ts';
|
import dbClient from 'db/client.ts';
|
||||||
import utils from '../../utils.ts';
|
|
||||||
import { verifyQueryHasParams } from '../utils.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> => {
|
export const apiKeyManage = async (query: Map<string, string>, apiUserid: bigint, path: string): Promise<Response> => {
|
||||||
if (verifyQueryHasParams(query, ['user', 'a'])) {
|
if (verifyQueryHasParams(query, ['user', 'a'])) {
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import {
|
import { STATUS_CODE, STATUS_TEXT, StatusCode } from '@std/http';
|
||||||
STATUS_CODE,
|
|
||||||
STATUS_TEXT,
|
|
||||||
// httpd deps
|
|
||||||
StatusCode,
|
|
||||||
} from '../../deps.ts';
|
|
||||||
|
|
||||||
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 {
|
export default {
|
||||||
BadRequest: (customText: string) => genericResponse(customText, STATUS_CODE.BadRequest),
|
BadRequest: (customText: string) => genericResponse(customText, STATUS_CODE.BadRequest),
|
||||||
|
|
|
@ -3,22 +3,17 @@
|
||||||
*
|
*
|
||||||
* December 21, 2020
|
* December 21, 2020
|
||||||
*/
|
*/
|
||||||
|
import { cache, cacheHandlers } from '@discordeno';
|
||||||
|
import { Image, decode } from '@imagescript';
|
||||||
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
|
|
||||||
import {
|
import config from '/config.ts';
|
||||||
// Discordeno deps
|
|
||||||
cache,
|
import dbClient from 'db/client.ts';
|
||||||
cacheHandlers,
|
import { weekDays } from 'db/common.ts';
|
||||||
// imagescript dep
|
|
||||||
is,
|
import { PastCommandCount } from 'src/mod.d.ts';
|
||||||
// Log4Deno deps
|
import utils from 'src/utils.ts';
|
||||||
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';
|
|
||||||
|
|
||||||
// getRandomStatus() returns status as string
|
// getRandomStatus() returns status as string
|
||||||
// Gets a new random status for the bot
|
// Gets a new random status for the bot
|
||||||
|
@ -163,8 +158,8 @@ let minRollCnt: number;
|
||||||
let maxRollCnt: number;
|
let maxRollCnt: number;
|
||||||
const updateHeatmapPng = async () => {
|
const updateHeatmapPng = async () => {
|
||||||
const baseHeatmap = Deno.readFileSync('./src/endpoints/gets/heatmap-base.png');
|
const baseHeatmap = Deno.readFileSync('./src/endpoints/gets/heatmap-base.png');
|
||||||
const heatmap = await is.decode(baseHeatmap);
|
const heatmap = await decode(baseHeatmap);
|
||||||
if (!(heatmap instanceof is.Image)) {
|
if (!(heatmap instanceof Image)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get latest data from DB
|
// Get latest data from DB
|
||||||
|
@ -198,7 +193,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),
|
Image.rgbToColor(255 * (1 - percent), 255 * percent, 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// mod.d.ts custom types
|
import { DiscordenoMessage } from '@discordeno';
|
||||||
import { DiscordenoMessage } from '../deps.ts';
|
|
||||||
|
|
||||||
// EmojiConf is used as a structure for the emojis stored in config.ts
|
// EmojiConf is used as a structure for the emojis stored in config.ts
|
||||||
export type EmojiConf = {
|
export type EmojiConf = {
|
||||||
|
@ -28,12 +27,12 @@ export type RollModifiers = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// QueuedRoll is the structure to track rolls we could not immediately handle
|
// QueuedRoll is the structure to track rolls we could not immediately handle
|
||||||
interface QueuedRoll {
|
interface BaseQueuedRoll {
|
||||||
rollCmd: string;
|
rollCmd: string;
|
||||||
modifiers: RollModifiers;
|
modifiers: RollModifiers;
|
||||||
originalCommand: string;
|
originalCommand: string;
|
||||||
}
|
}
|
||||||
export interface ApiQueuedRoll extends QueuedRoll {
|
export interface ApiQueuedRoll extends BaseQueuedRoll {
|
||||||
apiRoll: true;
|
apiRoll: true;
|
||||||
api: {
|
api: {
|
||||||
resolve: (value: Response | PromiseLike<Response>) => void;
|
resolve: (value: Response | PromiseLike<Response>) => void;
|
||||||
|
@ -41,13 +40,14 @@ export interface ApiQueuedRoll extends QueuedRoll {
|
||||||
userId: bigint;
|
userId: bigint;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
export interface DDQueuedRoll extends QueuedRoll {
|
export interface DDQueuedRoll extends BaseQueuedRoll {
|
||||||
apiRoll: false;
|
apiRoll: false;
|
||||||
dd: {
|
dd: {
|
||||||
m: DiscordenoMessage;
|
m: DiscordenoMessage;
|
||||||
message: DiscordenoMessage;
|
message: DiscordenoMessage;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
export type QueuedRoll = ApiQueuedRoll | DDQueuedRoll;
|
||||||
|
|
||||||
export type PastCommandCount = {
|
export type PastCommandCount = {
|
||||||
command: string;
|
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
|
* December 21, 2020
|
||||||
*/
|
*/
|
||||||
|
import { log, LogTypes as LT } from '@Log4Deno';
|
||||||
import {
|
import { DiscordenoMessage, sendMessage } from '@discordeno';
|
||||||
// Discordeno deps
|
|
||||||
DiscordenoMessage,
|
|
||||||
// Log4Deno deps
|
|
||||||
log,
|
|
||||||
LT,
|
|
||||||
// Discordeno deps
|
|
||||||
sendMessage,
|
|
||||||
} from '../deps.ts';
|
|
||||||
|
|
||||||
// ask(prompt) returns string
|
// ask(prompt) returns string
|
||||||
// ask prompts the user at command line for message
|
// 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}`);
|
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) => 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 {
|
export default {
|
||||||
commonLoggers: {
|
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