From 9fb5317bc815a31700dfadb1e646e82651ca175c Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 25 Oct 2024 18:29:57 +0100 Subject: [PATCH] maybe it just needs time to work idk --- projects/backend/src/bot/bot.ts | 25 +++++++++++++++---------- projects/backend/src/index.ts | 4 ++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/projects/backend/src/bot/bot.ts b/projects/backend/src/bot/bot.ts index 1d24d02..f51e645 100644 --- a/projects/backend/src/bot/bot.ts +++ b/projects/backend/src/bot/bot.ts @@ -1,4 +1,4 @@ -import { Client } from "discordx"; +import { Client, MetadataStorage } from "discordx"; import { ActivityType, EmbedBuilder } from "discord.js"; import { Config } from "@ssr/common/config"; @@ -10,7 +10,7 @@ export enum DiscordChannels { } const client = new Client({ - intents: [], + intents: ["Guilds", "GuildMessages"], presence: { status: "online", @@ -31,15 +31,20 @@ client.once("ready", () => { export async function initDiscordBot() { console.log("Initializing discord bot..."); - // Setup slash commands - client.once("ready", async () => { - await client.initApplicationCommands(); - }); - client.on("interactionCreate", interaction => { - client.executeInteraction(interaction); - }); + // We will now build our application to load all the commands/events for both bots. + MetadataStorage.instance.build().then(async () => { + // Setup slash commands + client.once("ready", async () => { + await client.initApplicationCommands(); + console.log(client.applicationCommands); + }); + client.on("interactionCreate", interaction => { + client.executeInteraction(interaction); + }); - await client.login(Config.discordBotToken!); + // Login + await client.login(Config.discordBotToken!); + }); } /** diff --git a/projects/backend/src/index.ts b/projects/backend/src/index.ts index 30471a0..6e53aeb 100644 --- a/projects/backend/src/index.ts +++ b/projects/backend/src/index.ts @@ -162,10 +162,10 @@ app.use( }) ); -app.onStart(() => { +app.onStart(async () => { console.log("Listening on port http://localhost:8080"); if (isProduction()) { - initDiscordBot(); + await initDiscordBot(); } });