This commit is contained in:
2026-05-26 14:15:09 +09:00
parent 55d402f606
commit d6b36c43c2
33 changed files with 1496 additions and 0 deletions

25
src/classes/Handler.ts Normal file
View File

@@ -0,0 +1,25 @@
import { ChatInputCommandInteraction, Collection } from "discord.js";
import { readdirSync } from "node:fs";
import { Command } from "../types/Command";
import { COMMAND_PATH, COMMANDS_PATH } from "../utils/Config";
export class Handler {
public commands: Collection<string, Command> = new Collection();
public coolDown: Map<string, number> = new Map();
public constructor() {
const commandFiles = readdirSync(COMMANDS_PATH);
for (const commandFile of commandFiles) {
const command = new (require(COMMAND_PATH(commandFile)).default)() as Command;
this.commands.set(command.metaData.name, command);
}
}
public runCommand(interaction: ChatInputCommandInteraction) {
const commandName = interaction.commandName;
const command = this.commands.get(commandName);
if (!command) return;
if (command.slashRun) command.slashRun(interaction);
}
}