Add queue getter

This commit is contained in:
Androz2091 2020-08-27 07:45:24 +02:00
parent 4cabc7dd5c
commit 4ecd83bbf2

View file

@ -1,5 +1,6 @@
const Discord = require('discord.js') const Discord = require('discord.js')
const Queue = require('./Queue') const Queue = require('./Queue')
const Player = require('./Player')
/** /**
* Represents a track. * Represents a track.
@ -7,10 +8,15 @@ const Queue = require('./Queue')
class Track { class Track {
/** /**
* @param {Object} videoData The video data for this track * @param {Object} videoData The video data for this track
* @param {Discord.User?} user The user who requested the track * @param {Discord.User | null} user The user who requested the track
* @param {Queue?} queue The queue in which is the track is * @param {Player} player
*/ */
constructor (videoData, user, queue) { constructor (videoData, user, player) {
/**
* The player instantiating the track
* @type {Player}
*/
this.player = player
/** /**
* The track title * The track title
* @type {string} * @type {string}
@ -56,11 +62,14 @@ class Track {
* @type {boolean} * @type {boolean}
*/ */
this.fromPlaylist = videoData.fromPlaylist || false this.fromPlaylist = videoData.fromPlaylist || false
}
/** /**
* The queue in which the track is * The queue in which the track is
* @type {Queue} * @type {Queue}
*/ */
this.queue = queue get queue () {
return this.player.queues.find((queue) => queue.tracks.includes(this))
} }
/** /**