From 957c5a8928cbeda5ffc6e0b133459fa41a9501e5 Mon Sep 17 00:00:00 2001 From: Matthew Date: Tue, 2 Apr 2024 16:38:39 -0400 Subject: [PATCH] add database connection "hardcoded for testing" --- index.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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();