Skip to content

Commit

Permalink
fix: add hindi locale
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Jan 1, 2024
1 parent 9b6e30f commit 719d06b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion locales
15 changes: 9 additions & 6 deletions src/commands/slash/Main/setlanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import db from '../../../utils/Db.js';
import { emojis } from '../../../utils/Constants.js';
import { t } from '../../../utils/Locale.js';

const locales = {
en: '🇺🇸 English',
tr: '🇹🇷 Turkish',
hi: '🇮🇳 Hindi',
};

export default class SetLanguage extends BaseCommand {
data: RESTPostAPIApplicationCommandsJSONBody = {
name: 'setlanguage',
Expand All @@ -18,16 +24,13 @@ export default class SetLanguage extends BaseCommand {
description: 'The language to set',
type: ApplicationCommandOptionType.String,
required: true,
choices: [
{ name: '🇺🇸 English', value: 'en' },
{ name: '🇹🇷 Turkish', value: 'tr' },
],
choices: Object.entries(locales).map((locale) => ({ name: locale[1], value: locale[0] })),
},
],
};

async execute(interaction: ChatInputCommandInteraction) {
const locale = interaction.options.getString('lang', true);
const locale = interaction.options.getString('lang', true) as keyof typeof locales;
await db.userData.upsert({
where: { userId: interaction.user.id },
create: {
Expand All @@ -40,7 +43,7 @@ export default class SetLanguage extends BaseCommand {
},
});

const lang = locale === 'en' ? '🇺🇸 English' : '🇹🇷 Turkish';
const lang = locales[locale];

await interaction.reply({
content: emojis.yes + t({ phrase: 'language.set', locale }, { lang }),
Expand Down

0 comments on commit 719d06b

Please sign in to comment.