🐛 Fix fromPlaylist again

This commit is contained in:
Androz2091 2021-01-03 12:00:52 +01:00
parent daa3d023a6
commit d443652c8c
2 changed files with 3 additions and 8 deletions

View file

@ -315,12 +315,7 @@ class Player extends EventEmitter {
async _handlePlaylist (message, query) {
const playlist = await ytsr.getPlaylist(query)
if (!playlist) return this.emit('noResults', message, query)
playlist.tracks = playlist.videos.map((item) => new Track({
...item,
...{
fromPlaylist: true
}
}, message.author))
playlist.tracks = playlist.videos.map((item) => new Track(item, message.author, this, true))
playlist.duration = playlist.tracks.reduce((prev, next) => prev + next.duration, 0)
playlist.thumbnail = playlist.tracks[0].thumbnail
playlist.requestedBy = message.author

View file

@ -11,7 +11,7 @@ class Track {
* @param {Discord.User | null} user The user who requested the track
* @param {Player} player
*/
constructor (videoData, user, player) {
constructor (videoData, user, player, fromPlaylist = false) {
/**
* The player instantiating the track
* @type {Player}
@ -66,7 +66,7 @@ class Track {
* Whether the track was added from a playlist
* @type {boolean}
*/
this.fromPlaylist = videoData.fromPlaylist || false
this.fromPlaylist = fromPlaylist
}
/**