1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-22 21:13:18 +00:00
musix-oss/commands/shuffle.js
2024-02-09 11:53:30 +02:00

22 lines
689 B
JavaScript

module.exports = {
name: 'Shuffle',
description: 'Shuffle command.',
alias: 'shuffle',
cooldown: 5,
execute(message, args, client, prefix) {
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;
}
}
};