chore: merge branch dev to main #200

Merged
Anri merged 19 commits from dev into main 2024-11-02 17:36:38 +01:00
4 changed files with 66 additions and 3 deletions
Showing only changes of commit 1b11a3728f - Show all commits

View file

@ -58,7 +58,7 @@ export default {
), ),
) )
// Synced // Synced start
.addSubcommand((subcommand) => .addSubcommand((subcommand) =>
subcommand subcommand
.setName(loc_default.get(`c_${filename}_sub3_name`)!.toLowerCase()) .setName(loc_default.get(`c_${filename}_sub3_name`)!.toLowerCase())
@ -66,6 +66,15 @@ export default {
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true)) .setNameLocalizations(getLocalizations(client, `c_${filename}_sub3_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`)), .setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub3_desc`)),
) )
// Synced stop
.addSubcommand((subcommand) =>
subcommand
.setName(loc_default.get(`c_${filename}_sub4_name`)!.toLowerCase())
.setDescription(loc_default.get(`c_${filename}_sub4_desc`)!)
.setNameLocalizations(getLocalizations(client, `c_${filename}_sub4_name`, true))
.setDescriptionLocalizations(getLocalizations(client, `c_${filename}_sub4_desc`)),
)
); );
}, },
@ -124,9 +133,14 @@ export default {
} }
// Load lyrics // Load lyrics
const syncedLyrics = queue.syncedLyrics(data[0]); if (queue.syncedLyricsMemory !== undefined) {
return await interaction.followUp(loc.get("c_lyrics9"));
}
let message: Message<boolean>; const syncedLyrics = queue.syncedLyrics(data[0]);
queue.syncedLyricsMemory = syncedLyrics;
let message: Message;
syncedLyrics?.onChange(async (lyrics) => { syncedLyrics?.onChange(async (lyrics) => {
if (interaction.channel?.isSendable()) { if (interaction.channel?.isSendable()) {
if (message) { if (message) {
@ -149,12 +163,39 @@ export default {
// Live update // Live update
syncedLyrics.subscribe(); syncedLyrics.subscribe();
syncedLyrics.onUnsubscribe(() => {
queue.syncedLyricsMemory = undefined;
});
return await interaction.followUp({ return await interaction.followUp({
content: `🎤 | ${loc.get("c_lyrics4")}`, content: `🎤 | ${loc.get("c_lyrics4")}`,
ephemeral: true, ephemeral: true,
}); });
} }
if (
interaction.options.getSubcommand() ===
loc_default?.get(`c_${filename}_sub4_name`)?.toLowerCase()
) {
if (queue === null) {
return await interaction.followUp(`❌ | ${loc.get("c_lyrics1")}`);
}
if (data === null || !data[0] || !data[0].syncedLyrics) {
return await interaction.followUp(
`❌ | ${loc.get("c_lyrics3")} \`${queue.currentTrack?.cleanTitle}\``,
);
}
// Load lyrics
if (queue.syncedLyricsMemory !== undefined && queue.syncedLyricsMemory.isSubscribed()) {
queue.syncedLyricsMemory.unsubscribe();
return await interaction.followUp(loc.get("c_lyrics7"));
}
return await interaction.followUp(loc.get("c_lyrics8"));
}
if (data && data.length > 0 && data[0].plainLyrics !== null) { if (data && data.length > 0 && data[0].plainLyrics !== null) {
const title = data[0]; const title = data[0];
const limit_desc = 4096; const limit_desc = 4096;

View file

@ -148,6 +148,8 @@
"c_lyrics_sub2_desc": "Search for romanized lyrics (e.g., hangul → Latin)", "c_lyrics_sub2_desc": "Search for romanized lyrics (e.g., hangul → Latin)",
"c_lyrics_sub3_name": "synced", "c_lyrics_sub3_name": "synced",
"c_lyrics_sub3_desc": "Synchronized lyrics search (updates in live)", "c_lyrics_sub3_desc": "Synchronized lyrics search (updates in live)",
"c_lyrics_sub4_name": "stop-synced",
"c_lyrics_sub4_desc": "Stop Synchronized lyrics",
"c_lyrics_opt1_name": "song", "c_lyrics_opt1_name": "song",
"c_lyrics_opt1_desc": "Wanted song", "c_lyrics_opt1_desc": "Wanted song",
"c_lyrics1": "The bot is not playing anything at the moment, and no songs are specified.", "c_lyrics1": "The bot is not playing anything at the moment, and no songs are specified.",
@ -156,6 +158,9 @@
"c_lyrics4": "It's karaoke time!", "c_lyrics4": "It's karaoke time!",
"c_lyrics5": "Unable to post the lyrics here.", "c_lyrics5": "Unable to post the lyrics here.",
"c_lyrics6": "More of :", "c_lyrics6": "More of :",
"c_lyrics7": "Stop synchronized lyrics.",
"c_lyrics8": "No synchronized lyrics currently posted.",
"c_lyrics9": "Synchronized lyrics currently posted.",
"c_repeat_name": "repeat", "c_repeat_name": "repeat",
"c_repeat_desc": "Command for the type of music repetition", "c_repeat_desc": "Command for the type of music repetition",

View file

@ -148,6 +148,8 @@
"c_lyrics_sub2_desc": "Recherche de paroles romanisées (ex: hangul → latin)", "c_lyrics_sub2_desc": "Recherche de paroles romanisées (ex: hangul → latin)",
"c_lyrics_sub3_name": "synced", "c_lyrics_sub3_name": "synced",
"c_lyrics_sub3_desc": "Recherche de paroles synchronisées (se mettent à jour avec la chanson en direct)", "c_lyrics_sub3_desc": "Recherche de paroles synchronisées (se mettent à jour avec la chanson en direct)",
"c_lyrics_sub4_name": "stop-synced",
"c_lyrics_sub4_desc": "Arrête les paroles synchronisées",
"c_lyrics_opt1_name": "chanson", "c_lyrics_opt1_name": "chanson",
"c_lyrics_opt1_desc": "Chanson recherchée", "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_lyrics1": "Le bot ne joue rien en ce moment et aucune chanson n'est renseignée.",
@ -156,6 +158,9 @@
"c_lyrics4": "C'est parti !", "c_lyrics4": "C'est parti !",
"c_lyrics5": "Impossible de poster les paroles ici.", "c_lyrics5": "Impossible de poster les paroles ici.",
"c_lyrics6": "Suite de :", "c_lyrics6": "Suite de :",
"c_lyrics7": "Arrêt des paroles synchronisées.",
"c_lyrics8": "Pas de paroles synchronisées en cours.",
"c_lyrics9": "Paroles synchronisées déjà en cours.",
"c_repeat_name": "repeat", "c_repeat_name": "repeat",
"c_repeat_desc": "Commande relative à la répétition des musiques", "c_repeat_desc": "Commande relative à la répétition des musiques",

12
src/modules/player.ts Normal file
View file

@ -0,0 +1,12 @@
export {};
declare module "discord-player" {
export interface GuildQueue {
syncedLyricsMemory:
| {
isSubscribed: () => unknown;
unsubscribe: () => unknown;
}
| undefined;
}
}