mbot/commands/music/queue.js

35 lines
1 KiB
JavaScript
Raw Permalink Normal View History

2024-07-04 09:14:01 +00:00
const { SlashCommandBuilder, PermissionsBitField } = require('discord.js');
const { useQueue } = require("discord-player");
const informationStatus = "[INFO]: ";
const warningStatus = "[WARNING]: ";
const errorStatus = "[ERROR]: ";
module.exports = {
data: new SlashCommandBuilder()
.setName('queue')
.setDescription('Shows the entire queue.'),
async execute(interaction) {
const queue = useQueue(interaction.guild.id);
const tracks = queue.tracks.toArray();
if(tracks.length === 0) return interaction.reply("There is nothing in the queue right now");
try {
const queueEmbed = {
color: 0x0F3061,
title: 'Current Queue:'
}
queueEmbed.fields = tracks.map((track, index) => ({
name: `Song ${index + 1} - ${track.author}`,
value: `${track.title}`,
}));
return interaction.reply({ embeds: [queueEmbed] });
} catch(erorr) {
interaction.reply({ content: "Something went wrong, try again later.", ephemeral: true });
return console.log(error);
}
}
}