Compare commits
No commits in common. "d3d9a305d0b877974da1fc5389e0175a06b2e48d" and "f70912e4fd8c7ce745d217df752a4ba8faf5359a" have entirely different histories.
d3d9a305d0
...
f70912e4fd
@ -1,6 +1,6 @@
|
||||
import { Events } from 'discord.js';
|
||||
|
||||
const executeCommand = async (interaction, command) => {
|
||||
const chatInputCommand = async (interaction, command) => {
|
||||
// Try executing command
|
||||
try {
|
||||
console.info(`[INFO] Command ${interaction.commandName} was executed.`);
|
||||
@ -21,9 +21,9 @@ const executeCommand = async (interaction, command) => {
|
||||
}
|
||||
};
|
||||
|
||||
const genericExecute = async (interaction, command, name, description, cmdName) => {
|
||||
const genericExecute = async (interaction, command, name, description) => {
|
||||
try {
|
||||
console.info(`[INFO] Command ${(cmdName ?? interaction.commandName) ?? 'anonymous'} ${description ?? `used "${name}"`}.`);
|
||||
console.info(`[INFO] Command ${interaction.commandName} ${description ?? `used "${name}"`}.`);
|
||||
await command[name](interaction);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@ -34,9 +34,9 @@ export const name = Events.InteractionCreate;
|
||||
export async function execute(interaction) {
|
||||
let command = interaction.client.commands.get(interaction.commandName);
|
||||
|
||||
// Execute slash- and context-menu-commands
|
||||
if (interaction.isChatInputCommand() || interaction.isMessageContextMenuCommand()) {
|
||||
await executeCommand(interaction, command);
|
||||
// Execute slash commands
|
||||
if (interaction.isChatInputCommand()) {
|
||||
await chatInputCommand(interaction, command);
|
||||
return;
|
||||
}
|
||||
// Autocomplete input
|
||||
@ -44,12 +44,12 @@ export async function execute(interaction) {
|
||||
await genericExecute(interaction, command, 'autocomplete');
|
||||
return;
|
||||
}
|
||||
// Modal submit event
|
||||
// Modeal submit event
|
||||
if (interaction.isModalSubmit()) {
|
||||
const name = interaction.customId.split('-')[0];
|
||||
command = interaction.client.commands.get(name);
|
||||
|
||||
await genericExecute(interaction, command, 'modalSubmit', 'submitted a modal', name);
|
||||
await genericExecute(interaction, command, 'modalSubmit', 'submitted a modal');
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user