From 75003af03c389eb22a886e7b00504301e95fa72b Mon Sep 17 00:00:00 2001 From: xHyroM Date: Thu, 24 Aug 2023 10:24:31 +0200 Subject: [PATCH] fix: dont run interaction command when there's no run --- src/commands/version.ts | 4 ++-- src/listeners/interaction_create.ts | 2 +- src/structs/Command.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/commands/version.ts b/src/commands/version.ts index fdd1109..7c60d04 100644 --- a/src/commands/version.ts +++ b/src/commands/version.ts @@ -1,11 +1,11 @@ import { defineCommand } from "../loaders/commands.ts"; import { COMMIT_HASH, PRODUCTION } from "../constants.ts"; -import { CommandContext } from "../structs/context/CommandContext.ts"; +import { InteractionCommandContext } from "../structs/context/CommandContext.ts"; export default defineCommand({ name: "version", options: [], - run: (context: CommandContext) => { + run: (context: InteractionCommandContext) => { context.interaction.reply({ content: [ `[git-bun-discord-bot-${COMMIT_HASH}]() ${!PRODUCTION ? "(dev)" : ""}`, diff --git a/src/listeners/interaction_create.ts b/src/listeners/interaction_create.ts index f8afbf6..e4839e0 100644 --- a/src/listeners/interaction_create.ts +++ b/src/listeners/interaction_create.ts @@ -15,7 +15,7 @@ defineListener({ function handleCommand(interaction: ChatInputCommandInteraction) { const command = COMMANDS.get(interaction.commandName); - if (!command) { + if (!command || !command.run) { interaction.reply({ content: "Hmm.. Invalid command :P", ephemeral: true, diff --git a/src/structs/Command.ts b/src/structs/Command.ts index 584d2a7..61e1cc9 100644 --- a/src/structs/Command.ts +++ b/src/structs/Command.ts @@ -11,10 +11,10 @@ interface StringOption extends SlashCommandStringOption { export interface Command { name: string; options: Option[]; - run: ( + run?: ( context: CommandContext ) => any; - runMessage: ( + runMessage?: ( context: CommandContext ) => any; }