2021-07-13 05:17:39 +02:00
|
|
|
const { MessageEmbed } = require("discord.js");
|
2021-06-12 12:53:51 +02:00
|
|
|
module.exports = {
|
|
|
|
name: "queue",
|
|
|
|
description: "To show the songs queue",
|
|
|
|
aliases: ["q"],
|
|
|
|
category: "Music",
|
|
|
|
run: async (client, message, args) => {
|
2021-07-13 05:17:39 +02:00
|
|
|
const player = message.client.manager.get(message.guild.id);
|
|
|
|
if (!player) return client.err(message, "Music", "queue", 34);
|
|
|
|
const queue = player.queue;
|
2021-06-12 12:53:51 +02:00
|
|
|
const embed = new MessageEmbed()
|
2021-07-13 05:17:39 +02:00
|
|
|
.setAuthor(
|
|
|
|
message.author.tag,
|
|
|
|
message.author.displayAvatarURL({ dynamic: true })
|
2021-06-12 12:53:51 +02:00
|
|
|
)
|
2021-07-13 05:17:39 +02:00
|
|
|
.setTitle(`Queue for ${message.guild.name}`)
|
|
|
|
.setTimestamp()
|
|
|
|
.setColor("RANDOM");
|
|
|
|
const multiple = 10;
|
|
|
|
const page = args.length && Number(args[0]) ? Number(args[0]) : 1;
|
|
|
|
const end = page * multiple;
|
|
|
|
const start = end - multiple;
|
|
|
|
const tracks = queue.slice(start, end);
|
|
|
|
if (queue.current)
|
|
|
|
embed.addField(
|
|
|
|
"Current",
|
|
|
|
`[${queue.current.title}](${queue.current.uri})`
|
2021-06-12 12:53:51 +02:00
|
|
|
);
|
2021-07-13 05:17:39 +02:00
|
|
|
|
|
|
|
if (!tracks.length)
|
2021-06-12 12:53:51 +02:00
|
|
|
embed.setDescription(
|
2021-07-13 05:17:39 +02:00
|
|
|
`No tracks in ${page > 1 ? `page ${page}` : "the queue"}.`
|
2021-06-12 12:53:51 +02:00
|
|
|
);
|
2021-07-13 05:17:39 +02:00
|
|
|
else
|
|
|
|
embed.setDescription(
|
|
|
|
tracks
|
|
|
|
.map((track, i) => `${start + ++i} - [${track.title}](${track.uri})`)
|
|
|
|
.join("\n")
|
|
|
|
);
|
|
|
|
const maxPages = Math.ceil(queue.length / multiple);
|
|
|
|
embed.setFooter(`Page ${page > maxPages ? maxPages : page} of ${maxPages}`);
|
2021-09-06 12:38:25 +02:00
|
|
|
return message.reply(embed);
|
2021-06-12 12:53:51 +02:00
|
|
|
},
|
|
|
|
};
|