1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-11-10 02:00:20 +00:00
musix-oss/commands/queue.js

40 lines
1.6 KiB
JavaScript
Raw Normal View History

2024-02-09 09:53:30 +00:00
const { EmbedBuilder } = require("discord.js");
2019-08-02 08:32:00 +00:00
module.exports = {
name: 'queue',
description: 'Queue command.',
alias: 'q',
2019-08-02 08:32:00 +00:00
cooldown: 5,
2024-02-09 09:53:30 +00:00
async execute(message, args, client, prefix) {
2019-08-02 08:32:00 +00:00
const serverQueue = client.queue.get(message.guild.id);
if (!serverQueue) return message.channel.send(':x: There is nothing playing.');
2019-08-03 07:19:32 +00:00
if (args[1]) {
if (isNaN(args[1])) return msg.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
}
2019-08-02 08:32:00 +00:00
let page = parseInt(args[1]);
if (!page) page = 1;
2019-08-03 07:19:32 +00:00
let pagetext = `:page_facing_up: Page: ${page} :page_facing_up:`
if (page === 1) pagetext = ':arrow_down: Next in queue :arrow_down:'
2019-08-02 18:35:25 +00:00
let queuesongs = serverQueue.songs.slice((page - 1) * 20 + 1, page * 20 + 1);
2019-08-02 08:32:00 +00:00
let queuemessage = `${queuesongs.map(song => `**#** ${song.title}`).join('\n')}`
const hashs = queuemessage.split('**#**').length;
for (let i = 0; i < hashs; i++) {
queuemessage = queuemessage.replace('**#**', `**${i + 1}**`);
}
2019-10-10 13:43:04 +00:00
if (!serverQueue.looping) {
2024-02-09 09:53:30 +00:00
const embed = new EmbedBuilder()
2019-10-10 13:43:04 +00:00
.setTitle("__Song queue__")
.setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`)
2019-12-05 13:17:15 +00:00
.setColor(client.config.embedColor)
2024-02-09 09:53:30 +00:00
return message.channel.send({ embeds: [embed] });
2019-10-10 13:43:04 +00:00
} else {
2024-02-09 09:53:30 +00:00
const embed = new EmbedBuilder()
2019-10-10 13:43:04 +00:00
.setTitle("__Song queue__")
.setDescription(`**Now playing:** ${serverQueue.songs[0].title}🎶\n${pagetext}\n${queuemessage}`)
2024-02-09 09:53:30 +00:00
.setFooter({ text: '🔁 Currently looping the queue!' })
2019-12-05 13:17:15 +00:00
.setColor(client.config.embedColor)
2024-02-09 09:53:30 +00:00
return message.channel.send({ embeds: [embed] });
2019-10-10 13:43:04 +00:00
}
2019-08-02 08:32:00 +00:00
}
};