mirror of
https://github.com/Burn-E99/TheArtificer.git
synced 2026-06-04 09:03:50 -04:00
Minor adjustments
report command now requires a description moved an insert query that was duplicated many times to new constant in the db.ts import improved error reporting on roll modifiers, they now are fancy EMBEDS!
This commit is contained in:
@@ -11,10 +11,16 @@ export const report = (message: DiscordenoMessage, args: string[]) => {
|
||||
utils.log(LT.ERROR, `Failed to call stored procedure INC_CNT: ${JSON.stringify(e)}`);
|
||||
});
|
||||
|
||||
sendMessage(config.reportChannel, generateReport(args.join(" "))).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
message.send(constantCmds.report).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
if (args.join(" ")) {
|
||||
sendMessage(config.reportChannel, generateReport(args.join(" "))).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
message.send(constantCmds.report).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
} else {
|
||||
message.send(constantCmds.reportFail).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to send message: ${JSON.stringify(message)} | ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import config from "../../config.ts";
|
||||
import { DEVMODE } from "../../flags.ts";
|
||||
import { dbClient } from "../db.ts";
|
||||
import { dbClient, queries } from "../db.ts";
|
||||
import { DiscordenoMessage, sendDirectMessage } from "../../deps.ts";
|
||||
import utils from "../utils.ts";
|
||||
import solver from "../solver.ts";
|
||||
@@ -49,7 +49,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute("INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,0,1)", [originalCommand, returnmsg.errorCode, m.id]).catch(e => {
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 1), [originalCommand, returnmsg.errorCode, m.id]).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute("INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,0,0)", [originalCommand, returnText, m.id]).catch(e => {
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 0), [originalCommand, returnText, m.id]).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
@@ -135,7 +135,7 @@ export const roll = async (message: DiscordenoMessage, args: string[], command:
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute("INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,0,0)", [originalCommand, returnText, m.id]).catch(e => {
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 0), [originalCommand, returnText, m.id]).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import config from "../../../config.ts";
|
||||
import { DEVMODE } from "../../../flags.ts";
|
||||
import { dbClient } from "../../db.ts";
|
||||
import { dbClient, queries } from "../../db.ts";
|
||||
import { DiscordenoMessage } from "../../../deps.ts";
|
||||
import { generateRollError } from "../../constantCmds.ts";
|
||||
import utils from "../../utils.ts";
|
||||
import { LogTypes as LT } from "../../utils.enums.ts";
|
||||
import { RollModifiers } from "../../mod.d.ts";
|
||||
|
||||
export const getModifiers = (m: DiscordenoMessage, args: string[], command: string, originalCommand: string): RollModifiers => {
|
||||
const errorType = "Modifiers invalid:";
|
||||
const modifiers: RollModifiers = {
|
||||
noDetails: false,
|
||||
spoiler: "",
|
||||
@@ -58,11 +60,11 @@ 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("Error: Must specifiy at least one GM by mentioning them");
|
||||
m.edit(generateRollError(errorType, "Must specifiy at least one GM by @mentioning them"));
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute("INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,0,1)", [originalCommand, "NoGMsFound", m.id]).catch(e => {
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 1), [originalCommand, "NoGMsFound", m.id]).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
@@ -73,15 +75,17 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
||||
i--;
|
||||
break;
|
||||
case "-o":
|
||||
console.log(args)
|
||||
args.splice(i, 1);
|
||||
|
||||
if (args[i].toLowerCase()[0] !== "d" && args[i].toLowerCase()[0] !== "a") {
|
||||
console.log(args)
|
||||
|
||||
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("Error: Must specifiy a or d to order the rolls ascending or descending");
|
||||
m.edit(generateRollError(errorType, "Must specifiy `a` or `d` to order the rolls ascending or descending"));
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute("INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,0,1)", [originalCommand, "NoOrderFound", m.id]).catch(e => {
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 1), [originalCommand, "NoOrderFound", m.id]).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
@@ -100,11 +104,11 @@ export const getModifiers = (m: DiscordenoMessage, args: string[], command: stri
|
||||
|
||||
// maxRoll and nominalRoll cannot both be on, throw an error
|
||||
if (modifiers.maxRoll && modifiers.nominalRoll) {
|
||||
m.edit("Error: Cannot maximise and nominise the roll at the same time");
|
||||
m.edit(generateRollError(errorType, "Cannot maximise and nominise the roll at the same time"));
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute("INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,0,1)", [originalCommand, "MaxAndNominal", m.id]).catch(e => {
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 1), [originalCommand, "MaxAndNominal", m.id]).catch(e => {
|
||||
utils.log(LT.ERROR, `Failed to insert into DB: ${JSON.stringify(e)}`);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user