forked from engineering/crv2
add database connection "hardcoded for testing"
parent
a1e59fa275
commit
957c5a8928
11
index.ts
11
index.ts
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue