DZ-Musicbot/commands/remove.js

22 lines
812 B
JavaScript

const { getQueue, removeFromQueue } = require('../utils/queueManager');
module.exports = {
name: 'remove',
description: 'Remove a specific song from the queue by its number',
execute(message, args) {
const queue = getQueue(message.guild.id);
const indexToRemove = parseInt(args[0], 10) - 1;
if (isNaN(indexToRemove) || indexToRemove < 0 || indexToRemove >= queue.length) {
return message.reply('Please provide a valid song number to remove.');
}
const removedTrack = removeFromQueue(message.guild.id, indexToRemove);
if (removedTrack) {
message.reply(`Removed **${removedTrack.title}** from the queue.`);
} else {
message.reply('There was an issue removing the song from the queue.');
}
},
};