JaBa/commands/Music/queue.js

67 lines
2 KiB
JavaScript
Raw Normal View History

const Command = require("../../base/Command"),
2022-01-04 02:18:28 +05:00
Discord = require("discord.js"),
Pagination = require("discord-paginationembed");
class Queue extends Command {
constructor(client) {
super(client, {
name: "queue",
dirname: __dirname,
enabled: true,
guildOnly: true,
aliases: ["qu"],
memberPermissions: [],
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
nsfw: false,
ownerOnly: false,
cooldown: 3000
});
}
2022-01-13 00:26:23 +05:00
async run(message, args, data) {
2022-01-04 02:18:28 +05:00
const voice = message.member.voice.channel;
const queue = this.client.player.getQueue(message);
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
if (!queue) return message.error("music/play:NOT_PLAYING");
if (queue.songs.length === 1) {
const embed = new Discord.MessageEmbed()
.setAuthor({
name: message.translate("music/queue:TITLE"),
iconURL: message.guild.iconURL({
dynamic: true
})
})
2022-01-04 02:18:28 +05:00
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.songs[0].name}](${queue.songs[0].url})\n*Добавил ${queue.songs[0].member}*\n`)
.setColor(data.config.embed.color);
return message.reply({
embeds: [embed]
});
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
const FieldsEmbed = new Pagination.FieldsEmbed();
FieldsEmbed.embed
.setColor(data.config.embed.color)
.setAuthor({
name: message.translate("music/queue:TITLE"),
iconURL: message.guild.iconURL({
dynamic: true
})
})
2022-01-04 02:18:28 +05:00
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.songs[0].name}](${queue.songs[0].url})\n*Добавил ${queue.songs[0].member}*\n`);
2022-01-04 23:34:43 +05:00
FieldsEmbed
.setArray(queue.songs[1] ? queue.songs.slice(1, queue.songs.length) : [])
2022-01-04 02:18:28 +05:00
.setAuthorizedUsers([message.author.id])
.setChannel(message.channel)
.setElementsPerPage(5)
.setDeleteOnTimeout(true)
.setPageIndicator(true)
2022-01-13 01:47:56 +05:00
.formatField("Очередь", (track) => `**${queue.songs.indexOf(track)}**. [${track.name}](${track.url})\n*Добавил ${track.member}*\n`)
2022-01-13 00:26:23 +05:00
.build();
2022-01-04 02:18:28 +05:00
}
2022-01-13 00:26:23 +05:00
}
2022-01-04 02:18:28 +05:00
module.exports = Queue;