51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
const { getQueue, getCurrentTrack } = require('../utils/queueManager');
|
|
const { EmbedBuilder } = require('discord.js');
|
|
|
|
module.exports = {
|
|
name: 'queue',
|
|
description: 'Show the current songs in queue',
|
|
execute(message) {
|
|
const queue = getQueue(message.guild.id);
|
|
const currentTrack = getCurrentTrack(message.guild.id);
|
|
|
|
const pageSize = 8;
|
|
|
|
const embed = new EmbedBuilder()
|
|
.setColor('#0099ff')
|
|
.setTitle('Current Queue');
|
|
|
|
if (currentTrack) {
|
|
const currentTrackDisplay = currentTrack.url
|
|
? `[${currentTrack.title}](${currentTrack.url})`
|
|
: currentTrack.title;
|
|
embed.addFields({
|
|
name: 'Currently playing',
|
|
value: `${currentTrackDisplay}\nRequested by: ${currentTrack.requester}`,
|
|
inline: false
|
|
});
|
|
}
|
|
|
|
if (queue.length > 0) {
|
|
const queueDisplay = queue.slice(0, pageSize).map((track, index) => {
|
|
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');
|
|
|
|
embed.addFields({
|
|
name: 'Up next',
|
|
value: queueDisplay,
|
|
inline: false
|
|
});
|
|
|
|
if (queue.length > pageSize) {
|
|
embed.setFooter({ text: `And ${queue.length - pageSize} more...` });
|
|
}
|
|
} else if (!currentTrack) {
|
|
embed.setDescription('The queue is empty!');
|
|
}
|
|
|
|
message.channel.send({ embeds: [embed] });
|
|
}
|
|
}; |