Skip to content
This repository has been archived by the owner on Apr 23, 2023. It is now read-only.

Commit

Permalink
fix command execution
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasptsch committed Dec 19, 2021
1 parent a74dacc commit 7700676
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/deploy-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
15 changes: 15 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "2021.12.12"
"version": "2021.12.13"
}

0 comments on commit 7700676

Please sign in to comment.