21 lines
550 B
TypeScript
21 lines
550 B
TypeScript
import { ChatInputCommandInteraction, SlashCommandBuilder } from "discord.js";
|
|
|
|
export interface Command {
|
|
data: SlashCommandBuilder;
|
|
execute: (interaction: ChatInputCommandInteraction) => Promise<void>;
|
|
}
|
|
|
|
const commands = new Map<string, Command>();
|
|
|
|
export function registerCommand(command: Command) {
|
|
commands.set(command.data.name, command);
|
|
}
|
|
|
|
export function getCommand(name: string): Command | undefined {
|
|
return commands.get(name);
|
|
}
|
|
|
|
export function getAllCommands(): Command[] {
|
|
return Array.from(commands.values());
|
|
}
|