Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. const reactions = require('../core/reactions');
  2. const _ = require('lodash');
  3.  
  4. exports.run = async (client, message, args, level) => {
  5.  
  6. let TempPageIndex = 0;
  7. const queue = client.getQueue(message.guild.id);
  8. const songsPerPage = 20;
  9. let pages;
  10. let pagesSize = Math.ceil(queue.length / 20);
  11.  
  12. pages = _.chunk(queue, songsPerPage);
  13. pages = pages.map((page) => {
  14. let index = 0;
  15. let desc = page.map(track => `**${++index}** - **${track.info.title}** added by: **${track.requester.username}** [\`${client.getYTLive(track.info.length)}\`]`).join("\n");
  16. TempPageIndex = TempPageIndex + 1;
  17. console.log(TempPageIndex);
  18. return {
  19. embed: {
  20. color: 0xbe3e99,
  21. author: {
  22. name: `Current queue for ${message.guild.name}`,
  23. icon_url: message.guild.iconURL
  24. },
  25. description: `Page **${TempPageIndex}** of **${pagesSize}**\n\n${desc}`,
  26. footer: {
  27. 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.`
  28. }
  29. }
  30. }
  31. });
  32.  
  33. message.channel.send(pages[0])
  34. .then(async (msg) => {
  35.  
  36. await msg.react('⬅');
  37. await msg.react('➡');
  38. await msg.react('🇽');
  39. const collector = msg.createReactionCollector((buttons, user) => user !== client.user);
  40.  
  41. let pageIndex = 0;
  42.  
  43. collector.on('collect', async (messageReaction) => {
  44.  
  45. const notbot = messageReaction.users.filter(clientuser => clientuser !== client.user).first();
  46. await messageReaction.remove(notbot);
  47. if (messageReaction.emoji.name === '⬅') {
  48.  
  49. msg.edit(pages[pageIndex--]);
  50.  
  51. } else if (messageReaction.emoji.name === '➡') {
  52.  
  53. msg.edit(pages[pageIndex++]);
  54.  
  55. } else if (messageReaction.emoji.name === '🇽') {
  56.  
  57. msg.delete(); // Delete the message
  58. collector.stop(); // Delete the collector.
  59. return;
  60.  
  61. }
  62. })
  63. }).catch(err => console.log(err));
  64.  
  65.  
  66. function switchPage(reaction) {
  67. if (reaction.emoji.name == '⬅') {
  68. if (currentPage === 0) reaction.fetchUsers().then(users => {
  69. users.forEach(user => {
  70. reaction.remove(user);
  71. });
  72. }).catch(console.error);
  73. else {
  74. //etc.
  75. }
  76. } else if (reaction.emoji.name == '➡') {
  77.  
  78. } else throw new Error('No valid emoji was catched.')
  79. }
  80. };
  81.  
  82. exports.conf = {
  83. enabled: true,
  84. guildOnly: false,
  85. aliases: ["l", "list"],
  86. permLevel: "Bot Owner"
  87. };
  88.  
  89. exports.help = {
  90. name: "list",
  91. category: "Music",
  92. description: "Displays the current queue playing on the bot",
  93. usage: "list"
  94. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement