diff --git a/src/deploy-commands.ts b/src/deploy-commands.ts index 4aea36f..8592d2c 100644 --- a/src/deploy-commands.ts +++ b/src/deploy-commands.ts @@ -23,10 +23,18 @@ if (!TOKEN || !CLIENT_ID) { await rest.put(Routes.applicationGuildCommands(CLIENT_ID, GUILD_ID), { body: commandList, }); + await logger.debug( + "Updated commands: ", + commandList.map((c) => c.name).join(", ") + ); } else { await rest.put(Routes.applicationCommands(CLIENT_ID), { body: commandList, }); + await logger.debug( + "Updated commands: ", + commandList.map((c) => c.name).join(", ") + ); } await logger.info("Successfully reloaded application (/) commands."); diff --git a/src/index.ts b/src/index.ts index 4711743..c09d503 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,8 @@ import { Client, Intents } from "discord.js"; import dotenv from "dotenv"; +import * as commands from "./commands"; import * as events from "./events"; +import { ErrorEmbed } from "./lib/discordEmbeds"; import { logger } from "./lib/logger"; import { db } from "./lib/prisma"; import { scheduler } from "./lib/scheduler"; @@ -17,6 +19,19 @@ const client = new Client({ const eventList = Object.values(events); +client.on("interactionCreate", async (interaction) => { + if (!interaction.isCommand()) return; + try { + await commands[interaction.commandName].execute(interaction); + } catch (e) { + logger.error(e); + interaction.reply({ + embeds: [ErrorEmbed("There was an error while executing this command!")], + ephemeral: true, + }); + } +}); + // Register event handlers for (const event of eventList) { if (event.once) { diff --git a/src/version.json b/src/version.json index 5f11e5b..229d46e 100644 --- a/src/version.json +++ b/src/version.json @@ -1,3 +1,3 @@ { - "version": "2021.12.12" + "version": "2021.12.13" } \ No newline at end of file