add commands system

This commit is contained in:
Asaki Yuki
2025-10-18 17:41:27 +07:00
parent c677cb5d68
commit ffdce31ecb
14 changed files with 148 additions and 105 deletions

View File

@@ -0,0 +1,22 @@
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)
}
}