33 lines
1.4 KiB
JavaScript
33 lines
1.4 KiB
JavaScript
|
const pattern = /^[0-9]{1,2}(\s*,\s*[0-9]{1,2})*$/;
|
||
|
const { MESSAGES } = require("../../util/constants");
|
||
|
const { canModifyQueue } = require("../../util/LanBot");
|
||
|
|
||
|
module.exports.run = (client, message, args, settings) => {
|
||
|
const queue = message.client.queue.get(message.guild.id);
|
||
|
|
||
|
if (!queue) return message.channel.send("Il n'y a pas de file d'attente.").catch(console.error);
|
||
|
if (!canModifyQueue(message.member))return message.channel.send('Vous devez être dans un salon vocal pour utiliser cette commande !');
|
||
|
|
||
|
|
||
|
const arguments = args.join("");
|
||
|
const songs = arguments.split(",").map((arg) => parseInt(arg));
|
||
|
let removed = [];
|
||
|
|
||
|
if (pattern.test(arguments)) {
|
||
|
queue.songs = queue.songs.filter((item, index) => {
|
||
|
if (songs.find((songIndex) => songIndex - 1 === index)) removed.push(item);
|
||
|
else return true;
|
||
|
});
|
||
|
|
||
|
queue.textChannel.send(
|
||
|
`${message.author} ❌ suppression de **${removed.map((song) => song.title).join("\n")}** de la file d'attente.`
|
||
|
);
|
||
|
} else if (!isNaN(args[0]) && args[0] >= 1 && args[0] <= queue.songs.length) {
|
||
|
console.log("On a eu de la chance !");
|
||
|
return queue.textChannel.send(
|
||
|
`${message.author} ❌ suppression de **${queue.songs.splice(args[0] - 1, 1)[0].title}** de la file d'attente.`
|
||
|
);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports.help = MESSAGES.COMMANDS.MUSIQUE.REMOVE;
|