Files
DiscordBOT/src/handler/executeCommand.ts
2025-10-20 23:56:33 +07:00

23 lines
735 B
TypeScript

import { ChatInputCommandInteraction, CacheType } from "discord.js"
import { execCmds } from "../cmd"
export async function execCmd(interaction: ChatInputCommandInteraction<CacheType>) {
try {
const commandName = interaction.commandName
const command = execCmds.get(commandName)
console.info(`Executing command '${commandName}' by ${interaction.user.tag} (${interaction.user.id})`)
const options = interaction.options.data
if (options.length > 0) {
console.info(
options.map(option => `\x1b[34m${option.name}\x1b[0m: \x1b[90m${option.value}\x1b[0m`).join(", ")
)
}
if (command) command.exec(interaction)
else console.warn(`Command ${commandName} not found`)
} catch (error) {
console.error(error)
}
}