hoshimi 0.3.3 → 0.3.6
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 +2031 -1336
- package/dist/index.d.ts +2031 -1336
- package/dist/index.js +877 -302
- package/dist/index.mjs +863 -299
- package/package.json +10 -2
package/dist/index.d.mts
CHANGED
|
@@ -41,6 +41,14 @@ declare class NodeError extends Error {
|
|
|
41
41
|
declare class StorageError extends Error {
|
|
42
42
|
constructor(message: string);
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Error class for the node manager.
|
|
46
|
+
* @class NodeManagerError
|
|
47
|
+
* @extends {Error}
|
|
48
|
+
*/
|
|
49
|
+
declare class NodeManagerError extends Error {
|
|
50
|
+
constructor(message: string);
|
|
51
|
+
}
|
|
44
52
|
/**
|
|
45
53
|
* Error class for resolving tracks.
|
|
46
54
|
* @class ResolveError
|
|
@@ -648,431 +656,113 @@ interface EnabledDSPXPluginFilters {
|
|
|
648
656
|
}
|
|
649
657
|
|
|
650
658
|
/**
|
|
651
|
-
*
|
|
652
|
-
* @class LyricsManager
|
|
659
|
+
* The methods for http requests
|
|
653
660
|
*/
|
|
654
|
-
declare
|
|
661
|
+
declare enum HttpMethods {
|
|
655
662
|
/**
|
|
656
|
-
* The
|
|
657
|
-
* @
|
|
658
|
-
* @
|
|
663
|
+
* The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
|
|
664
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
|
|
665
|
+
* @type {string}
|
|
659
666
|
*/
|
|
660
|
-
|
|
667
|
+
Get = "GET",
|
|
661
668
|
/**
|
|
662
|
-
*
|
|
663
|
-
* @
|
|
664
|
-
* @
|
|
665
|
-
* ```ts
|
|
666
|
-
* const node = manager.nodeManager.get("nodeId");
|
|
667
|
-
* const lyricsManager = new LyricsManager(node);
|
|
668
|
-
* ```
|
|
669
|
+
* The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
|
|
670
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
|
|
671
|
+
* @type {string}
|
|
669
672
|
*/
|
|
670
|
-
|
|
673
|
+
Post = "POST",
|
|
671
674
|
/**
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
* @
|
|
675
|
-
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
676
|
-
* @example
|
|
677
|
-
* ```ts
|
|
678
|
-
* const player = manager.getPlayer("guildId");
|
|
679
|
-
* const lyrics = await player.lyricsManager.current();
|
|
680
|
-
* ```
|
|
675
|
+
* The PUT method replaces all current representations of the target resource with the request payload.
|
|
676
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
|
|
677
|
+
* @type {string}
|
|
681
678
|
*/
|
|
682
|
-
|
|
679
|
+
Put = "PUT",
|
|
683
680
|
/**
|
|
684
|
-
*
|
|
685
|
-
*
|
|
686
|
-
* @
|
|
687
|
-
* @param {boolean} skipSource Whether to skip the track source or not.
|
|
688
|
-
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
689
|
-
* @example
|
|
690
|
-
* ```ts
|
|
691
|
-
* const node = manager.nodeManager.get("nodeId");
|
|
692
|
-
* const lyrics = await node.lyricsManager.get(track);
|
|
693
|
-
* ```
|
|
681
|
+
* The PATCH method is used to apply partial modifications to a resource.
|
|
682
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
|
|
683
|
+
* @type {string}
|
|
694
684
|
*/
|
|
695
|
-
|
|
685
|
+
Patch = "PATCH",
|
|
696
686
|
/**
|
|
697
|
-
*
|
|
698
|
-
*
|
|
699
|
-
* @
|
|
700
|
-
* @param {boolean} skipSource Whether to skip the track source or not.
|
|
701
|
-
* @returns {Promise<void>} Let's start the sing session!
|
|
702
|
-
* @example
|
|
703
|
-
* ```ts
|
|
704
|
-
* const node = manager.nodeManager.get("nodeId");
|
|
705
|
-
* await node.lyricsManager.subscribe("guildId");
|
|
706
|
-
* ```
|
|
687
|
+
* The DELETE method deletes the specified resource.
|
|
688
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
|
|
689
|
+
* @type {string}
|
|
707
690
|
*/
|
|
708
|
-
|
|
691
|
+
Delete = "DELETE",
|
|
709
692
|
/**
|
|
710
|
-
*
|
|
711
|
-
*
|
|
712
|
-
* @
|
|
713
|
-
* @returns {Promise<void>} Let's stop the sing session!
|
|
714
|
-
* @example
|
|
715
|
-
* ```ts
|
|
716
|
-
* const node = manager.nodeManager.get("nodeId");
|
|
717
|
-
* await node.lyricsManager.unsubscribe("guildId");
|
|
718
|
-
* ```
|
|
693
|
+
* The HEAD method asks for a response identical to that of a GET request, but without the response body.
|
|
694
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
|
|
695
|
+
* @type {string}
|
|
719
696
|
*/
|
|
720
|
-
|
|
697
|
+
Head = "HEAD"
|
|
698
|
+
}
|
|
699
|
+
declare enum RestPathType {
|
|
700
|
+
/**
|
|
701
|
+
* The raw path of the request.
|
|
702
|
+
* @type {string}
|
|
703
|
+
*/
|
|
704
|
+
Raw = "/",
|
|
705
|
+
/**
|
|
706
|
+
* The versioned path v4 of the request.
|
|
707
|
+
* @type {string}
|
|
708
|
+
*/
|
|
709
|
+
V4 = "/v4"
|
|
721
710
|
}
|
|
722
|
-
|
|
723
711
|
/**
|
|
724
|
-
*
|
|
725
|
-
* @
|
|
726
|
-
* @template V The type of the values in the collection.
|
|
712
|
+
* The status codes for the REST.
|
|
713
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
|
727
714
|
*/
|
|
728
|
-
declare
|
|
715
|
+
declare enum HttpStatusCodes {
|
|
729
716
|
/**
|
|
730
|
-
*
|
|
731
|
-
* @
|
|
732
|
-
* @param thisArg The value to use as `this` when executing the filter function.
|
|
733
|
-
* @returns The number of elements removed from the collection.
|
|
734
|
-
* @example
|
|
735
|
-
* const collection = new Collection<number, string>();
|
|
736
|
-
* collection.set(1, 'one');
|
|
737
|
-
* collection.set(2, 'two');
|
|
738
|
-
* collection.set(3, 'three');
|
|
739
|
-
* const removedCount = collection.sweep((value, key) => key % 2 === 0);
|
|
740
|
-
* console.log(removedCount); // Output: 1
|
|
741
|
-
* console.log(collection.size); // Output: 2
|
|
717
|
+
* The request has succeeded.
|
|
718
|
+
* @type {number}
|
|
742
719
|
*/
|
|
743
|
-
|
|
720
|
+
OK = 200,
|
|
744
721
|
/**
|
|
745
|
-
*
|
|
746
|
-
* @
|
|
747
|
-
* @param thisArg The value to use as `this` when executing the map function.
|
|
748
|
-
* @returns A new array with the results of calling the provided function on every element in the collection.
|
|
749
|
-
* @example
|
|
750
|
-
* const collection = new Collection<number, string>();
|
|
751
|
-
* collection.set(1, 'one');
|
|
752
|
-
* collection.set(2, 'two');
|
|
753
|
-
* collection.set(3, 'three');
|
|
754
|
-
* const mappedArray = collection.map((value, key) => `${key}: ${value}`);
|
|
755
|
-
* console.log(mappedArray); // Output: ['1: one', '2: two', '3: three']
|
|
722
|
+
* The request has been fulfilled and resulted in a new resource being created.
|
|
723
|
+
* @type {number}
|
|
756
724
|
*/
|
|
757
|
-
|
|
725
|
+
Created = 201,
|
|
758
726
|
/**
|
|
759
|
-
*
|
|
760
|
-
* @
|
|
761
|
-
* @param thisArg The value to use as `this` when executing the filter function.
|
|
762
|
-
* @returns A new array with the elements that pass the test.
|
|
763
|
-
* @example
|
|
764
|
-
* const collection = new Collection<number, string>();
|
|
765
|
-
* collection.set(1, 'one');
|
|
766
|
-
* collection.set(2, 'two');
|
|
767
|
-
* collection.set(3, 'three');
|
|
768
|
-
* const filteredArray = collection.filter((value, key) => key % 2 === 0);
|
|
769
|
-
* console.log(filteredArray); // Output: ['two']
|
|
727
|
+
* The request has been accepted for processing, but the processing has not been completed.
|
|
728
|
+
* @type {number}
|
|
770
729
|
*/
|
|
771
|
-
|
|
730
|
+
Accepted = 202,
|
|
772
731
|
/**
|
|
773
|
-
*
|
|
774
|
-
* @
|
|
775
|
-
* @returns The value of the first element that passes the test. `undefined` if no element passes the test.
|
|
776
|
-
* @example
|
|
777
|
-
* const collection = new Collection<number, number>();
|
|
778
|
-
* collection.set(1, 1);
|
|
779
|
-
* collection.set(2, 2);
|
|
780
|
-
* collection.set(3, 3);
|
|
781
|
-
* const firstEvenValue = collection.find(value => value % 2 === 0);
|
|
782
|
-
* console.log(firstEvenValue); // Output: 2
|
|
732
|
+
* The server successfully processed the request, but is not returning any content.
|
|
733
|
+
* @type {number}
|
|
783
734
|
*/
|
|
784
|
-
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
/**
|
|
788
|
-
* Class representing a node manager.
|
|
789
|
-
* @class NodeManager
|
|
790
|
-
*/
|
|
791
|
-
declare class NodeManager {
|
|
735
|
+
NoContent = 204,
|
|
792
736
|
/**
|
|
793
|
-
* The
|
|
794
|
-
* @type {
|
|
795
|
-
* @readonly
|
|
737
|
+
* The resource has been moved permanently to a new URI.
|
|
738
|
+
* @type {number}
|
|
796
739
|
*/
|
|
797
|
-
|
|
740
|
+
MovedPermanently = 301,
|
|
798
741
|
/**
|
|
799
|
-
* The
|
|
800
|
-
* @type {
|
|
801
|
-
* @readonly
|
|
742
|
+
* The requested resource has been found at a different URI.
|
|
743
|
+
* @type {number}
|
|
802
744
|
*/
|
|
803
|
-
|
|
745
|
+
Found = 302,
|
|
804
746
|
/**
|
|
805
|
-
*
|
|
806
|
-
*
|
|
807
|
-
* @param {Hoshimi} manager The manager for the node.
|
|
808
|
-
* @example
|
|
809
|
-
* ```ts
|
|
810
|
-
* const manager = new Hoshimi();
|
|
811
|
-
* const nodeManager = new NodeManager(manager);
|
|
812
|
-
*
|
|
813
|
-
* console.log(nodeManager.nodes.size); // 0
|
|
814
|
-
* ```
|
|
747
|
+
* The resource has not been modified since the last request.
|
|
748
|
+
* @type {number}
|
|
815
749
|
*/
|
|
816
|
-
|
|
750
|
+
NotModified = 304,
|
|
817
751
|
/**
|
|
818
|
-
*
|
|
819
|
-
*
|
|
820
|
-
* @param {NodeIdentifier} node The node or node id to delete.
|
|
821
|
-
* @returns {boolean} If the node was deleted.
|
|
822
|
-
* @example
|
|
823
|
-
* ```ts
|
|
824
|
-
* const node = manager.nodeManager.get("node1");
|
|
825
|
-
* if (node) manager.nodeManager.delete(node.id); // true if the node was deleted
|
|
826
|
-
* ```
|
|
752
|
+
* The request cannot be processed due to bad syntax.
|
|
753
|
+
* @type {number}
|
|
827
754
|
*/
|
|
828
|
-
|
|
755
|
+
BadRequest = 400,
|
|
829
756
|
/**
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
* @param {NodeIdentifier} node The node or node id to get.
|
|
833
|
-
* @returns {NodeStructure | undefined} The node or undefined if not found.
|
|
834
|
-
* @example
|
|
835
|
-
* ```ts
|
|
836
|
-
* const node = manager.nodeManager.get("node1");
|
|
837
|
-
* if (node) {
|
|
838
|
-
* console.log(node.id); // node1
|
|
839
|
-
* } else {
|
|
840
|
-
* console.log("Node not found");
|
|
841
|
-
* }
|
|
842
|
-
* ```
|
|
757
|
+
* The request requires user authentication.
|
|
758
|
+
* @type {number}
|
|
843
759
|
*/
|
|
844
|
-
|
|
760
|
+
Unauthorized = 401,
|
|
845
761
|
/**
|
|
846
|
-
*
|
|
847
|
-
*
|
|
848
|
-
* @param {NodeOptions} options The options for the node.
|
|
849
|
-
* @returns {NodeStructure} The created node.
|
|
850
|
-
* @example
|
|
851
|
-
* ```ts
|
|
852
|
-
* const node = manager.nodeManager.create({
|
|
853
|
-
* host: "localhost",
|
|
854
|
-
* port: 2333,
|
|
855
|
-
* password: "password",
|
|
856
|
-
* secure: false,
|
|
857
|
-
* });
|
|
858
|
-
*
|
|
859
|
-
* console.log(node.id); // localhost:2333
|
|
762
|
+
* The request was valid, but the server is refusing action.
|
|
763
|
+
* @type {number}
|
|
860
764
|
*/
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
*
|
|
864
|
-
* Destroy a node.
|
|
865
|
-
* @param {NodeIdentifier} node The node or node id to destroy.
|
|
866
|
-
* @returns {void}
|
|
867
|
-
* @example
|
|
868
|
-
* ```ts
|
|
869
|
-
* const node = manager.nodeManager.get("node1");
|
|
870
|
-
* if (node) node.destroy();
|
|
871
|
-
* ```
|
|
872
|
-
*/
|
|
873
|
-
destroy(node: NodeIdentifier): void;
|
|
874
|
-
/**
|
|
875
|
-
*
|
|
876
|
-
* Reconnect a node.
|
|
877
|
-
* @param {NodeIdentifier} node The node or node id to reconnect.
|
|
878
|
-
* @returns {void}
|
|
879
|
-
* @example
|
|
880
|
-
* ```ts
|
|
881
|
-
* const node = manager.nodeManager.get("node1");
|
|
882
|
-
* if (node) node.reconnect();
|
|
883
|
-
* ```
|
|
884
|
-
*/
|
|
885
|
-
reconnect(node: NodeIdentifier): void;
|
|
886
|
-
/**
|
|
887
|
-
*
|
|
888
|
-
* Disconnect a node.
|
|
889
|
-
* @param {NodeIdentifier} node The node or node id to disconnect.
|
|
890
|
-
* @returns {void}
|
|
891
|
-
* @example
|
|
892
|
-
* ```ts
|
|
893
|
-
* const node = manager.nodeManager.get("node1");
|
|
894
|
-
* if (node) node.disconnect();
|
|
895
|
-
* ```
|
|
896
|
-
*/
|
|
897
|
-
disconnect(node: NodeIdentifier): void;
|
|
898
|
-
/**
|
|
899
|
-
*
|
|
900
|
-
* Connect a node.
|
|
901
|
-
* @param {NodeIdentifier} node The node or node id to connect.
|
|
902
|
-
* @returns {void}
|
|
903
|
-
* @example
|
|
904
|
-
* ```ts
|
|
905
|
-
* const node = manager.nodeManager.get("node1");
|
|
906
|
-
* if (node) node.connect();
|
|
907
|
-
* ```
|
|
908
|
-
*/
|
|
909
|
-
connect(node: NodeIdentifier): void;
|
|
910
|
-
/**
|
|
911
|
-
*
|
|
912
|
-
* Get the least used node.
|
|
913
|
-
* @returns {NodeStructure} The least used node.
|
|
914
|
-
* @example
|
|
915
|
-
* ```ts
|
|
916
|
-
* const node = manager.nodeManager.getLeastUsed();
|
|
917
|
-
* if (node) {
|
|
918
|
-
* console.log(node.id); // node1
|
|
919
|
-
* console.log(node.penalties); // the penalties of the node
|
|
920
|
-
* console.log(node.state); // the state of the node
|
|
921
|
-
* }
|
|
922
|
-
* ```
|
|
923
|
-
*/
|
|
924
|
-
getLeastUsed(sortType?: NodeSortTypes): NodeStructure;
|
|
925
|
-
/**
|
|
926
|
-
*
|
|
927
|
-
* Reconnect the nodes.
|
|
928
|
-
* @returns {void}
|
|
929
|
-
* @example
|
|
930
|
-
* ```ts
|
|
931
|
-
* const node = manager.nodeManager.get("node1");
|
|
932
|
-
* if (node) node.reconnectAll();
|
|
933
|
-
* ```
|
|
934
|
-
*/
|
|
935
|
-
reconnectAll(): void;
|
|
936
|
-
/**
|
|
937
|
-
* Disconnect the nodes.
|
|
938
|
-
* @returns {void}
|
|
939
|
-
* @example
|
|
940
|
-
* ```ts
|
|
941
|
-
* const node = manager.nodeManager.get("node1");
|
|
942
|
-
* if (node) node.disconnectAll();
|
|
943
|
-
* ```
|
|
944
|
-
*/
|
|
945
|
-
disconnectAll(): void;
|
|
946
|
-
/**
|
|
947
|
-
* Connect the nodes.
|
|
948
|
-
* @returns {void}
|
|
949
|
-
* @example
|
|
950
|
-
* ```ts
|
|
951
|
-
* const node = manager.nodeManager.get("node1");
|
|
952
|
-
* if (node) node.connect();
|
|
953
|
-
* ```
|
|
954
|
-
*/
|
|
955
|
-
connectAll(): void;
|
|
956
|
-
/**
|
|
957
|
-
* Destroy the nodes.
|
|
958
|
-
* @returns {void}
|
|
959
|
-
* @example
|
|
960
|
-
* ```ts
|
|
961
|
-
* const node = manager.nodeManager.get("node1");
|
|
962
|
-
* if (node) node.destroy();
|
|
963
|
-
* ```
|
|
964
|
-
*/
|
|
965
|
-
destroyAll(): void;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
/**
|
|
969
|
-
* The methods for http requests
|
|
970
|
-
*/
|
|
971
|
-
declare enum HttpMethods {
|
|
972
|
-
/**
|
|
973
|
-
* The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
|
|
974
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
|
|
975
|
-
* @type {string}
|
|
976
|
-
*/
|
|
977
|
-
Get = "GET",
|
|
978
|
-
/**
|
|
979
|
-
* The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
|
|
980
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
|
|
981
|
-
* @type {string}
|
|
982
|
-
*/
|
|
983
|
-
Post = "POST",
|
|
984
|
-
/**
|
|
985
|
-
* The PUT method replaces all current representations of the target resource with the request payload.
|
|
986
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
|
|
987
|
-
* @type {string}
|
|
988
|
-
*/
|
|
989
|
-
Put = "PUT",
|
|
990
|
-
/**
|
|
991
|
-
* The PATCH method is used to apply partial modifications to a resource.
|
|
992
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
|
|
993
|
-
* @type {string}
|
|
994
|
-
*/
|
|
995
|
-
Patch = "PATCH",
|
|
996
|
-
/**
|
|
997
|
-
* The DELETE method deletes the specified resource.
|
|
998
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
|
|
999
|
-
* @type {string}
|
|
1000
|
-
*/
|
|
1001
|
-
Delete = "DELETE",
|
|
1002
|
-
/**
|
|
1003
|
-
* The HEAD method asks for a response identical to that of a GET request, but without the response body.
|
|
1004
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
|
|
1005
|
-
* @type {string}
|
|
1006
|
-
*/
|
|
1007
|
-
Head = "HEAD"
|
|
1008
|
-
}
|
|
1009
|
-
declare enum RestPathType {
|
|
1010
|
-
/**
|
|
1011
|
-
* The raw path of the request.
|
|
1012
|
-
* @type {string}
|
|
1013
|
-
*/
|
|
1014
|
-
Raw = "/",
|
|
1015
|
-
/**
|
|
1016
|
-
* The versioned path v4 of the request.
|
|
1017
|
-
* @type {string}
|
|
1018
|
-
*/
|
|
1019
|
-
V4 = "/v4"
|
|
1020
|
-
}
|
|
1021
|
-
/**
|
|
1022
|
-
* The status codes for the REST.
|
|
1023
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
|
1024
|
-
*/
|
|
1025
|
-
declare enum HttpStatusCodes {
|
|
1026
|
-
/**
|
|
1027
|
-
* The request has succeeded.
|
|
1028
|
-
* @type {number}
|
|
1029
|
-
*/
|
|
1030
|
-
OK = 200,
|
|
1031
|
-
/**
|
|
1032
|
-
* The request has been fulfilled and resulted in a new resource being created.
|
|
1033
|
-
* @type {number}
|
|
1034
|
-
*/
|
|
1035
|
-
Created = 201,
|
|
1036
|
-
/**
|
|
1037
|
-
* The request has been accepted for processing, but the processing has not been completed.
|
|
1038
|
-
* @type {number}
|
|
1039
|
-
*/
|
|
1040
|
-
Accepted = 202,
|
|
1041
|
-
/**
|
|
1042
|
-
* The server successfully processed the request, but is not returning any content.
|
|
1043
|
-
* @type {number}
|
|
1044
|
-
*/
|
|
1045
|
-
NoContent = 204,
|
|
1046
|
-
/**
|
|
1047
|
-
* The resource has been moved permanently to a new URI.
|
|
1048
|
-
* @type {number}
|
|
1049
|
-
*/
|
|
1050
|
-
MovedPermanently = 301,
|
|
1051
|
-
/**
|
|
1052
|
-
* The requested resource has been found at a different URI.
|
|
1053
|
-
* @type {number}
|
|
1054
|
-
*/
|
|
1055
|
-
Found = 302,
|
|
1056
|
-
/**
|
|
1057
|
-
* The resource has not been modified since the last request.
|
|
1058
|
-
* @type {number}
|
|
1059
|
-
*/
|
|
1060
|
-
NotModified = 304,
|
|
1061
|
-
/**
|
|
1062
|
-
* The request cannot be processed due to bad syntax.
|
|
1063
|
-
* @type {number}
|
|
1064
|
-
*/
|
|
1065
|
-
BadRequest = 400,
|
|
1066
|
-
/**
|
|
1067
|
-
* The request requires user authentication.
|
|
1068
|
-
* @type {number}
|
|
1069
|
-
*/
|
|
1070
|
-
Unauthorized = 401,
|
|
1071
|
-
/**
|
|
1072
|
-
* The request was valid, but the server is refusing action.
|
|
1073
|
-
* @type {number}
|
|
1074
|
-
*/
|
|
1075
|
-
Forbidden = 403,
|
|
765
|
+
Forbidden = 403,
|
|
1076
766
|
/**
|
|
1077
767
|
* The server cannot find the requested resource.
|
|
1078
768
|
* @type {number}
|
|
@@ -1129,15 +819,95 @@ declare enum HttpStatusCodes {
|
|
|
1129
819
|
*/
|
|
1130
820
|
GatewayTimeout = 504
|
|
1131
821
|
}
|
|
822
|
+
/**
|
|
823
|
+
* The REST routes.
|
|
824
|
+
*/
|
|
825
|
+
declare const RestRoutes: {
|
|
826
|
+
/**
|
|
827
|
+
*
|
|
828
|
+
* Get the updated player endpoint.
|
|
829
|
+
* @param {string} sessionId The session id of the node.
|
|
830
|
+
* @param {string} guildId The guild id of the player.
|
|
831
|
+
* @returns {RestEndpoint} The endpoint for updating the player.
|
|
832
|
+
*/
|
|
833
|
+
UpdatePlayer(sessionId: string, guildId: string): `/sessions/${string}/players/${string}`;
|
|
834
|
+
/**
|
|
835
|
+
*
|
|
836
|
+
* Get the update session endpoint.
|
|
837
|
+
* @param {string} sessionId The session id of the node.
|
|
838
|
+
* @returns {RestEndpoint} The endpoint for updating the session.
|
|
839
|
+
*/
|
|
840
|
+
UpdateSession(sessionId: string): `/sessions/${string}`;
|
|
841
|
+
/**
|
|
842
|
+
*
|
|
843
|
+
* Get the get players endpoint.
|
|
844
|
+
* @param {string} sessionId The session id of the node.
|
|
845
|
+
* @returns {RestEndpoint} The endpoint for getting the players.
|
|
846
|
+
*/
|
|
847
|
+
GetPlayers(sessionId: string): `/sessions/${string}/players`;
|
|
848
|
+
/**
|
|
849
|
+
*
|
|
850
|
+
* Get the current lyrics endpoint.
|
|
851
|
+
* @param {string} sessionId The session id of the node.
|
|
852
|
+
* @param {string} guildId The guild id of the player.
|
|
853
|
+
* @returns {RestEndpoint} The endpoint for getting the current lyrics.
|
|
854
|
+
*/
|
|
855
|
+
CurrentLyrics(sessionId: string, guildId: string): `/sessions/${string}/players/${string}/track/lyrics`;
|
|
856
|
+
/**
|
|
857
|
+
*
|
|
858
|
+
* Subscribe to lyrics endpoint.
|
|
859
|
+
* @param {string} sessionId The session id of the node.
|
|
860
|
+
* @param {string} guildId The guild id of the player.
|
|
861
|
+
* @returns {RestEndpoint} The endpoint for subscribing to lyrics.
|
|
862
|
+
*/
|
|
863
|
+
SubscribeLyrics(sessionId: string, guildId: string): `/sessions/${string}/players/${string}/lyrics/subscribe`;
|
|
864
|
+
/**
|
|
865
|
+
* Get the lyrics endpoint.
|
|
866
|
+
* @type {RestEndpoint}
|
|
867
|
+
*/
|
|
868
|
+
GetLyrics: "/lyrics";
|
|
869
|
+
/**
|
|
870
|
+
* Get the decode track endpoint.
|
|
871
|
+
* @type {RestEndpoint}
|
|
872
|
+
*/
|
|
873
|
+
DecodeTrack: "/decodetrack";
|
|
874
|
+
/**
|
|
875
|
+
* Get the decode tracks endpoint.
|
|
876
|
+
* @type {RestEndpoint}
|
|
877
|
+
*/
|
|
878
|
+
DecodeTracks: "/decodetracks";
|
|
879
|
+
/**
|
|
880
|
+
* Get the load tracks endpoint.
|
|
881
|
+
* @type {RestEndpoint}
|
|
882
|
+
*/
|
|
883
|
+
LoadTracks: "/loadtracks";
|
|
884
|
+
/**
|
|
885
|
+
* Get the node info endpoint.
|
|
886
|
+
* @type {RestEndpoint}
|
|
887
|
+
*/
|
|
888
|
+
NodeInfo: "/info";
|
|
889
|
+
/**
|
|
890
|
+
* Get the load lyrics endpoint.
|
|
891
|
+
* @type {RestEndpoint}
|
|
892
|
+
* @description Used in NodelinkLyricsManager, only for nodelink nodes.
|
|
893
|
+
*/
|
|
894
|
+
LoadLyrics: "/loadlyrics";
|
|
895
|
+
/**
|
|
896
|
+
* Get the connection endpoint.
|
|
897
|
+
* @type {RestEndpoint}
|
|
898
|
+
* @description Used for checking the connection status of the node, only for nodelink nodes.
|
|
899
|
+
*/
|
|
900
|
+
Connection: "/connection";
|
|
901
|
+
};
|
|
1132
902
|
/**
|
|
1133
903
|
* The options for the REST.
|
|
1134
904
|
*/
|
|
1135
905
|
interface RestOptions {
|
|
1136
906
|
/**
|
|
1137
907
|
* The endpoint for the REST.
|
|
1138
|
-
* @type {
|
|
908
|
+
* @type {RestEndpoint}
|
|
1139
909
|
*/
|
|
1140
|
-
endpoint:
|
|
910
|
+
endpoint: RestEndpoint;
|
|
1141
911
|
/**
|
|
1142
912
|
* The method for the REST.
|
|
1143
913
|
* @type {HttpMethods}
|
|
@@ -1357,134 +1127,29 @@ interface DecodeMethods {
|
|
|
1357
1127
|
*/
|
|
1358
1128
|
multiple(tracks: string[], requester: TrackRequester): Promise<Track[]>;
|
|
1359
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* The options for resuming a session.
|
|
1132
|
+
*/
|
|
1133
|
+
interface SessionResumingOptions {
|
|
1134
|
+
/**
|
|
1135
|
+
* Whether the session is resuming.
|
|
1136
|
+
* @type {boolean}
|
|
1137
|
+
*/
|
|
1138
|
+
resuming: boolean;
|
|
1139
|
+
/**
|
|
1140
|
+
* The timeout for resuming the session in milliseconds.
|
|
1141
|
+
* @type {number | null | undefined}
|
|
1142
|
+
*/
|
|
1143
|
+
timeout?: number | null;
|
|
1144
|
+
}
|
|
1360
1145
|
/**
|
|
1361
1146
|
* The session of the node.
|
|
1362
1147
|
*/
|
|
1363
1148
|
type NullableLavalinkSession = PickNullable<LavalinkSession, "timeout">;
|
|
1364
|
-
|
|
1365
1149
|
/**
|
|
1366
|
-
*
|
|
1367
|
-
* @class Rest
|
|
1150
|
+
* The REST endpoint type.
|
|
1368
1151
|
*/
|
|
1369
|
-
|
|
1370
|
-
/**
|
|
1371
|
-
* The URL for the REST.
|
|
1372
|
-
* @type {string}
|
|
1373
|
-
*/
|
|
1374
|
-
readonly url: string;
|
|
1375
|
-
/**
|
|
1376
|
-
* The version for the REST.
|
|
1377
|
-
* @type {string}
|
|
1378
|
-
*/
|
|
1379
|
-
readonly version: string;
|
|
1380
|
-
/**
|
|
1381
|
-
* The timeout for the REST.
|
|
1382
|
-
* @type {number}
|
|
1383
|
-
*/
|
|
1384
|
-
readonly restTimeout: number;
|
|
1385
|
-
/**
|
|
1386
|
-
* The user agent for the REST.
|
|
1387
|
-
* @type {UserAgent}
|
|
1388
|
-
*/
|
|
1389
|
-
readonly userAgent: UserAgent;
|
|
1390
|
-
/**
|
|
1391
|
-
* The node for the REST.
|
|
1392
|
-
* @type {Node}
|
|
1393
|
-
*/
|
|
1394
|
-
readonly node: NodeStructure;
|
|
1395
|
-
/**
|
|
1396
|
-
*
|
|
1397
|
-
* Create a new REST.
|
|
1398
|
-
* @param {NodeStructure} node The node for the REST.
|
|
1399
|
-
* @example
|
|
1400
|
-
* ```ts
|
|
1401
|
-
* const node = new Node({
|
|
1402
|
-
* host: "localhost",
|
|
1403
|
-
* port: 2333,
|
|
1404
|
-
* password: "youshallnotpass",
|
|
1405
|
-
* secure: false,
|
|
1406
|
-
* });
|
|
1407
|
-
*
|
|
1408
|
-
* const rest = new Rest(node);
|
|
1409
|
-
* console.log(rest.restUrl); // http://localhost:2333/v4
|
|
1410
|
-
* ```
|
|
1411
|
-
*/
|
|
1412
|
-
constructor(node: NodeStructure);
|
|
1413
|
-
/**
|
|
1414
|
-
* The REST URL to make requests.
|
|
1415
|
-
* @type {string}
|
|
1416
|
-
*/
|
|
1417
|
-
get restUrl(): string;
|
|
1418
|
-
/**
|
|
1419
|
-
* The session id of the node.
|
|
1420
|
-
* @type {string}
|
|
1421
|
-
*/
|
|
1422
|
-
get sessionId(): string;
|
|
1423
|
-
/**
|
|
1424
|
-
*
|
|
1425
|
-
* Make a request to the node.
|
|
1426
|
-
* @param {RestOptions} options The options to make the request.
|
|
1427
|
-
* @returns {Promise<T | null>} The response from the node.
|
|
1428
|
-
*/
|
|
1429
|
-
request<T>(options: RestOptions): Promise<T | null>;
|
|
1430
|
-
/**
|
|
1431
|
-
*
|
|
1432
|
-
* Update the player data.
|
|
1433
|
-
* @param {Partial<UpdatePlayerInfo>} data The player data to update.
|
|
1434
|
-
* @returns {LavalinkPlayer | null} The updated player data.
|
|
1435
|
-
* @example
|
|
1436
|
-
* ```ts
|
|
1437
|
-
* const player = await node.rest.updatePlayer({
|
|
1438
|
-
* guildId: "guildId",
|
|
1439
|
-
* noReplace: true,
|
|
1440
|
-
* playerOptions: {
|
|
1441
|
-
* paused: false,
|
|
1442
|
-
* track: { encoded: "encoded track" },
|
|
1443
|
-
* },
|
|
1444
|
-
* });
|
|
1445
|
-
*
|
|
1446
|
-
* console.log(player); // The updated lavalink player data
|
|
1447
|
-
* ```
|
|
1448
|
-
*/
|
|
1449
|
-
updatePlayer(data: Partial<UpdatePlayerInfo>): Promise<LavalinkPlayer | null>;
|
|
1450
|
-
/**
|
|
1451
|
-
*
|
|
1452
|
-
* Stop the track in player for the guild.
|
|
1453
|
-
* @param {string} guildId the guild id to stop the player
|
|
1454
|
-
* @returns {Promise<LavalinkPlayer | null>} The updated player data.
|
|
1455
|
-
* @example
|
|
1456
|
-
* ```ts
|
|
1457
|
-
* const player = await node.rest.stopPlayer("guildId");
|
|
1458
|
-
* if (player) console.log(player); // The lavalink player
|
|
1459
|
-
* ```
|
|
1460
|
-
*/
|
|
1461
|
-
stopPlayer(guildId: string): Promise<LavalinkPlayer | null>;
|
|
1462
|
-
/**
|
|
1463
|
-
*
|
|
1464
|
-
* Destroy the player for the guild.
|
|
1465
|
-
* @param {string} guildId The guild id to destroy the player.
|
|
1466
|
-
* @returns {Promise<void>} The updated player data.
|
|
1467
|
-
* @example
|
|
1468
|
-
* ```ts
|
|
1469
|
-
* await node.rest.destroyPlayer("guildId");
|
|
1470
|
-
* ```
|
|
1471
|
-
* @example
|
|
1472
|
-
*/
|
|
1473
|
-
destroyPlayer(guildId: string): Promise<void>;
|
|
1474
|
-
/**
|
|
1475
|
-
*
|
|
1476
|
-
* Update the session for the node
|
|
1477
|
-
* @param {boolean} resuming Enable resuming for the session.
|
|
1478
|
-
* @param {number | null} timeout The timeout for the session.
|
|
1479
|
-
* @returns {Promise<LavalinkSession | null>} The updated session data.
|
|
1480
|
-
* @example
|
|
1481
|
-
* ```ts
|
|
1482
|
-
* const session = await node.rest.updateSession(true, 10000);
|
|
1483
|
-
* if (session) console.log(session); // The lavalink session data
|
|
1484
|
-
* ```
|
|
1485
|
-
*/
|
|
1486
|
-
updateSession(resuming: boolean, timeout?: number | null): Promise<LavalinkSession | null>;
|
|
1487
|
-
}
|
|
1152
|
+
type RestEndpoint = `/${string}`;
|
|
1488
1153
|
|
|
1489
1154
|
/**
|
|
1490
1155
|
* Class representing the DSPX Plugin filters for a player.
|
|
@@ -1507,6 +1172,14 @@ declare class DSPXPluginFilter {
|
|
|
1507
1172
|
* Set the low-pass filter with the given settings.
|
|
1508
1173
|
* @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXLowPass] The settings for the low-pass filter.
|
|
1509
1174
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1175
|
+
* @throws {PlayerError} If the node does not have the required plugin or filter enabled.
|
|
1176
|
+
* @example
|
|
1177
|
+
* ```ts
|
|
1178
|
+
* // Set the low-pass filter with custom settings
|
|
1179
|
+
* await player.filterManager.dspxPlugin.setLowPass({ cutoffFrequency: 500, boostFactor: 1.5 });
|
|
1180
|
+
* // Disable the low-pass filter
|
|
1181
|
+
* await player.filterManager.dspxPlugin.setLowPass();
|
|
1182
|
+
* ```
|
|
1510
1183
|
*/
|
|
1511
1184
|
setLowPass(settings?: Partial<FilterPluginPassSettings>): Promise<this>;
|
|
1512
1185
|
/**
|
|
@@ -1514,6 +1187,14 @@ declare class DSPXPluginFilter {
|
|
|
1514
1187
|
* Set the high-pass filter with the given settings.
|
|
1515
1188
|
* @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXHighPass] The settings for the high-pass filter.
|
|
1516
1189
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1190
|
+
* @throws {PlayerError} If the node does not have the required plugin or filter enabled.
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```ts
|
|
1193
|
+
* // Set the high-pass filter with custom settings
|
|
1194
|
+
* await player.filterManager.dspxPlugin.setHighPass({ cutoffFrequency: 2000, boostFactor: 0.8 });
|
|
1195
|
+
* // Disable the high-pass filter
|
|
1196
|
+
* await player.filterManager.dspxPlugin.setHighPass();
|
|
1197
|
+
* ```
|
|
1517
1198
|
*/
|
|
1518
1199
|
setHighPass(settings?: Partial<FilterPluginPassSettings>): Promise<this>;
|
|
1519
1200
|
/**
|
|
@@ -1521,6 +1202,14 @@ declare class DSPXPluginFilter {
|
|
|
1521
1202
|
* Set the normalization filter with the given settings.
|
|
1522
1203
|
* @param {NormalizationSettings} [settings=DefaultFilter.DSPXNormalization] The settings for the normalization filter.
|
|
1523
1204
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1205
|
+
* @throws {PlayerError} If the node does not have the required plugin or filter enabled.
|
|
1206
|
+
* @example
|
|
1207
|
+
* ```ts
|
|
1208
|
+
* // Set the normalization filter with custom settings
|
|
1209
|
+
* await player.filterManager.dspxPlugin.setNormalization({ maxAmplitude: 0.9, adaptive: true });
|
|
1210
|
+
* // Disable the normalization filter
|
|
1211
|
+
* await player.filterManager.dspxPlugin.setNormalization();
|
|
1212
|
+
* ```
|
|
1524
1213
|
*/
|
|
1525
1214
|
setNormalization(settings?: Partial<NormalizationSettings>): Promise<this>;
|
|
1526
1215
|
/**
|
|
@@ -1528,6 +1217,14 @@ declare class DSPXPluginFilter {
|
|
|
1528
1217
|
* Set the echo filter with the given settings.
|
|
1529
1218
|
* @param {EchoSettings} [settings=DefaultFilter.DSPXEcho] The settings for the echo filter.
|
|
1530
1219
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1220
|
+
* @throws {PlayerError} If the node does not have the required plugin or filter enabled.
|
|
1221
|
+
* @example
|
|
1222
|
+
* ```ts
|
|
1223
|
+
* // Set the echo filter with custom settings
|
|
1224
|
+
* await player.filterManager.dspxPlugin.setEcho({ echoLength: 500, decay: 0.5, delay: 200 });
|
|
1225
|
+
* // Disable the echo filter
|
|
1226
|
+
* await player.filterManager.dspxPlugin.setEcho();
|
|
1227
|
+
* ```
|
|
1531
1228
|
*/
|
|
1532
1229
|
setEcho(settings?: Partial<EchoSettings>): Promise<this>;
|
|
1533
1230
|
}
|
|
@@ -1555,6 +1252,14 @@ declare class LavalinkPluginFilter {
|
|
|
1555
1252
|
* Set the echo filter with the given settings.
|
|
1556
1253
|
* @param {Omit<EchoSettings, "echoLength">} [settings=DefaultFilter.PluginEcho] The settings for the echo filter.
|
|
1557
1254
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1255
|
+
* @throws {PlayerError} If the node does not have the required plugin or filter enabled.
|
|
1256
|
+
* @example
|
|
1257
|
+
* ```ts
|
|
1258
|
+
* // Set the echo filter with custom settings
|
|
1259
|
+
* await player.filterManager.lavalinkPlugin.setEcho({ decay: 0.5, delay: 200 });
|
|
1260
|
+
* // Disable the echo filter
|
|
1261
|
+
* await player.filterManager.lavalinkPlugin.setEcho();
|
|
1262
|
+
* ```
|
|
1558
1263
|
*/
|
|
1559
1264
|
setEcho(settings?: Partial<NonLengthEchoSettings>): Promise<this>;
|
|
1560
1265
|
/**
|
|
@@ -1562,6 +1267,14 @@ declare class LavalinkPluginFilter {
|
|
|
1562
1267
|
* Set the reverb filter with the given settings.
|
|
1563
1268
|
* @param {Partial<LavalinkFilterPluginReverbSettings>} [settings=DefaultFilter.PluginReverb] The settings for the reverb filter.
|
|
1564
1269
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1270
|
+
* @throws {PlayerError} If the node does not have the required plugin or filter enabled.
|
|
1271
|
+
* @example
|
|
1272
|
+
* ```ts
|
|
1273
|
+
* // Set the reverb filter with custom settings
|
|
1274
|
+
* await player.filterManager.lavalinkPlugin.setReverb({ delays: [50, 100, 150], gains: [0.5, 0.3, 0.2] });
|
|
1275
|
+
* // Disable the reverb filter
|
|
1276
|
+
* await player.filterManager.lavalinkPlugin.setReverb();
|
|
1277
|
+
* ```
|
|
1565
1278
|
*/
|
|
1566
1279
|
setReverb(settings?: Partial<LavalinkFilterPluginReverbSettings>): Promise<this>;
|
|
1567
1280
|
}
|
|
@@ -1616,18 +1329,33 @@ declare class FilterManager {
|
|
|
1616
1329
|
/**
|
|
1617
1330
|
* Resets all filters to their default values.
|
|
1618
1331
|
* @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
|
|
1332
|
+
* @example
|
|
1333
|
+
* ```ts
|
|
1334
|
+
* // Reset all filters
|
|
1335
|
+
* await player.filterManager.reset();
|
|
1336
|
+
* ```
|
|
1619
1337
|
*/
|
|
1620
1338
|
reset(): Promise<this>;
|
|
1621
1339
|
/**
|
|
1622
1340
|
*
|
|
1623
1341
|
* Applies the current filters to the player.
|
|
1624
1342
|
* @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
|
|
1343
|
+
* @example
|
|
1344
|
+
* ```ts
|
|
1345
|
+
* // Apply the current filters
|
|
1346
|
+
* await player.filterManager.apply();
|
|
1347
|
+
* ```
|
|
1625
1348
|
*/
|
|
1626
1349
|
apply(): Promise<this>;
|
|
1627
1350
|
/**
|
|
1628
1351
|
* Checks if the current filters are active.
|
|
1629
1352
|
* @param {TimescaleSettings} timescale The timescale settings to check against.
|
|
1630
1353
|
* @returns {void} Nothing!
|
|
1354
|
+
* @example
|
|
1355
|
+
* ```ts
|
|
1356
|
+
* // Check the current filters
|
|
1357
|
+
* player.filterManager.check();
|
|
1358
|
+
* ```
|
|
1631
1359
|
*/
|
|
1632
1360
|
check(timescale?: TimescaleSettings): void;
|
|
1633
1361
|
/**
|
|
@@ -1635,6 +1363,12 @@ declare class FilterManager {
|
|
|
1635
1363
|
* Checks if a specific filter is active.
|
|
1636
1364
|
* @param {FilterType} filter The filter type to check.
|
|
1637
1365
|
* @returns {boolean} True if the filter is active, false otherwise.
|
|
1366
|
+
* @example
|
|
1367
|
+
* ```ts
|
|
1368
|
+
* // Check if the nightcore filter is active
|
|
1369
|
+
* const isNightcoreActive = player.filterManager.has(FilterType.Nightcore);
|
|
1370
|
+
* console.log(isNightcoreActive); // true or false
|
|
1371
|
+
* ```
|
|
1638
1372
|
*/
|
|
1639
1373
|
has(filter: FilterType): boolean;
|
|
1640
1374
|
/**
|
|
@@ -1642,12 +1376,24 @@ declare class FilterManager {
|
|
|
1642
1376
|
* Sets the volume for the player.
|
|
1643
1377
|
* @param {number} volume The volume level to set (between 0 and 5).
|
|
1644
1378
|
* @returns {Promise<this>} A promise that resolves to the player instance.
|
|
1379
|
+
* @throws {PlayerError} If the volume is not a number between 0 and 5.
|
|
1380
|
+
* @example
|
|
1381
|
+
* ```ts
|
|
1382
|
+
* // Set the volume to 2.5
|
|
1383
|
+
* await player.filterManager.setVolume(2.5);
|
|
1384
|
+
* ```
|
|
1645
1385
|
*/
|
|
1646
1386
|
setVolume(volume: number): Promise<this>;
|
|
1647
1387
|
/**
|
|
1648
1388
|
* Sets the audio output for the player.
|
|
1649
1389
|
* @param {AudioOutput} output The audio output to set.
|
|
1650
1390
|
* @returns {Promise<this>} A promise that resolves to the player instance.
|
|
1391
|
+
* @throws {PlayerError} If the output is not a valid AudioOutput value.
|
|
1392
|
+
* @example
|
|
1393
|
+
* ```ts
|
|
1394
|
+
* // Set the audio output to mono
|
|
1395
|
+
* await player.filterManager.setAudioOutput(AudioOutput.Mono);
|
|
1396
|
+
* ```
|
|
1651
1397
|
*/
|
|
1652
1398
|
setAudioOutput(output: AudioOutput): Promise<this>;
|
|
1653
1399
|
/**
|
|
@@ -1655,6 +1401,12 @@ declare class FilterManager {
|
|
|
1655
1401
|
* Sets the speed for the player.
|
|
1656
1402
|
* @param {number} speed The speed to set (default is 1).
|
|
1657
1403
|
* @returns {Promise<this>} A promise that resolves to the player instance.
|
|
1404
|
+
* @throws {PlayerError} If the node does not support the timescale filter.
|
|
1405
|
+
* @example
|
|
1406
|
+
* ```ts
|
|
1407
|
+
* // Set the speed to 1.5
|
|
1408
|
+
* await player.filterManager.setSpeed(1.5);
|
|
1409
|
+
* ```
|
|
1658
1410
|
*/
|
|
1659
1411
|
setSpeed(speed?: number): Promise<this>;
|
|
1660
1412
|
/**
|
|
@@ -1662,6 +1414,12 @@ declare class FilterManager {
|
|
|
1662
1414
|
* Sets the rate for the player.
|
|
1663
1415
|
* @param {number} rate The rate to set (default is 1).
|
|
1664
1416
|
* @returns {Promise<this>} A promise that resolves to the player instance.
|
|
1417
|
+
* @throws {PlayerError} If the node does not support the timescale filter.
|
|
1418
|
+
* @example
|
|
1419
|
+
* ```ts
|
|
1420
|
+
* // Set the rate to 1.2
|
|
1421
|
+
* await player.filterManager.setRate(1.2);
|
|
1422
|
+
* ```
|
|
1665
1423
|
*/
|
|
1666
1424
|
setRate(rate?: number): Promise<this>;
|
|
1667
1425
|
/**
|
|
@@ -1669,6 +1427,12 @@ declare class FilterManager {
|
|
|
1669
1427
|
* Sets the pitch for the player.
|
|
1670
1428
|
* @param {number} pitch The pitch
|
|
1671
1429
|
* @returns {Promise<this>} A promise that resolves to the player instance.
|
|
1430
|
+
* @throws {PlayerError} If the node does not support the timescale filter.
|
|
1431
|
+
* @example
|
|
1432
|
+
* ```ts
|
|
1433
|
+
* // Set the pitch to 0.8
|
|
1434
|
+
* await player.filterManager.setPitch(0.8);
|
|
1435
|
+
* ```
|
|
1672
1436
|
*/
|
|
1673
1437
|
setPitch(pitch?: number): Promise<this>;
|
|
1674
1438
|
/**
|
|
@@ -1676,12 +1440,26 @@ declare class FilterManager {
|
|
|
1676
1440
|
* Sets the EQ bands for the player.
|
|
1677
1441
|
* @param {RestOrArray<EQBandSettings>} bands The EQ band settings to set.
|
|
1678
1442
|
* @returns {Promise<this>} A promise that resolves to the instance of the manager.
|
|
1443
|
+
* @throws {PlayerError} If the bands array is empty or contains invalid band settings.
|
|
1444
|
+
* @example
|
|
1445
|
+
* ```ts
|
|
1446
|
+
* // Set multiple EQ bands
|
|
1447
|
+
* await player.filterManager.setEQBand(
|
|
1448
|
+
* { band: 0, gain: 0.5 },
|
|
1449
|
+
* { band: 1, gain: -0.3 },
|
|
1450
|
+
* );
|
|
1451
|
+
* ```
|
|
1679
1452
|
*/
|
|
1680
1453
|
setEQBand(...bands: RestOrArray<EQBandSettings>): Promise<this>;
|
|
1681
1454
|
/**
|
|
1682
1455
|
*
|
|
1683
1456
|
* Clears all EQ bands for the player.
|
|
1684
1457
|
* @returns {Promise<this>} A promise that resolves to the instance of the manager.
|
|
1458
|
+
* @example
|
|
1459
|
+
* ```ts
|
|
1460
|
+
* // Clear all EQ bands
|
|
1461
|
+
* await player.filterManager.clearEQBands();
|
|
1462
|
+
* ```
|
|
1685
1463
|
*/
|
|
1686
1464
|
clearEQBands(): Promise<this>;
|
|
1687
1465
|
/**
|
|
@@ -1689,6 +1467,12 @@ declare class FilterManager {
|
|
|
1689
1467
|
* Set the vibrato filter with the given settings.
|
|
1690
1468
|
* @param {TremoloSettings} [settings=DefaultFilterPreset.Vibrato] The settings for the vibrato filter.
|
|
1691
1469
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1470
|
+
* @throws {PlayerError} If the node does not support the vibrato filter.
|
|
1471
|
+
* @example
|
|
1472
|
+
* ```ts
|
|
1473
|
+
* // Set the vibrato filter
|
|
1474
|
+
* await player.filterManager.setVibrato({ frequency: 4.0, depth: 0.5 });
|
|
1475
|
+
* ```
|
|
1692
1476
|
*/
|
|
1693
1477
|
setVibrato(settings?: Partial<TremoloSettings>): Promise<this>;
|
|
1694
1478
|
/**
|
|
@@ -1696,6 +1480,12 @@ declare class FilterManager {
|
|
|
1696
1480
|
* Set the tremolo filter with the given settings.
|
|
1697
1481
|
* @param {TremoloSettings} [settings=DefaultFilterPreset.Tremolo] The settings for the tremolo filter.
|
|
1698
1482
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1483
|
+
* @throws {PlayerError} If the node does not support the tremolo filter.
|
|
1484
|
+
* @example
|
|
1485
|
+
* ```ts
|
|
1486
|
+
* // Set the tremolo filter
|
|
1487
|
+
* await player.filterManager.setTremolo({ frequency: 4.0, depth: 0.5 });
|
|
1488
|
+
* ```
|
|
1699
1489
|
*/
|
|
1700
1490
|
setTremolo(settings?: Partial<TremoloSettings>): Promise<this>;
|
|
1701
1491
|
/**
|
|
@@ -1703,12 +1493,24 @@ declare class FilterManager {
|
|
|
1703
1493
|
* Set the low-pass filter with the given settings.
|
|
1704
1494
|
* @param {LowPassSettings} [settings=DefaultFilterPreset.Lowpass] The settings for the low-pass filter.
|
|
1705
1495
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1496
|
+
* @throws {PlayerError} If the node does not support the low-pass filter.
|
|
1497
|
+
* @example
|
|
1498
|
+
* ```ts
|
|
1499
|
+
* // Set the low-pass filter
|
|
1500
|
+
* await player.filterManager.setLowPass({ smoothing: 20.0 });
|
|
1501
|
+
* ```
|
|
1706
1502
|
*/
|
|
1707
1503
|
setLowPass(settings?: Partial<LowPassSettings>): Promise<this>;
|
|
1708
1504
|
/**
|
|
1709
1505
|
* Set the nightcore filter with the given settings.
|
|
1710
1506
|
* @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Nightcore] The settings for the nightcore filter.
|
|
1711
1507
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1508
|
+
* @throws {PlayerError} If the node does not support the timescale filter.
|
|
1509
|
+
* @example
|
|
1510
|
+
* ```ts
|
|
1511
|
+
* // Set the nightcore filter
|
|
1512
|
+
* await player.filterManager.setNightcore();
|
|
1513
|
+
* ```
|
|
1712
1514
|
*/
|
|
1713
1515
|
setNightcore(settings?: Partial<TimescaleSettings>): Promise<this>;
|
|
1714
1516
|
/**
|
|
@@ -1716,6 +1518,12 @@ declare class FilterManager {
|
|
|
1716
1518
|
* Set the vaporwave filter with the given settings.
|
|
1717
1519
|
* @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Vaporwave] The settings for the vaporwave filter.
|
|
1718
1520
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1521
|
+
* @throws {PlayerError} If the node does not support the timescale filter.
|
|
1522
|
+
* @example
|
|
1523
|
+
* ```ts
|
|
1524
|
+
* // Set the vaporwave filter
|
|
1525
|
+
* await player.filterManager.setVaporwave();
|
|
1526
|
+
* ```
|
|
1719
1527
|
*/
|
|
1720
1528
|
setVaporwave(settings?: Partial<TimescaleSettings>): Promise<this>;
|
|
1721
1529
|
/**
|
|
@@ -1723,6 +1531,12 @@ declare class FilterManager {
|
|
|
1723
1531
|
* Set the karaoke filter with the given settings.
|
|
1724
1532
|
* @param {KaraokeSettings} [settings=DefaultFilterPreset.Karaoke] The settings for the karaoke filter.
|
|
1725
1533
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1534
|
+
* @throws {PlayerError} If the node does not support the karaoke filter.
|
|
1535
|
+
* @example
|
|
1536
|
+
* ```ts
|
|
1537
|
+
* // Set the karaoke filter
|
|
1538
|
+
* await player.filterManager.setKaraoke({ level: -15.0, monoLevel: -20.0, filterBand: 220.0, filterWidth: 100.0 });
|
|
1539
|
+
* ```
|
|
1726
1540
|
*/
|
|
1727
1541
|
setKaraoke(settings?: Partial<KaraokeSettings>): Promise<this>;
|
|
1728
1542
|
/**
|
|
@@ -1730,91 +1544,43 @@ declare class FilterManager {
|
|
|
1730
1544
|
* Set the distortion filter with the given settings.
|
|
1731
1545
|
* @param {Partial<DistortionSettings>} [settings=DefaultFilterPreset.Distortion] The settings for the distortion filter.
|
|
1732
1546
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1547
|
+
* @throws {PlayerError} If the node does not support the distortion filter.
|
|
1548
|
+
* @example
|
|
1549
|
+
* ```ts
|
|
1550
|
+
* // Set the distortion filter
|
|
1551
|
+
* await player.filterManager.setDistortion({ sinOffset: 0.5, sinScale: 2.0 });
|
|
1552
|
+
* ```
|
|
1733
1553
|
*/
|
|
1734
1554
|
setDistortion(settings?: Partial<DistortionSettings>): Promise<this>;
|
|
1735
1555
|
/**
|
|
1736
1556
|
* Set the timescale filter with the given settings.
|
|
1737
1557
|
* @param {Partial<TimescaleSettings>} settings The timescale settings to set.
|
|
1738
1558
|
* @returns {Promise<this>} The instance of the filter manager.
|
|
1559
|
+
* @throws {PlayerError} If the node does not support the timescale filter.
|
|
1560
|
+
* @example
|
|
1561
|
+
* ```ts
|
|
1562
|
+
* // Set the timescale filter
|
|
1563
|
+
* await player.filterManager.setTimescale({ speed: 1.2, pitch: 0.8, rate: 1.0 });
|
|
1564
|
+
* ```
|
|
1739
1565
|
*/
|
|
1740
1566
|
setTimescale(settings: Partial<TimescaleSettings>): Promise<this>;
|
|
1741
1567
|
/**
|
|
1742
1568
|
* Convert the filter settings to a JSON object.
|
|
1743
1569
|
* @returns {FilterSettings} The filter settings as a JSON object.
|
|
1570
|
+
* @example
|
|
1571
|
+
* ```ts
|
|
1572
|
+
* // Convert filter settings to JSON
|
|
1573
|
+
* const filterSettingsJSON = player.filterManager.toJSON();
|
|
1574
|
+
* console.log(filterSettingsJSON); // { volume: 1, equalizer: [...], ... }
|
|
1575
|
+
* ```
|
|
1744
1576
|
*/
|
|
1745
1577
|
toJSON(): FilterSettings;
|
|
1746
1578
|
}
|
|
1747
1579
|
|
|
1748
1580
|
/**
|
|
1749
|
-
* Type representing
|
|
1750
|
-
*/
|
|
1751
|
-
type StorageKeys = keyof CustomizablePlayerStorage | (string & {});
|
|
1752
|
-
/**
|
|
1753
|
-
* Type representing the customizable player storage values.
|
|
1754
|
-
*/
|
|
1755
|
-
type StorageValues<V extends StorageKeys = StorageKeys> = V extends keyof CustomizablePlayerStorage ? CustomizablePlayerStorage[V] : unknown;
|
|
1756
|
-
/**
|
|
1757
|
-
* Class representing a player storage.
|
|
1758
|
-
* @class PlayerStorage
|
|
1581
|
+
* Type representing a nullable voice channel update.
|
|
1759
1582
|
*/
|
|
1760
|
-
|
|
1761
|
-
/**
|
|
1762
|
-
*
|
|
1763
|
-
* Get the value for a key in the storage.
|
|
1764
|
-
* @param {K} key The key to get the value for.
|
|
1765
|
-
* @returns {V | undefined} The value for the key, or undefined if it doesn't exist.
|
|
1766
|
-
*/
|
|
1767
|
-
get<K extends StorageKeys, V extends StorageValues<K>>(key: K): V | undefined;
|
|
1768
|
-
/**
|
|
1769
|
-
* Set the value for a key in the storage.
|
|
1770
|
-
* @param {K} key The key to set the value for.
|
|
1771
|
-
* @param {V} value The value to set for the key.
|
|
1772
|
-
*/
|
|
1773
|
-
set<K extends StorageKeys, V extends StorageValues<K>>(key: K, value: V): void;
|
|
1774
|
-
/**
|
|
1775
|
-
* Check if the storage has a key.
|
|
1776
|
-
* @param {K} key The key to check for.
|
|
1777
|
-
* @returns {boolean} True if the storage has the key, false otherwise.
|
|
1778
|
-
*/
|
|
1779
|
-
has(key: K): boolean;
|
|
1780
|
-
/**
|
|
1781
|
-
* Delete a key from the storage.
|
|
1782
|
-
* @param {K} key The key to delete.
|
|
1783
|
-
* @returns {boolean} True if the key was deleted, false otherwise.
|
|
1784
|
-
*/
|
|
1785
|
-
delete(key: K): boolean;
|
|
1786
|
-
/**
|
|
1787
|
-
* Get all keys in the storage.
|
|
1788
|
-
* @returns {K[]} The keys in the storage.
|
|
1789
|
-
*/
|
|
1790
|
-
keys<K extends StorageKeys[]>(): K[];
|
|
1791
|
-
/**
|
|
1792
|
-
* Get all values in the storage.
|
|
1793
|
-
* @returns {V[]} The values in the storage.
|
|
1794
|
-
*/
|
|
1795
|
-
values<K extends StorageKeys[], V extends StorageValues<K[number]>>(): V[];
|
|
1796
|
-
/**
|
|
1797
|
-
* Get all entries in the storage.
|
|
1798
|
-
* @returns {[K, V][]} The entries in the storage.
|
|
1799
|
-
*/
|
|
1800
|
-
entries<K extends StorageKeys[], V extends StorageValues<K[number]>>(): [K, V][];
|
|
1801
|
-
/**
|
|
1802
|
-
*
|
|
1803
|
-
* Get all key-value pairs in the storage.
|
|
1804
|
-
* @returns {Record<K[number], V>} An object containing all key-value pairs in the storage, excluding internal keys.
|
|
1805
|
-
*/
|
|
1806
|
-
all<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Record<K[number], V>;
|
|
1807
|
-
/**
|
|
1808
|
-
* Clear the storage.
|
|
1809
|
-
*/
|
|
1810
|
-
clear(): void;
|
|
1811
|
-
/**
|
|
1812
|
-
* Get the size of the storage.
|
|
1813
|
-
* @returns {number} The number of entries in the storage.
|
|
1814
|
-
*/
|
|
1815
|
-
get size(): number;
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1583
|
+
type NullableVoiceChannelUpdate = Partial<Nullable<VoiceChannelUpdate>>;
|
|
1818
1584
|
/**
|
|
1819
1585
|
* Class representing a Hoshimi player.
|
|
1820
1586
|
* @class Player
|
|
@@ -1822,10 +1588,10 @@ declare class PlayerStorage<K extends StorageKeys = StorageKeys, V extends Stora
|
|
|
1822
1588
|
declare class Player {
|
|
1823
1589
|
/**
|
|
1824
1590
|
* The data for the player.
|
|
1825
|
-
* @type {
|
|
1591
|
+
* @type {PlayerStorageAdapter}
|
|
1826
1592
|
* @readonly
|
|
1827
1593
|
*/
|
|
1828
|
-
readonly data:
|
|
1594
|
+
readonly data: PlayerStorageAdapter;
|
|
1829
1595
|
/**
|
|
1830
1596
|
* The options for the player.
|
|
1831
1597
|
* @type {PlayerOptions}
|
|
@@ -1968,6 +1734,12 @@ declare class Player {
|
|
|
1968
1734
|
* @readonly
|
|
1969
1735
|
*/
|
|
1970
1736
|
readonly lyrics: LyricsMethods;
|
|
1737
|
+
/**
|
|
1738
|
+
*
|
|
1739
|
+
* Check if the player is currently playing a track.
|
|
1740
|
+
* @returns {boolean} Whether the player is currently playing a track.
|
|
1741
|
+
*/
|
|
1742
|
+
isPlaying(): boolean;
|
|
1971
1743
|
/**
|
|
1972
1744
|
*
|
|
1973
1745
|
* Search for a track or playlist.
|
|
@@ -2113,7 +1885,7 @@ declare class Player {
|
|
|
2113
1885
|
setLoop(mode: LoopMode): this;
|
|
2114
1886
|
/**
|
|
2115
1887
|
* Set the voice of the player.
|
|
2116
|
-
* @param {
|
|
1888
|
+
* @param {NullableVoiceChannelUpdate} options The voice state to set.
|
|
2117
1889
|
* @returns {Promise<void>}
|
|
2118
1890
|
* @example
|
|
2119
1891
|
* ```ts
|
|
@@ -2121,7 +1893,7 @@ declare class Player {
|
|
|
2121
1893
|
* player.setVoice({ voiceId: "newVoiceId" });
|
|
2122
1894
|
* ```
|
|
2123
1895
|
*/
|
|
2124
|
-
setVoice(
|
|
1896
|
+
setVoice(options?: NullableVoiceChannelUpdate): Promise<void>;
|
|
2125
1897
|
/**
|
|
2126
1898
|
*
|
|
2127
1899
|
* Change the node the player is connected to.
|
|
@@ -2139,6 +1911,12 @@ declare class Player {
|
|
|
2139
1911
|
* Update the player with new data.
|
|
2140
1912
|
* @param {NonGuildUpdatePlayerInfo} data The data to update the player with.
|
|
2141
1913
|
* @returns {Promise<LavalinkPlayer | null>} The updated player data.
|
|
1914
|
+
* @example
|
|
1915
|
+
* ```ts
|
|
1916
|
+
* const player = manager.getPlayer("guildId");
|
|
1917
|
+
* const updatedPlayer = await player.updatePlayer({ volume: 50 });
|
|
1918
|
+
* console.log(updatedPlayer); // the updated player data
|
|
1919
|
+
* ```
|
|
2142
1920
|
*/
|
|
2143
1921
|
updatePlayer(data: NonGuildUpdatePlayerInfo): Promise<LavalinkPlayer | null>;
|
|
2144
1922
|
/**
|
|
@@ -2165,25 +1943,188 @@ interface CustomizablePlayerStorage {
|
|
|
2165
1943
|
}
|
|
2166
1944
|
|
|
2167
1945
|
/**
|
|
2168
|
-
*
|
|
1946
|
+
* Type representing the customizable player storage.
|
|
1947
|
+
*/
|
|
1948
|
+
type StorageKeys = keyof CustomizablePlayerStorage | (string & {});
|
|
1949
|
+
/**
|
|
1950
|
+
* Type representing the customizable player storage values.
|
|
1951
|
+
*/
|
|
1952
|
+
type StorageValues<V extends StorageKeys = StorageKeys> = V extends keyof CustomizablePlayerStorage ? CustomizablePlayerStorage[V] : unknown;
|
|
1953
|
+
/**
|
|
1954
|
+
* Class representing a player storage adapter.
|
|
2169
1955
|
* @abstract
|
|
2170
|
-
* @class
|
|
1956
|
+
* @class PlayerStorageAdapter
|
|
2171
1957
|
* @example
|
|
2172
1958
|
* ```ts
|
|
2173
|
-
* class
|
|
1959
|
+
* class MyPlayerStorageAdapter extends PlayerStorageAdapter {};
|
|
2174
1960
|
*
|
|
2175
|
-
* const storage = new
|
|
2176
|
-
* storage.set("key", "value");
|
|
1961
|
+
* const storage = new MyPlayerStorageAdapter();
|
|
1962
|
+
* await storage.set("key", "value");
|
|
2177
1963
|
*
|
|
2178
1964
|
* const value = await storage.get("key");
|
|
2179
1965
|
* console.log(value); // "value"
|
|
2180
1966
|
* ```
|
|
2181
1967
|
*/
|
|
2182
|
-
declare abstract class
|
|
1968
|
+
declare abstract class PlayerStorageAdapter {
|
|
2183
1969
|
/**
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
* @
|
|
1970
|
+
* The namespace of the storage.
|
|
1971
|
+
* @type {string}
|
|
1972
|
+
* @default "hoshimiplayer"
|
|
1973
|
+
* @example
|
|
1974
|
+
* ```ts
|
|
1975
|
+
* console.log(storage.namespace); // "hoshimiplayer"
|
|
1976
|
+
* ```
|
|
1977
|
+
*/
|
|
1978
|
+
namespace: string;
|
|
1979
|
+
/**
|
|
1980
|
+
*
|
|
1981
|
+
* Get the value using the key.
|
|
1982
|
+
* @param {string} key The key to get the value from.
|
|
1983
|
+
* @returns {Awaitable<T | undefined>} The value of the key.
|
|
1984
|
+
* @example
|
|
1985
|
+
* ```ts
|
|
1986
|
+
* const value = await storage.get("key");
|
|
1987
|
+
* console.log(value); // "value"
|
|
1988
|
+
* ```
|
|
1989
|
+
*/
|
|
1990
|
+
abstract get<K extends StorageKeys, V extends StorageValues<K>>(key: K): Awaitable<V | undefined>;
|
|
1991
|
+
/**
|
|
1992
|
+
*
|
|
1993
|
+
* Set the value using the key.
|
|
1994
|
+
* @param {string} key The key to set the value to.
|
|
1995
|
+
* @param {unknown} value The value to set.
|
|
1996
|
+
* @returns {Awaitable<void>} Did you know this can be async?
|
|
1997
|
+
* @example
|
|
1998
|
+
* ```ts
|
|
1999
|
+
* await storage.set("key", "value");
|
|
2000
|
+
* ```
|
|
2001
|
+
*/
|
|
2002
|
+
abstract set<K extends StorageKeys, V extends StorageValues<K>>(key: K, value: V): Awaitable<void>;
|
|
2003
|
+
/**
|
|
2004
|
+
*
|
|
2005
|
+
* Delete the value using the key.
|
|
2006
|
+
* @param {string} key The key to delete the value from.
|
|
2007
|
+
* @returns {Awaitable<boolean>} Returns true if the key was deleted.
|
|
2008
|
+
* @example
|
|
2009
|
+
* ```ts
|
|
2010
|
+
* const success = await storage.delete("key");
|
|
2011
|
+
* console.log(success); // true
|
|
2012
|
+
* ```
|
|
2013
|
+
*/
|
|
2014
|
+
abstract delete<K extends StorageKeys>(key: K): Awaitable<boolean>;
|
|
2015
|
+
/**
|
|
2016
|
+
* Clear the storage.
|
|
2017
|
+
* @returns {Awaitable<void>} Scary, right?
|
|
2018
|
+
* @example
|
|
2019
|
+
* ```ts
|
|
2020
|
+
* await storage.clear();
|
|
2021
|
+
* ```
|
|
2022
|
+
*/
|
|
2023
|
+
abstract clear(): Awaitable<void>;
|
|
2024
|
+
/**
|
|
2025
|
+
* Check if the storage has the key.
|
|
2026
|
+
* @param {string} key The key to check.
|
|
2027
|
+
* @returns {Awaitable<boolean>} Return true if the key exists.
|
|
2028
|
+
* @example
|
|
2029
|
+
* ```ts
|
|
2030
|
+
* const exists = await storage.has("key");
|
|
2031
|
+
* console.log(exists); // true
|
|
2032
|
+
* ```
|
|
2033
|
+
*/
|
|
2034
|
+
abstract has<K extends StorageKeys>(key: K): Awaitable<boolean>;
|
|
2035
|
+
/**
|
|
2036
|
+
* Get all keys in the storage.
|
|
2037
|
+
* @returns {Awaitable<K[]>} The keys in the storage.
|
|
2038
|
+
* @example
|
|
2039
|
+
* ```ts
|
|
2040
|
+
* const keys = await storage.keys();
|
|
2041
|
+
* console.log(keys); // ["key1", "key2"]
|
|
2042
|
+
* ```
|
|
2043
|
+
*/
|
|
2044
|
+
abstract keys<K extends StorageKeys[]>(): Awaitable<K[]>;
|
|
2045
|
+
/**
|
|
2046
|
+
* Get all values in the storage.
|
|
2047
|
+
* @returns {Awaitable<V[]>} The values in the storage.
|
|
2048
|
+
* @example
|
|
2049
|
+
* ```ts
|
|
2050
|
+
* const values = await storage.values();
|
|
2051
|
+
* console.log(values); // ["value1", "value2"]
|
|
2052
|
+
* ```
|
|
2053
|
+
*/
|
|
2054
|
+
abstract values<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Awaitable<V[]>;
|
|
2055
|
+
/**
|
|
2056
|
+
* Get all entries in the storage.
|
|
2057
|
+
* @returns {Awaitable<[K, V][]>} The entries in the storage.
|
|
2058
|
+
* @example
|
|
2059
|
+
* ```ts
|
|
2060
|
+
* const entries = await storage.entries();
|
|
2061
|
+
* console.log(entries); // [["key1", "value1"], ["key2", "value2"]]
|
|
2062
|
+
* ```
|
|
2063
|
+
*/
|
|
2064
|
+
abstract entries<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Awaitable<[K, V][]>;
|
|
2065
|
+
/**
|
|
2066
|
+
* Get all key-value pairs in the storage.
|
|
2067
|
+
* @returns {Awaitable<Record<K[number], V>>} An object containing all key-value pairs in the storage, excluding internal keys.
|
|
2068
|
+
* @example
|
|
2069
|
+
* ```ts
|
|
2070
|
+
* const all = await storage.all();
|
|
2071
|
+
* console.log(all); // { key1: "value1", key2: "value2" }
|
|
2072
|
+
* ```
|
|
2073
|
+
*/
|
|
2074
|
+
abstract all<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Awaitable<Record<K[number], V>>;
|
|
2075
|
+
/**
|
|
2076
|
+
* Get the size of the storage.
|
|
2077
|
+
* @returns {Awaitable<number>} The size of the storage.
|
|
2078
|
+
* @example
|
|
2079
|
+
* ```ts
|
|
2080
|
+
* const size = await storage.size();
|
|
2081
|
+
* console.log(size); // 2
|
|
2082
|
+
* ```
|
|
2083
|
+
*/
|
|
2084
|
+
abstract size(): Awaitable<number>;
|
|
2085
|
+
/**
|
|
2086
|
+
*
|
|
2087
|
+
* Build a key from the given parts.
|
|
2088
|
+
* @param {string[]} parts The parts to build the key from.
|
|
2089
|
+
* @returns {string} The built key.
|
|
2090
|
+
* @example
|
|
2091
|
+
* ```ts
|
|
2092
|
+
* const key = storage.buildKey("part1", "part2", "part3");
|
|
2093
|
+
* ```
|
|
2094
|
+
*/
|
|
2095
|
+
abstract buildKey(...parts: RestOrArray<string>): string;
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* Class representing a storage manager.
|
|
2100
|
+
* @abstract
|
|
2101
|
+
* @class StorageManager
|
|
2102
|
+
* @example
|
|
2103
|
+
* ```ts
|
|
2104
|
+
* class MyStorageManager extends StorageManager {};
|
|
2105
|
+
*
|
|
2106
|
+
* const storage = new MyStorageManager();
|
|
2107
|
+
* storage.set("key", "value");
|
|
2108
|
+
*
|
|
2109
|
+
* const value = await storage.get("key");
|
|
2110
|
+
* console.log(value); // "value"
|
|
2111
|
+
* ```
|
|
2112
|
+
*/
|
|
2113
|
+
declare abstract class QueueStorageAdapter<T extends QueueJson = QueueJson> {
|
|
2114
|
+
/**
|
|
2115
|
+
* The namespace of the storage.
|
|
2116
|
+
* @type {string}
|
|
2117
|
+
* @default "hoshimiqueue"
|
|
2118
|
+
* @example
|
|
2119
|
+
* ```ts
|
|
2120
|
+
* console.log(storage.namespace); // "hoshimiqueue"
|
|
2121
|
+
* ```
|
|
2122
|
+
*/
|
|
2123
|
+
namespace: string;
|
|
2124
|
+
/**
|
|
2125
|
+
*
|
|
2126
|
+
* Get the value using the key.
|
|
2127
|
+
* @param {string} key The key to get the value from.
|
|
2187
2128
|
* @returns {Awaitable<T | undefined>} The value of the key.
|
|
2188
2129
|
* @example
|
|
2189
2130
|
* ```ts
|
|
@@ -2260,6 +2201,17 @@ declare abstract class StorageAdapter<T extends QueueJson = QueueJson> {
|
|
|
2260
2201
|
* ```
|
|
2261
2202
|
*/
|
|
2262
2203
|
abstract stringify<R = string>(value: unknown): Awaitable<R>;
|
|
2204
|
+
/**
|
|
2205
|
+
*
|
|
2206
|
+
* Build a key from the given parts.
|
|
2207
|
+
* @param {string[]} parts The parts to build the key from.
|
|
2208
|
+
* @returns {string} The built key.
|
|
2209
|
+
* @example
|
|
2210
|
+
* ```ts
|
|
2211
|
+
* const key = storage.buildKey("part1", "part2", "part3");
|
|
2212
|
+
* ```
|
|
2213
|
+
*/
|
|
2214
|
+
abstract buildKey(...parts: RestOrArray<string>): string;
|
|
2263
2215
|
}
|
|
2264
2216
|
|
|
2265
2217
|
/**
|
|
@@ -2271,7 +2223,7 @@ interface HoshimiQueueOptions {
|
|
|
2271
2223
|
* @type {number}
|
|
2272
2224
|
* @default 25
|
|
2273
2225
|
*/
|
|
2274
|
-
|
|
2226
|
+
maxHistory?: number;
|
|
2275
2227
|
/**
|
|
2276
2228
|
*
|
|
2277
2229
|
* The function to use for autoplay.
|
|
@@ -2287,10 +2239,10 @@ interface HoshimiQueueOptions {
|
|
|
2287
2239
|
autoPlay?: boolean;
|
|
2288
2240
|
/**
|
|
2289
2241
|
* The storage manager to use for the queue.
|
|
2290
|
-
* @type {
|
|
2242
|
+
* @type {QueueStorageAdapter}
|
|
2291
2243
|
* @default {MemoryAdapter}
|
|
2292
2244
|
*/
|
|
2293
|
-
storage?:
|
|
2245
|
+
storage?: QueueStorageAdapter;
|
|
2294
2246
|
}
|
|
2295
2247
|
/**
|
|
2296
2248
|
* The queue json.
|
|
@@ -2314,613 +2266,206 @@ interface QueueJson {
|
|
|
2314
2266
|
}
|
|
2315
2267
|
|
|
2316
2268
|
/**
|
|
2317
|
-
*
|
|
2318
|
-
* @class QueueUtils
|
|
2269
|
+
* Partial Lavalink track type.
|
|
2319
2270
|
*/
|
|
2320
|
-
|
|
2271
|
+
type PartialLavalinkTrack = Partial<Nullable<LavalinkTrack>>;
|
|
2272
|
+
/**
|
|
2273
|
+
* The base options for playing a track.
|
|
2274
|
+
*/
|
|
2275
|
+
interface BasePlayOptions {
|
|
2321
2276
|
/**
|
|
2322
|
-
*
|
|
2323
|
-
*
|
|
2324
|
-
* @param {QueueStructure} queue The queue instance.
|
|
2277
|
+
* The position to start the track.
|
|
2278
|
+
* @type {number | undefined}
|
|
2325
2279
|
*/
|
|
2326
|
-
|
|
2280
|
+
position?: number;
|
|
2327
2281
|
/**
|
|
2328
|
-
*
|
|
2329
|
-
*
|
|
2330
|
-
* @returns {Awaitable<void>}
|
|
2331
|
-
* @example
|
|
2332
|
-
* ```ts
|
|
2333
|
-
* await player.queue.utils.save();
|
|
2334
|
-
* ```
|
|
2282
|
+
* The position to end the track.
|
|
2283
|
+
* @type {number | undefined}
|
|
2335
2284
|
*/
|
|
2336
|
-
|
|
2285
|
+
endTime?: number;
|
|
2337
2286
|
/**
|
|
2338
|
-
*
|
|
2339
|
-
*
|
|
2340
|
-
* @returns {Promise<void>}
|
|
2341
|
-
* @example
|
|
2342
|
-
* ```ts
|
|
2343
|
-
* await player.queue.utils.destroy();
|
|
2344
|
-
* ```
|
|
2287
|
+
* The pause state of the player.
|
|
2288
|
+
* @type {boolean | undefined}
|
|
2345
2289
|
*/
|
|
2346
|
-
|
|
2290
|
+
paused?: boolean;
|
|
2347
2291
|
/**
|
|
2348
|
-
*
|
|
2349
|
-
*
|
|
2350
|
-
* @returns {Awaitable<void>}
|
|
2351
|
-
* @example
|
|
2352
|
-
* ```ts
|
|
2353
|
-
* await player.queue.utils.sync();
|
|
2354
|
-
* ```
|
|
2292
|
+
* The volume of the player.
|
|
2293
|
+
* @type {number | undefined}
|
|
2355
2294
|
*/
|
|
2356
|
-
|
|
2295
|
+
volume?: number;
|
|
2296
|
+
/**
|
|
2297
|
+
* The filters for the player.
|
|
2298
|
+
* @type {Partial<FilterSettings> | undefined}
|
|
2299
|
+
*/
|
|
2300
|
+
filters?: Partial<FilterSettings>;
|
|
2301
|
+
/**
|
|
2302
|
+
* The voice settings for the player.
|
|
2303
|
+
* @type {LavalinkPlayerVoice | undefined}
|
|
2304
|
+
*/
|
|
2305
|
+
voice?: LavalinkPlayerVoice;
|
|
2357
2306
|
}
|
|
2358
|
-
|
|
2359
2307
|
/**
|
|
2360
|
-
*
|
|
2361
|
-
* @class Queue
|
|
2308
|
+
* The types of loop modes.
|
|
2362
2309
|
*/
|
|
2363
|
-
declare
|
|
2310
|
+
declare enum LoopMode {
|
|
2364
2311
|
/**
|
|
2365
|
-
*
|
|
2366
|
-
* @type {HoshimiTrack[]}
|
|
2312
|
+
* Loop mode for repeating the current track.
|
|
2367
2313
|
*/
|
|
2368
|
-
|
|
2314
|
+
Track = 1,
|
|
2369
2315
|
/**
|
|
2370
|
-
*
|
|
2371
|
-
* @type {Track[]}
|
|
2316
|
+
* Loop mode for repeating the queue.
|
|
2372
2317
|
*/
|
|
2373
|
-
|
|
2318
|
+
Queue = 2,
|
|
2374
2319
|
/**
|
|
2375
|
-
*
|
|
2376
|
-
* @type {Track | null}
|
|
2320
|
+
* Loop mode for repeating nothing.
|
|
2377
2321
|
*/
|
|
2378
|
-
|
|
2322
|
+
Off = 3
|
|
2323
|
+
}
|
|
2324
|
+
/**
|
|
2325
|
+
* The types of player events.
|
|
2326
|
+
*/
|
|
2327
|
+
declare enum PlayerEventType {
|
|
2379
2328
|
/**
|
|
2380
|
-
*
|
|
2381
|
-
* @type {PlayerStructure}
|
|
2329
|
+
* Event type for when a track starts.
|
|
2382
2330
|
*/
|
|
2383
|
-
|
|
2331
|
+
TrackStart = "TrackStartEvent",
|
|
2384
2332
|
/**
|
|
2385
|
-
*
|
|
2386
|
-
* @type {QueueUtils}
|
|
2387
|
-
* @readonly
|
|
2333
|
+
* Event type for when a track ends.
|
|
2388
2334
|
*/
|
|
2389
|
-
|
|
2335
|
+
TrackEnd = "TrackEndEvent",
|
|
2390
2336
|
/**
|
|
2391
|
-
*
|
|
2392
|
-
* Constructor of the queue.
|
|
2393
|
-
* @param {PlayerStructure} player Player instance.
|
|
2394
|
-
* @example
|
|
2395
|
-
* ```ts
|
|
2396
|
-
* const player = new Player();
|
|
2397
|
-
* const queue = new Queue(player);
|
|
2398
|
-
*
|
|
2399
|
-
* console.log(queue.size); // 0
|
|
2400
|
-
* queue.add(track);
|
|
2401
|
-
* console.log(queue.size); // 1
|
|
2402
|
-
* ```
|
|
2337
|
+
* Event type for when a track encounters an exception.
|
|
2403
2338
|
*/
|
|
2404
|
-
|
|
2339
|
+
TrackException = "TrackExceptionEvent",
|
|
2405
2340
|
/**
|
|
2406
|
-
*
|
|
2407
|
-
* @type {number}
|
|
2408
|
-
* @returns {number} The track size of the queue.
|
|
2409
|
-
* @readonly
|
|
2410
|
-
* @example
|
|
2411
|
-
* ```ts
|
|
2412
|
-
* const queue = player.queue;
|
|
2413
|
-
*
|
|
2414
|
-
* console.log(queue.size); // 0
|
|
2415
|
-
* queue.add(track);
|
|
2416
|
-
*
|
|
2417
|
-
* console.log(queue.size); // 1
|
|
2418
|
-
* queue.add([track1, track2]);
|
|
2419
|
-
*
|
|
2420
|
-
* console.log(queue.size); // 3
|
|
2421
|
-
* queue.shift();
|
|
2422
|
-
* console.log(queue.size); // 2
|
|
2423
|
-
*
|
|
2424
|
-
* queue.clear();
|
|
2425
|
-
* console.log(queue.size); // 0
|
|
2426
|
-
* ```
|
|
2341
|
+
* Event type for when a track gets stuck.
|
|
2427
2342
|
*/
|
|
2428
|
-
|
|
2343
|
+
TrackStuck = "TrackStuckEvent",
|
|
2429
2344
|
/**
|
|
2430
|
-
*
|
|
2431
|
-
* @type {number}
|
|
2432
|
-
* @returns {number} The total track size of the queue.
|
|
2433
|
-
* @readonly
|
|
2434
|
-
* @example
|
|
2435
|
-
* ```ts
|
|
2436
|
-
* const queue = player.queue;
|
|
2437
|
-
*
|
|
2438
|
-
* console.log(queue.totalSize); // 0
|
|
2439
|
-
* queue.add(track);
|
|
2440
|
-
*
|
|
2441
|
-
* console.log(queue.totalSize); // 1
|
|
2442
|
-
* queue.add([track1, track2]);
|
|
2443
|
-
*
|
|
2444
|
-
* console.log(queue.totalSize); // 3
|
|
2445
|
-
* queue.shift();
|
|
2446
|
-
* console.log(queue.totalSize); // 2
|
|
2447
|
-
*
|
|
2448
|
-
* queue.clear();
|
|
2449
|
-
* console.log(queue.totalSize); // 0
|
|
2450
|
-
* ```
|
|
2345
|
+
* Event type for when lyrics are found.
|
|
2451
2346
|
*/
|
|
2452
|
-
|
|
2347
|
+
LyricsFound = "LyricsFoundEvent",
|
|
2453
2348
|
/**
|
|
2454
|
-
*
|
|
2455
|
-
* Check if the queue is empty.
|
|
2456
|
-
* @type {boolean}
|
|
2457
|
-
* @returns {boolean} True if the queue is empty.
|
|
2458
|
-
* @readonly
|
|
2459
|
-
* @example
|
|
2460
|
-
* ```ts
|
|
2461
|
-
* const queue = player.queue;
|
|
2462
|
-
*
|
|
2463
|
-
* console.log(queue.isEmpty()); // true
|
|
2464
|
-
* queue.add(track);
|
|
2465
|
-
*
|
|
2466
|
-
* console.log(queue.isEmpty()); // false
|
|
2467
|
-
* queue.clear();
|
|
2468
|
-
*
|
|
2469
|
-
* console.log(queue.isEmpty()); // true
|
|
2470
|
-
* ```
|
|
2349
|
+
* Event type for when lyrics are not found.
|
|
2471
2350
|
*/
|
|
2472
|
-
|
|
2351
|
+
LyricsNotFound = "LyricsNotFoundEvent",
|
|
2473
2352
|
/**
|
|
2474
|
-
*
|
|
2475
|
-
* Get the previous track of the queue.
|
|
2476
|
-
* @param {boolean} [remove=false] Whether to remove the track from the previous queue.
|
|
2477
|
-
* @returns {Track | null} The previous track of the queue.
|
|
2478
|
-
* @example
|
|
2479
|
-
* ```ts
|
|
2480
|
-
* const queue = player.queue;
|
|
2481
|
-
*
|
|
2482
|
-
* console.log(queue.previous()); // null
|
|
2483
|
-
* queue.add(track);
|
|
2484
|
-
* queue.add(track2);
|
|
2485
|
-
*
|
|
2486
|
-
* console.log(queue.previous()); // track
|
|
2487
|
-
* console.log(queue.previous(true)); // track and remove it from the previous tracks
|
|
2488
|
-
* ```
|
|
2353
|
+
* Event type for when a lyrics line is sent.
|
|
2489
2354
|
*/
|
|
2490
|
-
|
|
2355
|
+
LyricsLine = "LyricsLineEvent",
|
|
2491
2356
|
/**
|
|
2492
|
-
*
|
|
2493
|
-
* Add a track or tracks to the queue.
|
|
2494
|
-
* @param {Track | Track[]} track The track or tracks to add.
|
|
2495
|
-
* @param {number} [position] The position to add the track or tracks.
|
|
2496
|
-
* @returns {this} The queue instance.
|
|
2497
|
-
* @example
|
|
2498
|
-
* ```ts
|
|
2499
|
-
* const queue = player.queue;
|
|
2500
|
-
*
|
|
2501
|
-
* console.log(queue.size); // 0
|
|
2502
|
-
*
|
|
2503
|
-
* queue.add(track);
|
|
2504
|
-
* console.log(queue.size); // 1
|
|
2505
|
-
*
|
|
2506
|
-
* queue.add([track1, track2]);
|
|
2507
|
-
* console.log(queue.size); // 3
|
|
2508
|
-
*
|
|
2509
|
-
* queue.add(track3, 1);
|
|
2510
|
-
* console.log(queue.size); // 4
|
|
2511
|
-
* console.log(queue.tracks); // [track1, track3, track2, track]
|
|
2512
|
-
* ```
|
|
2357
|
+
* Event type for when the WebSocket connection is closed.
|
|
2513
2358
|
*/
|
|
2514
|
-
|
|
2359
|
+
WebsocketClosed = "WebSocketClosedEvent"
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* The reasons a track can end.
|
|
2363
|
+
*/
|
|
2364
|
+
declare enum TrackEndReason {
|
|
2515
2365
|
/**
|
|
2516
|
-
*
|
|
2517
|
-
* Get the first track of the queue.
|
|
2518
|
-
* @returns {HoshimiTrack | null} The first track of the queue.
|
|
2519
|
-
* @example
|
|
2520
|
-
* ```ts
|
|
2521
|
-
* const queue = player.queue;
|
|
2522
|
-
*
|
|
2523
|
-
* console.log(queue.shift()); // null
|
|
2524
|
-
* queue.add(track);
|
|
2525
|
-
*
|
|
2526
|
-
* console.log(queue.shift()); // track
|
|
2527
|
-
* queue.add(track2);
|
|
2528
|
-
* ```
|
|
2366
|
+
* The track ended normally.
|
|
2529
2367
|
*/
|
|
2530
|
-
|
|
2368
|
+
Finished = "finished",
|
|
2531
2369
|
/**
|
|
2532
|
-
*
|
|
2533
|
-
* Add tracks to the beginning of the queue.
|
|
2534
|
-
* @param {Track[]} tracks The tracks to add.
|
|
2535
|
-
* @returns {this} The queue instance.
|
|
2536
|
-
* @example
|
|
2537
|
-
* ```ts
|
|
2538
|
-
* const queue = player.queue;
|
|
2539
|
-
*
|
|
2540
|
-
* console.log(queue.size); // 0
|
|
2541
|
-
* queue.unshift(track);
|
|
2542
|
-
*
|
|
2543
|
-
* console.log(queue.size); // 1
|
|
2544
|
-
* queue.unshift([track1, track2]);
|
|
2545
|
-
*
|
|
2546
|
-
* console.log(queue.size); // 3
|
|
2547
|
-
* console.log(queue.tracks); // [track1, track2, track]
|
|
2548
|
-
* ```
|
|
2370
|
+
* The track fails to load.
|
|
2549
2371
|
*/
|
|
2550
|
-
|
|
2372
|
+
LoadFailed = "loadFailed",
|
|
2551
2373
|
/**
|
|
2552
|
-
*
|
|
2553
|
-
* Shuffle the queue.
|
|
2554
|
-
* @returns {this} The queue instance.
|
|
2555
|
-
* @example
|
|
2556
|
-
* ```ts
|
|
2557
|
-
* const queue = player.queue;
|
|
2558
|
-
*
|
|
2559
|
-
* console.log(queue.size); // 0
|
|
2560
|
-
* queue.add(track);
|
|
2561
|
-
* queue.add([track1, track2]);
|
|
2562
|
-
*
|
|
2563
|
-
* console.log(queue.size); // 3
|
|
2564
|
-
* console.log(queue.tracks); // [track, track1, track2]
|
|
2565
|
-
*
|
|
2566
|
-
* queue.shuffle();
|
|
2567
|
-
* console.log(queue.tracks); // [track2, track, track1]
|
|
2568
|
-
* ```
|
|
2374
|
+
* The track was stopped.
|
|
2569
2375
|
*/
|
|
2570
|
-
|
|
2376
|
+
Stopped = "stopped",
|
|
2571
2377
|
/**
|
|
2572
|
-
*
|
|
2573
|
-
* Clear the queue.
|
|
2574
|
-
* @returns {this} The queue instance.
|
|
2575
|
-
* @example
|
|
2576
|
-
* ```ts
|
|
2577
|
-
* const queue = player.queue;
|
|
2578
|
-
*
|
|
2579
|
-
* console.log(queue.size); // 0
|
|
2580
|
-
* queue.add(track);
|
|
2581
|
-
* queue.add([track1, track2]);
|
|
2582
|
-
*
|
|
2583
|
-
* console.log(queue.size); // 3
|
|
2584
|
-
* queue.clear();
|
|
2585
|
-
* console.log(queue.size); // 0
|
|
2586
|
-
* ```
|
|
2378
|
+
* The track was replaced.
|
|
2587
2379
|
*/
|
|
2588
|
-
|
|
2380
|
+
Replaced = "replaced",
|
|
2589
2381
|
/**
|
|
2590
|
-
*
|
|
2591
|
-
* Move a track to a specific position in the queue.
|
|
2592
|
-
* @param {Track} track The track to move.
|
|
2593
|
-
* @param {number} to The position to move.
|
|
2594
|
-
* @returns {this} The queue instance.
|
|
2382
|
+
* The track was cleaned up.
|
|
2595
2383
|
*/
|
|
2596
|
-
|
|
2384
|
+
Cleanup = "cleanup"
|
|
2385
|
+
}
|
|
2386
|
+
/**
|
|
2387
|
+
* The options for automatic player error handling.
|
|
2388
|
+
*/
|
|
2389
|
+
interface ErrorPlayerActions {
|
|
2597
2390
|
/**
|
|
2598
|
-
*
|
|
2599
|
-
*
|
|
2600
|
-
* @
|
|
2601
|
-
* @param {number} deleteCount The number of tracks to delete.
|
|
2602
|
-
* @param {Track | Track[]} [tracks] The tracks to add.
|
|
2603
|
-
* @returns {this} The queue instance.
|
|
2391
|
+
* Whether to automatically destroy the player on disconnect or error.
|
|
2392
|
+
* @type {boolean | undefined}
|
|
2393
|
+
* @default false
|
|
2604
2394
|
*/
|
|
2605
|
-
|
|
2395
|
+
autoDestroy?: boolean;
|
|
2606
2396
|
/**
|
|
2607
|
-
*
|
|
2608
|
-
*
|
|
2609
|
-
* @
|
|
2397
|
+
* Whether to automatically skip the track on error
|
|
2398
|
+
* @type {boolean | undefined}
|
|
2399
|
+
* @default false
|
|
2610
2400
|
*/
|
|
2611
|
-
|
|
2401
|
+
autoSkip?: boolean;
|
|
2402
|
+
/**
|
|
2403
|
+
* Whether to automatically stop the player on error.
|
|
2404
|
+
* @type {boolean | undefined}
|
|
2405
|
+
* @default false
|
|
2406
|
+
*/
|
|
2407
|
+
autoStop?: boolean;
|
|
2612
2408
|
}
|
|
2613
|
-
|
|
2614
|
-
/**
|
|
2615
|
-
* The structure for the Player class.
|
|
2616
|
-
*/
|
|
2617
|
-
type PlayerStructure = InferCustomStructure<Player, "Player">;
|
|
2618
|
-
/**
|
|
2619
|
-
* The structure for the Rest class.
|
|
2620
|
-
*/
|
|
2621
|
-
type RestStructure = InferCustomStructure<Rest, "Rest">;
|
|
2622
|
-
/**
|
|
2623
|
-
* The structure for the Node class.
|
|
2624
|
-
*/
|
|
2625
|
-
type NodeStructure = InferCustomStructure<Node, "Node">;
|
|
2626
|
-
/**
|
|
2627
|
-
* The structure for the Queue class.
|
|
2628
|
-
*/
|
|
2629
|
-
type QueueStructure = InferCustomStructure<Queue, "Queue">;
|
|
2630
2409
|
/**
|
|
2631
|
-
* The
|
|
2632
|
-
*/
|
|
2633
|
-
type LyricsManagerStructure = InferCustomStructure<LyricsManager, "LyricsManager">;
|
|
2634
|
-
/**
|
|
2635
|
-
* The structure for the NodeManager class.
|
|
2636
|
-
*/
|
|
2637
|
-
type NodeManagerStructure = InferCustomStructure<NodeManager, "NodeManager">;
|
|
2638
|
-
/**
|
|
2639
|
-
* The structure for the FilterManager class.
|
|
2640
|
-
*/
|
|
2641
|
-
type FilterManagerStructure = InferCustomStructure<FilterManager, "FilterManager">;
|
|
2642
|
-
/**
|
|
2643
|
-
* The structures of the Hoshimi classes.
|
|
2644
|
-
*/
|
|
2645
|
-
declare const Structures: {
|
|
2646
|
-
Player(manager: Hoshimi, options: PlayerOptions): PlayerStructure;
|
|
2647
|
-
Rest(node: Node): RestStructure;
|
|
2648
|
-
Node(nodeManager: NodeManager, options: NodeOptions): NodeStructure;
|
|
2649
|
-
Queue(player: Player): QueueStructure;
|
|
2650
|
-
LyricsManager(node: Node): LyricsManagerStructure;
|
|
2651
|
-
NodeManager(manager: Hoshimi): NodeManagerStructure;
|
|
2652
|
-
FilterManager(player: Player): FilterManagerStructure;
|
|
2653
|
-
};
|
|
2654
|
-
/**
|
|
2655
|
-
* Infers the custom structure for a given class.
|
|
2410
|
+
* The options for error actions.
|
|
2656
2411
|
*/
|
|
2657
|
-
|
|
2658
|
-
|
|
2412
|
+
interface DisconnectPlayerActions extends Pick<ErrorPlayerActions, "autoDestroy"> {
|
|
2413
|
+
/**
|
|
2414
|
+
* Whether to automatically reconnect on disconnect.
|
|
2415
|
+
* @type {boolean | undefined}
|
|
2416
|
+
* @default false
|
|
2417
|
+
*/
|
|
2418
|
+
autoReconnect?: boolean;
|
|
2419
|
+
/**
|
|
2420
|
+
* Whether to automatically add tracks back to the queue on disconnect.
|
|
2421
|
+
* @type {boolean | undefined}
|
|
2422
|
+
* @default false
|
|
2423
|
+
*/
|
|
2424
|
+
autoQueue?: boolean;
|
|
2425
|
+
}
|
|
2659
2426
|
/**
|
|
2660
|
-
*
|
|
2661
|
-
* @class Track
|
|
2662
|
-
* @implements {LavalinkTrack}
|
|
2427
|
+
* The Hoshimi player options.
|
|
2663
2428
|
*/
|
|
2664
|
-
|
|
2429
|
+
interface HoshimiPlayerOptions {
|
|
2665
2430
|
/**
|
|
2666
|
-
*
|
|
2667
|
-
*
|
|
2431
|
+
*
|
|
2432
|
+
* The function to use to get the requester data.
|
|
2433
|
+
* @param {TrackRequester} requester The requester of the track.
|
|
2668
2434
|
*/
|
|
2669
|
-
|
|
2435
|
+
requesterFn?<T extends TrackRequester = TrackRequester>(requester: TrackRequester): Awaitable<T>;
|
|
2670
2436
|
/**
|
|
2671
|
-
* The
|
|
2672
|
-
* @type {
|
|
2437
|
+
* The options for handling errors.
|
|
2438
|
+
* @type {ErrorPlayerActions | undefined}
|
|
2673
2439
|
*/
|
|
2674
|
-
|
|
2440
|
+
onError?: ErrorPlayerActions;
|
|
2675
2441
|
/**
|
|
2676
|
-
* The
|
|
2677
|
-
* @type {
|
|
2442
|
+
* The options for handling disconnects.
|
|
2443
|
+
* @type {DisconnectPlayerActions | undefined}
|
|
2678
2444
|
*/
|
|
2679
|
-
|
|
2445
|
+
onDisconnect?: DisconnectPlayerActions;
|
|
2680
2446
|
/**
|
|
2681
|
-
* The
|
|
2682
|
-
* @type {
|
|
2447
|
+
* The customizable player storage adapter.
|
|
2448
|
+
* @type {PlayerStorageAdapter | undefined}
|
|
2449
|
+
* @default {PlayerMemoryStorage}
|
|
2683
2450
|
*/
|
|
2684
|
-
|
|
2451
|
+
storage?: PlayerStorageAdapter;
|
|
2452
|
+
}
|
|
2453
|
+
/**
|
|
2454
|
+
* The base interface for player events.
|
|
2455
|
+
*/
|
|
2456
|
+
interface PlayerEvent<E extends PlayerEventType> {
|
|
2685
2457
|
/**
|
|
2686
|
-
* The
|
|
2687
|
-
* @type {
|
|
2458
|
+
* The type of the event.
|
|
2459
|
+
* @type {E}
|
|
2688
2460
|
*/
|
|
2689
|
-
|
|
2690
|
-
/**
|
|
2691
|
-
* The constructor for the track.
|
|
2692
|
-
* @param {LavalinkTrack} track The track to construct the track from.
|
|
2693
|
-
* @param {TrackRequester} requester The requester of the track.
|
|
2694
|
-
* @example
|
|
2695
|
-
* ```ts
|
|
2696
|
-
* const track = new Track({
|
|
2697
|
-
* encoded: "base64",
|
|
2698
|
-
* info: {
|
|
2699
|
-
* title: "Track Title",
|
|
2700
|
-
* uri: "https://example.com",
|
|
2701
|
-
* duration: 300000,
|
|
2702
|
-
* },
|
|
2703
|
-
* // the rest of the track info
|
|
2704
|
-
* }, requester);
|
|
2705
|
-
*
|
|
2706
|
-
* console.log(track.encoded); // the track encoded in base64
|
|
2707
|
-
* ```
|
|
2708
|
-
*/
|
|
2709
|
-
constructor(track: LavalinkTrack | null, requester?: TrackRequester);
|
|
2710
|
-
/**
|
|
2711
|
-
*
|
|
2712
|
-
* Get the hyperlink of the track.
|
|
2713
|
-
* @param {boolean} [embedable=true] Whether the hyperlink should be embedable or not.
|
|
2714
|
-
* @returns {string} The hyperlink of the track.
|
|
2715
|
-
* @example
|
|
2716
|
-
* ```ts
|
|
2717
|
-
* const track = queue.current;
|
|
2718
|
-
* console.log(track.toHyperlink()); // [Track Title](https://example.com)
|
|
2719
|
-
* console.log(track.toHyperlink(false)); // [Track Title](<https://example.com>)
|
|
2720
|
-
* ```
|
|
2721
|
-
*/
|
|
2722
|
-
toHyperlink(embedable?: boolean): string;
|
|
2723
|
-
}
|
|
2724
|
-
/**
|
|
2725
|
-
* Class representing an unresolved track.
|
|
2726
|
-
* @class UnresolvedTrack
|
|
2727
|
-
* @implements {UnresolvedLavalinkTrack}
|
|
2728
|
-
*/
|
|
2729
|
-
declare class UnresolvedTrack implements UnresolvedLavalinkTrack {
|
|
2730
|
-
/**
|
|
2731
|
-
* The base64 encoded track.
|
|
2732
|
-
* @type {string | undefined}
|
|
2733
|
-
*/
|
|
2734
|
-
readonly encoded?: string;
|
|
2735
|
-
/**
|
|
2736
|
-
* The track info.
|
|
2737
|
-
* @type {UnresolvedTrackInfo}
|
|
2738
|
-
*/
|
|
2739
|
-
readonly info: UnresolvedTrackInfo;
|
|
2740
|
-
/**
|
|
2741
|
-
* The plugin info of the track.
|
|
2742
|
-
* @type {Partial<PluginInfo>}
|
|
2743
|
-
*/
|
|
2744
|
-
readonly pluginInfo?: Partial<PluginInfo>;
|
|
2745
|
-
/**
|
|
2746
|
-
* The track user data.
|
|
2747
|
-
* @type {Record<string, unknown> | undefined}
|
|
2748
|
-
*/
|
|
2749
|
-
userData?: Record<string, unknown>;
|
|
2750
|
-
/**
|
|
2751
|
-
* The requester of the track.
|
|
2752
|
-
* @type {TrackRequester | undefined}
|
|
2753
|
-
*/
|
|
2754
|
-
requester: TrackRequester;
|
|
2755
|
-
/**
|
|
2756
|
-
* The constructor for the track.
|
|
2757
|
-
* @param {UnresolvedLavalinkTrack} track The track to construct the track from.
|
|
2758
|
-
* @param {TrackRequester} requester The requester of the track.
|
|
2759
|
-
* @example
|
|
2760
|
-
* ```ts
|
|
2761
|
-
* const track = new UnresolvedTrack({
|
|
2762
|
-
* encoded: "base64",
|
|
2763
|
-
* info: {
|
|
2764
|
-
* title: "Track Title",
|
|
2765
|
-
* },
|
|
2766
|
-
* // the rest of the track info
|
|
2767
|
-
* }, requester);
|
|
2768
|
-
*
|
|
2769
|
-
* console.log(track.encoded); // the track encoded in base64
|
|
2770
|
-
* ```
|
|
2771
|
-
*/
|
|
2772
|
-
constructor(track: UnresolvedLavalinkTrack, requester: TrackRequester);
|
|
2773
|
-
/**
|
|
2774
|
-
* Resolves the track to a playable track.
|
|
2775
|
-
* @param {PlayerStructure} player The player to resolve the track for.
|
|
2776
|
-
* @returns {Promise<Track>} The resolved track.
|
|
2777
|
-
* @throws {ResolveError} If the track cannot be resolved.
|
|
2778
|
-
*/
|
|
2779
|
-
resolve(player: PlayerStructure): Promise<Track>;
|
|
2780
|
-
}
|
|
2781
|
-
/**
|
|
2782
|
-
* Type representing a Hoshimi track, which can be either a resolved or unresolved track.
|
|
2783
|
-
*/
|
|
2784
|
-
type HoshimiTrack = Track | UnresolvedTrack;
|
|
2785
|
-
/**
|
|
2786
|
-
* Interface representing an extendable track.
|
|
2787
|
-
*/
|
|
2788
|
-
interface CustomizableTrack {
|
|
2789
|
-
}
|
|
2790
|
-
/**
|
|
2791
|
-
* The requester of the track.
|
|
2792
|
-
*/
|
|
2793
|
-
type TrackRequester = Inferable<CustomizableTrack, "requester">;
|
|
2794
|
-
|
|
2795
|
-
/**
|
|
2796
|
-
* Partial Lavalink track type.
|
|
2797
|
-
*/
|
|
2798
|
-
type PartialLavalinkTrack = Partial<Nullable<LavalinkTrack>>;
|
|
2799
|
-
/**
|
|
2800
|
-
* The base options for playing a track.
|
|
2801
|
-
*/
|
|
2802
|
-
interface BasePlayOptions {
|
|
2803
|
-
/**
|
|
2804
|
-
* The position to start the track.
|
|
2805
|
-
* @type {number | undefined}
|
|
2806
|
-
*/
|
|
2807
|
-
position?: number;
|
|
2808
|
-
/**
|
|
2809
|
-
* The position to end the track.
|
|
2810
|
-
* @type {number | undefined}
|
|
2811
|
-
*/
|
|
2812
|
-
endTime?: number;
|
|
2813
|
-
/**
|
|
2814
|
-
* The pause state of the player.
|
|
2815
|
-
* @type {boolean | undefined}
|
|
2816
|
-
*/
|
|
2817
|
-
paused?: boolean;
|
|
2818
|
-
/**
|
|
2819
|
-
* The volume of the player.
|
|
2820
|
-
* @type {number | undefined}
|
|
2821
|
-
*/
|
|
2822
|
-
volume?: number;
|
|
2823
|
-
/**
|
|
2824
|
-
* The filters for the player.
|
|
2825
|
-
* @type {Partial<FilterSettings> | undefined}
|
|
2826
|
-
*/
|
|
2827
|
-
filters?: Partial<FilterSettings>;
|
|
2828
|
-
/**
|
|
2829
|
-
* The voice settings for the player.
|
|
2830
|
-
* @type {LavalinkPlayerVoice | undefined}
|
|
2831
|
-
*/
|
|
2832
|
-
voice?: LavalinkPlayerVoice;
|
|
2833
|
-
}
|
|
2834
|
-
/**
|
|
2835
|
-
* The types of loop modes.
|
|
2836
|
-
*/
|
|
2837
|
-
declare enum LoopMode {
|
|
2838
|
-
/**
|
|
2839
|
-
* Loop mode for repeating the current track.
|
|
2840
|
-
*/
|
|
2841
|
-
Track = 1,
|
|
2842
|
-
/**
|
|
2843
|
-
* Loop mode for repeating the queue.
|
|
2844
|
-
*/
|
|
2845
|
-
Queue = 2,
|
|
2846
|
-
/**
|
|
2847
|
-
* Loop mode for repeating nothing.
|
|
2848
|
-
*/
|
|
2849
|
-
Off = 3
|
|
2850
|
-
}
|
|
2851
|
-
/**
|
|
2852
|
-
* The types of player events.
|
|
2853
|
-
*/
|
|
2854
|
-
declare enum PlayerEventType {
|
|
2855
|
-
/**
|
|
2856
|
-
* Event type for when a track starts.
|
|
2857
|
-
*/
|
|
2858
|
-
TrackStart = "TrackStartEvent",
|
|
2859
|
-
/**
|
|
2860
|
-
* Event type for when a track ends.
|
|
2861
|
-
*/
|
|
2862
|
-
TrackEnd = "TrackEndEvent",
|
|
2863
|
-
/**
|
|
2864
|
-
* Event type for when a track encounters an exception.
|
|
2865
|
-
*/
|
|
2866
|
-
TrackException = "TrackExceptionEvent",
|
|
2867
|
-
/**
|
|
2868
|
-
* Event type for when a track gets stuck.
|
|
2869
|
-
*/
|
|
2870
|
-
TrackStuck = "TrackStuckEvent",
|
|
2871
|
-
/**
|
|
2872
|
-
* Event type for when lyrics are found.
|
|
2873
|
-
*/
|
|
2874
|
-
LyricsFound = "LyricsFoundEvent",
|
|
2875
|
-
/**
|
|
2876
|
-
* Event type for when lyrics are not found.
|
|
2877
|
-
*/
|
|
2878
|
-
LyricsNotFound = "LyricsNotFoundEvent",
|
|
2879
|
-
/**
|
|
2880
|
-
* Event type for when a lyrics line is sent.
|
|
2881
|
-
*/
|
|
2882
|
-
LyricsLine = "LyricsLineEvent",
|
|
2883
|
-
/**
|
|
2884
|
-
* Event type for when the WebSocket connection is closed.
|
|
2885
|
-
*/
|
|
2886
|
-
WebsocketClosed = "WebSocketClosedEvent"
|
|
2887
|
-
}
|
|
2888
|
-
/**
|
|
2889
|
-
* The reasons a track can end.
|
|
2890
|
-
*/
|
|
2891
|
-
declare enum TrackEndReason {
|
|
2892
|
-
/**
|
|
2893
|
-
* The track ended normally.
|
|
2894
|
-
*/
|
|
2895
|
-
Finished = "finished",
|
|
2896
|
-
/**
|
|
2897
|
-
* The track fails to load.
|
|
2898
|
-
*/
|
|
2899
|
-
LoadFailed = "loadFailed",
|
|
2900
|
-
/**
|
|
2901
|
-
* The track was stopped.
|
|
2902
|
-
*/
|
|
2903
|
-
Stopped = "stopped",
|
|
2904
|
-
/**
|
|
2905
|
-
* The track was replaced.
|
|
2906
|
-
*/
|
|
2907
|
-
Replaced = "replaced",
|
|
2908
|
-
/**
|
|
2909
|
-
* The track was cleaned up.
|
|
2910
|
-
*/
|
|
2911
|
-
Cleanup = "cleanup"
|
|
2912
|
-
}
|
|
2913
|
-
/**
|
|
2914
|
-
* The base interface for player events.
|
|
2915
|
-
*/
|
|
2916
|
-
interface PlayerEvent {
|
|
2461
|
+
type: E;
|
|
2917
2462
|
/**
|
|
2918
2463
|
* The operation code for the event.
|
|
2919
2464
|
* @type {OpCodes.Event}
|
|
2920
2465
|
*/
|
|
2921
2466
|
op: OpCodes.Event;
|
|
2922
2467
|
/**
|
|
2923
|
-
* The guild
|
|
2468
|
+
* The guild id associated with the event.
|
|
2924
2469
|
* @type {string}
|
|
2925
2470
|
*/
|
|
2926
2471
|
guildId: string;
|
|
@@ -2928,12 +2473,7 @@ interface PlayerEvent {
|
|
|
2928
2473
|
/**
|
|
2929
2474
|
* The event for when a track starts playing.
|
|
2930
2475
|
*/
|
|
2931
|
-
interface TrackStartEvent extends PlayerEvent {
|
|
2932
|
-
/**
|
|
2933
|
-
* The type of the event.
|
|
2934
|
-
* @type {PlayerEventType.TrackStart}
|
|
2935
|
-
*/
|
|
2936
|
-
type: PlayerEventType.TrackStart;
|
|
2476
|
+
interface TrackStartEvent extends PlayerEvent<PlayerEventType.TrackStart> {
|
|
2937
2477
|
/**
|
|
2938
2478
|
* The track that started playing.
|
|
2939
2479
|
* @type {LavalinkTrack}
|
|
@@ -2943,12 +2483,7 @@ interface TrackStartEvent extends PlayerEvent {
|
|
|
2943
2483
|
/**
|
|
2944
2484
|
* The event for when a track ends.
|
|
2945
2485
|
*/
|
|
2946
|
-
interface TrackEndEvent extends PlayerEvent {
|
|
2947
|
-
/**
|
|
2948
|
-
* The type of the event.
|
|
2949
|
-
* @type {PlayerEventType.TrackEnd}
|
|
2950
|
-
*/
|
|
2951
|
-
type: PlayerEventType.TrackEnd;
|
|
2486
|
+
interface TrackEndEvent extends PlayerEvent<PlayerEventType.TrackEnd> {
|
|
2952
2487
|
/**
|
|
2953
2488
|
* The track that ended.
|
|
2954
2489
|
* @type {LavalinkTrack}
|
|
@@ -2963,12 +2498,7 @@ interface TrackEndEvent extends PlayerEvent {
|
|
|
2963
2498
|
/**
|
|
2964
2499
|
* The event for when a track gets stuck.
|
|
2965
2500
|
*/
|
|
2966
|
-
interface TrackStuckEvent extends PlayerEvent {
|
|
2967
|
-
/**
|
|
2968
|
-
* The type of the event.
|
|
2969
|
-
* @type {PlayerEventType.TrackStuck}
|
|
2970
|
-
*/
|
|
2971
|
-
type: PlayerEventType.TrackStuck;
|
|
2501
|
+
interface TrackStuckEvent extends PlayerEvent<PlayerEventType.TrackStuck> {
|
|
2972
2502
|
/**
|
|
2973
2503
|
* The track that got stuck.
|
|
2974
2504
|
* @type {LavalinkTrack}
|
|
@@ -2983,12 +2513,7 @@ interface TrackStuckEvent extends PlayerEvent {
|
|
|
2983
2513
|
/**
|
|
2984
2514
|
* The event for when a track encounters an exception.
|
|
2985
2515
|
*/
|
|
2986
|
-
interface TrackExceptionEvent extends PlayerEvent {
|
|
2987
|
-
/**
|
|
2988
|
-
* The type of the event.
|
|
2989
|
-
* @type {PlayerEventType.TrackException}
|
|
2990
|
-
*/
|
|
2991
|
-
type: PlayerEventType.TrackException;
|
|
2516
|
+
interface TrackExceptionEvent extends PlayerEvent<PlayerEventType.TrackException> {
|
|
2992
2517
|
/**
|
|
2993
2518
|
* The exception that occurred.
|
|
2994
2519
|
* @type {Exception}
|
|
@@ -2998,12 +2523,7 @@ interface TrackExceptionEvent extends PlayerEvent {
|
|
|
2998
2523
|
/**
|
|
2999
2524
|
* The event for when the WebSocket connection is closed.
|
|
3000
2525
|
*/
|
|
3001
|
-
interface WebSocketClosedEvent extends PlayerEvent {
|
|
3002
|
-
/**
|
|
3003
|
-
* The type of the event.
|
|
3004
|
-
* @type {PlayerEventType.WebsocketClosed}
|
|
3005
|
-
*/
|
|
3006
|
-
type: PlayerEventType.WebsocketClosed;
|
|
2526
|
+
interface WebSocketClosedEvent extends PlayerEvent<PlayerEventType.WebsocketClosed> {
|
|
3007
2527
|
/**
|
|
3008
2528
|
* The close code.
|
|
3009
2529
|
* @type {number}
|
|
@@ -3023,12 +2543,7 @@ interface WebSocketClosedEvent extends PlayerEvent {
|
|
|
3023
2543
|
/**
|
|
3024
2544
|
* The event for when lyrics are found.
|
|
3025
2545
|
*/
|
|
3026
|
-
interface LyricsFoundEvent extends PlayerEvent {
|
|
3027
|
-
/**
|
|
3028
|
-
* The type of the event.
|
|
3029
|
-
* @type {PlayerEventType.LyricsFound}
|
|
3030
|
-
*/
|
|
3031
|
-
type: PlayerEventType.LyricsFound;
|
|
2546
|
+
interface LyricsFoundEvent extends PlayerEvent<PlayerEventType.LyricsFound> {
|
|
3032
2547
|
/**
|
|
3033
2548
|
* The guild id associated with the event.
|
|
3034
2549
|
* @type {string}
|
|
@@ -3043,27 +2558,12 @@ interface LyricsFoundEvent extends PlayerEvent {
|
|
|
3043
2558
|
/**
|
|
3044
2559
|
* The event for when lyrics are not found.
|
|
3045
2560
|
*/
|
|
3046
|
-
interface LyricsNotFoundEvent extends PlayerEvent {
|
|
3047
|
-
/**
|
|
3048
|
-
* The type of the event.
|
|
3049
|
-
* @type {PlayerEventType.LyricsNotFound}
|
|
3050
|
-
*/
|
|
3051
|
-
type: PlayerEventType.LyricsNotFound;
|
|
3052
|
-
/**
|
|
3053
|
-
* The guild id associated with the event.
|
|
3054
|
-
* @type {string}
|
|
3055
|
-
*/
|
|
3056
|
-
guildId: string;
|
|
2561
|
+
interface LyricsNotFoundEvent extends PlayerEvent<PlayerEventType.LyricsNotFound> {
|
|
3057
2562
|
}
|
|
3058
2563
|
/**
|
|
3059
2564
|
* The event for when a lyrics line is sent.
|
|
3060
2565
|
*/
|
|
3061
|
-
interface LyricsLineEvent extends PlayerEvent {
|
|
3062
|
-
/**
|
|
3063
|
-
* The type of the event.
|
|
3064
|
-
* @type {PlayerEventType.LyricsLine}
|
|
3065
|
-
*/
|
|
3066
|
-
type: PlayerEventType.LyricsLine;
|
|
2566
|
+
interface LyricsLineEvent extends PlayerEvent<PlayerEventType.LyricsLine> {
|
|
3067
2567
|
/**
|
|
3068
2568
|
* The guild id associated with the event.
|
|
3069
2569
|
* @type {string}
|
|
@@ -3226,165 +2726,1147 @@ interface PlayerVoice {
|
|
|
3226
2726
|
/**
|
|
3227
2727
|
* The JSON representation of the player.
|
|
3228
2728
|
*/
|
|
3229
|
-
interface PlayerJson {
|
|
2729
|
+
interface PlayerJson {
|
|
2730
|
+
/**
|
|
2731
|
+
* The guild id of the player.
|
|
2732
|
+
* @type {string}
|
|
2733
|
+
*/
|
|
2734
|
+
guildId: string;
|
|
2735
|
+
/**
|
|
2736
|
+
* The volume of the player.
|
|
2737
|
+
* @type {number}
|
|
2738
|
+
*/
|
|
2739
|
+
volume: number;
|
|
2740
|
+
/**
|
|
2741
|
+
* The self deaf state of the player.
|
|
2742
|
+
* @type {boolean}
|
|
2743
|
+
*/
|
|
2744
|
+
selfDeaf: boolean;
|
|
2745
|
+
/**
|
|
2746
|
+
* The self mute state of the player.
|
|
2747
|
+
* @type {boolean}
|
|
2748
|
+
*/
|
|
2749
|
+
selfMute: boolean;
|
|
2750
|
+
/**
|
|
2751
|
+
* The voice settings for the player.
|
|
2752
|
+
* @type {LavalinkPlayerVoice}
|
|
2753
|
+
*/
|
|
2754
|
+
voice: Nullable<LavalinkPlayerVoice>;
|
|
2755
|
+
/**
|
|
2756
|
+
* The loop mode of the player.
|
|
2757
|
+
* @type {LoopMode}
|
|
2758
|
+
*/
|
|
2759
|
+
loop: LoopMode;
|
|
2760
|
+
/**
|
|
2761
|
+
* The options for the player.
|
|
2762
|
+
* @type {boolean}
|
|
2763
|
+
*/
|
|
2764
|
+
options: PlayerOptions;
|
|
2765
|
+
/**
|
|
2766
|
+
* The paused state of the player.
|
|
2767
|
+
* @type {boolean}
|
|
2768
|
+
*/
|
|
2769
|
+
paused: boolean;
|
|
2770
|
+
/**
|
|
2771
|
+
* The playing state of the player.
|
|
2772
|
+
* @type {boolean}
|
|
2773
|
+
*/
|
|
2774
|
+
playing: boolean;
|
|
2775
|
+
/**
|
|
2776
|
+
* The voice channel id of the player.
|
|
2777
|
+
* @type {string}
|
|
2778
|
+
*/
|
|
2779
|
+
voiceId?: string;
|
|
2780
|
+
/**
|
|
2781
|
+
* The text channel id of the player.
|
|
2782
|
+
* @type {string | undefined}
|
|
2783
|
+
*/
|
|
2784
|
+
textId?: string;
|
|
2785
|
+
/**
|
|
2786
|
+
* The last position received from Lavalink.
|
|
2787
|
+
* @type {number}
|
|
2788
|
+
*/
|
|
2789
|
+
lastPosition: number;
|
|
2790
|
+
/**
|
|
2791
|
+
* The timestamp when the last position change update happened.
|
|
2792
|
+
* @type {number | null}
|
|
2793
|
+
*/
|
|
2794
|
+
lastPositionUpdate: number | null;
|
|
2795
|
+
/**
|
|
2796
|
+
* The current calculated position of the player.
|
|
2797
|
+
* @type {number}
|
|
2798
|
+
*/
|
|
2799
|
+
position: number;
|
|
2800
|
+
/**
|
|
2801
|
+
* The timestamp when the player was created.
|
|
2802
|
+
* @type {number}
|
|
2803
|
+
*/
|
|
2804
|
+
createdTimestamp: number;
|
|
2805
|
+
/**
|
|
2806
|
+
* The ping of the player.
|
|
2807
|
+
* @type {number}
|
|
2808
|
+
*/
|
|
2809
|
+
ping: number;
|
|
2810
|
+
/**
|
|
2811
|
+
* The queue of the player.
|
|
2812
|
+
* @type {QueueJson}
|
|
2813
|
+
*/
|
|
2814
|
+
queue: QueueJson;
|
|
2815
|
+
/**
|
|
2816
|
+
* The node of the player.
|
|
2817
|
+
* @type {NodeJson}
|
|
2818
|
+
*/
|
|
2819
|
+
node: NodeJson;
|
|
2820
|
+
/**
|
|
2821
|
+
* The filter settings of the player.
|
|
2822
|
+
* @type {FilterSettings}
|
|
2823
|
+
*/
|
|
2824
|
+
filters: FilterSettings;
|
|
2825
|
+
}
|
|
2826
|
+
/**
|
|
2827
|
+
* The lyrics methods for the player.
|
|
2828
|
+
*/
|
|
2829
|
+
interface LyricsMethods {
|
|
2830
|
+
/**
|
|
2831
|
+
*
|
|
2832
|
+
* Get the current lyrics for the current track.
|
|
2833
|
+
* @param {boolean} [skipSource=false] Whether to skip the source or not.
|
|
2834
|
+
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
2835
|
+
* @example
|
|
2836
|
+
* ```ts
|
|
2837
|
+
* const player = manager.getPlayer("guildId");
|
|
2838
|
+
* const lyrics = await player.lyrics.current();
|
|
2839
|
+
* ```
|
|
2840
|
+
*/
|
|
2841
|
+
current(skipSource?: boolean): Promise<LyricsResult | null>;
|
|
2842
|
+
/**
|
|
2843
|
+
*
|
|
2844
|
+
* Get the lyrics for a specific track.
|
|
2845
|
+
* @param {Track} track The track to get the lyrics for.
|
|
2846
|
+
* @param {boolean} [skipSource=false] Whether to skip the source or not.
|
|
2847
|
+
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
2848
|
+
* @example
|
|
2849
|
+
* ```ts
|
|
2850
|
+
* const player = manager.getPlayer("guildId");
|
|
2851
|
+
* const track = player.queue.current;
|
|
2852
|
+
* const lyrics = await player.lyrics.get(track);
|
|
2853
|
+
* ```
|
|
2854
|
+
*/
|
|
2855
|
+
get(track: Track, skipSource?: boolean): Promise<LyricsResult | null>;
|
|
2856
|
+
/**
|
|
2857
|
+
*
|
|
2858
|
+
* Subscribe to the lyrics for a specific guild.
|
|
2859
|
+
* @param {boolean} [skipSource=false] Whether to skip the source or not.
|
|
2860
|
+
* @returns {Promise<void>} Let's start the sing session!
|
|
2861
|
+
* @example
|
|
2862
|
+
* ```ts
|
|
2863
|
+
* const player = manager.getPlayer("guildId");
|
|
2864
|
+
* await player.lyrics.subscribe();
|
|
2865
|
+
* ```
|
|
2866
|
+
*/
|
|
2867
|
+
subscribe(skipSource?: boolean): Promise<void>;
|
|
2868
|
+
/**
|
|
2869
|
+
*
|
|
2870
|
+
* Unsubscribe from the lyrics for a specific guild.
|
|
2871
|
+
* @returns {Promise<void>} Let's stop the sing session!
|
|
2872
|
+
* @example
|
|
2873
|
+
* ```ts
|
|
2874
|
+
* const player = manager.getPlayer("guildId");
|
|
2875
|
+
* await player.lyrics.unsubscribe();
|
|
2876
|
+
* ```
|
|
2877
|
+
*/
|
|
2878
|
+
unsubscribe(): Promise<void>;
|
|
2879
|
+
}
|
|
2880
|
+
/**
|
|
2881
|
+
* The voice channel update options.
|
|
2882
|
+
*/
|
|
2883
|
+
type VoiceChannelUpdate = Pick<PlayerOptions, "selfDeaf" | "voiceId" | "selfMute">;
|
|
2884
|
+
/**
|
|
2885
|
+
* The voice settings for the player.
|
|
2886
|
+
*/
|
|
2887
|
+
type LavalinkPlayerVoice = Omit<PlayerVoice, "connected" | "ping">;
|
|
2888
|
+
|
|
2889
|
+
/**
|
|
2890
|
+
* Class representing a LyricsManager.
|
|
2891
|
+
* @class LyricsManager
|
|
2892
|
+
*/
|
|
2893
|
+
declare class LyricsManager {
|
|
2894
|
+
/**
|
|
2895
|
+
* The node instance.
|
|
2896
|
+
* @type {NodeStructure}
|
|
2897
|
+
* @readonly
|
|
2898
|
+
*/
|
|
2899
|
+
readonly node: NodeStructure;
|
|
2900
|
+
/**
|
|
2901
|
+
* Create a new LyricsManager instance.
|
|
2902
|
+
* @param {NodeStructure} node The node instance.
|
|
2903
|
+
* @example
|
|
2904
|
+
* ```ts
|
|
2905
|
+
* const node = manager.nodeManager.get("nodeId");
|
|
2906
|
+
* const lyricsManager = new LyricsManager(node);
|
|
2907
|
+
* ```
|
|
2908
|
+
*/
|
|
2909
|
+
constructor(node: NodeStructure);
|
|
2910
|
+
/**
|
|
2911
|
+
*
|
|
2912
|
+
* Get the current lyrics for the current track.
|
|
2913
|
+
* @param {boolean} skipSource Whether to skip the track source or not.
|
|
2914
|
+
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
2915
|
+
* @example
|
|
2916
|
+
* ```ts
|
|
2917
|
+
* const player = manager.getPlayer("guildId");
|
|
2918
|
+
* const lyrics = await player.lyricsManager.current();
|
|
2919
|
+
* ```
|
|
2920
|
+
*/
|
|
2921
|
+
current(guildId: string, skipSource?: boolean): Promise<LyricsResult | null>;
|
|
2922
|
+
/**
|
|
2923
|
+
*
|
|
2924
|
+
* Get the lyrics for a specific track.
|
|
2925
|
+
* @param {Track} track The track to get the lyrics for.
|
|
2926
|
+
* @param {boolean} skipSource Whether to skip the track source or not.
|
|
2927
|
+
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
2928
|
+
* @example
|
|
2929
|
+
* ```ts
|
|
2930
|
+
* const node = manager.nodeManager.get("nodeId");
|
|
2931
|
+
* const lyrics = await node.lyricsManager.get(track);
|
|
2932
|
+
* ```
|
|
2933
|
+
*/
|
|
2934
|
+
get(track: Track, skipSource?: boolean): Promise<LyricsResult | null>;
|
|
2935
|
+
/**
|
|
2936
|
+
*
|
|
2937
|
+
* Subscribe to the lyrics for a specific guild.
|
|
2938
|
+
* @param {string} guildId The guild id to subscribe to.
|
|
2939
|
+
* @param {boolean} skipSource Whether to skip the track source or not.
|
|
2940
|
+
* @returns {Promise<void>} Let's start the sing session!
|
|
2941
|
+
* @example
|
|
2942
|
+
* ```ts
|
|
2943
|
+
* const node = manager.nodeManager.get("nodeId");
|
|
2944
|
+
* await node.lyricsManager.subscribe("guildId");
|
|
2945
|
+
* ```
|
|
2946
|
+
*/
|
|
2947
|
+
subscribe(guildId: string, skipSource?: boolean): Promise<void>;
|
|
2948
|
+
/**
|
|
2949
|
+
*
|
|
2950
|
+
* Unsubscribe from the lyrics for a specific guild.
|
|
2951
|
+
* @param {string} guildId The guild id to unsubscribe from.
|
|
2952
|
+
* @returns {Promise<void>} Let's stop the sing session!
|
|
2953
|
+
* @example
|
|
2954
|
+
* ```ts
|
|
2955
|
+
* const node = manager.nodeManager.get("nodeId");
|
|
2956
|
+
* await node.lyricsManager.unsubscribe("guildId");
|
|
2957
|
+
* ```
|
|
2958
|
+
*/
|
|
2959
|
+
unsubscribe(guildId: string): Promise<void>;
|
|
2960
|
+
}
|
|
2961
|
+
|
|
2962
|
+
/**
|
|
2963
|
+
* Represents a collection that extends the built-in Map class.
|
|
2964
|
+
* @template K The type of the keys in the collection.
|
|
2965
|
+
* @template V The type of the values in the collection.
|
|
2966
|
+
*/
|
|
2967
|
+
declare class Collection<K, V> extends Map<K, V> {
|
|
2968
|
+
/**
|
|
2969
|
+
* Removes elements from the collection based on a filter function.
|
|
2970
|
+
* @param fn The filter function that determines which elements to remove.
|
|
2971
|
+
* @param thisArg The value to use as `this` when executing the filter function.
|
|
2972
|
+
* @returns The number of elements removed from the collection.
|
|
2973
|
+
* @example
|
|
2974
|
+
* const collection = new Collection<number, string>();
|
|
2975
|
+
* collection.set(1, 'one');
|
|
2976
|
+
* collection.set(2, 'two');
|
|
2977
|
+
* collection.set(3, 'three');
|
|
2978
|
+
* const removedCount = collection.sweep((value, key) => key % 2 === 0);
|
|
2979
|
+
* console.log(removedCount); // Output: 1
|
|
2980
|
+
* console.log(collection.size); // Output: 2
|
|
2981
|
+
*/
|
|
2982
|
+
sweep(fn: (value: V, key: K, collection: this) => unknown): number;
|
|
2983
|
+
/**
|
|
2984
|
+
* Creates a new array with the results of calling a provided function on every element in the collection.
|
|
2985
|
+
* @param fn The function that produces an element of the new array.
|
|
2986
|
+
* @param thisArg The value to use as `this` when executing the map function.
|
|
2987
|
+
* @returns A new array with the results of calling the provided function on every element in the collection.
|
|
2988
|
+
* @example
|
|
2989
|
+
* const collection = new Collection<number, string>();
|
|
2990
|
+
* collection.set(1, 'one');
|
|
2991
|
+
* collection.set(2, 'two');
|
|
2992
|
+
* collection.set(3, 'three');
|
|
2993
|
+
* const mappedArray = collection.map((value, key) => `${key}: ${value}`);
|
|
2994
|
+
* console.log(mappedArray); // Output: ['1: one', '2: two', '3: three']
|
|
2995
|
+
*/
|
|
2996
|
+
map<T>(fn: (value: V, key: K, collection: this) => T): T[];
|
|
2997
|
+
/**
|
|
2998
|
+
* Creates a new array with all elements that pass the test implemented by the provided function.
|
|
2999
|
+
* @param fn The function to test each element of the collection.
|
|
3000
|
+
* @param thisArg The value to use as `this` when executing the filter function.
|
|
3001
|
+
* @returns A new array with the elements that pass the test.
|
|
3002
|
+
* @example
|
|
3003
|
+
* const collection = new Collection<number, string>();
|
|
3004
|
+
* collection.set(1, 'one');
|
|
3005
|
+
* collection.set(2, 'two');
|
|
3006
|
+
* collection.set(3, 'three');
|
|
3007
|
+
* const filteredArray = collection.filter((value, key) => key % 2 === 0);
|
|
3008
|
+
* console.log(filteredArray); // Output: ['two']
|
|
3009
|
+
*/
|
|
3010
|
+
filter(fn: (value: V, key: K, collection: this) => boolean): V[];
|
|
3011
|
+
/**
|
|
3012
|
+
* Returns the value of the first element in the collection that satisfies the provided testing function.
|
|
3013
|
+
* @param fn The function to test each element of the collection.
|
|
3014
|
+
* @returns The value of the first element that passes the test. `undefined` if no element passes the test.
|
|
3015
|
+
* @example
|
|
3016
|
+
* const collection = new Collection<number, number>();
|
|
3017
|
+
* collection.set(1, 1);
|
|
3018
|
+
* collection.set(2, 2);
|
|
3019
|
+
* collection.set(3, 3);
|
|
3020
|
+
* const firstEvenValue = collection.find(value => value % 2 === 0);
|
|
3021
|
+
* console.log(firstEvenValue); // Output: 2
|
|
3022
|
+
*/
|
|
3023
|
+
find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
|
|
3024
|
+
}
|
|
3025
|
+
|
|
3026
|
+
/**
|
|
3027
|
+
* Class representing a node manager.
|
|
3028
|
+
* @class NodeManager
|
|
3029
|
+
*/
|
|
3030
|
+
declare class NodeManager {
|
|
3031
|
+
/**
|
|
3032
|
+
* The manager for the node.
|
|
3033
|
+
* @type {Hoshimi}
|
|
3034
|
+
* @readonly
|
|
3035
|
+
*/
|
|
3036
|
+
readonly manager: Hoshimi;
|
|
3037
|
+
/**
|
|
3038
|
+
* The nodes for the manager.
|
|
3039
|
+
* @type {Collection<string, Node>}
|
|
3040
|
+
* @readonly
|
|
3041
|
+
*/
|
|
3042
|
+
readonly nodes: Collection<string, NodeStructure>;
|
|
3043
|
+
/**
|
|
3044
|
+
*
|
|
3045
|
+
* The constructor for the node manager.
|
|
3046
|
+
* @param {Hoshimi} manager The manager for the node.
|
|
3047
|
+
* @example
|
|
3048
|
+
* ```ts
|
|
3049
|
+
* const manager = new Hoshimi();
|
|
3050
|
+
* const nodeManager = new NodeManager(manager);
|
|
3051
|
+
*
|
|
3052
|
+
* console.log(nodeManager.nodes.size); // 0
|
|
3053
|
+
* ```
|
|
3054
|
+
*/
|
|
3055
|
+
constructor(manager: Hoshimi);
|
|
3056
|
+
/**
|
|
3057
|
+
*
|
|
3058
|
+
* Delete the node.
|
|
3059
|
+
* @param {NodeIdentifier} node The node or node id to delete.
|
|
3060
|
+
* @returns {boolean} If the node was deleted.
|
|
3061
|
+
* @example
|
|
3062
|
+
* ```ts
|
|
3063
|
+
* const node = manager.nodeManager.get("node1");
|
|
3064
|
+
* if (node) manager.nodeManager.delete(node.id); // true if the node was deleted
|
|
3065
|
+
* ```
|
|
3066
|
+
*/
|
|
3067
|
+
delete(node: NodeIdentifier): boolean;
|
|
3068
|
+
/**
|
|
3069
|
+
*
|
|
3070
|
+
* Get the node by id.
|
|
3071
|
+
* @param {NodeIdentifier} node The node or node id to get.
|
|
3072
|
+
* @returns {NodeStructure | undefined} The node or undefined if not found.
|
|
3073
|
+
* @example
|
|
3074
|
+
* ```ts
|
|
3075
|
+
* const node = manager.nodeManager.get("node1");
|
|
3076
|
+
* if (node) {
|
|
3077
|
+
* console.log(node.id); // node1
|
|
3078
|
+
* } else {
|
|
3079
|
+
* console.log("Node not found");
|
|
3080
|
+
* }
|
|
3081
|
+
* ```
|
|
3082
|
+
*/
|
|
3083
|
+
get(node: NodeIdentifier): NodeStructure | undefined;
|
|
3084
|
+
/**
|
|
3085
|
+
*
|
|
3086
|
+
* Create a new node.
|
|
3087
|
+
* @param {NodeOptions} options The options for the node.
|
|
3088
|
+
* @returns {NodeStructure} The created node.
|
|
3089
|
+
* @example
|
|
3090
|
+
* ```ts
|
|
3091
|
+
* const node = manager.nodeManager.create({
|
|
3092
|
+
* host: "localhost",
|
|
3093
|
+
* port: 2333,
|
|
3094
|
+
* password: "password",
|
|
3095
|
+
* secure: false,
|
|
3096
|
+
* });
|
|
3097
|
+
*
|
|
3098
|
+
* console.log(node.id); // localhost:2333
|
|
3099
|
+
*/
|
|
3100
|
+
create(options: NodeOptions): NodeStructure;
|
|
3101
|
+
/**
|
|
3102
|
+
*
|
|
3103
|
+
* Destroy a node.
|
|
3104
|
+
* @param {NodeIdentifier} node The node or node id to destroy.
|
|
3105
|
+
* @returns {void}
|
|
3106
|
+
* @example
|
|
3107
|
+
* ```ts
|
|
3108
|
+
* const node = manager.nodeManager.get("node1");
|
|
3109
|
+
* if (node) node.destroy();
|
|
3110
|
+
* ```
|
|
3111
|
+
*/
|
|
3112
|
+
destroy(node: NodeIdentifier): void;
|
|
3113
|
+
/**
|
|
3114
|
+
*
|
|
3115
|
+
* Reconnect a node.
|
|
3116
|
+
* @param {NodeIdentifier} node The node or node id to reconnect.
|
|
3117
|
+
* @returns {void}
|
|
3118
|
+
* @example
|
|
3119
|
+
* ```ts
|
|
3120
|
+
* const node = manager.nodeManager.get("node1");
|
|
3121
|
+
* if (node) node.reconnect();
|
|
3122
|
+
* ```
|
|
3123
|
+
*/
|
|
3124
|
+
reconnect(node: NodeIdentifier): void;
|
|
3125
|
+
/**
|
|
3126
|
+
*
|
|
3127
|
+
* Disconnect a node.
|
|
3128
|
+
* @param {NodeIdentifier} node The node or node id to disconnect.
|
|
3129
|
+
* @returns {void}
|
|
3130
|
+
* @example
|
|
3131
|
+
* ```ts
|
|
3132
|
+
* const node = manager.nodeManager.get("node1");
|
|
3133
|
+
* if (node) node.disconnect();
|
|
3134
|
+
* ```
|
|
3135
|
+
*/
|
|
3136
|
+
disconnect(node: NodeIdentifier): void;
|
|
3137
|
+
/**
|
|
3138
|
+
*
|
|
3139
|
+
* Connect a node.
|
|
3140
|
+
* @param {NodeIdentifier} node The node or node id to connect.
|
|
3141
|
+
* @returns {void}
|
|
3142
|
+
* @example
|
|
3143
|
+
* ```ts
|
|
3144
|
+
* const node = manager.nodeManager.get("node1");
|
|
3145
|
+
* if (node) node.connect();
|
|
3146
|
+
* ```
|
|
3147
|
+
*/
|
|
3148
|
+
connect(node: NodeIdentifier): void;
|
|
3149
|
+
/**
|
|
3150
|
+
*
|
|
3151
|
+
* Get the least used node.
|
|
3152
|
+
* @returns {NodeStructure} The least used node.
|
|
3153
|
+
* @example
|
|
3154
|
+
* ```ts
|
|
3155
|
+
* const node = manager.nodeManager.getLeastUsed();
|
|
3156
|
+
* if (node) {
|
|
3157
|
+
* console.log(node.id); // node1
|
|
3158
|
+
* console.log(node.penalties); // the penalties of the node
|
|
3159
|
+
* console.log(node.state); // the state of the node
|
|
3160
|
+
* }
|
|
3161
|
+
* ```
|
|
3162
|
+
*/
|
|
3163
|
+
getLeastUsed(sortType?: NodeSortTypes): NodeStructure;
|
|
3164
|
+
/**
|
|
3165
|
+
*
|
|
3166
|
+
* Reconnect the nodes.
|
|
3167
|
+
* @returns {void}
|
|
3168
|
+
* @example
|
|
3169
|
+
* ```ts
|
|
3170
|
+
* const node = manager.nodeManager.get("node1");
|
|
3171
|
+
* if (node) node.reconnectAll();
|
|
3172
|
+
* ```
|
|
3173
|
+
*/
|
|
3174
|
+
reconnectAll(): void;
|
|
3175
|
+
/**
|
|
3176
|
+
* Disconnect the nodes.
|
|
3177
|
+
* @returns {void}
|
|
3178
|
+
* @example
|
|
3179
|
+
* ```ts
|
|
3180
|
+
* const node = manager.nodeManager.get("node1");
|
|
3181
|
+
* if (node) node.disconnectAll();
|
|
3182
|
+
* ```
|
|
3183
|
+
*/
|
|
3184
|
+
disconnectAll(): void;
|
|
3185
|
+
/**
|
|
3186
|
+
* Connect the nodes.
|
|
3187
|
+
* @returns {void}
|
|
3188
|
+
* @example
|
|
3189
|
+
* ```ts
|
|
3190
|
+
* const node = manager.nodeManager.get("node1");
|
|
3191
|
+
* if (node) node.connect();
|
|
3192
|
+
* ```
|
|
3193
|
+
*/
|
|
3194
|
+
connectAll(): void;
|
|
3195
|
+
/**
|
|
3196
|
+
* Destroy the nodes.
|
|
3197
|
+
* @returns {void}
|
|
3198
|
+
* @example
|
|
3199
|
+
* ```ts
|
|
3200
|
+
* const node = manager.nodeManager.get("node1");
|
|
3201
|
+
* if (node) node.destroy();
|
|
3202
|
+
* ```
|
|
3203
|
+
*/
|
|
3204
|
+
destroyAll(): void;
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
/**
|
|
3208
|
+
* Class representing the REST for the node.
|
|
3209
|
+
* @class Rest
|
|
3210
|
+
*/
|
|
3211
|
+
declare class Rest {
|
|
3212
|
+
/**
|
|
3213
|
+
* The URL for the REST.
|
|
3214
|
+
* @type {string}
|
|
3215
|
+
*/
|
|
3216
|
+
readonly url: string;
|
|
3217
|
+
/**
|
|
3218
|
+
* The version for the REST.
|
|
3219
|
+
* @type {string}
|
|
3220
|
+
*/
|
|
3221
|
+
readonly version: string;
|
|
3222
|
+
/**
|
|
3223
|
+
* The timeout for the REST.
|
|
3224
|
+
* @type {number}
|
|
3225
|
+
*/
|
|
3226
|
+
readonly restTimeout: number;
|
|
3227
|
+
/**
|
|
3228
|
+
* The user agent for the REST.
|
|
3229
|
+
* @type {UserAgent}
|
|
3230
|
+
*/
|
|
3231
|
+
readonly userAgent: UserAgent;
|
|
3232
|
+
/**
|
|
3233
|
+
* The node for the REST.
|
|
3234
|
+
* @type {Node}
|
|
3235
|
+
*/
|
|
3236
|
+
readonly node: NodeStructure;
|
|
3237
|
+
/**
|
|
3238
|
+
*
|
|
3239
|
+
* Create a new REST.
|
|
3240
|
+
* @param {NodeStructure} node The node for the REST.
|
|
3241
|
+
* @example
|
|
3242
|
+
* ```ts
|
|
3243
|
+
* const node = new Node({
|
|
3244
|
+
* host: "localhost",
|
|
3245
|
+
* port: 2333,
|
|
3246
|
+
* password: "youshallnotpass",
|
|
3247
|
+
* secure: false,
|
|
3248
|
+
* });
|
|
3249
|
+
*
|
|
3250
|
+
* const rest = new Rest(node);
|
|
3251
|
+
* console.log(rest.restUrl); // http://localhost:2333/v4
|
|
3252
|
+
* ```
|
|
3253
|
+
*/
|
|
3254
|
+
constructor(node: NodeStructure);
|
|
3255
|
+
/**
|
|
3256
|
+
* The REST URL to make requests.
|
|
3257
|
+
* @type {string}
|
|
3258
|
+
*/
|
|
3259
|
+
get restUrl(): string;
|
|
3260
|
+
/**
|
|
3261
|
+
* The session id of the node.
|
|
3262
|
+
* @type {string}
|
|
3263
|
+
*/
|
|
3264
|
+
get sessionId(): string;
|
|
3265
|
+
/**
|
|
3266
|
+
*
|
|
3267
|
+
* Make a request to the node.
|
|
3268
|
+
* @param {RestOptions} options The options to make the request.
|
|
3269
|
+
* @returns {Promise<T | null>} The response from the node.
|
|
3270
|
+
*/
|
|
3271
|
+
request<T>(options: RestOptions): Promise<T | null>;
|
|
3272
|
+
/**
|
|
3273
|
+
*
|
|
3274
|
+
* Update the player data.
|
|
3275
|
+
* @param {Partial<UpdatePlayerInfo>} data The player data to update.
|
|
3276
|
+
* @returns {LavalinkPlayer | null} The updated player data.
|
|
3277
|
+
* @example
|
|
3278
|
+
* ```ts
|
|
3279
|
+
* const player = await node.rest.updatePlayer({
|
|
3280
|
+
* guildId: "guildId",
|
|
3281
|
+
* noReplace: true,
|
|
3282
|
+
* playerOptions: {
|
|
3283
|
+
* paused: false,
|
|
3284
|
+
* track: { encoded: "encoded track" },
|
|
3285
|
+
* },
|
|
3286
|
+
* });
|
|
3287
|
+
*
|
|
3288
|
+
* console.log(player); // The updated lavalink player data
|
|
3289
|
+
* ```
|
|
3290
|
+
*/
|
|
3291
|
+
updatePlayer(data: Partial<UpdatePlayerInfo>): Promise<LavalinkPlayer | null>;
|
|
3292
|
+
/**
|
|
3293
|
+
*
|
|
3294
|
+
* Stop the track in player for the guild.
|
|
3295
|
+
* @param {string} guildId the guild id to stop the player
|
|
3296
|
+
* @returns {Promise<LavalinkPlayer | null>} The updated player data.
|
|
3297
|
+
* @example
|
|
3298
|
+
* ```ts
|
|
3299
|
+
* const player = await node.rest.stopPlayer("guildId");
|
|
3300
|
+
* if (player) console.log(player); // The lavalink player
|
|
3301
|
+
* ```
|
|
3302
|
+
*/
|
|
3303
|
+
stopPlayer(guildId: string): Promise<LavalinkPlayer | null>;
|
|
3304
|
+
/**
|
|
3305
|
+
*
|
|
3306
|
+
* Destroy the player for the guild.
|
|
3307
|
+
* @param {string} guildId The guild id to destroy the player.
|
|
3308
|
+
* @returns {Promise<void>} The updated player data.
|
|
3309
|
+
* @example
|
|
3310
|
+
* ```ts
|
|
3311
|
+
* await node.rest.destroyPlayer("guildId");
|
|
3312
|
+
* ```
|
|
3313
|
+
* @example
|
|
3314
|
+
*/
|
|
3315
|
+
destroyPlayer(guildId: string): Promise<void>;
|
|
3316
|
+
/**
|
|
3317
|
+
*
|
|
3318
|
+
* Update the session for the node
|
|
3319
|
+
* @param {SessionResumingOptions} options The session resuming options.
|
|
3320
|
+
* @returns {Promise<LavalinkSession | null>} The updated session data.
|
|
3321
|
+
* @example
|
|
3322
|
+
* ```ts
|
|
3323
|
+
* const session = await node.rest.updateSession({ resuming: true, timeout: 30000 });
|
|
3324
|
+
* if (session) console.log(session); // The lavalink session data
|
|
3325
|
+
* ```
|
|
3326
|
+
*/
|
|
3327
|
+
updateSession(options: SessionResumingOptions): Promise<LavalinkSession | null>;
|
|
3328
|
+
/**
|
|
3329
|
+
*
|
|
3330
|
+
* Get all players for the current session.
|
|
3331
|
+
* @returns {Promise<LavalinkPlayer[]>} The players for the current session.
|
|
3332
|
+
* @example
|
|
3333
|
+
* ```ts
|
|
3334
|
+
* const players = await node.rest.getPlayers();
|
|
3335
|
+
* console.log(players); // The lavalink players for the current session
|
|
3336
|
+
* ```
|
|
3337
|
+
*/
|
|
3338
|
+
getPlayers(): Promise<LavalinkPlayer[]>;
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3341
|
+
/**
|
|
3342
|
+
* Class representing the queue utils.
|
|
3343
|
+
* @class QueueUtils
|
|
3344
|
+
*/
|
|
3345
|
+
declare class QueueUtils {
|
|
3346
|
+
/**
|
|
3347
|
+
*
|
|
3348
|
+
* Constructor of the queue utils.
|
|
3349
|
+
* @param {QueueStructure} queue The queue instance.
|
|
3350
|
+
*/
|
|
3351
|
+
constructor(queue: QueueStructure);
|
|
3352
|
+
/**
|
|
3353
|
+
*
|
|
3354
|
+
* Save the queue.
|
|
3355
|
+
* @returns {Awaitable<void>}
|
|
3356
|
+
* @example
|
|
3357
|
+
* ```ts
|
|
3358
|
+
* await player.queue.utils.save();
|
|
3359
|
+
* ```
|
|
3360
|
+
*/
|
|
3361
|
+
save(): Awaitable<void>;
|
|
3362
|
+
/**
|
|
3363
|
+
*
|
|
3364
|
+
* Destroy the queue.
|
|
3365
|
+
* @returns {Promise<void>}
|
|
3366
|
+
* @example
|
|
3367
|
+
* ```ts
|
|
3368
|
+
* await player.queue.utils.destroy();
|
|
3369
|
+
* ```
|
|
3370
|
+
*/
|
|
3371
|
+
destroy(): Awaitable<boolean>;
|
|
3372
|
+
/**
|
|
3373
|
+
*
|
|
3374
|
+
* Sync the queue.
|
|
3375
|
+
* @param {boolean} [override=true] Whether to override the current queue or not.
|
|
3376
|
+
* @param {boolean} [syncCurrent=false] Whether to sync the current track or not.
|
|
3377
|
+
* @returns {Awaitable<void>}
|
|
3378
|
+
* @example
|
|
3379
|
+
* ```ts
|
|
3380
|
+
* await player.queue.utils.sync();
|
|
3381
|
+
* ```
|
|
3382
|
+
*/
|
|
3383
|
+
sync(override?: boolean, syncCurrent?: boolean): Promise<void>;
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
/**
|
|
3387
|
+
* Class representing a queue.
|
|
3388
|
+
* @class Queue
|
|
3389
|
+
*/
|
|
3390
|
+
declare class Queue {
|
|
3391
|
+
/**
|
|
3392
|
+
* Tracks of the queue.
|
|
3393
|
+
* @type {HoshimiTrack[]}
|
|
3394
|
+
*/
|
|
3395
|
+
tracks: HoshimiTrack[];
|
|
3396
|
+
/**
|
|
3397
|
+
* Previous tracks of the queue.
|
|
3398
|
+
* @type {Track[]}
|
|
3399
|
+
*/
|
|
3400
|
+
history: Track[];
|
|
3401
|
+
/**
|
|
3402
|
+
* Current track of the queue.
|
|
3403
|
+
* @type {Track | null}
|
|
3404
|
+
*/
|
|
3405
|
+
current: Track | null;
|
|
3406
|
+
/**
|
|
3407
|
+
* The player instance.
|
|
3408
|
+
* @type {PlayerStructure}
|
|
3409
|
+
*/
|
|
3410
|
+
readonly player: PlayerStructure;
|
|
3411
|
+
/**
|
|
3412
|
+
* The queue utils instance.
|
|
3413
|
+
* @type {QueueUtils}
|
|
3414
|
+
* @readonly
|
|
3415
|
+
*/
|
|
3416
|
+
readonly utils: QueueUtils;
|
|
3417
|
+
/**
|
|
3418
|
+
*
|
|
3419
|
+
* Constructor of the queue.
|
|
3420
|
+
* @param {PlayerStructure} player Player instance.
|
|
3421
|
+
* @example
|
|
3422
|
+
* ```ts
|
|
3423
|
+
* const player = new Player();
|
|
3424
|
+
* const queue = new Queue(player);
|
|
3425
|
+
*
|
|
3426
|
+
* console.log(queue.size); // 0
|
|
3427
|
+
* queue.add(track);
|
|
3428
|
+
* console.log(queue.size); // 1
|
|
3429
|
+
* ```
|
|
3430
|
+
*/
|
|
3431
|
+
constructor(player: PlayerStructure);
|
|
3432
|
+
/**
|
|
3433
|
+
* Get the track size of the queue.
|
|
3434
|
+
* @type {number}
|
|
3435
|
+
* @returns {number} The track size of the queue.
|
|
3436
|
+
* @readonly
|
|
3437
|
+
* @example
|
|
3438
|
+
* ```ts
|
|
3439
|
+
* const queue = player.queue;
|
|
3440
|
+
*
|
|
3441
|
+
* console.log(queue.size); // 0
|
|
3442
|
+
* queue.add(track);
|
|
3443
|
+
*
|
|
3444
|
+
* console.log(queue.size); // 1
|
|
3445
|
+
* queue.add([track1, track2]);
|
|
3446
|
+
*
|
|
3447
|
+
* console.log(queue.size); // 3
|
|
3448
|
+
* queue.shift();
|
|
3449
|
+
* console.log(queue.size); // 2
|
|
3450
|
+
*
|
|
3451
|
+
* queue.clear();
|
|
3452
|
+
* console.log(queue.size); // 0
|
|
3453
|
+
* ```
|
|
3454
|
+
*/
|
|
3455
|
+
get size(): number;
|
|
3456
|
+
/**
|
|
3457
|
+
* Get the total track size of the queue (Includes the current track).
|
|
3458
|
+
* @type {number}
|
|
3459
|
+
* @returns {number} The total track size of the queue.
|
|
3460
|
+
* @readonly
|
|
3461
|
+
* @example
|
|
3462
|
+
* ```ts
|
|
3463
|
+
* const queue = player.queue;
|
|
3464
|
+
*
|
|
3465
|
+
* console.log(queue.totalSize); // 0
|
|
3466
|
+
* queue.add(track);
|
|
3467
|
+
*
|
|
3468
|
+
* console.log(queue.totalSize); // 1
|
|
3469
|
+
* queue.add([track1, track2]);
|
|
3470
|
+
*
|
|
3471
|
+
* console.log(queue.totalSize); // 3
|
|
3472
|
+
* queue.shift();
|
|
3473
|
+
* console.log(queue.totalSize); // 2
|
|
3474
|
+
*
|
|
3475
|
+
* queue.clear();
|
|
3476
|
+
* console.log(queue.totalSize); // 0
|
|
3477
|
+
* ```
|
|
3478
|
+
*/
|
|
3479
|
+
get totalSize(): number;
|
|
3480
|
+
/**
|
|
3481
|
+
*
|
|
3482
|
+
* Check if the queue is empty.
|
|
3483
|
+
* @type {boolean}
|
|
3484
|
+
* @returns {boolean} True if the queue is empty.
|
|
3485
|
+
* @readonly
|
|
3486
|
+
* @example
|
|
3487
|
+
* ```ts
|
|
3488
|
+
* const queue = player.queue;
|
|
3489
|
+
*
|
|
3490
|
+
* console.log(queue.isEmpty()); // true
|
|
3491
|
+
* queue.add(track);
|
|
3492
|
+
*
|
|
3493
|
+
* console.log(queue.isEmpty()); // false
|
|
3494
|
+
* queue.clear();
|
|
3495
|
+
*
|
|
3496
|
+
* console.log(queue.isEmpty()); // true
|
|
3497
|
+
* ```
|
|
3498
|
+
*/
|
|
3499
|
+
isEmpty(): boolean;
|
|
3500
|
+
/**
|
|
3501
|
+
*
|
|
3502
|
+
* Build a track from a Lavalink track or unresolved Lavalink track.
|
|
3503
|
+
* @param {LavalinkTrack | UnresolvedLavalinkTrack} track The track to build.
|
|
3504
|
+
* @param {TrackRequester} requester The requester of the track.
|
|
3505
|
+
* @returns {Promise<Track>} The built track.
|
|
3506
|
+
* @example
|
|
3507
|
+
* ```ts
|
|
3508
|
+
* const queue = player.queue;
|
|
3509
|
+
* const lavalinkTrack = {...} // some lavalink track
|
|
3510
|
+
* const track = await queue.build(lavalinkTrack, author);
|
|
3511
|
+
*
|
|
3512
|
+
* console.log(track.info.title); // The title of the track
|
|
3513
|
+
* ```
|
|
3514
|
+
*/
|
|
3515
|
+
build(track: LavalinkTrack | UnresolvedLavalinkTrack | HoshimiTrack, requester: TrackRequester): Promise<Track>;
|
|
3516
|
+
/**
|
|
3517
|
+
*
|
|
3518
|
+
* Get the previous track of the queue.
|
|
3519
|
+
* @param {boolean} [remove=false] Whether to remove the track from the previous queue.
|
|
3520
|
+
* @returns {Promise<Track | null>} The previous track of the queue.
|
|
3521
|
+
* @example
|
|
3522
|
+
* ```ts
|
|
3523
|
+
* const queue = player.queue;
|
|
3524
|
+
*
|
|
3525
|
+
* console.log(await queue.previous()); // null
|
|
3526
|
+
* queue.add(track);
|
|
3527
|
+
* queue.add(track2);
|
|
3528
|
+
*
|
|
3529
|
+
* console.log(await queue.previous()); // track
|
|
3530
|
+
* console.log(await queue.previous(true)); // track and remove it from the previous tracks
|
|
3531
|
+
* ```
|
|
3532
|
+
*/
|
|
3533
|
+
previous(remove?: boolean): Promise<Track | null>;
|
|
3534
|
+
/**
|
|
3535
|
+
*
|
|
3536
|
+
* Add a track or tracks to the queue.
|
|
3537
|
+
* @param {Track | Track[]} track The track or tracks to add.
|
|
3538
|
+
* @param {number} [position] The position to add the track or tracks.
|
|
3539
|
+
* @returns {Promise<this>} The queue instance.
|
|
3540
|
+
* @example
|
|
3541
|
+
* ```ts
|
|
3542
|
+
* const queue = player.queue;
|
|
3543
|
+
*
|
|
3544
|
+
* console.log(queue.size); // 0
|
|
3545
|
+
*
|
|
3546
|
+
* await queue.add(track);
|
|
3547
|
+
* console.log(queue.size); // 1
|
|
3548
|
+
*
|
|
3549
|
+
* await queue.add([track1, track2]);
|
|
3550
|
+
* console.log(queue.size); // 3
|
|
3551
|
+
*
|
|
3552
|
+
* await queue.add(track3, 1);
|
|
3553
|
+
* console.log(queue.size); // 4
|
|
3554
|
+
* console.log(queue.tracks); // [track1, track3, track2, track]
|
|
3555
|
+
* ```
|
|
3556
|
+
*/
|
|
3557
|
+
add(track: HoshimiTrack | HoshimiTrack[], position?: number): Promise<this>;
|
|
3558
|
+
/**
|
|
3559
|
+
*
|
|
3560
|
+
* Get the first track of the queue.
|
|
3561
|
+
* @returns {Promise<HoshimiTrack | null>} The first track of the queue.
|
|
3562
|
+
* @example
|
|
3563
|
+
* ```ts
|
|
3564
|
+
* const queue = player.queue;
|
|
3565
|
+
*
|
|
3566
|
+
* console.log(await queue.shift()); // null
|
|
3567
|
+
* await queue.add(track);
|
|
3568
|
+
*
|
|
3569
|
+
* console.log(await queue.shift()); // track
|
|
3570
|
+
* await queue.add(track2);
|
|
3571
|
+
* ```
|
|
3572
|
+
*/
|
|
3573
|
+
shift(): Promise<HoshimiTrack | null>;
|
|
3574
|
+
/**
|
|
3575
|
+
*
|
|
3576
|
+
* Add tracks to the beginning of the queue.
|
|
3577
|
+
* @param {Track[]} tracks The tracks to add.
|
|
3578
|
+
* @returns {Promise<this>} The queue instance.
|
|
3579
|
+
* @example
|
|
3580
|
+
* ```ts
|
|
3581
|
+
* const queue = player.queue;
|
|
3582
|
+
*
|
|
3583
|
+
* console.log(queue.size); // 0
|
|
3584
|
+
* await queue.unshift(track);
|
|
3585
|
+
*
|
|
3586
|
+
* console.log(queue.size); // 1
|
|
3587
|
+
* await queue.unshift(track1, track2);
|
|
3588
|
+
*
|
|
3589
|
+
* console.log(queue.size); // 3
|
|
3590
|
+
* console.log(queue.tracks); // [track1, track2, track]
|
|
3591
|
+
* ```
|
|
3592
|
+
*/
|
|
3593
|
+
unshift(...tracks: Track[]): Promise<this>;
|
|
3594
|
+
/**
|
|
3595
|
+
*
|
|
3596
|
+
* Shuffle the queue.
|
|
3597
|
+
* @returns {Promise<this>} The queue instance.
|
|
3598
|
+
* @example
|
|
3599
|
+
* ```ts
|
|
3600
|
+
* const queue = player.queue;
|
|
3601
|
+
*
|
|
3602
|
+
* console.log(queue.size); // 0
|
|
3603
|
+
* await queue.add(track);
|
|
3604
|
+
* await queue.add(track1, track2);
|
|
3605
|
+
*
|
|
3606
|
+
* console.log(queue.size); // 3
|
|
3607
|
+
* console.log(queue.tracks); // [track, track1, track2]
|
|
3608
|
+
*
|
|
3609
|
+
* await queue.shuffle();
|
|
3610
|
+
* console.log(queue.tracks); // [track2, track, track1]
|
|
3611
|
+
* ```
|
|
3612
|
+
*/
|
|
3613
|
+
shuffle(): Promise<this>;
|
|
3614
|
+
/**
|
|
3615
|
+
*
|
|
3616
|
+
* Clear the queue.
|
|
3617
|
+
* @returns {Promise<this>} The queue instance.
|
|
3618
|
+
* @example
|
|
3619
|
+
* ```ts
|
|
3620
|
+
* const queue = player.queue;
|
|
3621
|
+
*
|
|
3622
|
+
* console.log(queue.size); // 0
|
|
3623
|
+
* await queue.add(track);
|
|
3624
|
+
* await queue.add(track1, track2);
|
|
3625
|
+
*
|
|
3626
|
+
* console.log(queue.size); // 3
|
|
3627
|
+
* await queue.clear();
|
|
3628
|
+
* console.log(queue.size); // 0
|
|
3629
|
+
* ```
|
|
3630
|
+
*/
|
|
3631
|
+
clear(): Promise<this>;
|
|
3632
|
+
/**
|
|
3633
|
+
*
|
|
3634
|
+
* Move a track to a specific position in the queue.
|
|
3635
|
+
* @param {Track} track The track to move.
|
|
3636
|
+
* @param {number} to The position to move.
|
|
3637
|
+
* @returns {Promise<this>} The queue instance.
|
|
3638
|
+
* @example
|
|
3639
|
+
* ```ts
|
|
3640
|
+
* const queue = player.queue;
|
|
3641
|
+
* await queue.add(track);
|
|
3642
|
+
* await queue.add(track1);
|
|
3643
|
+
* await queue.add(track2);
|
|
3644
|
+
*
|
|
3645
|
+
* console.log(queue.tracks); // [track, track1, track2]
|
|
3646
|
+
* await queue.move(track1, 0);
|
|
3647
|
+
* console.log(queue.tracks); // [track1, track, track2]
|
|
3648
|
+
* ```
|
|
3649
|
+
*/
|
|
3650
|
+
move(track: Track, to: number): Promise<this>;
|
|
3651
|
+
/**
|
|
3652
|
+
*
|
|
3653
|
+
* Delete tracks from the queue.
|
|
3654
|
+
* @param {number} start The start index.
|
|
3655
|
+
* @param {number} deleteCount The number of tracks to delete.
|
|
3656
|
+
* @param {Track | Track[]} [tracks] The tracks to add.
|
|
3657
|
+
* @returns {Promise<this>} The queue instance.
|
|
3658
|
+
* @example
|
|
3659
|
+
* ```ts
|
|
3660
|
+
* const queue = player.queue;
|
|
3661
|
+
* await queue.add(track);
|
|
3662
|
+
* await queue.add(track1);
|
|
3663
|
+
* await queue.add(track2);
|
|
3664
|
+
*
|
|
3665
|
+
* console.log(queue.tracks); // [track, track1, track2]
|
|
3666
|
+
* await queue.splice(1, 1);
|
|
3667
|
+
* console.log(queue.tracks); // [track, track2]
|
|
3668
|
+
* ```
|
|
3669
|
+
*/
|
|
3670
|
+
splice(start: number, deleteCount: number, tracks?: HoshimiTrack | HoshimiTrack[]): Promise<this>;
|
|
3671
|
+
/**
|
|
3672
|
+
*
|
|
3673
|
+
* Convert the queue to a JSON object.
|
|
3674
|
+
* @returns {QueueJson} The queue JSON object.
|
|
3675
|
+
* @example
|
|
3676
|
+
* ```ts
|
|
3677
|
+
* const queue = player.queue;
|
|
3678
|
+
* await queue.add(track);
|
|
3679
|
+
*
|
|
3680
|
+
* console.log(queue.toJSON()); // { tracks: [track], history: [], current: null }
|
|
3681
|
+
* ```
|
|
3682
|
+
*/
|
|
3683
|
+
toJSON(): QueueJson;
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
/**
|
|
3687
|
+
* The structure for the Player class.
|
|
3688
|
+
*/
|
|
3689
|
+
type PlayerStructure = InferCustomStructure<Player, "Player">;
|
|
3690
|
+
/**
|
|
3691
|
+
* The structure for the Rest class.
|
|
3692
|
+
*/
|
|
3693
|
+
type RestStructure = InferCustomStructure<Rest, "Rest">;
|
|
3694
|
+
/**
|
|
3695
|
+
* The structure for the Node class.
|
|
3696
|
+
*/
|
|
3697
|
+
type NodeStructure = InferCustomStructure<Node, "Node">;
|
|
3698
|
+
/**
|
|
3699
|
+
* The structure for the Queue class.
|
|
3700
|
+
*/
|
|
3701
|
+
type QueueStructure = InferCustomStructure<Queue, "Queue">;
|
|
3702
|
+
/**
|
|
3703
|
+
* The structure for the LyricsManager class.
|
|
3704
|
+
*/
|
|
3705
|
+
type LyricsManagerStructure = InferCustomStructure<LyricsManager, "LyricsManager">;
|
|
3706
|
+
/**
|
|
3707
|
+
* The structure for the NodeManager class.
|
|
3708
|
+
*/
|
|
3709
|
+
type NodeManagerStructure = InferCustomStructure<NodeManager, "NodeManager">;
|
|
3710
|
+
/**
|
|
3711
|
+
* The structure for the FilterManager class.
|
|
3712
|
+
*/
|
|
3713
|
+
type FilterManagerStructure = InferCustomStructure<FilterManager, "FilterManager">;
|
|
3714
|
+
/**
|
|
3715
|
+
* The structures of the Hoshimi classes.
|
|
3716
|
+
*/
|
|
3717
|
+
declare const Structures: {
|
|
3718
|
+
Player(manager: Hoshimi, options: PlayerOptions): PlayerStructure;
|
|
3719
|
+
Rest(node: Node): RestStructure;
|
|
3720
|
+
Node(nodeManager: NodeManager, options: NodeOptions): NodeStructure;
|
|
3721
|
+
Queue(player: Player): QueueStructure;
|
|
3722
|
+
LyricsManager(node: Node): LyricsManagerStructure;
|
|
3723
|
+
NodeManager(manager: Hoshimi): NodeManagerStructure;
|
|
3724
|
+
FilterManager(player: Player): FilterManagerStructure;
|
|
3725
|
+
};
|
|
3726
|
+
/**
|
|
3727
|
+
* Infers the custom structure for a given class.
|
|
3728
|
+
*/
|
|
3729
|
+
type InferCustomStructure<T, N extends string> = CustomizableStructures extends Record<N, infer P> ? P : T;
|
|
3730
|
+
|
|
3731
|
+
/**
|
|
3732
|
+
* Class representing a Hoshimi track.
|
|
3733
|
+
* @class Track
|
|
3734
|
+
* @implements {LavalinkTrack}
|
|
3735
|
+
*/
|
|
3736
|
+
declare class Track implements LavalinkTrack {
|
|
3230
3737
|
/**
|
|
3231
|
-
* The
|
|
3738
|
+
* The base64 encoded track.
|
|
3232
3739
|
* @type {string}
|
|
3233
3740
|
*/
|
|
3234
|
-
|
|
3235
|
-
/**
|
|
3236
|
-
* The volume of the player.
|
|
3237
|
-
* @type {number}
|
|
3238
|
-
*/
|
|
3239
|
-
volume: number;
|
|
3240
|
-
/**
|
|
3241
|
-
* The self deaf state of the player.
|
|
3242
|
-
* @type {boolean}
|
|
3243
|
-
*/
|
|
3244
|
-
selfDeaf: boolean;
|
|
3245
|
-
/**
|
|
3246
|
-
* The self mute state of the player.
|
|
3247
|
-
* @type {boolean}
|
|
3248
|
-
*/
|
|
3249
|
-
selfMute: boolean;
|
|
3741
|
+
readonly encoded: string;
|
|
3250
3742
|
/**
|
|
3251
|
-
* The
|
|
3252
|
-
* @type {
|
|
3743
|
+
* The track info.
|
|
3744
|
+
* @type {TrackInfo}
|
|
3253
3745
|
*/
|
|
3254
|
-
|
|
3746
|
+
readonly info: TrackInfo;
|
|
3255
3747
|
/**
|
|
3256
|
-
* The
|
|
3257
|
-
* @type {
|
|
3748
|
+
* The plugin info of the track.
|
|
3749
|
+
* @type {PluginInfo}
|
|
3258
3750
|
*/
|
|
3259
|
-
|
|
3751
|
+
readonly pluginInfo: PluginInfo;
|
|
3260
3752
|
/**
|
|
3261
|
-
* The
|
|
3262
|
-
* @type {
|
|
3753
|
+
* The track user data.
|
|
3754
|
+
* @type {TrackUserData}
|
|
3263
3755
|
*/
|
|
3264
|
-
|
|
3756
|
+
userData: TrackUserData;
|
|
3265
3757
|
/**
|
|
3266
|
-
* The
|
|
3267
|
-
* @type {
|
|
3758
|
+
* The requester of the track.
|
|
3759
|
+
* @type {TrackRequester}
|
|
3268
3760
|
*/
|
|
3269
|
-
|
|
3761
|
+
requester: TrackRequester;
|
|
3270
3762
|
/**
|
|
3271
|
-
* The
|
|
3272
|
-
* @
|
|
3763
|
+
* The constructor for the track.
|
|
3764
|
+
* @param {LavalinkTrack} track The track to construct the track from.
|
|
3765
|
+
* @param {TrackRequester} requester The requester of the track.
|
|
3766
|
+
* @example
|
|
3767
|
+
* ```ts
|
|
3768
|
+
* const track = new Track({
|
|
3769
|
+
* encoded: "base64",
|
|
3770
|
+
* info: {
|
|
3771
|
+
* title: "Track Title",
|
|
3772
|
+
* uri: "https://example.com",
|
|
3773
|
+
* duration: 300000,
|
|
3774
|
+
* },
|
|
3775
|
+
* // the rest of the track info
|
|
3776
|
+
* }, requester);
|
|
3777
|
+
*
|
|
3778
|
+
* console.log(track.encoded); // the track encoded in base64
|
|
3779
|
+
* ```
|
|
3273
3780
|
*/
|
|
3274
|
-
|
|
3781
|
+
constructor(track: LavalinkTrack | null, requester?: TrackRequester);
|
|
3275
3782
|
/**
|
|
3276
|
-
*
|
|
3277
|
-
*
|
|
3783
|
+
*
|
|
3784
|
+
* Get the hyperlink of the track.
|
|
3785
|
+
* @param {boolean} [embedable=true] Whether the hyperlink should be embedable or not.
|
|
3786
|
+
* @returns {string} The hyperlink of the track.
|
|
3787
|
+
* @example
|
|
3788
|
+
* ```ts
|
|
3789
|
+
* const track = queue.current;
|
|
3790
|
+
* console.log(track.toHyperlink()); // [Track Title](https://example.com)
|
|
3791
|
+
* console.log(track.toHyperlink(false)); // [Track Title](<https://example.com>)
|
|
3792
|
+
* ```
|
|
3278
3793
|
*/
|
|
3279
|
-
|
|
3794
|
+
toHyperlink(embedable?: boolean): string;
|
|
3795
|
+
}
|
|
3796
|
+
/**
|
|
3797
|
+
* Class representing an unresolved track.
|
|
3798
|
+
* @class UnresolvedTrack
|
|
3799
|
+
* @implements {UnresolvedLavalinkTrack}
|
|
3800
|
+
*/
|
|
3801
|
+
declare class UnresolvedTrack implements UnresolvedLavalinkTrack {
|
|
3280
3802
|
/**
|
|
3281
|
-
* The
|
|
3803
|
+
* The base64 encoded track.
|
|
3282
3804
|
* @type {string | undefined}
|
|
3283
3805
|
*/
|
|
3284
|
-
|
|
3285
|
-
/**
|
|
3286
|
-
* The last position received from Lavalink.
|
|
3287
|
-
* @type {number}
|
|
3288
|
-
*/
|
|
3289
|
-
lastPosition: number;
|
|
3290
|
-
/**
|
|
3291
|
-
* The timestamp when the last position change update happened.
|
|
3292
|
-
* @type {number | null}
|
|
3293
|
-
*/
|
|
3294
|
-
lastPositionUpdate: number | null;
|
|
3295
|
-
/**
|
|
3296
|
-
* The current calculated position of the player.
|
|
3297
|
-
* @type {number}
|
|
3298
|
-
*/
|
|
3299
|
-
position: number;
|
|
3300
|
-
/**
|
|
3301
|
-
* The timestamp when the player was created.
|
|
3302
|
-
* @type {number}
|
|
3303
|
-
*/
|
|
3304
|
-
createdTimestamp: number;
|
|
3305
|
-
/**
|
|
3306
|
-
* The ping of the player.
|
|
3307
|
-
* @type {number}
|
|
3308
|
-
*/
|
|
3309
|
-
ping: number;
|
|
3806
|
+
readonly encoded?: string;
|
|
3310
3807
|
/**
|
|
3311
|
-
* The
|
|
3312
|
-
* @type {
|
|
3808
|
+
* The track info.
|
|
3809
|
+
* @type {UnresolvedTrackInfo}
|
|
3313
3810
|
*/
|
|
3314
|
-
|
|
3811
|
+
readonly info: UnresolvedTrackInfo;
|
|
3315
3812
|
/**
|
|
3316
|
-
* The
|
|
3317
|
-
* @type {
|
|
3813
|
+
* The plugin info of the track.
|
|
3814
|
+
* @type {Partial<PluginInfo>}
|
|
3318
3815
|
*/
|
|
3319
|
-
|
|
3816
|
+
readonly pluginInfo?: Partial<PluginInfo>;
|
|
3320
3817
|
/**
|
|
3321
|
-
* The
|
|
3322
|
-
* @type {
|
|
3818
|
+
* The track user data.
|
|
3819
|
+
* @type {TrackUserData | undefined}
|
|
3323
3820
|
*/
|
|
3324
|
-
|
|
3325
|
-
}
|
|
3326
|
-
/**
|
|
3327
|
-
* The lyrics methods for the player.
|
|
3328
|
-
*/
|
|
3329
|
-
interface LyricsMethods {
|
|
3821
|
+
userData?: TrackUserData;
|
|
3330
3822
|
/**
|
|
3331
|
-
*
|
|
3332
|
-
*
|
|
3333
|
-
* @param {boolean} [skipSource=false] Whether to skip the source or not.
|
|
3334
|
-
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
3335
|
-
* @example
|
|
3336
|
-
* ```ts
|
|
3337
|
-
* const player = manager.getPlayer("guildId");
|
|
3338
|
-
* const lyrics = await player.lyricsManager.current();
|
|
3339
|
-
* ```
|
|
3823
|
+
* The requester of the track.
|
|
3824
|
+
* @type {TrackRequester | undefined}
|
|
3340
3825
|
*/
|
|
3341
|
-
|
|
3826
|
+
requester: TrackRequester;
|
|
3342
3827
|
/**
|
|
3343
|
-
*
|
|
3344
|
-
*
|
|
3345
|
-
* @param {
|
|
3346
|
-
* @param {boolean} [skipSource=false] Whether to skip the source or not.
|
|
3347
|
-
* @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
|
|
3828
|
+
* The constructor for the track.
|
|
3829
|
+
* @param {UnresolvedLavalinkTrack} track The track to construct the track from.
|
|
3830
|
+
* @param {TrackRequester} requester The requester of the track.
|
|
3348
3831
|
* @example
|
|
3349
3832
|
* ```ts
|
|
3350
|
-
* const
|
|
3351
|
-
*
|
|
3352
|
-
*
|
|
3353
|
-
*
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3833
|
+
* const track = new UnresolvedTrack({
|
|
3834
|
+
* encoded: "base64",
|
|
3835
|
+
* info: {
|
|
3836
|
+
* title: "Track Title",
|
|
3837
|
+
* },
|
|
3838
|
+
* // the rest of the track info
|
|
3839
|
+
* }, requester);
|
|
3357
3840
|
*
|
|
3358
|
-
*
|
|
3359
|
-
* @param {boolean} [skipSource=false] Whether to skip the source or not.
|
|
3360
|
-
* @returns {Promise<void>} Let's start the sing session!
|
|
3361
|
-
* @example
|
|
3362
|
-
* ```ts
|
|
3363
|
-
* const player = manager.getPlayer("guildId");
|
|
3364
|
-
* await player.lyrics.subscribe();
|
|
3841
|
+
* console.log(track.encoded); // the track encoded in base64
|
|
3365
3842
|
* ```
|
|
3366
3843
|
*/
|
|
3367
|
-
|
|
3844
|
+
constructor(track: UnresolvedLavalinkTrack, requester?: TrackRequester);
|
|
3368
3845
|
/**
|
|
3369
|
-
*
|
|
3370
|
-
*
|
|
3371
|
-
* @returns {Promise<
|
|
3372
|
-
* @
|
|
3373
|
-
* ```ts
|
|
3374
|
-
* const player = manager.getPlayer("guildId");
|
|
3375
|
-
* await player.lyrics.unsubscribe();
|
|
3376
|
-
* ```
|
|
3846
|
+
* Resolves the track to a playable track.
|
|
3847
|
+
* @param {PlayerStructure} player The player to resolve the track for.
|
|
3848
|
+
* @returns {Promise<Track>} The resolved track.
|
|
3849
|
+
* @throws {ResolveError} If the track cannot be resolved.
|
|
3377
3850
|
*/
|
|
3378
|
-
|
|
3851
|
+
resolve(player: PlayerStructure): Promise<Track>;
|
|
3379
3852
|
}
|
|
3380
3853
|
/**
|
|
3381
|
-
*
|
|
3854
|
+
* Type representing a Hoshimi track, which can be either a resolved or unresolved track.
|
|
3382
3855
|
*/
|
|
3383
|
-
type
|
|
3856
|
+
type HoshimiTrack = Track | UnresolvedTrack;
|
|
3384
3857
|
/**
|
|
3385
|
-
*
|
|
3858
|
+
* Interface representing an extendable track.
|
|
3386
3859
|
*/
|
|
3387
|
-
|
|
3860
|
+
interface CustomizableTrack {
|
|
3861
|
+
}
|
|
3862
|
+
/**
|
|
3863
|
+
* The requester of the track.
|
|
3864
|
+
*/
|
|
3865
|
+
type TrackRequester = Inferable<CustomizableTrack, "requester">;
|
|
3866
|
+
/**
|
|
3867
|
+
* The user data of the track.
|
|
3868
|
+
*/
|
|
3869
|
+
type TrackUserData = Inferable<CustomizableTrack, "userData">;
|
|
3388
3870
|
|
|
3389
3871
|
/**
|
|
3390
3872
|
* The states.
|
|
@@ -3954,9 +4436,9 @@ interface LavalinkTrack {
|
|
|
3954
4436
|
info: TrackInfo;
|
|
3955
4437
|
/**
|
|
3956
4438
|
* The user data of the track.
|
|
3957
|
-
* @type {
|
|
4439
|
+
* @type {TrackUserData | undefined}
|
|
3958
4440
|
*/
|
|
3959
|
-
userData?:
|
|
4441
|
+
userData?: TrackUserData;
|
|
3960
4442
|
}
|
|
3961
4443
|
interface UnresolvedLavalinkTrack {
|
|
3962
4444
|
/**
|
|
@@ -3976,9 +4458,9 @@ interface UnresolvedLavalinkTrack {
|
|
|
3976
4458
|
pluginInfo?: Partial<PluginInfo>;
|
|
3977
4459
|
/**
|
|
3978
4460
|
* The user data of the track.
|
|
3979
|
-
* @type {
|
|
4461
|
+
* @type {TrackUserData | undefined}
|
|
3980
4462
|
*/
|
|
3981
|
-
userData?:
|
|
4463
|
+
userData?: TrackUserData;
|
|
3982
4464
|
}
|
|
3983
4465
|
/**
|
|
3984
4466
|
* The track information.
|
|
@@ -4381,6 +4863,11 @@ interface NodeInfo {
|
|
|
4381
4863
|
* @type {NodeInfoPlugin[]}
|
|
4382
4864
|
*/
|
|
4383
4865
|
plugins: NodeInfoPlugin[];
|
|
4866
|
+
/**
|
|
4867
|
+
* Whether the node is a Nodelink instance.
|
|
4868
|
+
* @type {boolean
|
|
4869
|
+
*/
|
|
4870
|
+
isNodelink: boolean;
|
|
4384
4871
|
}
|
|
4385
4872
|
/**
|
|
4386
4873
|
* The node options.
|
|
@@ -4648,7 +5135,7 @@ declare class Node {
|
|
|
4648
5135
|
readonly nodeManager: NodeManagerStructure;
|
|
4649
5136
|
/**
|
|
4650
5137
|
* The lyrics manager for the node.
|
|
4651
|
-
* @type {
|
|
5138
|
+
* @type {LyricsManagerStructure}
|
|
4652
5139
|
*/
|
|
4653
5140
|
readonly lyricsManager: LyricsManagerStructure;
|
|
4654
5141
|
/**
|
|
@@ -4741,6 +5228,23 @@ declare class Node {
|
|
|
4741
5228
|
* ```
|
|
4742
5229
|
*/
|
|
4743
5230
|
get id(): string;
|
|
5231
|
+
/**
|
|
5232
|
+
*
|
|
5233
|
+
* Check if the node is a Nodelink node.
|
|
5234
|
+
* @returns {boolean} True if the node is a Nodelink node, false otherwise.
|
|
5235
|
+
* @example
|
|
5236
|
+
* ```ts
|
|
5237
|
+
* const node = manager.nodeManager.get("node1");
|
|
5238
|
+
* if (node) {
|
|
5239
|
+
* if (node.isNodelink()) {
|
|
5240
|
+
* console.log("The node is a Nodelink node");
|
|
5241
|
+
* } else {
|
|
5242
|
+
* console.log("The node is a Lavalink node");
|
|
5243
|
+
* }
|
|
5244
|
+
* }
|
|
5245
|
+
* ```
|
|
5246
|
+
*/
|
|
5247
|
+
isNodelink(): boolean;
|
|
4744
5248
|
/**
|
|
4745
5249
|
* The socket address to connect the node.
|
|
4746
5250
|
* @type {string}
|
|
@@ -4879,19 +5383,18 @@ declare class Node {
|
|
|
4879
5383
|
/**
|
|
4880
5384
|
*
|
|
4881
5385
|
* Update the session for the node
|
|
4882
|
-
* @param {
|
|
4883
|
-
* @param {number | null} timeout The timeout for the session.
|
|
5386
|
+
* @param {SessionResumingOptions} options The session resuming options.
|
|
4884
5387
|
* @returns {Promise<LavalinkSession | null>}
|
|
4885
5388
|
* @example
|
|
4886
5389
|
* ```ts
|
|
4887
5390
|
* const node = manager.nodeManager.get("node1");
|
|
4888
5391
|
* if (node) {
|
|
4889
|
-
* const session = await node.updateSession(true,
|
|
5392
|
+
* const session = await node.updateSession({ resuming: true, timeout: 30000 });
|
|
4890
5393
|
* console.log(session); // the lavalink session
|
|
4891
5394
|
* }
|
|
4892
5395
|
* ```
|
|
4893
5396
|
*/
|
|
4894
|
-
updateSession(
|
|
5397
|
+
updateSession(options: SessionResumingOptions): Promise<LavalinkSession | null>;
|
|
4895
5398
|
/**
|
|
4896
5399
|
* Reconnect the node.
|
|
4897
5400
|
* @returns {void}
|
|
@@ -5081,7 +5584,12 @@ declare enum SearchEngines {
|
|
|
5081
5584
|
* Play voice using text to speech.
|
|
5082
5585
|
* @description Provided by skybot-lavalink-plugin plugin.
|
|
5083
5586
|
*/
|
|
5084
|
-
TextToSpeech = "speak"
|
|
5587
|
+
TextToSpeech = "speak",
|
|
5588
|
+
/**
|
|
5589
|
+
* Search via http url.
|
|
5590
|
+
* @description Provided by lavalink.
|
|
5591
|
+
*/
|
|
5592
|
+
HTTP = "http"
|
|
5085
5593
|
}
|
|
5086
5594
|
/**
|
|
5087
5595
|
* The debug levels for the manager.
|
|
@@ -5115,7 +5623,7 @@ declare enum DebugLevels {
|
|
|
5115
5623
|
/**
|
|
5116
5624
|
* The events for the manager.
|
|
5117
5625
|
*/
|
|
5118
|
-
declare enum
|
|
5626
|
+
declare enum EventNames {
|
|
5119
5627
|
/**
|
|
5120
5628
|
* Emitted when the manager emits a debug message.
|
|
5121
5629
|
*/
|
|
@@ -5168,6 +5676,10 @@ declare enum Events {
|
|
|
5168
5676
|
* Emitted when the player is destroyed.
|
|
5169
5677
|
*/
|
|
5170
5678
|
PlayerDestroy = "playerDestroy",
|
|
5679
|
+
/**
|
|
5680
|
+
* Emitted when the player has an error.
|
|
5681
|
+
*/
|
|
5682
|
+
PlayerError = "playerError",
|
|
5171
5683
|
/**
|
|
5172
5684
|
* Emitted when a track starts playing.
|
|
5173
5685
|
*/
|
|
@@ -5236,7 +5748,15 @@ declare enum DestroyReasons {
|
|
|
5236
5748
|
/**
|
|
5237
5749
|
* The player was destroyed because the voice channel was deleted.
|
|
5238
5750
|
*/
|
|
5239
|
-
VoiceChannelDeleted = "Player-VoiceChannelDeleted"
|
|
5751
|
+
VoiceChannelDeleted = "Player-VoiceChannelDeleted",
|
|
5752
|
+
/**
|
|
5753
|
+
* The player was destroyed because it left the voice channel.
|
|
5754
|
+
*/
|
|
5755
|
+
VoiceChannelLeft = "Player-VoiceChannelLeft",
|
|
5756
|
+
/**
|
|
5757
|
+
* The player was destroyed because it failed to reconnect.
|
|
5758
|
+
*/
|
|
5759
|
+
ReconnectFailed = "Player-ReconnectFailed"
|
|
5240
5760
|
}
|
|
5241
5761
|
/**
|
|
5242
5762
|
* The client data for the manager.
|
|
@@ -5335,6 +5855,11 @@ interface HoshimiOptions {
|
|
|
5335
5855
|
* @type {HoshimiRestOptions}
|
|
5336
5856
|
*/
|
|
5337
5857
|
restOptions?: HoshimiRestOptions;
|
|
5858
|
+
/**
|
|
5859
|
+
* The player options to use.
|
|
5860
|
+
* @type {HoshimiPlayerOptions}
|
|
5861
|
+
*/
|
|
5862
|
+
playerOptions?: HoshimiPlayerOptions;
|
|
5338
5863
|
}
|
|
5339
5864
|
/**
|
|
5340
5865
|
* The events for the manager.
|
|
@@ -5417,6 +5942,12 @@ interface HoshimiEvents {
|
|
|
5417
5942
|
* @param {string} reason The reason for the destroy.
|
|
5418
5943
|
*/
|
|
5419
5944
|
playerDestroy: [player: PlayerStructure, reason: string];
|
|
5945
|
+
/**
|
|
5946
|
+
* Emitted when the player has an error.
|
|
5947
|
+
* @param {PlayerStructure} player The player that emitted the event.
|
|
5948
|
+
* @param {Error | unknown} error The error that was emitted.
|
|
5949
|
+
*/
|
|
5950
|
+
playerError: [player: PlayerStructure, error: Error | unknown];
|
|
5420
5951
|
/**
|
|
5421
5952
|
* Emitted when a track starts playing.
|
|
5422
5953
|
* @param {PlayerStructure} player The player that emitted the event.
|
|
@@ -5678,7 +6209,7 @@ interface ChannelDeletePacket {
|
|
|
5678
6209
|
/**
|
|
5679
6210
|
* Make a function awaitable by returning a promise or the value.
|
|
5680
6211
|
*/
|
|
5681
|
-
type Awaitable<T> = T |
|
|
6212
|
+
type Awaitable<T> = Promise<T> | T;
|
|
5682
6213
|
/**
|
|
5683
6214
|
* Create a type that infers the value of a key from an object.
|
|
5684
6215
|
*/
|
|
@@ -5693,6 +6224,10 @@ type Omit$1<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
|
5693
6224
|
* Create a type that can be a rest or an array.
|
|
5694
6225
|
*/
|
|
5695
6226
|
type RestOrArray<T> = T[] | [T[]];
|
|
6227
|
+
/**
|
|
6228
|
+
* Conditional type to check if T is true, then A, else B or A | null.
|
|
6229
|
+
*/
|
|
6230
|
+
type If<T extends boolean, A, B = null> = T extends true ? A : B extends null ? A | null : B;
|
|
5696
6231
|
/**
|
|
5697
6232
|
* Make a type required.
|
|
5698
6233
|
*/
|
|
@@ -5735,19 +6270,43 @@ type GatewayPackets = VoicePacket | VoiceServer | VoiceState | ChannelDeletePack
|
|
|
5735
6270
|
* The required options for the manager.
|
|
5736
6271
|
*/
|
|
5737
6272
|
type RequiredOptions = DeepRequired<HoshimiOptions>;
|
|
5738
|
-
/**
|
|
5739
|
-
* The events for the manager.
|
|
5740
|
-
* This allows to extend the events.
|
|
5741
|
-
*/
|
|
5742
|
-
type RawEvents = {
|
|
5743
|
-
[K in keyof HoshimiEvents]: HoshimiEvents[K];
|
|
5744
|
-
};
|
|
5745
6273
|
/**
|
|
5746
6274
|
* Class representing the Hoshimi manager.
|
|
5747
6275
|
* @class Hoshimi
|
|
5748
|
-
* @extends {EventEmitter<
|
|
6276
|
+
* @extends {EventEmitter<HoshimiEvents>}
|
|
6277
|
+
* @example
|
|
6278
|
+
* ```ts
|
|
6279
|
+
* import { Hoshimi, SearchEngines } from "hoshimi";
|
|
6280
|
+
*
|
|
6281
|
+
* const manager = new Hoshimi({ // or via createHoshimi() function
|
|
6282
|
+
* sendPayload: async (guildId, payload) => {
|
|
6283
|
+
* const guild = await <Client>.guilds.fetch(guildId);
|
|
6284
|
+
* if (!guild) return;
|
|
6285
|
+
*
|
|
6286
|
+
* guild.shard.send(payload); // Adjust this line based on your library's method to send payloads
|
|
6287
|
+
* },
|
|
6288
|
+
* nodes: [
|
|
6289
|
+
* {
|
|
6290
|
+
* host: "localhost",
|
|
6291
|
+
* port: 2333,
|
|
6292
|
+
* password: "youshallnotpass",
|
|
6293
|
+
* secure: false,
|
|
6294
|
+
* },
|
|
6295
|
+
* ],
|
|
6296
|
+
* });
|
|
6297
|
+
*
|
|
6298
|
+
* manager.on("nodeReady", (node) => console.log(`Node ${node.id} is ready.`));
|
|
6299
|
+
* manager.on("playerCreate", (player) => console.log(`Player created for guild ${player.guildId}.`));
|
|
6300
|
+
* manager.on("error", (error) => console.error("An error occurred:", error));
|
|
6301
|
+
*
|
|
6302
|
+
* <Client>.on("ready", () => {
|
|
6303
|
+
* manager.init({ id: <Client>.user.id, username: <Client>.user.username });
|
|
6304
|
+
* });
|
|
6305
|
+
*
|
|
6306
|
+
* console.log(manager); // The manager instance
|
|
6307
|
+
* ```
|
|
5749
6308
|
*/
|
|
5750
|
-
declare class Hoshimi extends EventEmitter<
|
|
6309
|
+
declare class Hoshimi extends EventEmitter<HoshimiEvents> {
|
|
5751
6310
|
/**
|
|
5752
6311
|
* The options for the manager.
|
|
5753
6312
|
* @type {HoshimiOptions}
|
|
@@ -5774,6 +6333,7 @@ declare class Hoshimi extends EventEmitter<RawEvents> {
|
|
|
5774
6333
|
* The constructor for the manager.
|
|
5775
6334
|
* @param {HoshimiOptions} options The options for the manager.
|
|
5776
6335
|
* @throws {ManagerError} If the options are not provided.
|
|
6336
|
+
* @throws {OptionError} If the options are invalid.
|
|
5777
6337
|
* @example
|
|
5778
6338
|
* ```ts
|
|
5779
6339
|
* const manager = new Hoshimi({
|
|
@@ -5799,10 +6359,24 @@ declare class Hoshimi extends EventEmitter<RawEvents> {
|
|
|
5799
6359
|
* resumeByLibrary: false,
|
|
5800
6360
|
* },
|
|
5801
6361
|
* queueOptions: {
|
|
5802
|
-
*
|
|
5803
|
-
*
|
|
5804
|
-
*
|
|
6362
|
+
* maxHistory: 25,
|
|
6363
|
+
* autoplayFn: autoplayFn,
|
|
6364
|
+
* autoPlay: false,
|
|
6365
|
+
* storage: new MemoryAdapter(),
|
|
6366
|
+
* requesterFn: defaultRequesterFn,
|
|
5805
6367
|
* },
|
|
6368
|
+
* playerOptions: {
|
|
6369
|
+
* onDisconnect: {
|
|
6370
|
+
* autoDestroy: false,
|
|
6371
|
+
* autoReconnect: false,
|
|
6372
|
+
* autoQueue: false,
|
|
6373
|
+
* },
|
|
6374
|
+
* onError: {
|
|
6375
|
+
* autoDestroy: false,
|
|
6376
|
+
* autoSkip: false,
|
|
6377
|
+
* autoStop: false,
|
|
6378
|
+
* },
|
|
6379
|
+
* },
|
|
5806
6380
|
* });
|
|
5807
6381
|
*
|
|
5808
6382
|
* console.log(manager); // The manager instance
|
|
@@ -5921,12 +6495,31 @@ declare class Hoshimi extends EventEmitter<RawEvents> {
|
|
|
5921
6495
|
*/
|
|
5922
6496
|
declare function createHoshimi(...args: ConstructorParameters<typeof Hoshimi>): Hoshimi;
|
|
5923
6497
|
|
|
6498
|
+
/**
|
|
6499
|
+
* Class representing a player storage.
|
|
6500
|
+
* @class PlayerMemoryStorage
|
|
6501
|
+
* @extends {PlayerStorageAdapter}
|
|
6502
|
+
*/
|
|
6503
|
+
declare class PlayerMemoryStorage<K extends StorageKeys = StorageKeys, V extends StorageValues<K> = StorageValues<K>> extends PlayerStorageAdapter {
|
|
6504
|
+
get<K extends StorageKeys, V extends StorageValues<K>>(key: K): Awaitable<V | undefined>;
|
|
6505
|
+
set<K extends StorageKeys, V extends StorageValues<K>>(key: K, value: V): Awaitable<void>;
|
|
6506
|
+
has<K extends StorageKeys>(key: K): Awaitable<boolean>;
|
|
6507
|
+
delete<K extends StorageKeys>(key: K): Awaitable<boolean>;
|
|
6508
|
+
keys<K extends StorageKeys[]>(): Awaitable<K[]>;
|
|
6509
|
+
values<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Awaitable<V[]>;
|
|
6510
|
+
entries<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Awaitable<[K, V][]>;
|
|
6511
|
+
all<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Awaitable<Record<K[number], V>>;
|
|
6512
|
+
clear(): Awaitable<void>;
|
|
6513
|
+
size(): Awaitable<number>;
|
|
6514
|
+
buildKey(...parts: RestOrArray<string>): string;
|
|
6515
|
+
}
|
|
6516
|
+
|
|
5924
6517
|
/**
|
|
5925
6518
|
* Class representing a memory storage manager.
|
|
5926
6519
|
* @class MemoryAdapter
|
|
5927
|
-
* @extends {
|
|
6520
|
+
* @extends {QueueStorageAdapter}
|
|
5928
6521
|
*/
|
|
5929
|
-
declare class
|
|
6522
|
+
declare class QueueMemoryStorage<T extends QueueJson = QueueJson> extends QueueStorageAdapter<T> {
|
|
5930
6523
|
get(key: string): T | undefined;
|
|
5931
6524
|
set(key: string, value: T): void;
|
|
5932
6525
|
delete(key: string): boolean;
|
|
@@ -5934,6 +6527,108 @@ declare class MemoryAdapter<T extends QueueJson = QueueJson> extends StorageAdap
|
|
|
5934
6527
|
has(key: string): boolean;
|
|
5935
6528
|
parse(value: unknown): T;
|
|
5936
6529
|
stringify<R = string>(value: unknown): R;
|
|
6530
|
+
buildKey(...parts: RestOrArray<string>): string;
|
|
5937
6531
|
}
|
|
5938
6532
|
|
|
5939
|
-
|
|
6533
|
+
/**
|
|
6534
|
+
* The auto output record type.
|
|
6535
|
+
*/
|
|
6536
|
+
type AutoOutputRecord = Record<AudioOutput, Required<ChannelMixSettings>>;
|
|
6537
|
+
/**
|
|
6538
|
+
* The user agent for Hoshimi.
|
|
6539
|
+
* @type {UserAgent}
|
|
6540
|
+
*/
|
|
6541
|
+
declare const HoshimiAgent: UserAgent;
|
|
6542
|
+
/**
|
|
6543
|
+
* The url regex for Hoshimi.
|
|
6544
|
+
* @type {RegExp}
|
|
6545
|
+
*/
|
|
6546
|
+
declare const UrlRegex: RegExp;
|
|
6547
|
+
/**
|
|
6548
|
+
* The valid search engines for Hoshimi.
|
|
6549
|
+
* @type {SearchEngines[]}
|
|
6550
|
+
*/
|
|
6551
|
+
declare const ValidEngines: SearchEngines[];
|
|
6552
|
+
/**
|
|
6553
|
+
* The valid sources for Hoshimi.
|
|
6554
|
+
* @type {Map<SourceNames, SearchEngines>}
|
|
6555
|
+
*/
|
|
6556
|
+
declare const ValidSources: Map<SourceNames, SearchEngines>;
|
|
6557
|
+
/**
|
|
6558
|
+
* The audio output data for Hoshimi.
|
|
6559
|
+
* @type {Readonly<Record<AudioOutput, Required<ChannelMixSettings>>>}
|
|
6560
|
+
*/
|
|
6561
|
+
declare const AudioOutputData: Readonly<AutoOutputRecord>;
|
|
6562
|
+
/**
|
|
6563
|
+
* The default filter presets.
|
|
6564
|
+
*/
|
|
6565
|
+
declare const DefaultFilterPreset: Readonly<{
|
|
6566
|
+
Karaoke: {
|
|
6567
|
+
level: number;
|
|
6568
|
+
monoLevel: number;
|
|
6569
|
+
filterBand: number;
|
|
6570
|
+
filterWidth: number;
|
|
6571
|
+
};
|
|
6572
|
+
Vaporwave: {
|
|
6573
|
+
speed: number;
|
|
6574
|
+
pitch: number;
|
|
6575
|
+
rate: number;
|
|
6576
|
+
};
|
|
6577
|
+
Nightcore: {
|
|
6578
|
+
speed: number;
|
|
6579
|
+
pitch: number;
|
|
6580
|
+
rate: number;
|
|
6581
|
+
};
|
|
6582
|
+
Lowpass: {
|
|
6583
|
+
smoothing: number;
|
|
6584
|
+
};
|
|
6585
|
+
Tremolo: {
|
|
6586
|
+
frequency: number;
|
|
6587
|
+
depth: number;
|
|
6588
|
+
};
|
|
6589
|
+
Vibrato: {
|
|
6590
|
+
frequency: number;
|
|
6591
|
+
depth: number;
|
|
6592
|
+
};
|
|
6593
|
+
Distortion: {
|
|
6594
|
+
cosOffset: number;
|
|
6595
|
+
sinOffset: number;
|
|
6596
|
+
tanOffset: number;
|
|
6597
|
+
offset: number;
|
|
6598
|
+
scale: number;
|
|
6599
|
+
cosScale: number;
|
|
6600
|
+
sinScale: number;
|
|
6601
|
+
tanScale: number;
|
|
6602
|
+
};
|
|
6603
|
+
DSPXHighPass: {
|
|
6604
|
+
boostFactor: number;
|
|
6605
|
+
cutoffFrequency: number;
|
|
6606
|
+
};
|
|
6607
|
+
DSPXLowPass: {
|
|
6608
|
+
boostFactor: number;
|
|
6609
|
+
cutoffFrequency: number;
|
|
6610
|
+
};
|
|
6611
|
+
DSPXNormalization: {
|
|
6612
|
+
adaptive: boolean;
|
|
6613
|
+
maxAmplitude: number;
|
|
6614
|
+
};
|
|
6615
|
+
DSPXEcho: {
|
|
6616
|
+
decay: number;
|
|
6617
|
+
echoLength: number;
|
|
6618
|
+
};
|
|
6619
|
+
PluginEcho: {
|
|
6620
|
+
decay: number;
|
|
6621
|
+
delay: number;
|
|
6622
|
+
};
|
|
6623
|
+
PluginReverb: {
|
|
6624
|
+
delays: number[];
|
|
6625
|
+
gains: number[];
|
|
6626
|
+
};
|
|
6627
|
+
}>;
|
|
6628
|
+
/**
|
|
6629
|
+
* The default filter settings.
|
|
6630
|
+
* @type {Readonly<FilterSettings>} DefaultFilters
|
|
6631
|
+
*/
|
|
6632
|
+
declare const DefaultPlayerFilters: Readonly<FilterSettings>;
|
|
6633
|
+
|
|
6634
|
+
export { AudioOutput, AudioOutputData, type Awaitable, type ChannelDelete, type ChannelDeletePacket, type ChannelMixSettings, type ClientData, type CustomizablePlayerStorage, type CustomizableStructures, type CustomizableTrack, DSPXPluginFilter, DebugLevels, type DecodeMethods, type DeepRequired, DefaultFilterPreset, DefaultPlayerFilters, DestroyReasons, type DistortionSettings, type EQBandSettings, type EchoSettings, type EnabledDSPXPluginFilters, type EnabledLavalinkFilters, type EnabledPlayerFilters, EventNames, type Exception, type FetchOptions, FilterManager, type FilterManagerStructure, type FilterPluginPassSettings, type FilterSettings, FilterType, type FreqSettings, type GatewayPayload, type GatewaySendPayload, Hoshimi, HoshimiAgent, type HoshimiEvents, type HoshimiNodeOptions, type HoshimiOptions, type HoshimiPlayerOptions, type HoshimiQueueOptions, type HoshimiRestOptions, type HoshimiTrack, HttpMethods, HttpStatusCodes, type If, type InferCustomStructure, type Inferable, type KaraokeSettings, type LavalinkFilterPluginEchoSettings, type LavalinkFilterPluginReverbSettings, type LavalinkFilterPluginSettings, type LavalinkPayload, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerState, type LavalinkPlayerVoice, LavalinkPluginFilter, type LavalinkRestError, type LavalinkSearchResponse, type LavalinkSession, type LavalinkTrack, LoadType, LoopMode, type LowPassSettings, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsManagerStructure, type LyricsMethods, type LyricsNotFoundEvent, type LyricsResult, ManagerError, Node, type NodeCpu, type NodeDestroyInfo, NodeDestroyReasons, type NodeDisconnectInfo, NodeError, type NodeFrameStats, type NodeIdentifier, type NodeInfo, type NodeInfoGit, type NodeInfoPlugin, type NodeInfoVersion, type NodeJson, NodeManagerError, type NodeManagerStructure, type NodeMemory, type NodeOptions, NodeSortTypes, type NodeStructure, type NormalizationSettings, type Nullable, type NullableLavalinkSession, type Omit$1 as Omit, OpCodes, OptionError, type PickNullable, type PickRequired, type PlayOptions, Player, PlayerError, type PlayerEvent, PlayerEventType, type PlayerJson, PlayerMemoryStorage, type PlayerOptions, PlayerStorageAdapter, type PlayerStructure, type PlayerUpdate, type PlayerUpdateState, type PlayerVoice, type Playlist, type PlaylistInfo, type PluginFilterSettings, type PluginInfo, PluginInfoType, PluginNames, type QueryResult, Queue, type QueueJson, QueueMemoryStorage, QueueStorageAdapter, type QueueStructure, type Ready, ResolveError, Rest, type RestEndpoint, type RestOptions, type RestOrArray, RestPathType, RestRoutes, type RestStructure, type ResumableHeaders, type RotationSettings, SearchEngines, type SearchOptions, type SearchQuery, type SessionResumingOptions, Severity, SourceNames, State, type Stats, StorageError, type StorageKeys, type StorageValues, Structures, type TimescaleSettings, Track, type TrackEndEvent, TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackRequester, type TrackStartEvent, type TrackStuckEvent, type TrackUserData, type TremoloSettings, type UnresolvedLavalinkTrack, UnresolvedTrack, type UnresolvedTrackInfo, type UpdatePlayerInfo, UrlRegex, type UserAgent, ValidEngines, ValidSources, type VoiceChannelUpdate, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, WebsocketCloseCodes, createHoshimi };
|