From c5a58ac97896f536fd4f70abde4f11f4390a0f10 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 8 Nov 2023 00:08:08 +0100 Subject: [PATCH 1/2] add romanized mode --- src/commands/music/lyrics.ts | 52 ++++++++++++++++++++++++++++++------ src/locales/fr.json | 4 +++ 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/commands/music/lyrics.ts b/src/commands/music/lyrics.ts index d526252..2402624 100644 --- a/src/commands/music/lyrics.ts +++ b/src/commands/music/lyrics.ts @@ -21,13 +21,40 @@ export default { .setNameLocalizations(getLocalizations(client, `c_${filename}_name`, true)) .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_desc`)) - // Command option - .addStringOption((option) => - option - .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") - .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") - .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) - .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)) + // Normal + .addSubcommand((subcommand) => + subcommand + .setName(loc_default.get(`c_${filename}_sub1_name`)?.toLowerCase() ?? "") + .setDescription(loc_default.get(`c_${filename}_sub1_desc`) ?? "") + .setNameLocalizations(getLocalizations(client, `c_${filename}_sub1_name`, true)) + .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub1_desc`)) + + // Command option + .addStringOption((option) => + option + .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") + .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") + .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) + .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)) + ) + ) + + // Romanized + .addSubcommand((subcommand) => + subcommand + .setName(loc_default.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? "") + .setDescription(loc_default.get(`c_${filename}_sub2_desc`) ?? "") + .setNameLocalizations(getLocalizations(client, `c_${filename}_sub2_name`, true)) + .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub2_desc`)) + + // Command option + .addStringOption((option) => + option + .setName(loc_default.get(`c_${filename}_opt1_name`)?.toLowerCase() ?? "") + .setDescription(loc_default.get(`c_${filename}_opt1_desc`) ?? "") + .setNameLocalizations(getLocalizations(client, `c_${filename}_opt1_name`, true)) + .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)) + ) ) ); }, @@ -38,7 +65,7 @@ export default { const loc = getLocale(client, interaction.locale); - const request = interaction.options.getString( + let request = interaction.options.getString( loc_default?.get(`c_${filename}_opt1_name`) as string ); @@ -47,6 +74,15 @@ export default { const player = useMainPlayer() as Player; if (request) { + if ( + interaction.options.getSubcommand() == + loc_default?.get(`c_${filename}_sub2_name`)?.toLowerCase() ?? + "" + ) { + // Romanized + request += " romanized"; + } + try { data = await player.lyrics.search(request); } catch { diff --git a/src/locales/fr.json b/src/locales/fr.json index b634f29..7e0da9a 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -137,6 +137,10 @@ "c_lyrics_name": "paroles", "c_lyrics_desc": "Affiche les paroles d'une chanson", + "c_lyrics_sub1_name": "normal", + "c_lyrics_sub1_desc": "Recherche de paroles", + "c_lyrics_sub2_name": "romanized", + "c_lyrics_sub2_desc": "Recherche de paroles \"romanized\"", "c_lyrics_opt1_name": "chanson", "c_lyrics_opt1_desc": "Chanson recherchée", "c_lyrics1": "Le bot ne joue rien en ce moment et aucune chanson n'est renseignée.", -- 2.45.2 From de0b7a613adae77c4383d5d36f73c4da001f295e Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 8 Nov 2023 00:09:09 +0100 Subject: [PATCH 2/2] exemple --- src/locales/fr.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/locales/fr.json b/src/locales/fr.json index 7e0da9a..a466e6f 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -140,7 +140,7 @@ "c_lyrics_sub1_name": "normal", "c_lyrics_sub1_desc": "Recherche de paroles", "c_lyrics_sub2_name": "romanized", - "c_lyrics_sub2_desc": "Recherche de paroles \"romanized\"", + "c_lyrics_sub2_desc": "Recherche de paroles romanisée (ex: hangul -> latin)", "c_lyrics_opt1_name": "chanson", "c_lyrics_opt1_desc": "Chanson recherchée", "c_lyrics1": "Le bot ne joue rien en ce moment et aucune chanson n'est renseignée.", -- 2.45.2