1
0
mirror of https://github.com/musix-org/musix-oss synced 2025-06-15 17:45:59 +00:00

Added shuffle command

This commit is contained in:
MatteZ02
2020-01-01 19:05:50 +02:00
parent decc53083f
commit 7d3c2dd416
3 changed files with 433 additions and 111 deletions

22
commands/shuffle.js Normal file
View File

@ -0,0 +1,22 @@
module.exports = {
name: 'Shuffle',
description: 'Shuffle command.',
alias: 'shuffle',
cooldown: 5,
onlyDev: false,
execute(message, args, client, Discord, 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;
}
}
};