fix(Queue): watch destroyed state for insert method

This commit is contained in:
DevAndromeda 2021-09-06 20:12:11 +05:45
parent 751ce122bc
commit 1c9a00bf1a
No known key found for this signature in database
GPG key ID: FA40E3EC5CB6DCD6

View file

@ -534,6 +534,7 @@ class Queue<T = unknown> {
* @param {number} [index=0] The index where this track should be
*/
insert(track: Track, index = 0) {
if (this.#watchDestroyed()) return;
if (!track || !(track instanceof Track)) throw new PlayerError("track must be the instance of Track", ErrorStatusCode.INVALID_TRACK);
if (typeof index !== "number" || index < 0 || !Number.isFinite(index)) throw new PlayerError(`Invalid index "${index}"`, ErrorStatusCode.INVALID_ARG_TYPE);