Added code coments, refactored db.ts and redis.ts, and added two new commands

This commit is contained in:
Ahmad 2025-03-16 20:31:43 -04:00
parent b3fbd2358b
commit 890ca26c78
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
30 changed files with 1899 additions and 462 deletions

View file

@ -1,16 +1,28 @@
import { Client, Events } from 'discord.js';
import { setMembers } from '../db/db.js';
import { ensureDbInitialized, setMembers } from '../db/db.js';
import { loadConfig } from '../util/configLoader.js';
import { Event } from '../types/EventTypes.js';
import { scheduleFactOfTheDay } from '../util/factManager.js';
import {
ensureRedisConnection,
setDiscordClient as setRedisDiscordClient,
} from '../db/redis.js';
import { setDiscordClient as setDbDiscordClient } from '../db/db.js';
export default {
name: Events.ClientReady,
once: true,
execute: async (client: Client) => {
const config = loadConfig();
try {
setRedisDiscordClient(client);
setDbDiscordClient(client);
await ensureDbInitialized();
await ensureRedisConnection();
const guild = client.guilds.cache.find(
(guilds) => guilds.id === config.guildId,
);
@ -25,7 +37,7 @@ export default {
await scheduleFactOfTheDay(client);
} catch (error) {
console.error('Failed to initialize members in database:', error);
console.error('Failed to initialize the bot:', error);
}
console.log(`Ready! Logged in as ${client.user?.tag}`);