edit instead of posting a new message (fix #145)
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 21s
All checks were successful
PR Check / lint-and-format (pull_request) Successful in 21s
This commit is contained in:
parent
75ec77a880
commit
2fc39560f0
3 changed files with 20 additions and 8 deletions
|
@ -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<boolean>;
|
||||
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"));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue