diff --git a/src/commands/music/lyrics.ts b/src/commands/music/lyrics.ts index 416ff5c..a3f2202 100644 --- a/src/commands/music/lyrics.ts +++ b/src/commands/music/lyrics.ts @@ -1,8 +1,9 @@ import { SlashCommandBuilder } from "@discordjs/builders"; import { useMainPlayer, useQueue } from "discord-player"; -import { ChatInputCommandInteraction, Client, EmbedBuilder } from "discord.js"; +import { ChatInputCommandInteraction, Client, EmbedBuilder, Message } from "discord.js"; import { getLocale, getLocalizations } from "../../utils/locales"; import { getFilename } from "../../utils/misc"; +import { discord_limit_message } from "../../utils/constants"; export default { scope: () => [], @@ -125,16 +126,23 @@ export default { // Load lyrics const syncedLyrics = queue.syncedLyrics(data[0]); + let message: Message; syncedLyrics?.onChange(async (lyrics) => { - const content = `[${data[0].trackName}]: ${lyrics}`; if (interaction.channel?.isSendable()) { - await interaction.channel?.send({ - content, - }); + if (message) { + const payload = message.cleanContent + "\n" + lyrics; + if (payload.length < discord_limit_message) { + message.edit(payload); + return; + } + } + message = await interaction.channel?.send( + (message ? loc.get("c_lyrics6") + " " : "") + + `${data[0].artistName} : **${data[0].trackName}**\n\n` + + lyrics, + ); } else { - await interaction.followUp({ - content, - }); + await interaction.followUp(loc.get("c_lyrics5")); } }); diff --git a/src/locales/en-US.json b/src/locales/en-US.json index fd60ed6..192f7fb 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -154,6 +154,8 @@ "c_lyrics2": "Unable to find the lyrics for", "c_lyrics3": "Unable to find synchronized lyrics for", "c_lyrics4": "It's karaoke time!", + "c_lyrics5": "Unable to post the lyrics here.", + "c_lyrics6": "More of :", "c_repeat_name": "repeat", "c_repeat_desc": "Command for the type of music repetition", diff --git a/src/locales/fr.json b/src/locales/fr.json index a31d70e..9780ec7 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -154,6 +154,8 @@ "c_lyrics2": "Impossible de trouver les paroles pour", "c_lyrics3": "Impossible de trouver les paroles synchronisées pour", "c_lyrics4": "C'est parti !", + "c_lyrics5": "Impossible de poster les paroles ici.", + "c_lyrics6": "Suite de :", "c_repeat_name": "repeat", "c_repeat_desc": "Commande relative à la répétition des musiques",