1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-23 13:03:18 +00:00
musix-oss/commands/playlist/list.js

25 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-02-09 09:53:30 +00:00
const { EmbedBuilder } = require("discord.js");
module.exports = {
name: 'list',
2024-02-09 09:53:30 +00:00
async execute(message, args, client, prefix) {
if (args[2]) {
if (isNaN(args[2])) return msg.channel.send(':x: I\'m sorry, But you need to enter a valid __number__.');
}
let page = parseInt(args[2]);
if (!page) page = 1;
let pagetext = `:page_facing_up: Page: ${page} :page_facing_up:`
let queuesongs = client.global.db.playlists[message.guild.id].songs.slice((page - 1) * 20, page * 20);
let queuemessage = `${queuesongs.map(song => `**#** ${song.title}`).join('\n')}`
const hashs = queuemessage.split('**#**').length;
for (let i = 0; i < hashs; i++) {
queuemessage = queuemessage.replace('**#**', `**${i + 1}**`);
}
2024-02-09 09:53:30 +00:00
const embed = new EmbedBuilder()
.setTitle("__playlist queue__")
.setDescription(`${pagetext}\n${queuemessage}`)
.setColor("#b50002")
2024-02-09 09:53:30 +00:00
return message.channel.send({ embeds: [embed] });
}
2024-02-09 09:53:30 +00:00
};