fix: dont run command as message when there's no runMessage

This commit is contained in:
Jozef Steinhübl 2023-08-24 10:22:47 +02:00
parent e2dc7e32d6
commit 2a3bf141d9
2 changed files with 6 additions and 8 deletions

View file

@ -1,13 +1,11 @@
import { Events } from "discord.js";
import { Events, Interaction, ChatInputCommandInteraction } from "discord.js";
import { COMMANDS } from "../loaders/commands.ts";
import { defineListener } from "../loaders/listeners.ts";
import { CommandContext } from "../structs/context/CommandContext.ts";
import { BaseInteraction } from "discord.js";
import { ChatInputCommandInteraction } from "discord.js";
import { InteractionCommandContext } from "../structs/context/CommandContext.ts";
defineListener({
event: Events.InteractionCreate,
run: (interaction: BaseInteraction) => {
run: (interaction: Interaction) => {
if (interaction.isChatInputCommand()) return handleCommand(interaction);
return;
@ -25,5 +23,5 @@ function handleCommand(interaction: ChatInputCommandInteraction) {
return;
}
command.run(new CommandContext(command, interaction));
command.run(new InteractionCommandContext(command, interaction));
}

View file

@ -18,11 +18,11 @@ defineListener({
if (commandName.length === 0) return;
const command = COMMANDS.get(commandName);
if (!command) return;
if (!command || !command.runMessage) return;
const context = new MessageCommandContext(command, message, args);
await Promise.resolve(command.run(context))
await Promise.resolve(command.runMessage(context))
.catch(async error => {
context.reply({
content: `Something went wrong... ${error.message} (${error.code})`