forked from embee/woomy
		
	shuffle command now excluses the first element
This commit is contained in:
		
							parent
							
								
									6d5d476528
								
							
						
					
					
						commit
						4d97bc1ad0
					
				
					 1 changed files with 7 additions and 9 deletions
				
			
		| 
						 | 
					@ -25,15 +25,13 @@ module.exports.run = (client, message, args, level) => {
 | 
				
			||||||
    return message.channel.send('Not enough songs are in the queue for this command to work!')
 | 
					    return message.channel.send('Not enough songs are in the queue for this command to work!')
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let j, x, i
 | 
					  const max = queue.length - 1
 | 
				
			||||||
 | 
					  const min = 1
 | 
				
			||||||
  // Make it so it shuffles all elements EXCEPT [0]
 | 
					  for (let i = max; i >= min; i--) {
 | 
				
			||||||
 | 
					    const randomIndex = Math.floor(Math.random() * (max - min + 1)) + min
 | 
				
			||||||
  for (i = queue.length - 1; i > 1; i--) {
 | 
					    const itemAtIndex = queue[randomIndex]
 | 
				
			||||||
    j = Math.floor(Math.random() * (i + 1))
 | 
					    queue[randomIndex] = queue[i]
 | 
				
			||||||
    x = queue[i]
 | 
					    queue[i] = itemAtIndex
 | 
				
			||||||
    queue[i] = queue[j]
 | 
					 | 
				
			||||||
    queue[j] = x
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  message.channel.send('Queue shuffled!')
 | 
					  message.channel.send('Queue shuffled!')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue