DZ-Musicbot/commands/queue.js

52 lines
1.8 KiB
JavaScript
Raw Normal View History

const { getQueue, getCurrentTrack } = require('../utils/queueManager');
2024-08-17 12:10:35 -04:00
const { EmbedBuilder } = require('discord.js');
2024-08-17 11:11:10 -04:00
module.exports = {
name: 'queue',
2024-08-17 15:24:09 -04:00
description: 'Show the current songs in queue',
2024-08-17 20:13:09 -04:00
aliases: ['q'],
2024-08-17 11:11:10 -04:00
execute(message) {
const queue = getQueue(message.guild.id);
const currentTrack = getCurrentTrack(message.guild.id);
2024-08-17 19:06:58 -04:00
const pageSize = 8;
2024-08-17 12:10:35 -04:00
const embed = new EmbedBuilder()
.setColor('#0099ff')
.setTitle('Current Queue');
if (currentTrack) {
2024-08-17 17:56:35 -04:00
const currentTrackDisplay = currentTrack.url
? `[${currentTrack.title}](${currentTrack.url})`
: currentTrack.title;
2024-08-17 18:16:33 -04:00
embed.addFields({
name: 'Currently playing',
2024-08-17 19:55:13 -04:00
value: `**${currentTrackDisplay}**\nRequested by: ${currentTrack.requester}`,
2024-08-17 18:16:33 -04:00
inline: false
});
2024-08-17 11:11:10 -04:00
}
2024-08-17 12:10:35 -04:00
if (queue.length > 0) {
2024-08-17 19:06:58 -04:00
const queueDisplay = queue.slice(0, pageSize).map((track, index) => {
2024-08-17 17:56:35 -04:00
const trackDisplay = track.url
2024-08-17 19:55:13 -04:00
? `**${index + 1}.** [**${track.title}**](${track.url})\nRequested by: ${track.requester}`
: `**${index + 1}.** **${track.title}**\nRequested by: ${track.requester}`;
2024-08-17 18:05:36 -04:00
return trackDisplay;
2024-08-17 18:16:33 -04:00
}).join('\n\n');
2024-08-17 17:56:35 -04:00
2024-08-17 12:10:35 -04:00
embed.addFields({
name: 'Up next',
2024-08-17 17:56:35 -04:00
value: queueDisplay,
2024-08-17 12:10:35 -04:00
inline: false
});
2024-08-17 19:06:58 -04:00
if (queue.length > pageSize) {
embed.setFooter({ text: `And ${queue.length - pageSize} more...` });
}
2024-08-17 12:10:35 -04:00
} else if (!currentTrack) {
embed.setDescription('The queue is empty!');
}
2024-08-17 12:10:35 -04:00
message.channel.send({ embeds: [embed] });
2024-08-17 11:11:10 -04:00
}
2024-08-17 18:34:28 -04:00
};