fix: lyrics crash (#70)

Co-authored-by: Mylloon <kennel.anri@tutanota.com>
Reviewed-on: #70
This commit is contained in:
Mylloon 2023-02-13 22:32:03 +01:00
parent 98de82d2d6
commit 883c91d4cd

View file

@ -42,11 +42,13 @@ export default {
);
let data = null;
await interaction.deferReply();
if (request) {
try {
data = await client.player.lyrics.search(request);
} catch {
return await interaction.reply(loc.get("c_lyrics2") + ` \`${request}\``);
return await interaction.followUp(loc.get("c_lyrics2") + ` \`${request}\``);
}
} else {
const queue = client.player.queues.get(interaction.guildId ?? "");
@ -56,7 +58,7 @@ export default {
try {
data = await client.player.lyrics.search(title);
} catch {
return await interaction.reply(loc.get("c_lyrics2") + ` \`${title}\``);
return await interaction.followUp(loc.get("c_lyrics2") + ` \`${title}\``);
}
}
}
@ -66,9 +68,6 @@ export default {
const limit_desc = 4096;
const nb_embed = Math.ceil(data.lyrics.length / limit_desc);
// May send multiples message
await interaction.deferReply();
// TODO: If lyrics < 6000, only send one message with multiples embed
for (let i = 0, j = 0; i < nb_embed; i++, j += limit_desc) {
// TODO: Better cut in lyrics
@ -115,6 +114,6 @@ export default {
return;
}
return await interaction.reply(loc.get("c_lyrics1"));
return await interaction.followUp(loc.get("c_lyrics1"));
},
};