Add support of synced lyrics
This commit is contained in:
parent
9d4da0db49
commit
2f8cb0f797
2 changed files with 54 additions and 12 deletions
|
@ -56,6 +56,15 @@ export default {
|
|||
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_opt1_desc`)),
|
||||
),
|
||||
)
|
||||
|
||||
// Synced
|
||||
.addSubcommand((subcommand) =>
|
||||
subcommand
|
||||
.setName(loc_default.get(`c_${filename}_sub3_name`)?.toLowerCase() ?? "")
|
||||
.setDescription(loc_default.get(`c_${filename}_sub3_desc`) ?? "")
|
||||
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true))
|
||||
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`)),
|
||||
)
|
||||
);
|
||||
},
|
||||
|
||||
|
@ -73,6 +82,7 @@ export default {
|
|||
await interaction.deferReply();
|
||||
|
||||
const player = useMainPlayer() as Player;
|
||||
const queue = useQueue(interaction.guildId ?? "");
|
||||
if (request) {
|
||||
if (
|
||||
interaction.options.getSubcommand() ==
|
||||
|
@ -88,22 +98,50 @@ export default {
|
|||
} catch {
|
||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${request}\``);
|
||||
}
|
||||
} else {
|
||||
const queue = useQueue(interaction.guildId ?? "");
|
||||
if (queue) {
|
||||
const track = queue.history.currentTrack;
|
||||
if (track) {
|
||||
try {
|
||||
data = await player.lyrics.search({
|
||||
q: track.cleanTitle + " " + queue.history.currentTrack?.author,
|
||||
});
|
||||
} catch {
|
||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${track.title}\``);
|
||||
}
|
||||
} else if (queue) {
|
||||
const track = queue.history.currentTrack;
|
||||
if (track) {
|
||||
try {
|
||||
data = await player.lyrics.search({
|
||||
q: track.cleanTitle + " " + queue.history.currentTrack?.author,
|
||||
});
|
||||
} catch {
|
||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics2")} \`${track.title}\``);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
interaction.options.getSubcommand() ==
|
||||
loc_default?.get(`c_${filename}_sub3_name`)?.toLowerCase() ??
|
||||
""
|
||||
) {
|
||||
if (queue === null) {
|
||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics1")}`);
|
||||
}
|
||||
|
||||
if (data === null || !data[0].syncedLyrics) {
|
||||
return await interaction.followUp(`❌ | ${loc.get("c_lyrics3")} \`${request}\``);
|
||||
}
|
||||
|
||||
// Load lyrics
|
||||
const syncedLyrics = queue?.syncedLyrics(data[0]);
|
||||
|
||||
syncedLyrics?.onChange(async (lyrics) => {
|
||||
await interaction.channel?.send({
|
||||
content: `[${data[0].trackName}]: ${lyrics}`,
|
||||
});
|
||||
});
|
||||
|
||||
// Live update
|
||||
syncedLyrics.subscribe();
|
||||
|
||||
return await interaction.followUp({
|
||||
content: `🎤 | ${loc.get("c_lyrics4")}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
|
||||
if (data && data.length > 0) {
|
||||
const title = data[0];
|
||||
const limit_desc = 4096;
|
||||
|
|
|
@ -141,10 +141,14 @@
|
|||
"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_sub3_name": "synced",
|
||||
"c_lyrics_sub3_desc": "Recherche de paroles synchronisée (se met à jour avec la chanson en direct)",
|
||||
"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.",
|
||||
"c_lyrics2": "Impossible de trouver les paroles pour",
|
||||
"c_lyrics3": "Impossible de trouver les paroles synchronisées pour",
|
||||
"c_lyrics4": "C'est parti !",
|
||||
|
||||
"c_repeat_name": "repeat",
|
||||
"c_repeat_desc": "Commande relative à la répétition des musiques",
|
||||
|
|
Loading…
Reference in a new issue