From c4768e7fb4ff7300537f8f31bf7a68183031e428 Mon Sep 17 00:00:00 2001 From: Wizzard Date: Sun, 8 Sep 2024 12:46:39 -0400 Subject: [PATCH] Update queue.js --- commands/queue.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/commands/queue.js b/commands/queue.js index 53485b0..9ee9e14 100644 --- a/commands/queue.js +++ b/commands/queue.js @@ -9,7 +9,8 @@ module.exports = { const queue = getQueue(message.guild.id); const currentTrack = getCurrentTrack(message.guild.id); - const pageSize = 8; + const pageSize = 10; + const maxLength = 1024; const embed = new EmbedBuilder() .setColor('#0099ff') @@ -27,21 +28,31 @@ module.exports = { } if (queue.length > 0) { - const queueDisplay = queue.slice(0, pageSize).map((track, index) => { + let queueDisplay = ''; + let songCount = 0; + + for (let i = 0; i < Math.min(queue.length, pageSize); i++) { + const track = queue[i]; const trackDisplay = track.url - ? `**${index + 1}.** [**${track.title}**](${track.url})\nRequested by: ${track.requester}` - : `**${index + 1}.** **${track.title}**\nRequested by: ${track.requester}`; - return trackDisplay; - }).join('\n\n'); + ? `**${i + 1}.** [**${track.title}**](${track.url})\nRequested by: ${track.requester}` + : `**${i + 1}.** **${track.title}**\nRequested by: ${track.requester}`; + + if ((queueDisplay + trackDisplay).length > maxLength) { + break; + } + + queueDisplay += trackDisplay + '\n\n'; + songCount++; + } embed.addFields({ name: 'Up next', - value: queueDisplay, + value: queueDisplay.trim(), inline: false }); - if (queue.length > pageSize) { - embed.setFooter({ text: `And ${queue.length - pageSize} more...` }); + if (queue.length > songCount) { + embed.setFooter({ text: `And ${queue.length - songCount} more...` }); } } else if (!currentTrack) { embed.setDescription('The queue is empty!');