check track before adding

This commit is contained in:
Snowflake107 2021-06-22 12:53:52 +05:45
parent 9dc01b68bb
commit 821e3d1053

View file

@ -203,6 +203,7 @@ class Queue<T = unknown> {
*/ */
addTrack(track: Track) { addTrack(track: Track) {
this.#watchDestroyed(); this.#watchDestroyed();
if (!(track instanceof Track)) throw new Error("invalid track");
this.tracks.push(track); this.tracks.push(track);
this.player.emit("trackAdd", this, track); this.player.emit("trackAdd", this, track);
} }
@ -213,6 +214,7 @@ class Queue<T = unknown> {
*/ */
addTracks(tracks: Track[]) { addTracks(tracks: Track[]) {
this.#watchDestroyed(); this.#watchDestroyed();
if (!tracks.every((y) => y instanceof Track)) throw new Error("invalid track");
this.tracks.push(...tracks); this.tracks.push(...tracks);
this.player.emit("tracksAdd", this, tracks); this.player.emit("tracksAdd", this, tracks);
} }