feat: synced lyrics (#142)
All checks were successful
Publish latest version / build (push) Successful in 2m10s
All checks were successful
Publish latest version / build (push) Successful in 2m10s
Close #134 Implement synced lyrics Reviewed-on: #142 Co-authored-by: Mylloon <kennel.anri@tutanota.com> Co-committed-by: Mylloon <kennel.anri@tutanota.com>
This commit is contained in:
parent
9d4da0db49
commit
3e43eddc8e
3 changed files with 58 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;
|
||||
|
|
|
@ -134,10 +134,14 @@
|
|||
|
||||
"c_lyrics_name": "lyrics",
|
||||
"c_lyrics_desc": "Displays the lyrics of a song",
|
||||
"c_lyrics_sub3_name": "synced",
|
||||
"c_lyrics_sub3_desc": "Synchronized lyrics search (updates in live)",
|
||||
"c_lyrics_opt1_name": "song",
|
||||
"c_lyrics_opt1_desc": "Wanted song",
|
||||
"c_lyrics1": "The bot is not playing anything at the moment and no songs are specified.",
|
||||
"c_lyrics2": "Unable to find the lyrics for",
|
||||
"c_lyrics3": "Impossible to find synchronized lyrics for",
|
||||
"c_lyrics4": "It's karaoke time!",
|
||||
|
||||
"c_repeat_name": "repeat",
|
||||
"c_repeat_desc": "Command for the type of music repetition",
|
||||
|
|
|
@ -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