Skip to content

Commit

Permalink
language command end #2273
Browse files Browse the repository at this point in the history
  • Loading branch information
BastLast committed Feb 28, 2024
1 parent eafff13 commit 51a9c2d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Discord/src/commands/admin/LanguageCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {KeycloakUtils} from "../../../../Lib/src/keycloak/KeycloakUtils";
import {keycloakConfig} from "../../bot/DraftBotShard";
import {Constants} from "../../Constants";
import {sendInteractionNotForYou} from "../../utils/ErrorUtils";
import { Language } from "../../../../Lib/src/Language";
import {Language} from "../../../../Lib/src/Language";

/**
* Allow an admin to change the prefix the bot uses in a specific server
Expand All @@ -28,22 +28,22 @@ async function getPacket(interaction: DraftbotInteraction, keycloakUser: Keycloa
const languageCode = StringConstants.LANGUAGE[key as keyof typeof StringConstants.LANGUAGE];
return new StringSelectMenuOptionBuilder()
.setLabel(i18n.t(`commands:language.languages.${languageCode}.name`, {lng: interaction.userLanguage}))
.setEmoji(i18n.t(`commands:language.languages.${languageCode}.emoji`, {lng: interaction.userLanguage}))
.setEmoji(i18n.t(`commands:language.languages.${languageCode}.emoji`, {lng: interaction.userLanguage}))
.setValue(languageCode);
});
const languageSelectionMenu = new StringSelectMenuBuilder()
.setCustomId(selectLanguageMenuId)
.setPlaceholder(i18n.t("commands:language.selectLanguage", {lng: interaction.userLanguage}))
.setPlaceholder(i18n.t("commands:language.selectLanguage", {lng: interaction.userLanguage}))
.addOptions(selectLanguageMenuOptions);
const row = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents(languageSelectionMenu);
const msg = await interaction.reply({
embeds: [new DraftBotEmbed()
.setTitle(i18n.t("commands:language.title", {
lng: interaction.userLanguage
lng: interaction.userLanguage
}))
.setDescription(i18n.t("commands:language.description", {
lng: interaction.userLanguage
lng: interaction.userLanguage
}))],
components: [row]
});
Expand All @@ -55,13 +55,20 @@ async function getPacket(interaction: DraftbotInteraction, keycloakUser: Keycloa

collector.on("collect", async (menuInteraction: StringSelectMenuInteraction) => {
if (menuInteraction.user.id !== interaction.user.id) {
await sendInteractionNotForYou(menuInteraction.user, menuInteraction, interaction.userLanguage);
await sendInteractionNotForYou(menuInteraction.user, menuInteraction, interaction.userLanguage);
return;
}
await KeycloakUtils.updateUserLanguage(keycloakConfig, keycloakUser, menuInteraction.values[0] as Language);
menuInteraction.reply("test")
await menuInteraction.reply({
embeds: [new DraftBotEmbed()
.setTitle(i18n.t("commands:language.newLanguageSetTitle", {
lng: menuInteraction.values[0] as Language

Check warning on line 65 in Discord/src/commands/admin/LanguageCommand.ts

View workflow job for this annotation

GitHub Actions / eslint-discord-module

Extra space before value for key 'lng'
}))
.setDescription(i18n.t("commands:language.newLanguageSetDescription", {
lng: menuInteraction.values[0] as Language

Check warning on line 68 in Discord/src/commands/admin/LanguageCommand.ts

View workflow job for this annotation

GitHub Actions / eslint-discord-module

Extra space before value for key 'lng'
}))]
})

Check failure on line 70 in Discord/src/commands/admin/LanguageCommand.ts

View workflow job for this annotation

GitHub Actions / eslint-discord-module

Missing semicolon
});

return null;
}

Expand Down
2 changes: 2 additions & 0 deletions Lang/en/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@
"language": {
"selectLanguage": "Select a new language",
"description": "Use the menu below to change the language used by the bot on this discord server. This command can only be used by server administrators.",
"newLanguageSetTitle": "Language changed",
"newLanguageSetDescription": "DraftBot will now speak in english with you! 🇬🇧",
"title": ":earth_africa: Language selection",
"languages": {
"en": {
Expand Down
2 changes: 2 additions & 0 deletions Lang/fr/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
"selectLanguage": "Sélectionnez une langue",
"description": "Utilisez le menu ci-dessous pour changer la langue utilisée par le bot sur ce serveur. Cette commande est réservée aux administrateurs du serveur.",
"title": ":earth_africa: Sélection de la langue",
"newLanguageSetTitle": "Langue changée",
"newLanguageSetDescription": "DraftBot vous parlera désormais en français ! 🥖",
"languages": {
"en": {
"emoji": "🇬🇧",
Expand Down

0 comments on commit 51a9c2d

Please sign in to comment.