2020-01-01 17:05:50 +00:00
|
|
|
module.exports = {
|
|
|
|
name: 'Shuffle',
|
|
|
|
description: 'Shuffle command.',
|
|
|
|
alias: 'shuffle',
|
|
|
|
cooldown: 5,
|
2024-02-09 09:53:30 +00:00
|
|
|
execute(message, args, client, prefix) {
|
2020-01-01 17:05:50 +00:00
|
|
|
const serverQueue = client.queue.get(message.guild.id);
|
|
|
|
let currentIndex = serverQueue.songs.length,
|
|
|
|
temporaryValue,
|
|
|
|
randomIndex;
|
|
|
|
|
|
|
|
while (0 !== currentIndex) {
|
|
|
|
randomIndex = Math.floor(Math.random() * currentIndex);
|
|
|
|
currentIndex -= 1;
|
|
|
|
|
|
|
|
temporaryValue = serverQueue.songs[currentIndex];
|
|
|
|
serverQueue.songs[currentIndex] = serverQueue.songs[randomIndex];
|
|
|
|
serverQueue.songs[randomIndex] = temporaryValue;
|
|
|
|
}
|
|
|
|
}
|
2024-02-09 09:53:30 +00:00
|
|
|
};
|