Remove command
This commit is contained in:
parent
566d7461b0
commit
1af2e87809
|
@ -22,9 +22,9 @@ module.exports = {
|
||||||
if (queue.length > 0) {
|
if (queue.length > 0) {
|
||||||
const queueDisplay = queue.map((track, index) => {
|
const queueDisplay = queue.map((track, index) => {
|
||||||
const trackDisplay = track.url
|
const trackDisplay = track.url
|
||||||
? `[${track.title}](${track.url})`
|
? `**${index + 1}.** [${track.title}](${track.url})`
|
||||||
: track.title;
|
: `**${index + 1}.** ${track.title}`;
|
||||||
return `${index + 1}. ${trackDisplay}`;
|
return trackDisplay;
|
||||||
}).join('\n');
|
}).join('\n');
|
||||||
|
|
||||||
embed.addFields({
|
embed.addFields({
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
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.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -24,6 +24,16 @@ function addToQueue(guildId, filePath, title, voiceChannel, url = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeFromQueue(guildId, index) {
|
||||||
|
const queue = getQueue(guildId);
|
||||||
|
|
||||||
|
if (index >= 0 && index < queue.length) {
|
||||||
|
return queue.splice(index, 1)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function getQueue(guildId) {
|
function getQueue(guildId) {
|
||||||
return queueMap.get(guildId) || [];
|
return queueMap.get(guildId) || [];
|
||||||
}
|
}
|
||||||
|
@ -145,4 +155,4 @@ function clearQueue(guildId) {
|
||||||
queueMap.set(guildId, []);
|
queueMap.set(guildId, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { addToQueue, getQueue, getCurrentTrack, playNextInQueue, skipTrack, toggleRepeat, clearQueue };
|
module.exports = { addToQueue, getQueue, getCurrentTrack, playNextInQueue, skipTrack, toggleRepeat, clearQueue, removeFromQueue };
|
Loading…
Reference in New Issue