Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 songsPerPage = 20;
- let pages;
- let pagesSize = Math.ceil(queue.length / 20);
- pages = _.chunk(queue, songsPerPage);
- pages = pages.map((page) => {
- let index = 0;
- let desc = page.map(track => `**${++index}** - **${track.info.title}** added by: **${track.requester.username}** [\`${client.getYTLive(track.info.length)}\`]`).join("\n");
- TempPageIndex = TempPageIndex + 1;
- console.log(TempPageIndex);
- 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) => {
- await msg.react('⬅');
- await msg.react('➡');
- await msg.react('🇽');
- const collector = msg.createReactionCollector((buttons, user) => user !== client.user);
- let pageIndex = 0;
- collector.on('collect', async (messageReaction) => {
- const notbot = messageReaction.users.filter(clientuser => clientuser !== client.user).first();
- await messageReaction.remove(notbot);
- if (messageReaction.emoji.name === '⬅') {
- msg.edit(pages[pageIndex--]);
- } else if (messageReaction.emoji.name === '➡') {
- msg.edit(pages[pageIndex++]);
- } else if (messageReaction.emoji.name === '🇽') {
- msg.delete(); // Delete the message
- collector.stop(); // Delete the collector.
- return;
- }
- if(pageIndex === 0) messageReaction.fetchUsers().then(users => {
- users.forEach(user => {
- messageReaction.remove(user);
- });
- }).catch(console.error);
- })
- }).catch(err => console.log(err));
- function switchPage(reaction) {
- if (reaction.emoji.name == '⬅') {
- if (currentPage === 0) reaction.fetchUsers().then(users => {
- users.forEach(user => {
- reaction.remove(user);
- });
- }).catch(console.error);
- else {
- //etc.
- }
- } else if (reaction.emoji.name == '➡') {
- } else throw new Error('No valid emoji was catched.')
- }
- };
- 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