diff --git a/index.ts b/index.ts index 008f101..aba8752 100644 --- a/index.ts +++ b/index.ts @@ -5,6 +5,7 @@ import DiscordInteractionCommand from "./util/DiscordInteractionCommand"; import DiscordEvent from "./util/DiscordEvent"; import * as DiscordInteractionCommandsIndex from "./discord/commands"; import * as DiscordEventsIndex from "./discord/events"; +import mongoose from "mongoose"; export const DiscordInteractionCommands: Collection = new Collection(); export const DiscordEvents: Collection = new Collection(); @@ -25,6 +26,16 @@ const discordREST = new REST().setToken(discordBotToken); // const stripeClient = new Stripe(stripeToken, { typescript: true }); export async function main() { + // Connect to the databases + try { + mongoose.connection.once("open", () => { + console.info("[Info - Database] Connected to MongoDB"); + }) + await mongoose.connect("mongodb://localhost:27017/crra-main", {}); + } catch (error) { + console.error(`[Error - Database] Failed to connect to MongoDB: ${error}`); + process.exit(1); + } // Load Discord interaction commands for (const Command of Object.values(DiscordInteractionCommandsIndex)) { const instance = new Command();