add database connection "hardcoded for testing"

pull/1/head
Matthew 2024-04-02 16:38:39 -04:00
parent a1e59fa275
commit 957c5a8928
Signed by: matthew
SSH Key Fingerprint: SHA256:piIXekA9q1p0ZGi4ogFbNY1embip5Ytbi3v8AZ8UYq4
1 changed files with 11 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import DiscordInteractionCommand from "./util/DiscordInteractionCommand";
import DiscordEvent from "./util/DiscordEvent"; import DiscordEvent from "./util/DiscordEvent";
import * as DiscordInteractionCommandsIndex from "./discord/commands"; import * as DiscordInteractionCommandsIndex from "./discord/commands";
import * as DiscordEventsIndex from "./discord/events"; import * as DiscordEventsIndex from "./discord/events";
import mongoose from "mongoose";
export const DiscordInteractionCommands: Collection<DiscordInteractionCommand> = new Collection(); export const DiscordInteractionCommands: Collection<DiscordInteractionCommand> = new Collection();
export const DiscordEvents: Collection<DiscordEvent> = new Collection(); export const DiscordEvents: Collection<DiscordEvent> = new Collection();
@ -25,6 +26,16 @@ const discordREST = new REST().setToken(discordBotToken);
// const stripeClient = new Stripe(stripeToken, { typescript: true }); // const stripeClient = new Stripe(stripeToken, { typescript: true });
export async function main() { 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 // Load Discord interaction commands
for (const Command of Object.values(DiscordInteractionCommandsIndex)) { for (const Command of Object.values(DiscordInteractionCommandsIndex)) {
const instance = new Command(); const instance = new Command();