lavalink-client 2.6.3 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +23 -0
- package/dist/index.mjs +23 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1404,6 +1404,24 @@ declare class ManagerUtils {
|
|
|
1404
1404
|
* @param data
|
|
1405
1405
|
*/
|
|
1406
1406
|
isNodeOptions(data: LavalinkNodeOptions): boolean;
|
|
1407
|
+
/**
|
|
1408
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
1409
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
1410
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
1411
|
+
* @example
|
|
1412
|
+
* ```ts
|
|
1413
|
+
* const tracks = await player.search("Adele");
|
|
1414
|
+
*
|
|
1415
|
+
* // short hand:
|
|
1416
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
1417
|
+
* // or with options:
|
|
1418
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
1419
|
+
*
|
|
1420
|
+
* // then you can add it to the queue.
|
|
1421
|
+
* await player.queue.add(validTracks);
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
isNotBrokenTrack(data: Track, minDuration?: number): data is Track;
|
|
1407
1425
|
/**
|
|
1408
1426
|
* Validate if a data is equal to a track
|
|
1409
1427
|
* @param data the Track to validate
|
package/dist/index.d.ts
CHANGED
|
@@ -1404,6 +1404,24 @@ declare class ManagerUtils {
|
|
|
1404
1404
|
* @param data
|
|
1405
1405
|
*/
|
|
1406
1406
|
isNodeOptions(data: LavalinkNodeOptions): boolean;
|
|
1407
|
+
/**
|
|
1408
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
1409
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
1410
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
1411
|
+
* @example
|
|
1412
|
+
* ```ts
|
|
1413
|
+
* const tracks = await player.search("Adele");
|
|
1414
|
+
*
|
|
1415
|
+
* // short hand:
|
|
1416
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
1417
|
+
* // or with options:
|
|
1418
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
1419
|
+
*
|
|
1420
|
+
* // then you can add it to the queue.
|
|
1421
|
+
* await player.queue.add(validTracks);
|
|
1422
|
+
* ```
|
|
1423
|
+
*/
|
|
1424
|
+
isNotBrokenTrack(data: Track, minDuration?: number): data is Track;
|
|
1407
1425
|
/**
|
|
1408
1426
|
* Validate if a data is equal to a track
|
|
1409
1427
|
* @param data the Track to validate
|
package/dist/index.js
CHANGED
|
@@ -671,6 +671,29 @@ var ManagerUtils = class {
|
|
|
671
671
|
if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0 && data.requestTimeout !== void 0)) return false;
|
|
672
672
|
return true;
|
|
673
673
|
}
|
|
674
|
+
/**
|
|
675
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
676
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
677
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
678
|
+
* @example
|
|
679
|
+
* ```ts
|
|
680
|
+
* const tracks = await player.search("Adele");
|
|
681
|
+
*
|
|
682
|
+
* // short hand:
|
|
683
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
684
|
+
* // or with options:
|
|
685
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
686
|
+
*
|
|
687
|
+
* // then you can add it to the queue.
|
|
688
|
+
* await player.queue.add(validTracks);
|
|
689
|
+
* ```
|
|
690
|
+
*/
|
|
691
|
+
isNotBrokenTrack(data, minDuration = 29e3) {
|
|
692
|
+
if (typeof data?.info?.duration !== "number" || isNaN(data?.info?.duration)) return false;
|
|
693
|
+
if (data.info.duration <= Math.max(minDuration, 0)) return false;
|
|
694
|
+
if (!data.info) return false;
|
|
695
|
+
return this.isTrack(data);
|
|
696
|
+
}
|
|
674
697
|
/**
|
|
675
698
|
* Validate if a data is equal to a track
|
|
676
699
|
* @param data the Track to validate
|
package/dist/index.mjs
CHANGED
|
@@ -611,6 +611,29 @@ var ManagerUtils = class {
|
|
|
611
611
|
if ("requestTimeout" in data && (typeof data.requestTimeout !== "number" || isNaN(data.requestTimeout) || data.requestTimeout <= 0 && data.requestTimeout !== void 0)) return false;
|
|
612
612
|
return true;
|
|
613
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Validate tracks based on duration wether they are playble or broken tracks.
|
|
616
|
+
* most tracks should be longer than 30s, so you can put a minDuration of 29e3 (cause preview tracks are exactly 30s) or put 0.
|
|
617
|
+
* This check is not done automatically, you need to check it yourself by doing:
|
|
618
|
+
* @example
|
|
619
|
+
* ```ts
|
|
620
|
+
* const tracks = await player.search("Adele");
|
|
621
|
+
*
|
|
622
|
+
* // short hand:
|
|
623
|
+
* const validTracks = tracks.filter(client.lavalink.utils.isNotBrokenTrack)
|
|
624
|
+
* // or with options:
|
|
625
|
+
* const vaildTracks = tracks.filter(t => client.lavalink.utils.isNotBrokenTrack(t, 29e3));
|
|
626
|
+
*
|
|
627
|
+
* // then you can add it to the queue.
|
|
628
|
+
* await player.queue.add(validTracks);
|
|
629
|
+
* ```
|
|
630
|
+
*/
|
|
631
|
+
isNotBrokenTrack(data, minDuration = 29e3) {
|
|
632
|
+
if (typeof data?.info?.duration !== "number" || isNaN(data?.info?.duration)) return false;
|
|
633
|
+
if (data.info.duration <= Math.max(minDuration, 0)) return false;
|
|
634
|
+
if (!data.info) return false;
|
|
635
|
+
return this.isTrack(data);
|
|
636
|
+
}
|
|
614
637
|
/**
|
|
615
638
|
* Validate if a data is equal to a track
|
|
616
639
|
* @param data the Track to validate
|
package/package.json
CHANGED