add greeting
add locales
This commit is contained in:
32
adapters/discord/src/entities/commands/index.ts
Normal file
32
adapters/discord/src/entities/commands/index.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user