created callIncCnt function for simplicity
This commit is contained in:
parent
b0266ad385
commit
011120845e
|
@ -1,4 +1,4 @@
|
|||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -10,7 +10,7 @@ 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(`CALL INC_CNT("api");`).catch((e) => utils.commonLoggers.dbError('apiCmd.ts:16', 'call sproc INC_CNT on', e));
|
||||
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();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -10,7 +10,7 @@ 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(`CALL INC_CNT("audit");`).catch((e) => utils.commonLoggers.dbError('audit.ts:16', 'call sproc INC_CNT on', e));
|
||||
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();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -25,7 +25,7 @@ export const emoji = (message: DiscordenoMessage, command: string) => {
|
|||
// 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(`CALL INC_CNT("emojis");`).catch((e) => utils.commonLoggers.dbError('emojis.ts:28', 'call sproc INC_CNT on', e));
|
||||
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));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -14,7 +14,7 @@ export const handleMentions = (message: DiscordenoMessage) => {
|
|||
log(LT.LOG, `Handling @mention message: ${JSON.stringify(message)}`);
|
||||
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(`CALL INC_CNT("mention");`).catch((e) => utils.commonLoggers.dbError('handleMentions.ts:17', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('mention')).catch((e) => utils.commonLoggers.dbError('handleMentions.ts:17', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -9,7 +9,7 @@ import utils from '../utils.ts';
|
|||
|
||||
export const help = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(`CALL INC_CNT("help");`).catch((e) => utils.commonLoggers.dbError('htlp.ts:15', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('help')).catch((e) => utils.commonLoggers.dbError('htlp.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -8,7 +8,7 @@ import utils from '../utils.ts';
|
|||
|
||||
export const info = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(`CALL INC_CNT("info");`).catch((e) => utils.commonLoggers.dbError('info.ts:14', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('info')).catch((e) => utils.commonLoggers.dbError('info.ts:14', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -8,7 +8,7 @@ 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(`CALL INC_CNT("ping");`).catch((e) => utils.commonLoggers.dbError('ping.ts:14', 'call sproc INC_CNT on', e));
|
||||
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 {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -9,7 +9,7 @@ import utils from '../utils.ts';
|
|||
|
||||
export const privacy = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(`CALL INC_CNT("privacy");`).catch((e) => utils.commonLoggers.dbError('privacy.ts:15', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('privacy')).catch((e) => utils.commonLoggers.dbError('privacy.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -11,7 +11,7 @@ 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(`CALL INC_CNT("report");`).catch((e) => utils.commonLoggers.dbError('report.ts:17', 'call sproc INC_CNT on', e));
|
||||
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));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -8,7 +8,7 @@ import utils from '../utils.ts';
|
|||
|
||||
export const rip = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(`CALL INC_CNT("rip");`).catch((e) => utils.commonLoggers.dbError('rip.ts:14', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('rip')).catch((e) => utils.commonLoggers.dbError('rip.ts:14', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import config from '../../config.ts';
|
||||
import { DEVMODE } from '../../flags.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -16,7 +16,7 @@ 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
|
||||
dbClient.execute(`CALL INC_CNT("roll");`).catch((e) => utils.commonLoggers.dbError('roll.ts:19', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('roll')).catch((e) => utils.commonLoggers.dbError('roll.ts:19', 'call sproc INC_CNT on', e));
|
||||
|
||||
// If DEVMODE is on, only allow this command to be used in the devServer
|
||||
if (DEVMODE && message.guildId !== config.devServer) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -9,7 +9,7 @@ import utils from '../utils.ts';
|
|||
|
||||
export const rollHelp = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(`CALL INC_CNT("rollhelp");`).catch((e) => utils.commonLoggers.dbError('rollHelp.ts:15', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('rollhelp')).catch((e) => utils.commonLoggers.dbError('rollHelp.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
cache,
|
||||
|
@ -11,7 +11,7 @@ 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(`CALL INC_CNT("stats");`).catch((e) => utils.commonLoggers.dbError('stats.ts', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('stats')).catch((e) => utils.commonLoggers.dbError('stats.ts', 'call sproc INC_CNT on', e));
|
||||
|
||||
try {
|
||||
const m = await message.send(compilingStats);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import config from '../../config.ts';
|
||||
import { dbClient } from '../db.ts';
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
|
@ -9,7 +9,7 @@ import utils from '../utils.ts';
|
|||
|
||||
export const version = (message: DiscordenoMessage) => {
|
||||
// Light telemetry to see how many times a command is being run
|
||||
dbClient.execute(`CALL INC_CNT("version");`).catch((e) => utils.commonLoggers.dbError('version.ts:15', 'call sproc INC_CNT on', e));
|
||||
dbClient.execute(queries.callIncCnt('version')).catch((e) => utils.commonLoggers.dbError('version.ts:15', 'call sproc INC_CNT on', e));
|
||||
|
||||
message.send({
|
||||
embeds: [{
|
||||
|
|
|
@ -12,4 +12,5 @@ export const dbClient = await new Client().connect({
|
|||
|
||||
export const queries = {
|
||||
insertRollLogCmd: (api: number, error: number) => `INSERT INTO roll_log(input,result,resultid,api,error) values(?,?,?,${api},${error})`,
|
||||
callIncCnt: (cmdName: string) => `CALL INC_CNT("${cmdName}");`,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue