check track before adding
This commit is contained in:
parent
9dc01b68bb
commit
821e3d1053
1 changed files with 2 additions and 0 deletions
|
@ -203,6 +203,7 @@ class Queue<T = unknown> {
|
|||
*/
|
||||
addTrack(track: Track) {
|
||||
this.#watchDestroyed();
|
||||
if (!(track instanceof Track)) throw new Error("invalid track");
|
||||
this.tracks.push(track);
|
||||
this.player.emit("trackAdd", this, track);
|
||||
}
|
||||
|
@ -213,6 +214,7 @@ class Queue<T = unknown> {
|
|||
*/
|
||||
addTracks(tracks: Track[]) {
|
||||
this.#watchDestroyed();
|
||||
if (!tracks.every((y) => y instanceof Track)) throw new Error("invalid track");
|
||||
this.tracks.push(...tracks);
|
||||
this.player.emit("tracksAdd", this, tracks);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue