Files
bot/adapters/discord/src/entities/commands/index.ts
mo bc0a6f2526 add greeting
add locales
2026-02-22 00:09:27 +01:00

33 lines
892 B
TypeScript

import { CommandsCollection } from "@avocadi/bot-core/entities/commands/commands.entity";
import type { Command } from "@avocadi/bot-core/entities/commands/commands.schema";
import { SlashCommandBuilder } from "discord.js";
import type { z } from "zod";
const convertCommandToDiscordFormat = (
command: z.output<typeof Command>,
key: string,
) => {
const slashCommand = new SlashCommandBuilder()
.setName(command.name || key)
.setDescription(command.description);
if (command.options) {
command.options.forEach((option) => {
slashCommand.addStringOption((opt) =>
opt
.setName(option.name)
.setDescription(option.description)
.setRequired(option.required),
);
});
}
return slashCommand;
};
export default function getCommands() {
return Object.entries(CommandsCollection).map(([key, command]) =>
convertCommandToDiscordFormat(command, key),
);
}