mirror of
https://github.com/Burn-E99/TheArtificer.git
synced 2026-01-08 13:27:55 -05:00
Initial work on [[heatmap, fixed some loggers to be edit instead of send
This commit is contained in:
@ -12,6 +12,7 @@ import { emoji } from './emoji.ts';
|
||||
import { roll } from './roll.ts';
|
||||
import { handleMentions } from './handleMentions.ts';
|
||||
import { audit } from './audit.ts';
|
||||
import { heatmap } from './heatmap.ts';
|
||||
|
||||
export default {
|
||||
ping,
|
||||
@ -28,4 +29,5 @@ export default {
|
||||
roll,
|
||||
handleMentions,
|
||||
audit,
|
||||
heatmap,
|
||||
};
|
||||
|
||||
@ -35,7 +35,7 @@ export const auditDB = async (message: DiscordenoMessage) => {
|
||||
timestamp: new Date().toISOString(),
|
||||
fields: embedFields,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('auditDB.ts:43', message, e));
|
||||
}).catch((e: Error) => utils.commonLoggers.messageEditError('auditDB.ts:43', message, e));
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('auditDB.ts:45', message, e);
|
||||
}
|
||||
|
||||
27
src/commands/heatmap.ts
Normal file
27
src/commands/heatmap.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import { dbClient, queries } from '../db.ts';
|
||||
import {
|
||||
// Discordeno deps
|
||||
DiscordenoMessage,
|
||||
} from '../../deps.ts';
|
||||
import { } from '../commandUtils.ts';
|
||||
import { compilingStats } from '../commonEmbeds.ts';
|
||||
import utils from '../utils.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));
|
||||
|
||||
try {
|
||||
const m = await message.send(compilingStats);
|
||||
|
||||
// Calculate how many times commands have been run
|
||||
const hmQuery = await dbClient.query(`SELECT * FROM roll_time_heatmap`).catch((e) => utils.commonLoggers.dbError('heatmap.ts:20', 'query', e));
|
||||
console.log(hmQuery);
|
||||
|
||||
m.edit('').catch((e: Error) =>
|
||||
utils.commonLoggers.messageEditError('heatmap.ts:21', m, e)
|
||||
);
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('heatmap.ts:24', message, e);
|
||||
}
|
||||
};
|
||||
@ -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(queries.callIncCnt('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:14', 'call sproc INC_CNT on', e));
|
||||
|
||||
try {
|
||||
const m = await message.send(compilingStats);
|
||||
@ -28,7 +28,7 @@ export const stats = async (message: DiscordenoMessage) => {
|
||||
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.messageSendError('stats.ts:38', message, e)
|
||||
utils.commonLoggers.messageEditError('stats.ts:38', m, e)
|
||||
);
|
||||
} catch (e) {
|
||||
utils.commonLoggers.messageSendError('stats.ts:41', message, e);
|
||||
|
||||
@ -190,7 +190,7 @@ export const queueRoll = async (rq: QueuedRoll) => {
|
||||
|
||||
The results for this roll will replace this message when it is done.`,
|
||||
}],
|
||||
}).catch((e: Error) => utils.commonLoggers.messageSendError('rollQueue.ts:197', rq.dd.m, e));
|
||||
}).catch((e: Error) => utils.commonLoggers.messageEditError('rollQueue.ts:197', rq.dd.m, e));
|
||||
rollQueue.push(rq);
|
||||
}
|
||||
};
|
||||
@ -201,7 +201,7 @@ setInterval(async () => {
|
||||
if (rollQueue.length && currentWorkers < config.limits.maxWorkers) {
|
||||
const temp = rollQueue.shift();
|
||||
if (temp) {
|
||||
temp.dd.m.edit(rollingEmbed).catch((e: Error) => utils.commonLoggers.messageSendError('rollQueue.ts:208', temp.dd.m, e));
|
||||
temp.dd.m.edit(rollingEmbed).catch((e: Error) => utils.commonLoggers.messageEditError('rollQueue.ts:208', temp.dd.m, e));
|
||||
handleRollWorker(temp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user