add config option for mongo db connection uri
parent
ba6c9218c1
commit
28d0a2d485
15
index.ts
15
index.ts
|
@ -1,5 +1,5 @@
|
|||
import { Client, GatewayIntentBits, Partials, REST, Routes } from "discord.js";
|
||||
import { discordBotToken, discordClientID } from "./config.json"
|
||||
import { discordBotToken, discordClientID, mongoDBConnectionURI } from "./config.json";
|
||||
import Collection from "./util/Collection";
|
||||
import DiscordInteractionCommand from "./util/DiscordInteractionCommand";
|
||||
import DiscordEvent from "./util/DiscordEvent";
|
||||
|
@ -21,7 +21,7 @@ const discordClient = new Client({
|
|||
GatewayIntentBits.GuildInvites,
|
||||
GatewayIntentBits.GuildModeration,
|
||||
],
|
||||
partials: [ Partials.GuildMember, Partials.Message, Partials.User, Partials.Channel, ],
|
||||
partials: [Partials.GuildMember, Partials.Message, Partials.User, Partials.Channel],
|
||||
});
|
||||
const discordREST = new REST().setToken(discordBotToken);
|
||||
// const stripeClient = new Stripe(stripeToken, { typescript: true });
|
||||
|
@ -31,9 +31,9 @@ export async function main() {
|
|||
try {
|
||||
mongoose.connection.once("open", () => {
|
||||
console.info("[Info - Database] Connected to MongoDB");
|
||||
})
|
||||
});
|
||||
// TODO: Fetch the MongoDB URI from the config file
|
||||
await mongoose.connect("mongodb://localhost:27017/crra-main", {});
|
||||
await mongoose.connect(mongoDBConnectionURI, {});
|
||||
} catch (error) {
|
||||
console.error(`[Error - Database] Failed to connect to MongoDB: ${error}`);
|
||||
process.exit(1);
|
||||
|
@ -61,10 +61,9 @@ export async function main() {
|
|||
}
|
||||
|
||||
// The put method is used to fully refresh all commands in the guild with the current set
|
||||
const data = await discordREST.put(
|
||||
Routes.applicationCommands(discordClientID),
|
||||
{ body: interactionCommandsData },
|
||||
);
|
||||
const data = await discordREST.put(Routes.applicationCommands(discordClientID), {
|
||||
body: interactionCommandsData,
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
console.log(`Successfully reloaded ${data?.length} application (/) commands.`);
|
||||
|
|
Loading…
Reference in New Issue