✨ Add queue getter
This commit is contained in:
parent
4cabc7dd5c
commit
4ecd83bbf2
1 changed files with 17 additions and 8 deletions
17
src/Track.js
17
src/Track.js
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue