watch destroyed if queue is not destroyed

This commit is contained in:
Snowflake107 2021-07-03 19:31:39 +05:45
parent f61953d42a
commit f395fcff9e
No known key found for this signature in database
GPG key ID: FA40E3EC5CB6DCD6

View file

@ -534,6 +534,7 @@ class Queue<T = unknown> {
const currentTimecode = Util.buildTimeCode(Util.parseMS(currentStreamTime));
const endTimecode = Util.buildTimeCode(Util.parseMS(totalTime));
// why
return {
current: currentTimecode,
end: endTimecode,
@ -593,12 +594,14 @@ class Queue<T = unknown> {
* @returns {Promise<void>}
*/
async play(src?: Track, options: PlayOptions = {}): Promise<void> {
this.#watchDestroyed();
if (!this.destroyed) this.#watchDestroyed();
if (!this.connection || !this.connection.voiceConnection) throw new Error("Voice connection is not available, use <Queue>.connect()!");
if (src && (this.playing || this.tracks.length) && !options.immediate) return this.addTrack(src);
const track = options.filtersUpdate && !options.immediate ? src || this.current : src ?? this.tracks.shift();
if (!track) return;
this.player.emit("debug", this, "Received play request");
if (!options.filtersUpdate) {
this.previousTracks = this.previousTracks.filter((x) => x.id !== track.id);
this.previousTracks.push(track);