mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-11-14 10:58: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 { COMMANDS } from "../loaders/commands.ts";
|
||||||
import { defineListener } from "../loaders/listeners.ts";
|
import { defineListener } from "../loaders/listeners.ts";
|
||||||
import { CommandContext } from "../structs/context/CommandContext.ts";
|
import { InteractionCommandContext } from "../structs/context/CommandContext.ts";
|
||||||
import { BaseInteraction } from "discord.js";
|
|
||||||
import { ChatInputCommandInteraction } from "discord.js";
|
|
||||||
|
|
||||||
defineListener({
|
defineListener({
|
||||||
event: Events.InteractionCreate,
|
event: Events.InteractionCreate,
|
||||||
run: (interaction: BaseInteraction) => {
|
run: (interaction: Interaction) => {
|
||||||
if (interaction.isChatInputCommand()) return handleCommand(interaction);
|
if (interaction.isChatInputCommand()) return handleCommand(interaction);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -25,5 +23,5 @@ function handleCommand(interaction: ChatInputCommandInteraction) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
command.run(new CommandContext(command, interaction));
|
command.run(new InteractionCommandContext(command, interaction));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@ defineListener({
|
||||||
if (commandName.length === 0) return;
|
if (commandName.length === 0) return;
|
||||||
|
|
||||||
const command = COMMANDS.get(commandName);
|
const command = COMMANDS.get(commandName);
|
||||||
if (!command) return;
|
if (!command || !command.runMessage) return;
|
||||||
|
|
||||||
const context = new MessageCommandContext(command, message, args);
|
const context = new MessageCommandContext(command, message, args);
|
||||||
|
|
||||||
await Promise.resolve(command.run(context))
|
await Promise.resolve(command.runMessage(context))
|
||||||
.catch(async error => {
|
.catch(async error => {
|
||||||
context.reply({
|
context.reply({
|
||||||
content: `Something went wrong... ${error.message} (${error.code})`
|
content: `Something went wrong... ${error.message} (${error.code})`
|
||||||
|
|
Loading…
Reference in a new issue