Skip to content

Commit

Permalink
feat: database name
Browse files Browse the repository at this point in the history
  • Loading branch information
louiszn committed Oct 8, 2024
1 parent ed4ba6e commit 1ee462c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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);

0 comments on commit 1ee462c

Please sign in to comment.