mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-12-22 12:11:06 +01:00
fix: dont run command as message when there's no runMessage
This commit is contained in:
parent
e2dc7e32d6
commit
2a3bf141d9
2 changed files with 6 additions and 8 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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})`
|
||||
|
|
Loading…
Reference in a new issue