JaBa/commands/Music/queue.js

59 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-12-10 21:39:54 +05:00
const Command = require("../../base/Command.js"),
Discord = require("discord.js"),
Pagination = require("discord-paginationembed");
class Queue extends Command {
2021-12-26 19:29:37 +05:00
constructor(client) {
2021-12-10 21:39:54 +05:00
super(client, {
name: "queue",
dirname: __dirname,
enabled: true,
guildOnly: true,
2021-12-26 19:29:37 +05:00
aliases: ["playlist"],
2021-12-10 21:39:54 +05:00
memberPermissions: [],
2021-12-26 19:29:37 +05:00
botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"],
2021-12-10 21:39:54 +05:00
nsfw: false,
ownerOnly: false,
cooldown: 3000
2021-12-10 21:39:54 +05:00
});
}
2021-12-26 19:29:37 +05:00
async run(message, args, data) {
2021-12-10 21:39:54 +05:00
const voice = message.member.voice.channel;
const queue = this.client.player.getQueue(message);
2021-12-26 00:04:26 +05:00
if (!voice) return message.error("music/play:NO_VOICE_CHANNEL");
2021-12-11 01:11:50 +05:00
if (!queue) return message.error("music/play:NOT_PLAYING");
2021-12-10 21:39:54 +05:00
2021-12-26 00:04:26 +05:00
if (queue.songs.length === 1) {
2021-12-10 21:39:54 +05:00
const embed = new Discord.MessageEmbed()
2021-12-26 19:29:37 +05:00
.setAuthor(message.translate("music/queue:TITLE"), message.guild.iconURL({
dynamic: true
}))
2021-12-26 00:04:26 +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);
2021-12-10 21:39:54 +05:00
return message.channel.send(embed);
2021-12-11 01:11:50 +05:00
};
2021-12-26 00:04:26 +05:00
2021-12-10 21:39:54 +05:00
const FieldsEmbed = new Pagination.FieldsEmbed();
FieldsEmbed.embed
.setColor(data.config.embed.color)
2021-12-26 19:29:37 +05:00
.setAuthor(message.translate("music/queue:TITLE"), message.guild.iconURL({
dynamic: true
}))
2021-12-26 00:04:26 +05:00
.addField(message.translate("music/np:CURRENTLY_PLAYING"), `[${queue.songs[0].name}](${queue.songs[0].url})\n*Добавил ${queue.songs[0].member}*\n`);
2021-12-11 01:11:50 +05:00
2021-12-26 00:04:26 +05:00
FieldsEmbed.setArray(queue.songs[1] ? queue.songs.slice(1, queue.songs.length) : [])
2021-12-10 21:39:54 +05:00
.setAuthorizedUsers([message.author.id])
.setChannel(message.channel)
.setElementsPerPage(5)
2021-12-26 14:52:36 +05:00
.setDeleteOnTimeout(true)
2021-12-10 21:39:54 +05:00
.setPageIndicator(true)
2021-12-26 14:46:18 +05:00
.formatField("Очередь", (track) => `[${track.name}](${track.url})\n*Добавил ${track.member}*\n`);
2021-12-11 01:11:50 +05:00
2021-12-10 21:39:54 +05:00
FieldsEmbed.build();
}
2021-12-11 01:11:50 +05:00
};
2021-12-10 21:39:54 +05:00
module.exports = Queue;