From 1ee462c417b321a87dfd1d49ff101323c865acae Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 8 Oct 2024 12:34:07 +0700 Subject: [PATCH] feat: database name --- src/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 86e7f12..34bfd2e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import { Client, Collection, GatewayIntentBits } from "discord.js"; import { loadCommands, loadEvents } from "./utils/loader"; import mongoose from "mongoose"; -const { MONGO_URI, BOT_TOKEN } = process.env; +const { MONGO_URI: mongoURI, BOT_TOKEN: token, NODE_ENV: nodeEnv } = process.env; const client = new Client({ intents: [ @@ -17,6 +17,12 @@ client.commands = new Collection(); mongoose.connection.on("connected", () => console.log("Đã kết nối tới MongoDB")); -await Promise.all([loadEvents(client), loadCommands(client), mongoose.connect(MONGO_URI!)]); +await Promise.all([ + loadEvents(client), + loadCommands(client), + mongoose.connect(mongoURI!, { + dbName: nodeEnv === "development" ? "dev" : "prod", + }), +]); -await client.login(BOT_TOKEN); +await client.login(token);