Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const fetch = require('node-fetch');
- const convert = require('xml-js');
- const reactions = require('../core/reactions');
- const _ = require('lodash');
- exports.run = async (client, message, args, level) => {
- let TempPageIndex = 0;
- const queue = client.getQueue(message.guild.id);
- const buttons = [
- reactions.zero, reactions.one, reactions.two, reactions.three, reactions.four,
- reactions.five, reactions.six, reactions.seven, reactions.eight, reactions.nine,
- ];
- const songsPerPage = 10;
- let pages;
- pages = _.chunk(queue, songsPerPage);
- pages = pages.map((page) => {
- let desc = page.map(track => ` **${track.info.title}** added by: **${track.requester.username}** [\`${client.getYTLive(track.info.length)}\`]`).join("\n");
- let pagesSize = Math.ceil(queue.length / 10);
- TempPageIndex += 1;
- return {
- embed: {
- color: 0xbe3e99,
- author: {
- name: `Current queue for ${message.guild.name}`,
- icon_url: message.guild.iconURL
- },
- description: `Page **${TempPageIndex}** of **${pagesSize}**\n\n${desc}`,
- footer: {
- text: `There are ${Math.ceil(queue.length - 1)} tracks with a remaining length of [${client.getYTLive(queue.reduce((a, b) => a + b.info.length, 0))}] in the queue.`
- }
- }
- }
- });
- message.channel.send(pages[0])
- .then(async (msg) => {
- /*for (const [index, _] of pages.entries()) {
- await msg.react(buttons[index]);
- }*/
- await msg.react(reactions.arrowleft);
- await msg.react(reactions.arrowright);
- await msg.react(reactions.x);
- msg.delete(60000).catch();
- const collector = msg.createReactionCollector((buttons, user) => user !== client.user);
- let pageIndex = 0; //keep this here
- collector.on('collect', async (messageReaction) => {
- const notbot = messageReaction.users.filter(clientuser => clientuser !== client.user).first();
- await messageReaction.remove(notbot);
- if (pagesSize > 1) {
- if (messageReaction.emoji.name === reactions.arrowleft) {
- msg.edit(pages[pageIndex--]);
- } else if (messageReaction.emoji.name === reactions.arrowright) {
- msg.edit(pages[pageIndex++]);
- } else if (messageReaction.emoji.name === reactions.x) {
- msg.delete(); // Delete the message
- collector.stop(); // Delete the collector.
- return;
- }
- } else {
- if (messageReaction.emoji.name === reactions.x) {
- msg.delete(); // Delete the message
- collector.stop(); // Delete the collector.
- return;
- }
- }
- if (messageReaction.emoji.name === reactions.x) {
- msg.delete(); // Delete the message
- collector.stop(); // Delete the collector.
- return;
- };
- /* const pageIndex = buttons.indexOf(messageReaction.emoji.name);
- if (pageIndex === -1 || !pages[pageIndex]) return;
- msg.edit(pages[pageIndex]);
- const notbot = messageReaction.users.filter(clientuser => clientuser !== client.user).first();
- await messageReaction.remove(notbot); */
- })
- }).catch(err => console.log(err));
- };
- exports.conf = {
- enabled: true,
- guildOnly: false,
- aliases: ["l", "list"],
- permLevel: "Bot Owner"
- };
- exports.help = {
- name: "list",
- category: "Music",
- description: "Displays the current queue playing on the bot",
- usage: "list"
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement