镜像来自
https://github.com/aydenjahola/discord-multipurpose-bot.git
已同步 2025-07-09 06:17:08 +01:00
update guild id in index.js
This commit is contained in:
父節點
2600ab8523
當前提交
697fe198d7
共有 1 個文件被更改,包括 11 次插入 和 2 次删除
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,
|
||||
});
|
||||
|
|
載入中…
Reference in a new issue