mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 00:35:56 +00:00
update guild id in index.js
This commit is contained in:
parent
2600ab8523
commit
697fe198d7
1 changed files with 11 additions and 2 deletions
13
index.js
13
index.js
|
@ -9,6 +9,7 @@ const {
|
|||
const mongoose = require("mongoose");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const ServerSettings = require("./models/ServerSettings");
|
||||
|
||||
const client = new Client({
|
||||
intents: [
|
||||
|
@ -18,8 +19,6 @@ const client = new Client({
|
|||
],
|
||||
});
|
||||
|
||||
const GUILD_ID = process.env.GUILD_ID;
|
||||
|
||||
client.commands = new Collection();
|
||||
|
||||
// Function to recursively read commands from subdirectories
|
||||
|
@ -63,7 +62,17 @@ client.once("ready", async () => {
|
|||
|
||||
const rest = new REST({ version: "10" }).setToken(process.env.BOT_TOKEN);
|
||||
|
||||
// Fetching the guild ID from MongoDB
|
||||
let GUILD_ID;
|
||||
try {
|
||||
const serverSettings = await ServerSettings.findOne();
|
||||
if (serverSettings) {
|
||||
GUILD_ID = serverSettings.guildId;
|
||||
} else {
|
||||
console.error("No server settings found in MongoDB.");
|
||||
return;
|
||||
}
|
||||
|
||||
await rest.put(Routes.applicationGuildCommands(client.user.id, GUILD_ID), {
|
||||
body: commands,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue