mirror of
https://github.com/Burn-E99/TheArtificer.git
synced 2026-06-04 09:03:50 -04:00
update db structure to let init work correctly
This commit is contained in:
@@ -1,74 +1,84 @@
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
hasGuildPermissions,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
hasGuildPermissions,
|
||||
} from '../../deps.ts';
|
||||
import apiCommands from './apiCmd/_index.ts';
|
||||
import { failColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const api = async (message: DiscordenoMessage, args: string[]) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('api')).catch((e) => utils.commonLoggers.dbError('apiCmd.ts:16', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('api')).catch((e) => utils.commonLoggers.dbError('apiCmd.ts:16', 'call sproc INC_CNT on', e));
|
||||
|
||||
// Local apiArg in lowercase
|
||||
const apiArg = (args[0] || 'help').toLowerCase();
|
||||
// Local apiArg in lowercase
|
||||
const apiArg = (args[0] || 'help').toLowerCase();
|
||||
|
||||
// Alert users who DM the bot that this command is for guilds only
|
||||
if (message.guildId === 0n) {
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: 'API commands are only available in guilds.',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('apiCmd.ts:30', message, e));
|
||||
return;
|
||||
}
|
||||
// Alert users who DM the bot that this command is for guilds only
|
||||
if (message.guildId === 0n) {
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: 'API commands are only available in guilds.',
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('apiCmd.ts:30', message, e));
|
||||
return;
|
||||
}
|
||||
|
||||
// Makes sure the user is authenticated to run the API command
|
||||
if (await hasGuildPermissions(message.authorId, message.guildId, ['ADMINISTRATOR'])) {
|
||||
switch (apiArg) {
|
||||
case 'help':
|
||||
case 'h':
|
||||
// [[api help
|
||||
// Shows API help details
|
||||
apiCommands.help(message);
|
||||
break;
|
||||
case 'allow':
|
||||
case 'block':
|
||||
case 'enable':
|
||||
case 'disable':
|
||||
// [[api allow/block
|
||||
// Lets a guild admin allow or ban API rolls from happening in said guild
|
||||
apiCommands.allowBlock(message, apiArg);
|
||||
break;
|
||||
case 'delete':
|
||||
// [[api delete
|
||||
// Lets a guild admin delete their server from the database
|
||||
apiCommands.deleteGuild(message);
|
||||
break;
|
||||
case 'status':
|
||||
// [[api status
|
||||
// Lets a guild admin check the status of API rolling in said guild
|
||||
apiCommands.status(message);
|
||||
break;
|
||||
case 'show-warn':
|
||||
case 'hide-warn':
|
||||
// [[api show-warn/hide-warn
|
||||
// Lets a guild admin decide if the API warning should be shown on messages from the API
|
||||
apiCommands.showHideWarn(message, apiArg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: 'API commands are powerful and can only be used by guild Owners and Admins.',
|
||||
description: 'For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer).',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('apiCmd.ts:77', message, e));
|
||||
}
|
||||
// Makes sure the user is authenticated to run the API command
|
||||
if (await hasGuildPermissions(message.authorId, message.guildId, ['ADMINISTRATOR'])) {
|
||||
switch (apiArg) {
|
||||
case 'help':
|
||||
case 'h':
|
||||
// [[api help
|
||||
// Shows API help details
|
||||
apiCommands.help(message);
|
||||
break;
|
||||
case 'allow':
|
||||
case 'block':
|
||||
case 'enable':
|
||||
case 'disable':
|
||||
// [[api allow/block
|
||||
// Lets a guild admin allow or ban API rolls from happening in said guild
|
||||
apiCommands.allowBlock(message, apiArg);
|
||||
break;
|
||||
case 'delete':
|
||||
// [[api delete
|
||||
// Lets a guild admin delete their server from the database
|
||||
apiCommands.deleteGuild(message);
|
||||
break;
|
||||
case 'status':
|
||||
// [[api status
|
||||
// Lets a guild admin check the status of API rolling in said guild
|
||||
apiCommands.status(message);
|
||||
break;
|
||||
case 'show-warn':
|
||||
case 'hide-warn':
|
||||
// [[api show-warn/hide-warn
|
||||
// Lets a guild admin decide if the API warning should be shown on messages from the API
|
||||
apiCommands.showHideWarn(message, apiArg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: 'API commands are powerful and can only be used by guild Owners and Admins.',
|
||||
description:
|
||||
'For information on how to use the API, please check the GitHub README for more information [here](https://github.com/Burn-E99/TheArtificer).',
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('apiCmd.ts:77', message, e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,42 +1,52 @@
|
||||
import { dbClient } from '../../db.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
|
||||
export const allowBlock = async (message: DiscordenoMessage, apiArg: string) => {
|
||||
let errorOutInitial = false;
|
||||
const guildQuery = await dbClient.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
|
||||
utils.commonLoggers.dbError('allowBlock.ts:15', 'query', e0);
|
||||
message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:16', message, e));
|
||||
errorOutInitial = true;
|
||||
});
|
||||
if (errorOutInitial) return;
|
||||
let errorOutInitial = false;
|
||||
const guildQuery = await dbClient
|
||||
.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId])
|
||||
.catch((e0) => {
|
||||
utils.commonLoggers.dbError('allowBlock.ts:15', 'query', e0);
|
||||
message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:16', message, e));
|
||||
errorOutInitial = true;
|
||||
});
|
||||
if (errorOutInitial) return;
|
||||
|
||||
let errorOut = false;
|
||||
if (guildQuery.length === 0) {
|
||||
// Since guild is not in our DB, add it in
|
||||
await dbClient.execute(`INSERT INTO allowed_guilds(guildid,channelid,active) values(?,?,?)`, [message.guildId, message.channelId, (apiArg === 'allow' || apiArg === 'enable') ? 1 : 0]).catch(
|
||||
(e0) => {
|
||||
utils.commonLoggers.dbError('allowBlock:26', 'insert into', e0);
|
||||
message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:27', message, e));
|
||||
errorOut = true;
|
||||
},
|
||||
);
|
||||
} else {
|
||||
// Since guild is in our DB, update it
|
||||
await dbClient.execute(`UPDATE allowed_guilds SET active = ? WHERE guildid = ? AND channelid = ?`, [(apiArg === 'allow' || apiArg === 'enable') ? 1 : 0, message.guildId, message.channelId]).catch(
|
||||
(e0) => {
|
||||
utils.commonLoggers.dbError('allowBlock.ts:35', 'update', e0);
|
||||
message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:36', message, e));
|
||||
errorOut = true;
|
||||
},
|
||||
);
|
||||
}
|
||||
if (errorOut) return;
|
||||
let errorOut = false;
|
||||
if (guildQuery.length === 0) {
|
||||
// Since guild is not in our DB, add it in
|
||||
await dbClient
|
||||
.execute(`INSERT INTO allowed_guilds(guildid,channelid,active) values(?,?,?)`, [
|
||||
message.guildId,
|
||||
message.channelId,
|
||||
apiArg === 'allow' || apiArg === 'enable' ? 1 : 0,
|
||||
])
|
||||
.catch((e0) => {
|
||||
utils.commonLoggers.dbError('allowBlock:26', 'insert into', e0);
|
||||
message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:27', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
} else {
|
||||
// Since guild is in our DB, update it
|
||||
await dbClient
|
||||
.execute(`UPDATE allowed_guilds SET active = ? WHERE guildid = ? AND channelid = ?`, [
|
||||
apiArg === 'allow' || apiArg === 'enable' ? 1 : 0,
|
||||
message.guildId,
|
||||
message.channelId,
|
||||
])
|
||||
.catch((e0) => {
|
||||
utils.commonLoggers.dbError('allowBlock.ts:35', 'update', e0);
|
||||
message.send(generateApiFailed(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:36', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
}
|
||||
if (errorOut) return;
|
||||
|
||||
// We won't get here if there's any errors, so we know it has bee successful, so report as such
|
||||
message.send(generateApiSuccess(`${apiArg}ed`)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:44', message, e));
|
||||
// We won't get here if there's any errors, so we know it has bee successful, so report as such
|
||||
message.send(generateApiSuccess(`${apiArg}ed`)).catch((e: Error) => utils.commonLoggers.messageSendError('allowBlock.ts:44', message, e));
|
||||
};
|
||||
|
||||
@@ -1,31 +1,39 @@
|
||||
import { dbClient } from '../../db.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { failColor, successColor } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
|
||||
export const deleteGuild = async (message: DiscordenoMessage) => {
|
||||
let errorOut = false;
|
||||
await dbClient.execute(`DELETE FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
|
||||
utils.commonLoggers.dbError('deleteGuild.ts:15', 'query', e0);
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: 'Failed to delete this guild from the database.',
|
||||
description: 'If this issue persists, please report this to the developers.',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteGuild.ts:22', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
if (errorOut) return;
|
||||
let errorOut = false;
|
||||
await dbClient.execute(`DELETE FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
|
||||
utils.commonLoggers.dbError('deleteGuild.ts:15', 'query', e0);
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: 'Failed to delete this guild from the database.',
|
||||
description: 'If this issue persists, please report this to the developers.',
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('deleteGuild.ts:22', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
if (errorOut) return;
|
||||
|
||||
// We won't get here if there's any errors, so we know it has bee successful, so report as such
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: successColor,
|
||||
title: 'This guild\'s API setting has been removed from The Artifier\'s Database.',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('deleteGuild.ts:33', message, e));
|
||||
// We won't get here if there's any errors, so we know it has bee successful, so report as such
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: successColor,
|
||||
title: "This guild's API setting has been removed from The Artifier's Database.",
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('deleteGuild.ts:33', message, e));
|
||||
};
|
||||
|
||||
@@ -1,38 +1,48 @@
|
||||
import { dbClient } from '../../db.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { generateApiFailed, generateApiSuccess } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
|
||||
export const showHideWarn = async (message: DiscordenoMessage, apiArg: string) => {
|
||||
let errorOutInitial = false;
|
||||
const guildQuery = await dbClient.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
|
||||
utils.commonLoggers.dbError('showHideWarn.ts:15', 'query', e0);
|
||||
message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:16', message, e));
|
||||
errorOutInitial = true;
|
||||
});
|
||||
if (errorOutInitial) return;
|
||||
let errorOutInitial = false;
|
||||
const guildQuery = await dbClient
|
||||
.query(`SELECT guildid, channelid FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId])
|
||||
.catch((e0) => {
|
||||
utils.commonLoggers.dbError('showHideWarn.ts:15', 'query', e0);
|
||||
message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:16', message, e));
|
||||
errorOutInitial = true;
|
||||
});
|
||||
if (errorOutInitial) return;
|
||||
|
||||
let errorOut = false;
|
||||
if (guildQuery.length === 0) {
|
||||
// Since guild is not in our DB, add it in
|
||||
await dbClient.execute(`INSERT INTO allowed_guilds(guildid,channelid,hidewarn) values(?,?,?)`, [message.guildId, message.channelId, (apiArg === 'hide-warn') ? 1 : 0]).catch((e0) => {
|
||||
utils.commonLoggers.dbError('showHideWarn.ts:25', 'insert inot', e0);
|
||||
message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:26', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
} else {
|
||||
// Since guild is in our DB, update it
|
||||
await dbClient.execute(`UPDATE allowed_guilds SET hidewarn = ? WHERE guildid = ? AND channelid = ?`, [(apiArg === 'hide-warn') ? 1 : 0, message.guildId, message.channelId]).catch((e0) => {
|
||||
utils.commonLoggers.dbError('showHideWarn.ts:32', 'update', e0);
|
||||
message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:33', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
}
|
||||
if (errorOut) return;
|
||||
let errorOut = false;
|
||||
if (guildQuery.length === 0) {
|
||||
// Since guild is not in our DB, add it in
|
||||
await dbClient
|
||||
.execute(`INSERT INTO allowed_guilds(guildid,channelid,hidewarn) values(?,?,?)`, [message.guildId, message.channelId, apiArg === 'hide-warn' ? 1 : 0])
|
||||
.catch((e0) => {
|
||||
utils.commonLoggers.dbError('showHideWarn.ts:25', 'insert inot', e0);
|
||||
message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:26', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
} else {
|
||||
// Since guild is in our DB, update it
|
||||
await dbClient
|
||||
.execute(`UPDATE allowed_guilds SET hidewarn = ? WHERE guildid = ? AND channelid = ?`, [
|
||||
apiArg === 'hide-warn' ? 1 : 0,
|
||||
message.guildId,
|
||||
message.channelId,
|
||||
])
|
||||
.catch((e0) => {
|
||||
utils.commonLoggers.dbError('showHideWarn.ts:32', 'update', e0);
|
||||
message.send(generateApiFailed(`${apiArg} on`)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:33', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
}
|
||||
if (errorOut) return;
|
||||
|
||||
// We won't get here if there's any errors, so we know it has bee successful, so report as such
|
||||
message.send(generateApiSuccess(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:40', message, e));
|
||||
// We won't get here if there's any errors, so we know it has bee successful, so report as such
|
||||
message.send(generateApiSuccess(apiArg)).catch((e: Error) => utils.commonLoggers.messageSendError('showHideWarn.ts:40', message, e));
|
||||
};
|
||||
|
||||
@@ -1,37 +1,43 @@
|
||||
import { dbClient } from '../../db.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../../deps.ts';
|
||||
import { failColor, generateApiStatus } from '../../commandUtils.ts';
|
||||
import utils from '../../utils.ts';
|
||||
|
||||
export const status = async (message: DiscordenoMessage) => {
|
||||
// Get status of guild from the db
|
||||
let errorOut = false;
|
||||
const guildQuery = await dbClient.query(`SELECT active, banned FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId]).catch((e0) => {
|
||||
utils.commonLoggers.dbError('status.ts:16', 'query', e0);
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: 'Failed to check API rolls status for this guild.',
|
||||
description: 'If this issue persists, please report this to the developers.',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:23', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
if (errorOut) return;
|
||||
// Get status of guild from the db
|
||||
let errorOut = false;
|
||||
const guildQuery = await dbClient
|
||||
.query(`SELECT active, banned FROM allowed_guilds WHERE guildid = ? AND channelid = ?`, [message.guildId, message.channelId])
|
||||
.catch((e0) => {
|
||||
utils.commonLoggers.dbError('status.ts:16', 'query', e0);
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: 'Failed to check API rolls status for this guild.',
|
||||
description: 'If this issue persists, please report this to the developers.',
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:23', message, e));
|
||||
errorOut = true;
|
||||
});
|
||||
if (errorOut) return;
|
||||
|
||||
// Check if we got an item back or not
|
||||
if (guildQuery.length > 0) {
|
||||
// Check if guild is banned from using API and return appropriate message
|
||||
if (guildQuery[0].banned) {
|
||||
message.send(generateApiStatus(true, false)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:32', message, e));
|
||||
} else {
|
||||
message.send(generateApiStatus(false, guildQuery[0].active)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:34', message, e));
|
||||
}
|
||||
} else {
|
||||
// Guild is not in DB, therefore they are blocked
|
||||
message.send(generateApiStatus(false, false)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:38', message, e));
|
||||
}
|
||||
// Check if we got an item back or not
|
||||
if (guildQuery.length > 0) {
|
||||
// Check if guild is banned from using API and return appropriate message
|
||||
if (guildQuery[0].banned) {
|
||||
message.send(generateApiStatus(true, false)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:32', message, e));
|
||||
} else {
|
||||
message.send(generateApiStatus(false, guildQuery[0].active)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:34', message, e));
|
||||
}
|
||||
} else {
|
||||
// Guild is not in DB, therefore they are blocked
|
||||
message.send(generateApiStatus(false, false)).catch((e: Error) => utils.commonLoggers.messageSendError('status.ts:38', message, e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,48 +1,53 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import auditCommands from './auditCmd/_index.ts';
|
||||
import { failColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const audit = async (message: DiscordenoMessage, args: string[]) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('audit')).catch((e) => utils.commonLoggers.dbError('audit.ts:16', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('audit')).catch((e) => utils.commonLoggers.dbError('audit.ts:16', 'call sproc INC_CNT on', e));
|
||||
|
||||
// Local apiArg in lowercase
|
||||
const auditArg = (args[0] || 'help').toLowerCase();
|
||||
// Local apiArg in lowercase
|
||||
const auditArg = (args[0] || 'help').toLowerCase();
|
||||
|
||||
// Makes sure the user is authenticated to run the API command
|
||||
if (message.authorId === config.api.admin) {
|
||||
switch (auditArg) {
|
||||
case 'help':
|
||||
case 'h':
|
||||
// [[audit help or [[audit h
|
||||
// Shows API help details
|
||||
auditCommands.auditHelp(message);
|
||||
break;
|
||||
case 'db':
|
||||
// [[audit db
|
||||
// Shows current DB table sizes
|
||||
auditCommands.auditDB(message);
|
||||
break;
|
||||
case 'guilds':
|
||||
// [[audit guilds
|
||||
// Shows breakdown of guilds and detials on them
|
||||
auditCommands.auditGuilds(message);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: `Audit commands are powerful and can only be used by ${config.name}'s owner.`,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('audit.ts:51', message, e));
|
||||
}
|
||||
// Makes sure the user is authenticated to run the API command
|
||||
if (message.authorId === config.api.admin) {
|
||||
switch (auditArg) {
|
||||
case 'help':
|
||||
case 'h':
|
||||
// [[audit help or [[audit h
|
||||
// Shows API help details
|
||||
auditCommands.auditHelp(message);
|
||||
break;
|
||||
case 'db':
|
||||
// [[audit db
|
||||
// Shows current DB table sizes
|
||||
auditCommands.auditDB(message);
|
||||
break;
|
||||
case 'guilds':
|
||||
// [[audit guilds
|
||||
// Shows breakdown of guilds and detials on them
|
||||
auditCommands.auditGuilds(message);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: `Audit commands are powerful and can only be used by ${config.name}'s owner.`,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('audit.ts:51', message, e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,42 +1,44 @@
|
||||
import { dbClient } from '../../db.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
EmbedField,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
EmbedField,
|
||||
} from '../../../deps.ts';
|
||||
import { infoColor2 } from '../../commandUtils.ts';
|
||||
import { compilingStats } from '../../commonEmbeds.ts';
|
||||
import utils from '../../utils.ts';
|
||||
|
||||
export const auditDB = async (message: DiscordenoMessage) => {
|
||||
try {
|
||||
const m = await message.send(compilingStats);
|
||||
try {
|
||||
const m = await message.send(compilingStats);
|
||||
|
||||
// Get DB statistics
|
||||
const auditQuery = await dbClient.query(`SELECT * FROM db_size;`).catch((e) => utils.commonLoggers.dbError('auditDB.ts:19', 'query', e));
|
||||
// Get DB statistics
|
||||
const auditQuery = await dbClient.query(`SELECT * FROM db_size;`).catch((e) => utils.commonLoggers.dbError('auditDB.ts:19', 'query', e));
|
||||
|
||||
// Turn all tables into embed fields, currently only properly will handle 25 tables, but we'll fix that when artificer gets 26 tables
|
||||
const embedFields: Array<EmbedField> = [];
|
||||
auditQuery.forEach((row: any) => {
|
||||
embedFields.push({
|
||||
name: `${row.table}`,
|
||||
value: `**Size:** ${row.size} MB
|
||||
// Turn all tables into embed fields, currently only properly will handle 25 tables, but we'll fix that when artificer gets 26 tables
|
||||
const embedFields: Array<EmbedField> = [];
|
||||
auditQuery.forEach((row: any) => {
|
||||
embedFields.push({
|
||||
name: `${row.table}`,
|
||||
value: `**Size:** ${row.size} MB
|
||||
**Rows:** ${row.rows}`,
|
||||
inline: true,
|
||||
});
|
||||
});
|
||||
inline: true,
|
||||
});
|
||||
});
|
||||
|
||||
// Send the results
|
||||
m.edit({
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: 'Database Audit',
|
||||
description: 'Lists all tables with their current size and row count.',
|
||||
timestamp: new Date().toISOString(),
|
||||
fields: embedFields,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageEditError('auditDB.ts:43', message, e));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('auditDB.ts:45', message, e);
|
||||
}
|
||||
// Send the results
|
||||
m.edit({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'Database Audit',
|
||||
description: 'Lists all tables with their current size and row count.',
|
||||
timestamp: new Date().toISOString(),
|
||||
fields: embedFields,
|
||||
},
|
||||
],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageEditError('auditDB.ts:43', message, e));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('auditDB.ts:45', message, e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { EmojiConf } from '../mod.d.ts';
|
||||
import utils from '../utils.ts';
|
||||
@@ -13,28 +14,30 @@ import utils from '../utils.ts';
|
||||
const allEmojiAliases: string[] = [];
|
||||
|
||||
config.emojis.forEach((emji: EmojiConf) => {
|
||||
allEmojiAliases.push(...emji.aliases);
|
||||
allEmojiAliases.push(...emji.aliases);
|
||||
});
|
||||
|
||||
export const emoji = (message: DiscordenoMessage, command: string) => {
|
||||
// shortcut
|
||||
if (allEmojiAliases.indexOf(command)) {
|
||||
// Start looping thru the possible emojis
|
||||
config.emojis.some((emji: EmojiConf) => {
|
||||
log(LT.LOG, `Checking if command was emoji ${JSON.stringify(emji)}`);
|
||||
// If a match gets found
|
||||
if (emji.aliases.indexOf(command || '') > -1) {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('emojis')).catch((e) => utils.commonLoggers.dbError('emojis.ts:28', 'call sproc INC_CNT on', e));
|
||||
// shortcut
|
||||
if (allEmojiAliases.indexOf(command)) {
|
||||
// Start looping thru the possible emojis
|
||||
config.emojis.some((emji: EmojiConf) => {
|
||||
log(LT.LOG, `Checking if command was emoji ${JSON.stringify(emji)}`);
|
||||
// If a match gets found
|
||||
if (emji.aliases.indexOf(command || '') > -1) {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('emojis')).catch((e) => utils.commonLoggers.dbError('emojis.ts:28', 'call sproc INC_CNT on', e));
|
||||
|
||||
// Send the needed emoji
|
||||
message.send(`<${emji.animated ? 'a' : ''}:${emji.name}:${emji.id}>`).catch((e: Error) => utils.commonLoggers.messageSendError('emoji.ts:33', message, e));
|
||||
// And attempt to delete if needed
|
||||
if (emji.deleteSender) {
|
||||
message.delete().catch((e: Error) => utils.commonLoggers.messageDeleteError('emoji.ts:36', message, e));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
// Send the needed emoji
|
||||
message
|
||||
.send(`<${emji.animated ? 'a' : ''}:${emji.name}:${emji.id}>`)
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('emoji.ts:33', message, e));
|
||||
// And attempt to delete if needed
|
||||
if (emji.deleteSender) {
|
||||
message.delete().catch((e: Error) => utils.commonLoggers.messageDeleteError('emoji.ts:36', message, e));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,31 +1,38 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const handleMentions = (message: DiscordenoMessage) => {
|
||||
log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
|
||||
log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
|
||||
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('mention')).catch((e) => utils.commonLoggers.dbError('handleMentions.ts:17', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('mention')).catch((e) => utils.commonLoggers.dbError('handleMentions.ts:17', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: infoColor1,
|
||||
title: `Hello! I am ${config.name}!`,
|
||||
fields: [{
|
||||
name: 'I am a bot that specializes in rolling dice and doing basic algebra.',
|
||||
value: `To learn about my available commands, please run \`${config.prefix}help\`.
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor1,
|
||||
title: `Hello! I am ${config.name}!`,
|
||||
fields: [
|
||||
{
|
||||
name: 'I am a bot that specializes in rolling dice and doing basic algebra.',
|
||||
value: `To learn about my available commands, please run \`${config.prefix}help\`.
|
||||
|
||||
Want me to ignore you? Simply run \`${config.prefix}opt-out\` and ${config.name} will no longer read your messages or respond to you.`,
|
||||
}],
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('handleMentions.ts:30', message, e));
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('handleMentions.ts:30', message, e));
|
||||
};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import config from '../../config.ts';
|
||||
import { failColor, infoColor2 } from '../commandUtils.ts';
|
||||
@@ -9,33 +10,41 @@ import utils from '../utils.ts';
|
||||
import intervals from '../intervals.ts';
|
||||
|
||||
export const heatmap = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('heatmap')).catch((e) => utils.commonLoggers.dbError('heatmap.ts:14', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('heatmap')).catch((e) => utils.commonLoggers.dbError('heatmap.ts:14', 'call sproc INC_CNT on', e));
|
||||
|
||||
if (config.api.enable) {
|
||||
message.send({
|
||||
embeds: [{
|
||||
title: 'Roll Heatmap',
|
||||
description: `Over time, this image will show a nice pattern of when rolls are requested the most.
|
||||
if (config.api.enable) {
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
title: 'Roll Heatmap',
|
||||
description: `Over time, this image will show a nice pattern of when rolls are requested the most.
|
||||
|
||||
Least Rolls: ${intervals.getMinRollCnt()}
|
||||
Most Rolls: ${intervals.getMaxRollCnt()}`,
|
||||
footer: {
|
||||
text: 'Data is shown in US Eastern Time. | This heatmap uses data starting 6/26/2022.',
|
||||
},
|
||||
color: infoColor2,
|
||||
image: {
|
||||
url: `${config.api.publicDomain}api/heatmap.png`,
|
||||
},
|
||||
}],
|
||||
}).catch((e) => utils.commonLoggers.messageSendError('heatmap.ts:21', message, e));
|
||||
} else {
|
||||
message.send({
|
||||
embeds: [{
|
||||
title: 'Roll Heatmap Disabled',
|
||||
description: 'This command requires the bot\'s API to be enabled. If you are the host of this bot, check your `config.ts` file to enable it.',
|
||||
color: failColor,
|
||||
}],
|
||||
}).catch((e) => utils.commonLoggers.messageSendError('heatmap.ts:21', message, e));
|
||||
}
|
||||
footer: {
|
||||
text: 'Data is shown in US Eastern Time. | This heatmap uses data starting 6/26/2022.',
|
||||
},
|
||||
color: infoColor2,
|
||||
image: {
|
||||
url: `${config.api.publicDomain}api/heatmap.png`,
|
||||
},
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e) => utils.commonLoggers.messageSendError('heatmap.ts:21', message, e));
|
||||
} else {
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
title: 'Roll Heatmap Disabled',
|
||||
description: "This command requires the bot's API to be enabled. If you are the host of this bot, check your `config.ts` file to enable it.",
|
||||
color: failColor,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e) => utils.commonLoggers.messageSendError('heatmap.ts:21', message, e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,98 +1,102 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const help = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('help')).catch((e) => utils.commonLoggers.dbError('htlp.ts:15', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('help')).catch((e) => utils.commonLoggers.dbError('htlp.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: 'The Artificer\'s Available Commands:',
|
||||
fields: [
|
||||
{
|
||||
name: `\`${config.prefix}?\``,
|
||||
value: 'This command',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}rollhelp\` or \`${config.prefix}??\``,
|
||||
value: `Details on how to use the roll command, listed as \`${config.prefix}xdy...${config.postfix}\` below`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}rollDecorators\` or \`${config.prefix}???\``,
|
||||
value: `Details on how to use decorators on the roll command`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}api [subcommand]\``,
|
||||
value: `Administrative tools for the bots's API, run \`${config.prefix}api help\` for more details`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}ping\``,
|
||||
value: 'Pings the bot to check connectivity',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}info\``,
|
||||
value: 'Prints some information and links relating to the bot',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}privacy\``,
|
||||
value: 'Prints some information about the Privacy Policy',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}version\``,
|
||||
value: 'Prints the bots version',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}popcat\``,
|
||||
value: 'Popcat',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}report [text]\``,
|
||||
value: 'Report a command that failed to run',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}stats\``,
|
||||
value: 'Statistics on the bot',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}heatmap\``,
|
||||
value: 'Heatmap of when the roll command is run the most',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}opt-out\` or \`${config.prefix}ignore-me\``,
|
||||
value: 'Adds you to an ignore list so the bot will never respond to you',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}opt-in\` **Available via DM ONLY**`,
|
||||
value: 'Removes you from the ignore list',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
||||
value:
|
||||
`Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`), run \`${config.prefix}??\` for more details`,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('help.ts:82', message, e));
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: "The Artificer's Available Commands:",
|
||||
fields: [
|
||||
{
|
||||
name: `\`${config.prefix}?\``,
|
||||
value: 'This command',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}rollhelp\` or \`${config.prefix}??\``,
|
||||
value: `Details on how to use the roll command, listed as \`${config.prefix}xdy...${config.postfix}\` below`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}rollDecorators\` or \`${config.prefix}???\``,
|
||||
value: `Details on how to use decorators on the roll command`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}api [subcommand]\``,
|
||||
value: `Administrative tools for the bots's API, run \`${config.prefix}api help\` for more details`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}ping\``,
|
||||
value: 'Pings the bot to check connectivity',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}info\``,
|
||||
value: 'Prints some information and links relating to the bot',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}privacy\``,
|
||||
value: 'Prints some information about the Privacy Policy',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}version\``,
|
||||
value: 'Prints the bots version',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}popcat\``,
|
||||
value: 'Popcat',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}report [text]\``,
|
||||
value: 'Report a command that failed to run',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}stats\``,
|
||||
value: 'Statistics on the bot',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}heatmap\``,
|
||||
value: 'Heatmap of when the roll command is run the most',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}opt-out\` or \`${config.prefix}ignore-me\``,
|
||||
value: 'Adds you to an ignore list so the bot will never respond to you',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}opt-in\` **Available via DM ONLY**`,
|
||||
value: 'Removes you from the ignore list',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
||||
value: `Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`), run \`${config.prefix}??\` for more details`,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('help.ts:82', message, e));
|
||||
};
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const info = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('info')).catch((e) => utils.commonLoggers.dbError('info.ts:12', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('info')).catch((e) => utils.commonLoggers.dbError('info.ts:12', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: `${config.name}, a Discord bot that specializing in rolling dice and calculating math`,
|
||||
description: `${config.name} is developed by Ean AKA Burn_E99.
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: `${config.name}, a Discord bot that specializing in rolling dice and calculating math`,
|
||||
description: `${config.name} is developed by Ean AKA Burn_E99.
|
||||
Additional information can be found on my website [here](https://discord.burne99.com/TheArtificer/).
|
||||
Want to check out my source code? Check it out [here](https://github.com/Burn-E99/TheArtificer).
|
||||
Need help with this bot? Join my support server [here](https://discord.gg/peHASXMZYv).`,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('info.ts:23', message, e));
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('info.ts:23', message, e));
|
||||
};
|
||||
|
||||
@@ -1,39 +1,48 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, ignoreList, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries, ignoreList } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { failColor, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const optIn = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('opt-out')).catch((e) => utils.commonLoggers.dbError('optIn.ts:11', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('opt-out')).catch((e) => utils.commonLoggers.dbError('optIn.ts:11', 'call sproc INC_CNT on', e));
|
||||
|
||||
const idIdx = ignoreList.indexOf(message.authorId);
|
||||
if (idIdx !== -1) {
|
||||
try {
|
||||
ignoreList.splice(idIdx, 1);
|
||||
await dbClient.execute('DELETE FROM ignore_list WHERE userid = ?', [message.authorId]);
|
||||
const idIdx = ignoreList.indexOf(message.authorId);
|
||||
if (idIdx !== -1) {
|
||||
try {
|
||||
ignoreList.splice(idIdx, 1);
|
||||
await dbClient.execute('DELETE FROM ignore_list WHERE userid = ?', [message.authorId]);
|
||||
|
||||
message.reply({
|
||||
embeds: [{
|
||||
color: successColor,
|
||||
title: `${config.name} will now respond to you again.`,
|
||||
description: `If you want ${config.name} to ignore to you again, please run the following command:
|
||||
message
|
||||
.reply({
|
||||
embeds: [
|
||||
{
|
||||
color: successColor,
|
||||
title: `${config.name} will now respond to you again.`,
|
||||
description: `If you want ${config.name} to ignore to you again, please run the following command:
|
||||
|
||||
\`${config.prefix}opt-out\``,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e));
|
||||
} catch (err) {
|
||||
message.reply({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: 'Opt-In failed',
|
||||
description: 'Please try the command again. If the issue persists, please join the support server, linked in my About Me section.',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e));
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e));
|
||||
} catch (err) {
|
||||
message
|
||||
.reply({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: 'Opt-In failed',
|
||||
description: 'Please try the command again. If the issue persists, please join the support server, linked in my About Me section.',
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('optIn.ts:27', message, e));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,36 +1,45 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, ignoreList, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries, ignoreList } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { failColor, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const optOut = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('opt-out')).catch((e) => utils.commonLoggers.dbError('optOut.ts:11', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('opt-out')).catch((e) => utils.commonLoggers.dbError('optOut.ts:11', 'call sproc INC_CNT on', e));
|
||||
|
||||
try {
|
||||
ignoreList.push(message.authorId);
|
||||
await dbClient.execute('INSERT INTO ignore_list(userid) values(?)', [message.authorId]);
|
||||
try {
|
||||
ignoreList.push(message.authorId);
|
||||
await dbClient.execute('INSERT INTO ignore_list(userid) values(?)', [message.authorId]);
|
||||
|
||||
message.reply({
|
||||
embeds: [{
|
||||
color: successColor,
|
||||
title: `${config.name} will no longer respond to you.`,
|
||||
description: `If you want ${config.name} to respond to you again, please DM ${config.name} the following command:
|
||||
message
|
||||
.reply({
|
||||
embeds: [
|
||||
{
|
||||
color: successColor,
|
||||
title: `${config.name} will no longer respond to you.`,
|
||||
description: `If you want ${config.name} to respond to you again, please DM ${config.name} the following command:
|
||||
|
||||
\`${config.prefix}opt-in\``,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('optOut.ts:25', message, e));
|
||||
} catch (err) {
|
||||
message.reply({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: 'Opt-Out failed',
|
||||
description: `Please try the command again. If the issue persists, please report this using the \`${config.prefix}report opt-out failed\` command.`,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('optOut.ts:33', message, e));
|
||||
}
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('optOut.ts:25', message, e));
|
||||
} catch (err) {
|
||||
message
|
||||
.reply({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: 'Opt-Out failed',
|
||||
description: `Please try the command again. If the issue persists, please report this using the \`${config.prefix}report opt-out failed\` command.`,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('optOut.ts:33', message, e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { generatePing } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const ping = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('ping')).catch((e) => utils.commonLoggers.dbError('ping.ts:14', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('ping')).catch((e) => utils.commonLoggers.dbError('ping.ts:14', 'call sproc INC_CNT on', e));
|
||||
|
||||
// Calculates ping between sending a message and editing it, giving a nice round-trip latency.
|
||||
try {
|
||||
const m = await message.send(generatePing(-1));
|
||||
m.edit(generatePing(m.timestamp - message.timestamp));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('ping.ts:23', message, e);
|
||||
}
|
||||
// Calculates ping between sending a message and editing it, giving a nice round-trip latency.
|
||||
try {
|
||||
const m = await message.send(generatePing(-1));
|
||||
m.edit(generatePing(m.timestamp - message.timestamp));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('ping.ts:23', message, e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,31 +1,37 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const privacy = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('privacy')).catch((e) => utils.commonLoggers.dbError('privacy.ts:15', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('privacy')).catch((e) => utils.commonLoggers.dbError('privacy.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: infoColor1,
|
||||
title: 'Privacy Policy',
|
||||
fields: [{
|
||||
name: 'The Artificer does not track or collect user information via Discord.',
|
||||
value:
|
||||
`The only user submitted information that is stored is submitted via the \`${config.prefix}report\` command. This information is only stored for a short period of time in a location that only the Developer of The Artificer can see.
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor1,
|
||||
title: 'Privacy Policy',
|
||||
fields: [
|
||||
{
|
||||
name: 'The Artificer does not track or collect user information via Discord.',
|
||||
value: `The only user submitted information that is stored is submitted via the \`${config.prefix}report\` command. This information is only stored for a short period of time in a location that only the Developer of The Artificer can see.
|
||||
|
||||
For more details, please check out the Privacy Policy on the GitHub [here](https://github.com/Burn-E99/TheArtificer/blob/master/PRIVACY.md).
|
||||
|
||||
Terms of Service can also be found on GitHub [here](https://github.com/Burn-E99/TheArtificer/blob/master/TERMS.md).
|
||||
|
||||
Want me to ignore you? Simply run \`${config.prefix}opt-out\` and ${config.name} will no longer read your messages or respond to you.`,
|
||||
}],
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('privacy.ts:33', message, e));
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('privacy.ts:33', message, e));
|
||||
};
|
||||
|
||||
@@ -1,34 +1,43 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
sendMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
sendMessage,
|
||||
} from '../../deps.ts';
|
||||
import { failColor, generateReport, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const report = (message: DiscordenoMessage, args: string[]) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('report')).catch((e) => utils.commonLoggers.dbError('report.ts:17', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('report')).catch((e) => utils.commonLoggers.dbError('report.ts:17', 'call sproc INC_CNT on', e));
|
||||
|
||||
if (args.join(' ')) {
|
||||
sendMessage(config.reportChannel, generateReport(args.join(' '))).catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:22', message, e));
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: successColor,
|
||||
title: 'Failed command has been reported to my developer.',
|
||||
description: `For more in depth support, and information about planned maintenance, please join the support server [here](https://discord.gg/peHASXMZYv).`,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:29', message, e));
|
||||
} else {
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: failColor,
|
||||
title: 'Please provide a short description of what failed',
|
||||
description: 'Providing a short description helps my developer quickly diagnose what went wrong.',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:37', message, e));
|
||||
}
|
||||
if (args.join(' ')) {
|
||||
sendMessage(config.reportChannel, generateReport(args.join(' '))).catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:22', message, e));
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: successColor,
|
||||
title: 'Failed command has been reported to my developer.',
|
||||
description: `For more in depth support, and information about planned maintenance, please join the support server [here](https://discord.gg/peHASXMZYv).`,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:29', message, e));
|
||||
} else {
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: failColor,
|
||||
title: 'Please provide a short description of what failed',
|
||||
description: 'Providing a short description helps my developer quickly diagnose what went wrong.',
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('report.ts:37', message, e));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,22 +1,27 @@
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const rip = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('rip')).catch((e) => utils.commonLoggers.dbError('rip.ts:14', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('rip')).catch((e) => utils.commonLoggers.dbError('rip.ts:14', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: infoColor2,
|
||||
title: 'The Artificer was built in memory of my Grandmother, Babka',
|
||||
description: `With much love, Ean
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'The Artificer was built in memory of my Grandmother, Babka',
|
||||
description: `With much love, Ean
|
||||
|
||||
December 21, 2020`,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('rip.ts:26', message, e));
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('rip.ts:26', message, e));
|
||||
};
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import config from '../../config.ts';
|
||||
import { DEVMODE } from '../../flags.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../deps.ts';
|
||||
import { rollingEmbed, warnColor } from '../commandUtils.ts';
|
||||
import rollFuncs from './roll/_index.ts';
|
||||
@@ -15,49 +16,51 @@ import { QueuedRoll } from '../mod.d.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const roll = async (message: DiscordenoMessage, args: string[], command: string) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
const currDateTime = new Date();
|
||||
dbClient.execute(queries.callIncCnt('roll')).catch((e) => utils.commonLoggers.dbError('roll.ts:20', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncHeatmap(currDateTime)).catch((e) => utils.commonLoggers.dbError('roll.ts:21', 'update', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
const currDateTime = new Date();
|
||||
dbClient.execute(queries.callIncCnt('roll')).catch((e) => utils.commonLoggers.dbError('roll.ts:20', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncHeatmap(currDateTime)).catch((e) => utils.commonLoggers.dbError('roll.ts:21', 'update', e));
|
||||
|
||||
// If DEVMODE is on, only allow this command to be used in the devServer
|
||||
if (DEVMODE && message.guildId !== config.devServer) {
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: warnColor,
|
||||
title: 'Command is in development, please try again later.',
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('roll.ts:30', message, e));
|
||||
return;
|
||||
}
|
||||
// If DEVMODE is on, only allow this command to be used in the devServer
|
||||
if (DEVMODE && message.guildId !== config.devServer) {
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: warnColor,
|
||||
title: 'Command is in development, please try again later.',
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('roll.ts:30', message, e));
|
||||
return;
|
||||
}
|
||||
|
||||
// Rest of this command is in a try-catch to protect all sends/edits from erroring out
|
||||
try {
|
||||
const originalCommand = `${config.prefix}${command} ${args.join(' ')}`;
|
||||
// Rest of this command is in a try-catch to protect all sends/edits from erroring out
|
||||
try {
|
||||
const originalCommand = `${config.prefix}${command} ${args.join(' ')}`;
|
||||
|
||||
const m = await message.reply(rollingEmbed);
|
||||
const m = await message.reply(rollingEmbed);
|
||||
|
||||
// Get modifiers from command
|
||||
const modifiers = rollFuncs.getModifiers(m, args, command, originalCommand);
|
||||
// Get modifiers from command
|
||||
const modifiers = rollFuncs.getModifiers(m, args, command, originalCommand);
|
||||
|
||||
// Return early if the modifiers were invalid
|
||||
if (!modifiers.valid) {
|
||||
return;
|
||||
}
|
||||
// Return early if the modifiers were invalid
|
||||
if (!modifiers.valid) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Rejoin all of the args and send it into the solver, if solver returns a falsy item, an error object will be substituded in
|
||||
const rollCmd = message.content.substring(2);
|
||||
// Rejoin all of the args and send it into the solver, if solver returns a falsy item, an error object will be substituded in
|
||||
const rollCmd = message.content.substring(2);
|
||||
|
||||
queueRoll(
|
||||
<QueuedRoll> {
|
||||
apiRoll: false,
|
||||
dd: { m, message },
|
||||
rollCmd,
|
||||
modifiers,
|
||||
originalCommand,
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
log(LT.ERROR, `Undandled Error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
queueRoll(<QueuedRoll>{
|
||||
apiRoll: false,
|
||||
dd: { m, message },
|
||||
rollCmd,
|
||||
modifiers,
|
||||
originalCommand,
|
||||
});
|
||||
} catch (e) {
|
||||
log(LT.ERROR, `Undandled Error: ${JSON.stringify(e)}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,117 +1,130 @@
|
||||
import config from '../../../config.ts';
|
||||
import { DEVMODE } from '../../../flags.ts';
|
||||
import { dbClient, queries } from '../../db.ts';
|
||||
import dbClient from '../../db/client.ts';
|
||||
import { queries } from '../../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Log4Deno deps
|
||||
log,
|
||||
LT,
|
||||
} from '../../../deps.ts';
|
||||
import { generateRollError } from '../../commandUtils.ts';
|
||||
import { RollModifiers } from '../../mod.d.ts';
|
||||
import utils from '../../utils.ts';
|
||||
|
||||
export const getModifiers = (m: DiscordenoMessage, args: string[], command: string, originalCommand: string): RollModifiers => {
|
||||
const errorType = 'Modifiers invalid:';
|
||||
const modifiers: RollModifiers = {
|
||||
noDetails: false,
|
||||
superNoDetails: false,
|
||||
spoiler: '',
|
||||
maxRoll: false,
|
||||
nominalRoll: false,
|
||||
gmRoll: false,
|
||||
gms: [],
|
||||
order: '',
|
||||
valid: false,
|
||||
count: false,
|
||||
apiWarn: '',
|
||||
};
|
||||
const errorType = 'Modifiers invalid:';
|
||||
const modifiers: RollModifiers = {
|
||||
noDetails: false,
|
||||
superNoDetails: false,
|
||||
spoiler: '',
|
||||
maxRoll: false,
|
||||
nominalRoll: false,
|
||||
gmRoll: false,
|
||||
gms: [],
|
||||
order: '',
|
||||
valid: false,
|
||||
count: false,
|
||||
apiWarn: '',
|
||||
};
|
||||
|
||||
// Check if any of the args are command flags and pull those out into the modifiers object
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
log(LT.LOG, `Checking ${command}${args.join(' ')} for command modifiers ${i}`);
|
||||
let defaultCase = false;
|
||||
switch (args[i].toLowerCase()) {
|
||||
case '-c':
|
||||
modifiers.count = true;
|
||||
break;
|
||||
case '-nd':
|
||||
modifiers.noDetails = true;
|
||||
break;
|
||||
case '-snd':
|
||||
modifiers.superNoDetails = true;
|
||||
break;
|
||||
case '-s':
|
||||
modifiers.spoiler = '||';
|
||||
break;
|
||||
case '-m':
|
||||
modifiers.maxRoll = true;
|
||||
break;
|
||||
case '-n':
|
||||
modifiers.nominalRoll = true;
|
||||
break;
|
||||
case '-gm':
|
||||
modifiers.gmRoll = true;
|
||||
// Check if any of the args are command flags and pull those out into the modifiers object
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
log(LT.LOG, `Checking ${command}${args.join(' ')} for command modifiers ${i}`);
|
||||
let defaultCase = false;
|
||||
switch (args[i].toLowerCase()) {
|
||||
case '-c':
|
||||
modifiers.count = true;
|
||||
break;
|
||||
case '-nd':
|
||||
modifiers.noDetails = true;
|
||||
break;
|
||||
case '-snd':
|
||||
modifiers.superNoDetails = true;
|
||||
break;
|
||||
case '-s':
|
||||
modifiers.spoiler = '||';
|
||||
break;
|
||||
case '-m':
|
||||
modifiers.maxRoll = true;
|
||||
break;
|
||||
case '-n':
|
||||
modifiers.nominalRoll = true;
|
||||
break;
|
||||
case '-gm':
|
||||
modifiers.gmRoll = true;
|
||||
|
||||
// -gm is a little more complex, as we must get all of the GMs that need to be DMd
|
||||
while (((i + 1) < args.length) && args[i + 1].startsWith('<@')) {
|
||||
log(LT.LOG, `Finding all GMs, checking args ${JSON.stringify(args)}`);
|
||||
// Keep looping thru the rest of the args until one does not start with the discord mention code
|
||||
modifiers.gms.push(args[i + 1].replace(/!/g, ''));
|
||||
args.splice(i + 1, 1);
|
||||
}
|
||||
if (modifiers.gms.length < 1) {
|
||||
// If -gm is on and none were found, throw an error
|
||||
m.edit(generateRollError(errorType, 'Must specifiy at least one GM by @mentioning them')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e));
|
||||
// -gm is a little more complex, as we must get all of the GMs that need to be DMd
|
||||
while (i + 1 < args.length && args[i + 1].startsWith('<@')) {
|
||||
log(LT.LOG, `Finding all GMs, checking args ${JSON.stringify(args)}`);
|
||||
// Keep looping thru the rest of the args until one does not start with the discord mention code
|
||||
modifiers.gms.push(args[i + 1].replace(/!/g, ''));
|
||||
args.splice(i + 1, 1);
|
||||
}
|
||||
if (modifiers.gms.length < 1) {
|
||||
// If -gm is on and none were found, throw an error
|
||||
m.edit(generateRollError(errorType, 'Must specifiy at least one GM by @mentioning them')).catch((e) =>
|
||||
utils.commonLoggers.messageEditError('getModifiers.ts:66', m, e)
|
||||
);
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 1), [originalCommand, 'NoGMsFound', m.id]).catch((e) => utils.commonLoggers.dbError('getModifiers.ts:72', 'insert into', e));
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
break;
|
||||
case '-o':
|
||||
// Shift the -o out of the array so the next item is the direction
|
||||
args.splice(i, 1);
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient
|
||||
.execute(queries.insertRollLogCmd(0, 1), [originalCommand, 'NoGMsFound', m.id])
|
||||
.catch((e) => utils.commonLoggers.dbError('getModifiers.ts:72', 'insert into', e));
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
break;
|
||||
case '-o':
|
||||
// Shift the -o out of the array so the next item is the direction
|
||||
args.splice(i, 1);
|
||||
|
||||
if (!args[i] || args[i].toLowerCase()[0] !== 'd' && args[i].toLowerCase()[0] !== 'a') {
|
||||
// If -o is on and asc or desc was not specified, error out
|
||||
m.edit(generateRollError(errorType, 'Must specifiy `a` or `d` to order the rolls ascending or descending')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:81', m, e));
|
||||
if (!args[i] || (args[i].toLowerCase()[0] !== 'd' && args[i].toLowerCase()[0] !== 'a')) {
|
||||
// If -o is on and asc or desc was not specified, error out
|
||||
m.edit(generateRollError(errorType, 'Must specifiy `a` or `d` to order the rolls ascending or descending')).catch((e) =>
|
||||
utils.commonLoggers.messageEditError('getModifiers.ts:81', m, e)
|
||||
);
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 1), [originalCommand, 'NoOrderFound', m.id]).catch((e) => utils.commonLoggers.dbError('getModifiers.ts:89', 'insert into', e));
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient
|
||||
.execute(queries.insertRollLogCmd(0, 1), [originalCommand, 'NoOrderFound', m.id])
|
||||
.catch((e) => utils.commonLoggers.dbError('getModifiers.ts:89', 'insert into', e));
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
modifiers.order = args[i].toLowerCase()[0];
|
||||
break;
|
||||
default:
|
||||
// Default case should not mess with the array
|
||||
defaultCase = true;
|
||||
break;
|
||||
}
|
||||
modifiers.order = args[i].toLowerCase()[0];
|
||||
break;
|
||||
default:
|
||||
// Default case should not mess with the array
|
||||
defaultCase = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!defaultCase) {
|
||||
args.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (!defaultCase) {
|
||||
args.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
// maxRoll and nominalRoll cannot both be on, throw an error
|
||||
if (modifiers.maxRoll && modifiers.nominalRoll) {
|
||||
m.edit(generateRollError(errorType, 'Cannot maximise and nominise the roll at the same time')).catch((e) => utils.commonLoggers.messageEditError('getModifiers.ts:106', m, e));
|
||||
// maxRoll and nominalRoll cannot both be on, throw an error
|
||||
if (modifiers.maxRoll && modifiers.nominalRoll) {
|
||||
m.edit(generateRollError(errorType, 'Cannot maximise and nominise the roll at the same time')).catch((e) =>
|
||||
utils.commonLoggers.messageEditError('getModifiers.ts:106', m, e)
|
||||
);
|
||||
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient.execute(queries.insertRollLogCmd(0, 1), [originalCommand, 'MaxAndNominal', m.id]).catch((e) => utils.commonLoggers.dbError('getModifiers.ts:120', 'insert into', e));
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
if (DEVMODE && config.logRolls) {
|
||||
// If enabled, log rolls so we can verify the bots math
|
||||
dbClient
|
||||
.execute(queries.insertRollLogCmd(0, 1), [originalCommand, 'MaxAndNominal', m.id])
|
||||
.catch((e) => utils.commonLoggers.dbError('getModifiers.ts:120', 'insert into', e));
|
||||
}
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
modifiers.valid = true;
|
||||
return modifiers;
|
||||
modifiers.valid = true;
|
||||
return modifiers;
|
||||
};
|
||||
|
||||
@@ -1,71 +1,75 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor2 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const rollDecorators = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('rollDecorators')).catch((e) => utils.commonLoggers.dbError('rollHelp.ts:15', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('rollDecorators')).catch((e) => utils.commonLoggers.dbError('rollHelp.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'Roll Command Decorators:',
|
||||
description: `This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message.
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'Roll Command Decorators:',
|
||||
description: `This command also has some useful decorators that can used. These decorators simply need to be placed after all rolls in the message.
|
||||
|
||||
Examples: \`${config.prefix}d20${config.postfix} -nd\`, \`${config.prefix}d20${config.postfix} -nd -s\`, \`${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} ${config.prefix}d20${config.postfix} -o a\``,
|
||||
fields: [
|
||||
{
|
||||
name: '`-nd` - No Details',
|
||||
value: 'Suppresses all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-snd` - Super No Details',
|
||||
value: 'Suppresses all details of the requested roll and hides no details message',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-s` - Spoiler',
|
||||
value: 'Spoilers all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-m` - Maximize Roll',
|
||||
value: 'Rolls the theoretical maximum roll, cannot be used with -n',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-n` - Nominal Roll',
|
||||
value: 'Rolls the theoretical nominal roll, cannot be used with -m',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-c` - Count Rolls',
|
||||
value: 'Shows the Count Embed, containing the count of successful rolls, failed rolls, rerolls, drops, and explosions',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-o [direction]` - Order Roll',
|
||||
value: `Rolls the requested roll and orders the results in the requested direction
|
||||
fields: [
|
||||
{
|
||||
name: '`-nd` - No Details',
|
||||
value: 'Suppresses all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-snd` - Super No Details',
|
||||
value: 'Suppresses all details of the requested roll and hides no details message',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-s` - Spoiler',
|
||||
value: 'Spoilers all details of the requested roll',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-m` - Maximize Roll',
|
||||
value: 'Rolls the theoretical maximum roll, cannot be used with -n',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-n` - Nominal Roll',
|
||||
value: 'Rolls the theoretical nominal roll, cannot be used with -m',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-c` - Count Rolls',
|
||||
value: 'Shows the Count Embed, containing the count of successful rolls, failed rolls, rerolls, drops, and explosions',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`-o [direction]` - Order Roll',
|
||||
value: `Rolls the requested roll and orders the results in the requested direction
|
||||
|
||||
Available directions:
|
||||
\`a\` - Ascending (least to greatest)
|
||||
\`d\` - Descending (greatest to least)`,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('rollHelp.ts:247', message, e));
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('rollHelp.ts:247', message, e));
|
||||
};
|
||||
|
||||
@@ -1,262 +1,275 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1, infoColor2, successColor } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const rollHelp = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('rollhelp')).catch((e) => utils.commonLoggers.dbError('rollHelp.ts:15', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('rollhelp')).catch((e) => utils.commonLoggers.dbError('rollHelp.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor1,
|
||||
title: 'The Artificer\'s Roll Command Details:',
|
||||
description: `You can chain as many of these options as you want, as long as the option does not disallow it.
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor1,
|
||||
title: "The Artificer's Roll Command Details:",
|
||||
description: `You can chain as many of these options as you want, as long as the option does not disallow it.
|
||||
|
||||
This command also can fully solve math equations with parenthesis.
|
||||
|
||||
The Artificer supports most of the [Roll20 formatting](https://artificer.eanm.dev/roll20). More details and examples can be found [here](https://artificer.eanm.dev/roll20).
|
||||
|
||||
Run \`[[???\` or \`[[rollDecorators\` for details on the roll decorators.`,
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'Roll20 Dice Options:',
|
||||
fields: [
|
||||
{
|
||||
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
||||
value: `Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`)`,
|
||||
},
|
||||
{
|
||||
name: '`x` [Optional]',
|
||||
value: `Number of dice to roll, if omitted, 1 is used
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
title: 'Roll20 Dice Options:',
|
||||
fields: [
|
||||
{
|
||||
name: `\`${config.prefix}xdydzracsq!${config.postfix}\` ...`,
|
||||
value: `Rolls all configs requested, you may repeat the command multiple times in the same message (just ensure you close each roll with \`${config.postfix}\`)`,
|
||||
},
|
||||
{
|
||||
name: '`x` [Optional]',
|
||||
value: `Number of dice to roll, if omitted, 1 is used
|
||||
Additionally, replace \`x\` with \`F\` to roll Fate dice`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`dy` [Required]',
|
||||
value: 'Size of dice to roll, `d20` = 20 sided die',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`dz` or `dlz` [Optional]',
|
||||
value: 'Drops the lowest `z` dice, cannot be used with `kz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`kz` or `khz` [Optional]',
|
||||
value: 'Keeps the highest `z` dice, cannot be used with `dz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`dhz` [Optional]',
|
||||
value: 'Drops the highest `z` dice, cannot be used with `kz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`klz` [Optional]',
|
||||
value: 'Keeps the lowest `z` dice, cannot be used with `dz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ra` or `r=q` [Optional]',
|
||||
value: 'Rerolls any rolls that match `a`, `r3` will reroll every die that land on 3, throwing out old rolls, cannot be used with `ro`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`r>q` [Optional]',
|
||||
value: 'Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll every die that land on 3 or greater, throwing out old rolls, cannot be used with `ro`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`roa` or `ro=q` [Optional]',
|
||||
value: 'Rerolls any rolls that match `a`, `ro3` will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ro<q` [Optional]',
|
||||
value: 'Rerolls any rolls that are less than or equal to `a`, `ro3` will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ro>q` [Optional]',
|
||||
value: 'Rerolls any rolls that are greater than or equal to `a`, `ro3` will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`csq` or `cs=q` [Optional]',
|
||||
value: 'Changes crit score to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cs<q` [Optional]',
|
||||
value: 'Changes crit score to be less than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cs>q` [Optional]',
|
||||
value: 'Changes crit score to be greater than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cfq` or `cf=q` [Optional]',
|
||||
value: 'Changes crit fail to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cf<q` [Optional]',
|
||||
value: 'Changes crit fail to be less than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cf>q` [Optional]',
|
||||
value: 'Changes crit fail to be greater than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!` [Optional]',
|
||||
value: 'Exploding, rolls another `dy` for every crit success',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o` [Optional]',
|
||||
value: 'Exploding Once, rolls one `dy` for each original crit success',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p` [Optional]',
|
||||
value: 'Penetrating Explosion, rolls one `dy` for each crit success, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!` [Optional]',
|
||||
value: 'Compounding Explosion, rolls one `dy` for each crit success, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!=u` [Optional]',
|
||||
value: 'Explode on `u`, rolls another `dy` for every die that lands on `u`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!>u` [Optional]',
|
||||
value: 'Explode on `u` and greater, rolls another `dy` for every die that lands on `u` or greater',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
fields: [
|
||||
{
|
||||
name: '`!<u` [Optional]',
|
||||
value: 'Explode on `u` and under, rolls another `dy` for every die that lands on `u` or less',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o=u` [Optional]',
|
||||
value: 'Explodes Once on `u`, rolls another `dy` for each original die that landed on `u`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o>u` [Optional]',
|
||||
value: 'Explode Once on `u` and greater, rolls another `dy` for each original die that landed on `u` or greater',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o<u` [Optional]',
|
||||
value: 'Explode Once on `u` and under, rolls another `dy` for each original die that landed on `u` or less',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p=u` [Optional]',
|
||||
value: 'Penetrating Explosion on `u`, rolls one `dy` for each die that lands on `u`, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p<u` [Optional]',
|
||||
value: 'Penetrating Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!=u` [Optional]',
|
||||
value: 'Compounding Explosion on `u`, rolls one `dy` for each die that lands on `u`, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!>u` [Optional]',
|
||||
value: 'Compounding Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!<u` [Optional]',
|
||||
value: 'Compounding Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: infoColor1,
|
||||
title: 'Custom Dice Options',
|
||||
fields: [
|
||||
{
|
||||
name: 'CWOD Rolling',
|
||||
value: `\`${config.prefix}xcwody${config.postfix}\`
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`dy` [Required]',
|
||||
value: 'Size of dice to roll, `d20` = 20 sided die',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`dz` or `dlz` [Optional]',
|
||||
value: 'Drops the lowest `z` dice, cannot be used with `kz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`kz` or `khz` [Optional]',
|
||||
value: 'Keeps the highest `z` dice, cannot be used with `dz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`dhz` [Optional]',
|
||||
value: 'Drops the highest `z` dice, cannot be used with `kz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`klz` [Optional]',
|
||||
value: 'Keeps the lowest `z` dice, cannot be used with `dz`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ra` or `r=q` [Optional]',
|
||||
value: 'Rerolls any rolls that match `a`, `r3` will reroll every die that land on 3, throwing out old rolls, cannot be used with `ro`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
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`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`r>q` [Optional]',
|
||||
value:
|
||||
'Rerolls any rolls that are greater than or equal to `a`, `r3` will reroll every die that land on 3 or greater, throwing out old rolls, cannot be used with `ro`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`roa` or `ro=q` [Optional]',
|
||||
value:
|
||||
'Rerolls any rolls that match `a`, `ro3` will reroll each die that lands on 3 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ro<q` [Optional]',
|
||||
value:
|
||||
'Rerolls any rolls that are less than or equal to `a`, `ro3` will reroll each die that lands on 3, 2, or 1 ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`ro>q` [Optional]',
|
||||
value:
|
||||
'Rerolls any rolls that are greater than or equal to `a`, `ro3` will reroll each die that lands on 3 or greater ONLY ONE TIME, throwing out old rolls, cannot be used with `r`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`csq` or `cs=q` [Optional]',
|
||||
value: 'Changes crit score to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cs<q` [Optional]',
|
||||
value: 'Changes crit score to be less than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cs>q` [Optional]',
|
||||
value: 'Changes crit score to be greater than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cfq` or `cf=q` [Optional]',
|
||||
value: 'Changes crit fail to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cf<q` [Optional]',
|
||||
value: 'Changes crit fail to be less than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`cf>q` [Optional]',
|
||||
value: 'Changes crit fail to be greater than or equal to `q`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!` [Optional]',
|
||||
value: 'Exploding, rolls another `dy` for every crit success',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o` [Optional]',
|
||||
value: 'Exploding Once, rolls one `dy` for each original crit success',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p` [Optional]',
|
||||
value: 'Penetrating Explosion, rolls one `dy` for each crit success, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!` [Optional]',
|
||||
value: 'Compounding Explosion, rolls one `dy` for each crit success, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!=u` [Optional]',
|
||||
value: 'Explode on `u`, rolls another `dy` for every die that lands on `u`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!>u` [Optional]',
|
||||
value: 'Explode on `u` and greater, rolls another `dy` for every die that lands on `u` or greater',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: infoColor2,
|
||||
fields: [
|
||||
{
|
||||
name: '`!<u` [Optional]',
|
||||
value: 'Explode on `u` and under, rolls another `dy` for every die that lands on `u` or less',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o=u` [Optional]',
|
||||
value: 'Explodes Once on `u`, rolls another `dy` for each original die that landed on `u`',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o>u` [Optional]',
|
||||
value: 'Explode Once on `u` and greater, rolls another `dy` for each original die that landed on `u` or greater',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!o<u` [Optional]',
|
||||
value: 'Explode Once on `u` and under, rolls another `dy` for each original die that landed on `u` or less',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p=u` [Optional]',
|
||||
value: 'Penetrating Explosion on `u`, rolls one `dy` for each die that lands on `u`, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
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',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!p<u` [Optional]',
|
||||
value:
|
||||
'Penetrating Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but subtracts one from each resulting explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!=u` [Optional]',
|
||||
value:
|
||||
'Compounding Explosion on `u`, rolls one `dy` for each die that lands on `u`, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!>u` [Optional]',
|
||||
value:
|
||||
'Compounding Explosion on `u` and greater, rolls one `dy` for each die that lands on `u` or greater, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: '`!!<u` [Optional]',
|
||||
value:
|
||||
'Compounding Explosion on `u` and under, rolls one `dy` for each die that lands on `u` or under, but adds the resulting explosion to the die that caused this explosion',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: infoColor1,
|
||||
title: 'Custom Dice Options',
|
||||
fields: [
|
||||
{
|
||||
name: 'CWOD Rolling',
|
||||
value: `\`${config.prefix}xcwody${config.postfix}\`
|
||||
\`x\` - Number of CWOD dice to roll
|
||||
\`y\` - Difficulty to roll at`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'OVA Rolling',
|
||||
value: `\`${config.prefix}xovady${config.postfix}\`
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'OVA Rolling',
|
||||
value: `\`${config.prefix}xovady${config.postfix}\`
|
||||
\`x\` - Number of OVA dice to roll
|
||||
\`y\` - Size of the die to roll (defaults to 6 if omitted)`,
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: successColor,
|
||||
title: 'Results Formatting:',
|
||||
description: 'The results have some formatting applied on them to provide details on what happened during this roll.',
|
||||
fields: [
|
||||
{
|
||||
name: 'Bold',
|
||||
value: 'Critical successes will be **bolded**.',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Underline',
|
||||
value: 'Critical fails will be __underlined__.',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Strikethrough',
|
||||
value: 'Rolls that were dropped or rerolled ~~crossed out~~.',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Exclamation mark (`!`)',
|
||||
value: 'Rolls that were caused by an explosion have an exclamation mark (`!`) after them.',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('rollHelp.ts:247', message, e));
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
color: successColor,
|
||||
title: 'Results Formatting:',
|
||||
description: 'The results have some formatting applied on them to provide details on what happened during this roll.',
|
||||
fields: [
|
||||
{
|
||||
name: 'Bold',
|
||||
value: 'Critical successes will be **bolded**.',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Underline',
|
||||
value: 'Critical fails will be __underlined__.',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Strikethrough',
|
||||
value: 'Rolls that were dropped or rerolled ~~crossed out~~.',
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Exclamation mark (`!`)',
|
||||
value: 'Rolls that were caused by an explosion have an exclamation mark (`!`) after them.',
|
||||
inline: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('rollHelp.ts:247', message, e));
|
||||
};
|
||||
|
||||
@@ -1,36 +1,49 @@
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
cache,
|
||||
cacheHandlers,
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
cache,
|
||||
cacheHandlers,
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { generateStats } from '../commandUtils.ts';
|
||||
import { compilingStats } from '../commonEmbeds.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const stats = async (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('stats')).catch((e) => utils.commonLoggers.dbError('stats.ts:14', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('stats')).catch((e) => utils.commonLoggers.dbError('stats.ts:14', 'call sproc INC_CNT on', e));
|
||||
|
||||
try {
|
||||
const m = await message.send(compilingStats);
|
||||
try {
|
||||
const m = await message.send(compilingStats);
|
||||
|
||||
// Calculate how many times commands have been run
|
||||
const rollQuery = await dbClient.query(`SELECT count, hourlyRate FROM command_cnt WHERE command = "roll";`).catch((e) => utils.commonLoggers.dbError('stats.ts:23', 'query', e));
|
||||
const totalQuery = await dbClient.query(`SELECT SUM(count) as count, SUM(hourlyRate) as hourlyRate FROM command_cnt;`).catch((e) => utils.commonLoggers.dbError('stats.ts:24', 'query', e));
|
||||
const rolls = BigInt(rollQuery[0].count);
|
||||
const rollRate = parseFloat(rollQuery[0].hourlyRate);
|
||||
const total = BigInt(totalQuery[0].count);
|
||||
const totalRate = parseFloat(totalQuery[0].hourlyRate);
|
||||
// Calculate how many times commands have been run
|
||||
const rollQuery = await dbClient
|
||||
.query(`SELECT count, hourlyRate FROM command_cnt WHERE command = "roll";`)
|
||||
.catch((e) => utils.commonLoggers.dbError('stats.ts:23', 'query', e));
|
||||
const totalQuery = await dbClient
|
||||
.query(`SELECT SUM(count) as count, SUM(hourlyRate) as hourlyRate FROM command_cnt;`)
|
||||
.catch((e) => utils.commonLoggers.dbError('stats.ts:24', 'query', e));
|
||||
const rolls = BigInt(rollQuery[0].count);
|
||||
const rollRate = parseFloat(rollQuery[0].hourlyRate);
|
||||
const total = BigInt(totalQuery[0].count);
|
||||
const totalRate = parseFloat(totalQuery[0].hourlyRate);
|
||||
|
||||
const cachedGuilds = await cacheHandlers.size('guilds');
|
||||
const cachedChannels = await cacheHandlers.size('channels');
|
||||
const cachedMembers = await cacheHandlers.size('members');
|
||||
m.edit(generateStats(cachedGuilds + cache.dispatchedGuildIds.size, cachedChannels + cache.dispatchedChannelIds.size, cachedMembers, rolls, total - rolls, rollRate, totalRate - rollRate)).catch((
|
||||
e: Error,
|
||||
) => utils.commonLoggers.messageEditError('stats.ts:38', m, e));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('stats.ts:41', message, e);
|
||||
}
|
||||
const cachedGuilds = await cacheHandlers.size('guilds');
|
||||
const cachedChannels = await cacheHandlers.size('channels');
|
||||
const cachedMembers = await cacheHandlers.size('members');
|
||||
m.edit(
|
||||
generateStats(
|
||||
cachedGuilds + cache.dispatchedGuildIds.size,
|
||||
cachedChannels + cache.dispatchedChannelIds.size,
|
||||
cachedMembers,
|
||||
rolls,
|
||||
total - rolls,
|
||||
rollRate,
|
||||
totalRate - rollRate
|
||||
)
|
||||
).catch((e: Error) => utils.commonLoggers.messageEditError('stats.ts:38', m, e));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('stats.ts:41', message, e);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,25 @@
|
||||
import config from '../../config.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import dbClient from '../db/client.ts';
|
||||
import { queries } from '../db/common.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { infoColor1 } from '../commandUtils.ts';
|
||||
import utils from '../utils.ts';
|
||||
|
||||
export const version = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('version')).catch((e) => utils.commonLoggers.dbError('version.ts:15', 'call sproc INC_CNT on', e));
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(queries.callIncCnt('version')).catch((e) => utils.commonLoggers.dbError('version.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
color: infoColor1,
|
||||
title: `My current version is ${config.version}`,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('version.ts:24', message, e));
|
||||
message
|
||||
.send({
|
||||
embeds: [
|
||||
{
|
||||
color: infoColor1,
|
||||
title: `My current version is ${config.version}`,
|
||||
},
|
||||
],
|
||||
})
|
||||
.catch((e: Error) => utils.commonLoggers.messageSendError('version.ts:24', message, e));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user