diff --git a/src/Player.js b/src/Player.js index a4d8d13..48f62d5 100644 --- a/src/Player.js +++ b/src/Player.js @@ -312,6 +312,24 @@ class Player { }); } + /** + * Shuffles the guild queue. + * @param {string} guildID + * @returns {Promise} + */ + shuffle(guildID){ + return new Promise(async(resolve, reject) => { + // Gets guild queue + let queue = this.queues.find((g) => g.guildID === guildID); + if(!queue) return reject('Not playing'); + // Shuffle the queue (except the first song) + let currentSong = queue.songs.shift(); + queue.songs = queue.songs.sort(() => Math.random() - 0.5); + queue.songs.unshift(currentSong); + // Resolve + resolve(); + }); + } /** * Start playing songs in a guild. * @ignore diff --git a/src/Song.js b/src/Song.js index 0bfb5c5..7f53c41 100644 --- a/src/Song.js +++ b/src/Song.js @@ -6,7 +6,7 @@ class Song { * @param {Video} video The Youtube video * @param {Queue} queue The queue in which the song is */ - constructor(video, queue) { + constructor(video, queue, requestedBy) { /** * Song name. * @type {string} @@ -47,6 +47,11 @@ class Song { * @type {Queue} */ this.queue = queue; + /** + * The user who requested that song. + * @type {User} + */ + this.requestedBy = requestedBy; } };