feat: Lyrics romanized mode (#109)
All checks were successful
ci/woodpecker/push/publish Pipeline was successful

Close #101

Reviewed-on: #109
Co-authored-by: Mylloon <kennel.anri@tutanota.com>
Co-committed-by: Mylloon <kennel.anri@tutanota.com>
This commit is contained in:
Mylloon 2023-11-08 00:10:02 +01:00 committed by Anri Kennel
parent 2ed3fec8ec
commit c416e2371c
Signed by: Forgejo
GPG key ID: E72245C752A07631
2 changed files with 48 additions and 8 deletions

View file

@ -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 {

View file

@ -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 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.",