From caa23d6cb2d6295dce21fa92842fab8c53dec7d3 Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sun, 4 Feb 2024 23:52:08 +0100 Subject: [PATCH] generalise command execution for interaction create --- events/interactionCreate.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/events/interactionCreate.js b/events/interactionCreate.js index 86b465b..4afa97a 100644 --- a/events/interactionCreate.js +++ b/events/interactionCreate.js @@ -1,6 +1,6 @@ import { Events } from 'discord.js'; -const chatInputCommand = async (interaction, command) => { +const executeCommand = async (interaction, command) => { // Try executing command try { console.info(`[INFO] Command ${interaction.commandName} was executed.`); @@ -34,9 +34,9 @@ export const name = Events.InteractionCreate; export async function execute(interaction) { let command = interaction.client.commands.get(interaction.commandName); - // Execute slash commands - if (interaction.isChatInputCommand()) { - await chatInputCommand(interaction, command); + // Execute slash- and context-menu-commands + if (interaction.isChatInputCommand() || interaction.isMessageContextMenuCommand()) { + await executeCommand(interaction, command); return; } // Autocomplete input @@ -44,7 +44,7 @@ export async function execute(interaction) { await genericExecute(interaction, command, 'autocomplete'); return; } - // Modeal submit event + // Modal submit event if (interaction.isModalSubmit()) { const name = interaction.customId.split('-')[0]; command = interaction.client.commands.get(name);