1
1
mirror of https://github.com/Burn-E99/GroupUp.git synced 2026-06-04 08:53:49 -04:00

Add bot list stat posting system

This commit is contained in:
Ean Milligan (Bastion)
2023-05-01 13:26:25 -04:00
parent ce40b52faa
commit 0926a7df09
2 changed files with 35 additions and 0 deletions

View File

@@ -6,10 +6,12 @@ import { ActiveEvent } from '../types/commandTypes.ts';
import utils from '../utils.ts';
import { dbClient, queries } from '../db.ts';
import { deleteEvent, handleFailures, lockEvent, notifyEventMembers, tenMinutes } from '../notificationSystem.ts';
import { updateBotListStatistics } from '../botListPoster.ts';
// Storing intervalIds in case bot soft reboots to prevent multiple of these intervals from stacking
let notificationIntervalId: number;
let botStatusIntervalId: number;
let botListPosterIntervalId: number;
export const ready = (rawBot: Bot) => {
const bot = rawBot as BotWithCache;
@@ -60,6 +62,13 @@ export const ready = (rawBot: Bot) => {
eventFailuresToHandle?.rows?.forEach((event) => handleFailures(bot, event as ActiveEvent));
}, 30000);
// Interval to handle updating botList statistics
if (botListPosterIntervalId) clearInterval(botListPosterIntervalId)
LOCALMODE ? log(LT.INFO, 'updateListStatistics not running') : botListPosterIntervalId = setInterval(() => {
log(LT.LOG, 'Updating all bot lists statistics');
updateBotListStatistics(bot.guilds.size + bot.dispatchedGuildIds.size);
}, 86400000);
// setTimeout added to make sure the startup message does not error out
setTimeout(() => {
LOCALMODE && bot.helpers.editBotMember(config.devServer, { nick: `LOCAL - ${config.name}` });