diff options
Diffstat (limited to 'src/handlers/queueCommand.js')
| -rw-r--r-- | src/handlers/queueCommand.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/handlers/queueCommand.js b/src/handlers/queueCommand.js new file mode 100644 index 0000000..e0fbee1 --- /dev/null +++ b/src/handlers/queueCommand.js @@ -0,0 +1,38 @@ +const { EmbedBuilder } = require('discord.js'); +const { formatDuration } = require('../utils/player'); +const { getQueueOrReply } = require('../utils/helpers'); + +function handleQueue(interaction, queues) { + const queue = getQueueOrReply(interaction, queues, 'Queue is empty!'); + if (!queue || queue.songs.length === 0) { + if (queue) interaction.reply('Queue is empty!'); + return; + } + + const nowPlaying = queue.songs[0]; + const upcoming = queue.songs.slice(1, 10); + + const embed = new EmbedBuilder() + .setColor(0x0099ff) + .setTitle('Queue') + .setDescription( + `**Now Playing:**\n${nowPlaying.title}\n` + + `Duration: ${formatDuration(nowPlaying.duration)} | Requested by: ${nowPlaying.requestedBy}` + ) + .setThumbnail(nowPlaying.thumbnail); + + if (upcoming.length > 0) { + const upcomingText = upcoming + .map((song, i) => `${i + 1}. ${song.title} - ${formatDuration(song.duration)}`) + .join('\n'); + embed.addFields({ name: 'Up Next', value: upcomingText }); + } + + if (queue.songs.length > 10) { + embed.setFooter({ text: `...and ${queue.songs.length - 10} more` }); + } + + interaction.reply({ embeds: [embed] }); +} + +module.exports = { handleQueue }; |
