mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-22 19:19:52 +02:00
feat: partially translated /about
This commit is contained in:
1 parent
8e35e0d6d9
commit
db7c865c76
5 files changed
+104
-43
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { Locale, SlashCommandBuilder } from 'discord.js';
|
||||
import { translator } from '../localization/translator';
|
||||
import { localizationObject } from './localizationObject';
|
||||
|
||||
interface CreateLocalizedCommandSubcommand {
|
||||
subcommand: string;
|
||||
}
|
||||
|
||||
export async function createLocalizedCommand(
|
||||
command: string,
|
||||
subcommands?: CreateLocalizedCommandSubcommand[],
|
||||
) {
|
||||
const { translate } = await translator(Locale.EnglishUS);
|
||||
const slashCommand = new SlashCommandBuilder()
|
||||
.setName(command)
|
||||
.setNameLocalizations(await localizationObject(`bot.commands.${command}`))
|
||||
.setDescription(translate(`bot.commands.${command}.description`))
|
||||
.setDescriptionLocalizations(
|
||||
await localizationObject(`bot.commands.${command}.description`),
|
||||
);
|
||||
|
||||
if (subcommands) {
|
||||
await Promise.all(
|
||||
subcommands.map(async ({ subcommand }) => {
|
||||
const subcommandNameLocalizations = await localizationObject(
|
||||
`bot.commands.${command}.subcommands.${subcommand}`,
|
||||
);
|
||||
const subcommandDescriptionLocalizations = await localizationObject(
|
||||
`bot.commands.${command}.subcommands.${subcommand}.description`,
|
||||
);
|
||||
|
||||
slashCommand.addSubcommand((option) =>
|
||||
option
|
||||
.setName(subcommand)
|
||||
.setNameLocalizations(subcommandNameLocalizations)
|
||||
.setDescription(
|
||||
translate(
|
||||
`bot.commands.${command}.subcommands.${subcommand}.description`,
|
||||
),
|
||||
)
|
||||
.setDescriptionLocalizations(subcommandDescriptionLocalizations),
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return slashCommand;
|
||||
}
|
||||
Reference in new issue
Block a user