hoshimi 0.3.1 → 0.3.5

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 CHANGED
@@ -648,2697 +648,2828 @@ interface EnabledDSPXPluginFilters {
648
648
  }
649
649
 
650
650
  /**
651
- * Class representing a LyricsManager.
652
- * @class LyricsManager
651
+ * Class representing a storage manager.
652
+ * @abstract
653
+ * @class StorageManager
654
+ * @example
655
+ * ```ts
656
+ * class MyStorageManager extends StorageManager {};
657
+ *
658
+ * const storage = new MyStorageManager();
659
+ * storage.set("key", "value");
660
+ *
661
+ * const value = await storage.get("key");
662
+ * console.log(value); // "value"
663
+ * ```
653
664
  */
654
- declare class LyricsManager {
665
+ declare abstract class StorageAdapter<T extends QueueJson = QueueJson> {
655
666
  /**
656
- * The node instance.
657
- * @type {NodeStructure}
658
- * @readonly
667
+ *
668
+ * Get the value using the key.
669
+ * @param {string} key The key to get the value from.
670
+ * @returns {Awaitable<T | undefined>} The value of the key.
671
+ * @example
672
+ * ```ts
673
+ * const value = await storage.get("key");
674
+ * console.log(value); // "value"
675
+ * ```
659
676
  */
660
- readonly node: NodeStructure;
677
+ abstract get(key: string): Awaitable<T | undefined>;
661
678
  /**
662
- * Create a new LyricsManager instance.
663
- * @param {NodeStructure} node The node instance.
679
+ *
680
+ * Set the value using the key.
681
+ * @param {string} key The key to set the value to.
682
+ * @param {unknown} value The value to set.
683
+ * @returns {Awaitable<void>} Did you know this can be async?
664
684
  * @example
665
685
  * ```ts
666
- * const node = manager.nodeManager.get("nodeId");
667
- * const lyricsManager = new LyricsManager(node);
686
+ * await storage.set("key", "value");
668
687
  * ```
669
688
  */
670
- constructor(node: NodeStructure);
689
+ abstract set(key: string, value: T): Awaitable<void>;
671
690
  /**
672
691
  *
673
- * Get the current lyrics for the current track.
674
- * @param {boolean} skipSource Whether to skip the track source or not.
675
- * @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
692
+ * Delete the value using the key.
693
+ * @param {string} key The key to delete the value from.
694
+ * @returns {Awaitable<boolean>} Returns true if the key was deleted.
676
695
  * @example
677
696
  * ```ts
678
- * const player = manager.getPlayer("guildId");
679
- * const lyrics = await player.lyricsManager.current();
697
+ * const success = await storage.delete("key");
698
+ * console.log(success); // true
680
699
  * ```
681
700
  */
682
- current(guildId: string, skipSource?: boolean): Promise<LyricsResult | null>;
701
+ abstract delete(key: string): Awaitable<boolean>;
683
702
  /**
684
- *
685
- * Get the lyrics for a specific track.
686
- * @param {Track} track The track to get the lyrics for.
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.
703
+ * Clear the storage.
704
+ * @returns {Awaitable<void>} Scary, right?
689
705
  * @example
690
706
  * ```ts
691
- * const node = manager.nodeManager.get("nodeId");
692
- * const lyrics = await node.lyricsManager.get(track);
707
+ * await storage.clear();
693
708
  * ```
694
709
  */
695
- get(track: Track, skipSource?: boolean): Promise<LyricsResult | null>;
710
+ abstract clear(): Awaitable<void>;
711
+ /**
712
+ * Check if the storage has the key.
713
+ * @param {string} key The key to check.
714
+ * @returns {Awaitable<boolean>} Return true if the key exists.
715
+ * @example
716
+ * ```ts
717
+ * const exists = await storage.has("key");
718
+ * console.log(exists); // true
719
+ * ```
720
+ */
721
+ abstract has(key: string): Awaitable<boolean>;
696
722
  /**
697
723
  *
698
- * Subscribe to the lyrics for a specific guild.
699
- * @param {string} guildId The guild id to subscribe to.
700
- * @param {boolean} skipSource Whether to skip the track source or not.
701
- * @returns {Promise<void>} Let's start the sing session!
724
+ * Parse the value.
725
+ * @param {unknown} value The value to parse.
726
+ * @returns {T} The parsed value.
702
727
  * @example
703
728
  * ```ts
704
- * const node = manager.nodeManager.get("nodeId");
705
- * await node.lyricsManager.subscribe("guildId");
729
+ * const parsed = await storage.parse<{ key: string }>("{'key':'value'}");
730
+ * console.log(parsed); // { key: "value" }
706
731
  * ```
707
732
  */
708
- subscribe(guildId: string, skipSource?: boolean): Promise<void>;
733
+ abstract parse(value: unknown): Awaitable<T>;
709
734
  /**
710
735
  *
711
- * Unsubscribe from the lyrics for a specific guild.
712
- * @param {string} guildId The guild id to unsubscribe from.
713
- * @returns {Promise<void>} Let's stop the sing session!
736
+ * Stringify the value.
737
+ * @param {unknown} value The value to stringify.
738
+ * @returns {R} The stringified value.
714
739
  * @example
715
740
  * ```ts
716
- * const node = manager.nodeManager.get("nodeId");
717
- * await node.lyricsManager.unsubscribe("guildId");
741
+ * const stringified = await storage.stringify({ key: "value" });
742
+ * console.log(stringified); // "{'key':'value'}"
718
743
  * ```
719
744
  */
720
- unsubscribe(guildId: string): Promise<void>;
745
+ abstract stringify<R = string>(value: unknown): Awaitable<R>;
721
746
  }
722
747
 
723
748
  /**
724
- * Represents a collection that extends the built-in Map class.
725
- * @template K The type of the keys in the collection.
726
- * @template V The type of the values in the collection.
749
+ * The queue options.
727
750
  */
728
- declare class Collection<K, V> extends Map<K, V> {
751
+ interface HoshimiQueueOptions {
729
752
  /**
730
- * Removes elements from the collection based on a filter function.
731
- * @param fn The filter function that determines which elements to remove.
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
753
+ * The maximum amount of tracks that can be saved in the queue.
754
+ * @type {number}
755
+ * @default 25
742
756
  */
743
- sweep(fn: (value: V, key: K, collection: this) => unknown): number;
757
+ maxHistory?: number;
744
758
  /**
745
- * Creates a new array with the results of calling a provided function on every element in the collection.
746
- * @param fn The function that produces an element of the new array.
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']
759
+ *
760
+ * The function to use for autoplay.
761
+ * @param {Player} player The player.
762
+ * @param {HoshimiTrack | null} lastTrack The last track played.
756
763
  */
757
- map<T>(fn: (value: V, key: K, collection: this) => T): T[];
764
+ autoplayFn?(player: PlayerStructure, lastTrack: HoshimiTrack | null): Awaitable<void>;
758
765
  /**
759
- * Creates a new array with all elements that pass the test implemented by the provided function.
760
- * @param fn The function to test each element of the collection.
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']
766
+ * Enable the auto play for the queue. (By default, only supports `youtube` and `spotify`, add more with your own function)
767
+ * @type {boolean}
768
+ * @default false
770
769
  */
771
- filter(fn: (value: V, key: K, collection: this) => boolean): V[];
770
+ autoPlay?: boolean;
772
771
  /**
773
- * Returns the value of the first element in the collection that satisfies the provided testing function.
774
- * @param fn The function to test each element of the collection.
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
772
+ * The storage manager to use for the queue.
773
+ * @type {StorageAdapter}
774
+ * @default {MemoryAdapter}
783
775
  */
784
- find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
776
+ storage?: StorageAdapter;
785
777
  }
786
-
787
778
  /**
788
- * Class representing a node manager.
789
- * @class NodeManager
779
+ * The queue json.
790
780
  */
791
- declare class NodeManager {
781
+ interface QueueJson {
792
782
  /**
793
- * The manager for the node.
794
- * @type {Hoshimi}
795
- * @readonly
783
+ * The tracks of the queue.
784
+ * @type {HoshimiTrack[]}
796
785
  */
797
- readonly manager: Hoshimi;
786
+ tracks: HoshimiTrack[];
798
787
  /**
799
- * The nodes for the manager.
800
- * @type {Collection<string, Node>}
801
- * @readonly
788
+ * The previous tracks of the queue.
789
+ * @type {Track[]}
802
790
  */
803
- readonly nodes: Collection<string, NodeStructure>;
791
+ history: Track[];
804
792
  /**
805
- *
806
- * The constructor for the node manager.
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
- * ```
793
+ * The current track of the queue.
794
+ * @type {Track | null}
815
795
  */
816
- constructor(manager: Hoshimi);
796
+ current: Track | null;
797
+ }
798
+
799
+ /**
800
+ * Partial Lavalink track type.
801
+ */
802
+ type PartialLavalinkTrack = Partial<Nullable<LavalinkTrack>>;
803
+ /**
804
+ * The base options for playing a track.
805
+ */
806
+ interface BasePlayOptions {
817
807
  /**
818
- *
819
- * Delete the node.
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
- * ```
808
+ * The position to start the track.
809
+ * @type {number | undefined}
827
810
  */
828
- delete(node: NodeIdentifier): boolean;
811
+ position?: number;
829
812
  /**
830
- *
831
- * Get the node by id.
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
- * ```
813
+ * The position to end the track.
814
+ * @type {number | undefined}
843
815
  */
844
- get(node: NodeIdentifier): NodeStructure | undefined;
816
+ endTime?: number;
845
817
  /**
846
- *
847
- * Create a new node.
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
860
- */
861
- create(options: NodeOptions): NodeStructure;
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
- * ```
818
+ * The pause state of the player.
819
+ * @type {boolean | undefined}
896
820
  */
897
- disconnect(node: NodeIdentifier): void;
821
+ paused?: boolean;
898
822
  /**
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
- * ```
823
+ * The volume of the player.
824
+ * @type {number | undefined}
908
825
  */
909
- connect(node: NodeIdentifier): void;
826
+ volume?: number;
910
827
  /**
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
- * ```
828
+ * The filters for the player.
829
+ * @type {Partial<FilterSettings> | undefined}
923
830
  */
924
- getLeastUsed(sortType?: NodeSortTypes): NodeStructure;
831
+ filters?: Partial<FilterSettings>;
925
832
  /**
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
- * ```
833
+ * The voice settings for the player.
834
+ * @type {LavalinkPlayerVoice | undefined}
934
835
  */
935
- reconnectAll(): void;
836
+ voice?: LavalinkPlayerVoice;
837
+ }
838
+ /**
839
+ * The types of loop modes.
840
+ */
841
+ declare enum LoopMode {
936
842
  /**
937
- * Disconnect the nodes.
938
- * @returns {void}
939
- * @example
940
- * ```ts
941
- * const node = manager.nodeManager.get("node1");
942
- * if (node) node.disconnectAll();
943
- * ```
843
+ * Loop mode for repeating the current track.
944
844
  */
945
- disconnectAll(): void;
845
+ Track = 1,
946
846
  /**
947
- * Connect the nodes.
948
- * @returns {void}
949
- * @example
950
- * ```ts
951
- * const node = manager.nodeManager.get("node1");
952
- * if (node) node.connect();
953
- * ```
847
+ * Loop mode for repeating the queue.
954
848
  */
955
- connectAll(): void;
849
+ Queue = 2,
956
850
  /**
957
- * Destroy the nodes.
958
- * @returns {void}
959
- * @example
960
- * ```ts
961
- * const node = manager.nodeManager.get("node1");
962
- * if (node) node.destroy();
963
- * ```
851
+ * Loop mode for repeating nothing.
964
852
  */
965
- destroyAll(): void;
853
+ Off = 3
966
854
  }
967
-
968
855
  /**
969
- * The methods for http requests
856
+ * The types of player events.
970
857
  */
971
- declare enum HttpMethods {
858
+ declare enum PlayerEventType {
972
859
  /**
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}
860
+ * Event type for when a track starts.
976
861
  */
977
- Get = "GET",
862
+ TrackStart = "TrackStartEvent",
978
863
  /**
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}
864
+ * Event type for when a track ends.
982
865
  */
983
- Post = "POST",
866
+ TrackEnd = "TrackEndEvent",
984
867
  /**
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}
868
+ * Event type for when a track encounters an exception.
988
869
  */
989
- Put = "PUT",
870
+ TrackException = "TrackExceptionEvent",
990
871
  /**
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}
872
+ * Event type for when a track gets stuck.
994
873
  */
995
- Patch = "PATCH",
874
+ TrackStuck = "TrackStuckEvent",
996
875
  /**
997
- * The DELETE method deletes the specified resource.
998
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
999
- * @type {string}
876
+ * Event type for when lyrics are found.
1000
877
  */
1001
- Delete = "DELETE",
878
+ LyricsFound = "LyricsFoundEvent",
1002
879
  /**
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}
880
+ * Event type for when lyrics are not found.
1006
881
  */
1007
- Head = "HEAD"
1008
- }
1009
- declare enum RestPathType {
882
+ LyricsNotFound = "LyricsNotFoundEvent",
1010
883
  /**
1011
- * The raw path of the request.
1012
- * @type {string}
884
+ * Event type for when a lyrics line is sent.
1013
885
  */
1014
- Raw = "/",
886
+ LyricsLine = "LyricsLineEvent",
1015
887
  /**
1016
- * The versioned path v4 of the request.
1017
- * @type {string}
888
+ * Event type for when the WebSocket connection is closed.
1018
889
  */
1019
- V4 = "/v4"
890
+ WebsocketClosed = "WebSocketClosedEvent"
1020
891
  }
1021
892
  /**
1022
- * The status codes for the REST.
1023
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
893
+ * The reasons a track can end.
1024
894
  */
1025
- declare enum HttpStatusCodes {
895
+ declare enum TrackEndReason {
1026
896
  /**
1027
- * The request has succeeded.
1028
- * @type {number}
897
+ * The track ended normally.
1029
898
  */
1030
- OK = 200,
899
+ Finished = "finished",
1031
900
  /**
1032
- * The request has been fulfilled and resulted in a new resource being created.
1033
- * @type {number}
901
+ * The track fails to load.
1034
902
  */
1035
- Created = 201,
903
+ LoadFailed = "loadFailed",
1036
904
  /**
1037
- * The request has been accepted for processing, but the processing has not been completed.
1038
- * @type {number}
905
+ * The track was stopped.
1039
906
  */
1040
- Accepted = 202,
907
+ Stopped = "stopped",
1041
908
  /**
1042
- * The server successfully processed the request, but is not returning any content.
1043
- * @type {number}
909
+ * The track was replaced.
1044
910
  */
1045
- NoContent = 204,
911
+ Replaced = "replaced",
1046
912
  /**
1047
- * The resource has been moved permanently to a new URI.
1048
- * @type {number}
913
+ * The track was cleaned up.
1049
914
  */
1050
- MovedPermanently = 301,
915
+ Cleanup = "cleanup"
916
+ }
917
+ /**
918
+ * The options for automatic player error handling.
919
+ */
920
+ interface ErrorPlayerActions {
1051
921
  /**
1052
- * The requested resource has been found at a different URI.
1053
- * @type {number}
922
+ * Whether to automatically destroy the player on error.
923
+ * @type {boolean | undefined}
924
+ * @default false
1054
925
  */
1055
- Found = 302,
926
+ autoDestroy?: boolean;
1056
927
  /**
1057
- * The resource has not been modified since the last request.
1058
- * @type {number}
928
+ * Whether to automatically skip the track on error.
929
+ * @type {boolean | undefined}
930
+ * @default false
1059
931
  */
1060
- NotModified = 304,
932
+ autoSkip?: boolean;
1061
933
  /**
1062
- * The request cannot be processed due to bad syntax.
1063
- * @type {number}
934
+ * Whether to automatically stop the player on error.
935
+ * @type {boolean | undefined}
936
+ * @default false
1064
937
  */
1065
- BadRequest = 400,
938
+ autoStop?: boolean;
939
+ }
940
+ /**
941
+ * The options for error actions.
942
+ */
943
+ interface DisconnectPlayerActions extends Pick<ErrorPlayerActions, "autoDestroy"> {
1066
944
  /**
1067
- * The request requires user authentication.
1068
- * @type {number}
945
+ * Whether to automatically reconnect on disconnect.
946
+ * @type {boolean | undefined}
947
+ * @default false
1069
948
  */
1070
- Unauthorized = 401,
949
+ autoReconnect?: boolean;
1071
950
  /**
1072
- * The request was valid, but the server is refusing action.
1073
- * @type {number}
951
+ * Whether to automatically add tracks back to the queue on disconnect.
952
+ * @type {boolean | undefined}
953
+ * @default false
1074
954
  */
1075
- Forbidden = 403,
955
+ autoQueue?: boolean;
956
+ }
957
+ /**
958
+ * The Hoshimi player options.
959
+ */
960
+ interface HoshimiPlayerOptions {
1076
961
  /**
1077
- * The server cannot find the requested resource.
1078
- * @type {number}
962
+ *
963
+ * The function to use to get the requester data.
964
+ * @param {TrackRequester} requester The requester of the track.
1079
965
  */
1080
- NotFound = 404,
966
+ requesterFn?<T extends TrackRequester = TrackRequester>(requester: TrackRequester): Awaitable<T>;
1081
967
  /**
1082
- * The request method is known by the server but has been disabled and cannot be used.
1083
- * @type {number}
968
+ * The options for handling errors.
969
+ * @type {ErrorPlayerActions | undefined}
1084
970
  */
1085
- MethodNotAllowed = 405,
971
+ onError?: ErrorPlayerActions;
1086
972
  /**
1087
- * The server timed out waiting for the request.
1088
- * @type {number}
973
+ * The options for handling disconnects.
974
+ * @type {DisconnectPlayerActions | undefined}
1089
975
  */
1090
- RequestTimeout = 408,
976
+ onDisconnect?: DisconnectPlayerActions;
977
+ }
978
+ /**
979
+ * The base interface for player events.
980
+ */
981
+ interface PlayerEvent {
1091
982
  /**
1092
- * The request could not be completed due to a conflict with the current state of the resource.
1093
- * @type {number}
1094
- */
1095
- Conflict = 409,
1096
- /**
1097
- * The requested resource is no longer available and will not be available again.
1098
- * @type {number}
1099
- */
1100
- Gone = 410,
1101
- /**
1102
- * The user has sent too many requests in a given amount of time.
1103
- * @type {number}
1104
- */
1105
- TooManyRequests = 429,
1106
- /**
1107
- * A generic error message, given when no more specific message is suitable.
1108
- * @type {number}
1109
- */
1110
- InternalServerError = 500,
1111
- /**
1112
- * The server does not recognize the request method or lacks the ability to fulfill it.
1113
- * @type {number}
983
+ * The operation code for the event.
984
+ * @type {OpCodes.Event}
1114
985
  */
1115
- NotImplemented = 501,
986
+ op: OpCodes.Event;
1116
987
  /**
1117
- * The server was acting as a gateway and received an invalid response.
1118
- * @type {number}
988
+ * The guild ID associated with the event.
989
+ * @type {string}
1119
990
  */
1120
- BadGateway = 502,
991
+ guildId: string;
992
+ }
993
+ /**
994
+ * The event for when a track starts playing.
995
+ */
996
+ interface TrackStartEvent extends PlayerEvent {
1121
997
  /**
1122
- * The server is currently unavailable (overloaded or down).
1123
- * @type {number}
998
+ * The type of the event.
999
+ * @type {PlayerEventType.TrackStart}
1124
1000
  */
1125
- ServiceUnavailable = 503,
1001
+ type: PlayerEventType.TrackStart;
1126
1002
  /**
1127
- * The server did not receive a timely response from an upstream server.
1128
- * @type {number}
1003
+ * The track that started playing.
1004
+ * @type {LavalinkTrack}
1129
1005
  */
1130
- GatewayTimeout = 504
1006
+ track: LavalinkTrack;
1131
1007
  }
1132
1008
  /**
1133
- * The options for the REST.
1009
+ * The event for when a track ends.
1134
1010
  */
1135
- interface RestOptions {
1011
+ interface TrackEndEvent extends PlayerEvent {
1136
1012
  /**
1137
- * The endpoint for the REST.
1138
- * @type {string}
1013
+ * The type of the event.
1014
+ * @type {PlayerEventType.TrackEnd}
1139
1015
  */
1140
- endpoint: `/${string}`;
1016
+ type: PlayerEventType.TrackEnd;
1141
1017
  /**
1142
- * The method for the REST.
1143
- * @type {HttpMethods}
1018
+ * The track that ended.
1019
+ * @type {LavalinkTrack}
1144
1020
  */
1145
- method?: HttpMethods;
1021
+ track: LavalinkTrack;
1146
1022
  /**
1147
- * The headers for the REST.
1148
- * @type {Record<string, string>}
1023
+ * The reason the track ended.
1024
+ * @type {TrackEndReason}
1149
1025
  */
1150
- headers?: Record<string, string>;
1026
+ reason: TrackEndReason;
1027
+ }
1028
+ /**
1029
+ * The event for when a track gets stuck.
1030
+ */
1031
+ interface TrackStuckEvent extends PlayerEvent {
1151
1032
  /**
1152
- * The body for the REST.
1153
- * @type {Record<string, unknown> | string | undefined}
1033
+ * The type of the event.
1034
+ * @type {PlayerEventType.TrackStuck}
1154
1035
  */
1155
- body?: Record<string, unknown> | string;
1036
+ type: PlayerEventType.TrackStuck;
1156
1037
  /**
1157
- * The query parameters for the REST.
1158
- * @type {Record<string, string>}
1038
+ * The track that got stuck.
1039
+ * @type {LavalinkTrack}
1159
1040
  */
1160
- params?: Record<string, string>;
1041
+ track: LavalinkTrack;
1161
1042
  /**
1162
- * The path type for the REST.
1163
- * @type {RestPathType}
1043
+ * The threshold in milliseconds.
1044
+ * @type {number}
1164
1045
  */
1165
- pathType?: RestPathType;
1046
+ thresholdMs: number;
1166
1047
  }
1167
1048
  /**
1168
- * The fetch options for the request.
1049
+ * The event for when a track encounters an exception.
1169
1050
  */
1170
- interface FetchOptions extends Omit<RestOptions, "endpoint" | "body"> {
1051
+ interface TrackExceptionEvent extends PlayerEvent {
1171
1052
  /**
1172
- * The signal for the request.
1053
+ * The type of the event.
1054
+ * @type {PlayerEventType.TrackException}
1173
1055
  */
1174
- signal: AbortSignal;
1056
+ type: PlayerEventType.TrackException;
1175
1057
  /**
1176
- * The stringified body for the request.
1058
+ * The exception that occurred.
1059
+ * @type {Exception}
1177
1060
  */
1178
- body?: string;
1061
+ exception: Exception;
1179
1062
  }
1180
1063
  /**
1181
- * The error for the REST.
1064
+ * The event for when the WebSocket connection is closed.
1182
1065
  */
1183
- interface LavalinkRestError {
1066
+ interface WebSocketClosedEvent extends PlayerEvent {
1184
1067
  /**
1185
- * The timestamp for the REST.
1186
- * @type {number}
1068
+ * The type of the event.
1069
+ * @type {PlayerEventType.WebsocketClosed}
1187
1070
  */
1188
- timestamp: number;
1071
+ type: PlayerEventType.WebsocketClosed;
1189
1072
  /**
1190
- * The status for the REST.
1073
+ * The close code.
1191
1074
  * @type {number}
1192
1075
  */
1193
- status: number;
1076
+ code: number;
1194
1077
  /**
1195
- * The error for the REST.
1196
- * @type {string}
1078
+ * Whether the connection was closed by the remote.
1079
+ * @type {boolean}
1197
1080
  */
1198
- error: string;
1081
+ byRemote: boolean;
1199
1082
  /**
1200
- * The trace for the REST.
1083
+ * The reason for the closure.
1201
1084
  * @type {string}
1202
1085
  */
1203
- trace?: string;
1086
+ reason: string;
1087
+ }
1088
+ /**
1089
+ * The event for when lyrics are found.
1090
+ */
1091
+ interface LyricsFoundEvent extends PlayerEvent {
1204
1092
  /**
1205
- * The message for the REST.
1206
- * @type {string}
1093
+ * The type of the event.
1094
+ * @type {PlayerEventType.LyricsFound}
1207
1095
  */
1208
- message: string;
1096
+ type: PlayerEventType.LyricsFound;
1209
1097
  /**
1210
- * The path for the REST.
1098
+ * The guild id associated with the event.
1211
1099
  * @type {string}
1212
1100
  */
1213
- path: string;
1101
+ guildId: string;
1102
+ /**
1103
+ * The lyrics result of the event.
1104
+ * @type {LyricsResult}
1105
+ */
1106
+ lyrics: LyricsResult;
1214
1107
  }
1215
1108
  /**
1216
- * The player response from the Lavalink REST API.
1109
+ * The event for when lyrics are not found.
1217
1110
  */
1218
- interface LavalinkPlayer {
1111
+ interface LyricsNotFoundEvent extends PlayerEvent {
1219
1112
  /**
1220
- * The guild ID associated with the player.
1113
+ * The type of the event.
1114
+ * @type {PlayerEventType.LyricsNotFound}
1115
+ */
1116
+ type: PlayerEventType.LyricsNotFound;
1117
+ /**
1118
+ * The guild id associated with the event.
1221
1119
  * @type {string}
1222
1120
  */
1223
1121
  guildId: string;
1122
+ }
1123
+ /**
1124
+ * The event for when a lyrics line is sent.
1125
+ */
1126
+ interface LyricsLineEvent extends PlayerEvent {
1224
1127
  /**
1225
- * The track currently being played.
1226
- * @type {LavalinkTrack}
1128
+ * The type of the event.
1129
+ * @type {PlayerEventType.LyricsLine}
1227
1130
  */
1228
- track?: LavalinkTrack;
1131
+ type: PlayerEventType.LyricsLine;
1229
1132
  /**
1230
- * The volume of the player.
1133
+ * The guild id associated with the event.
1134
+ * @type {string}
1135
+ */
1136
+ guildId: string;
1137
+ /**
1138
+ * The line index of the lyrics line.
1231
1139
  * @type {number}
1232
1140
  */
1233
- volume: number;
1141
+ lineIndex: number;
1234
1142
  /**
1235
- * Whether the player is paused.
1143
+ * The lyrics line of the event.
1144
+ * @type {LyricsLine}
1145
+ */
1146
+ line: LyricsLine;
1147
+ /**
1148
+ * Returns if the line was skipped.
1236
1149
  * @type {boolean}
1237
1150
  */
1238
- paused: boolean;
1151
+ skipped: boolean;
1152
+ }
1153
+ /**
1154
+ * The update for the player state.
1155
+ */
1156
+ interface PlayerUpdate {
1239
1157
  /**
1240
- * The voice connection details.
1241
- * @type {LavalinkPlayerVoice}
1158
+ * The operation code for the update.
1159
+ * @type {OpCodes.PlayerUpdate}
1242
1160
  */
1243
- voice: LavalinkPlayerVoice;
1161
+ op: OpCodes.PlayerUpdate;
1244
1162
  /**
1245
- * The filter options applied to the player.
1246
- * @type {FilterSettings}
1163
+ * The guild ID associated with the update.
1164
+ * @type {string}
1247
1165
  */
1248
- filters: FilterSettings;
1166
+ guildId: string;
1249
1167
  /**
1250
1168
  * The state of the player.
1251
- * @type {LavalinkPlayerState}
1169
+ * @type {PlayerUpdateState}
1252
1170
  */
1253
- state: LavalinkPlayerState;
1171
+ state: PlayerUpdateState;
1254
1172
  }
1255
- /**
1256
- * The state of the player.
1257
- */
1258
- interface LavalinkPlayerState {
1173
+ interface PlayerUpdateState {
1259
1174
  /**
1260
- * The time since the connection was established.
1261
- * @type {number}
1175
+ * Whether the player is connected.
1176
+ * @type {boolean}
1262
1177
  */
1263
- time: number;
1178
+ connected: boolean;
1264
1179
  /**
1265
- * The position of the current track in milliseconds.
1180
+ * The position of the track.
1266
1181
  * @type {number}
1267
1182
  */
1268
1183
  position: number;
1269
1184
  /**
1270
- * Whether the player is connected to the voice channel.
1271
- * @type {boolean}
1185
+ * The time of the update.
1186
+ * @type {number}
1272
1187
  */
1273
- connected: boolean;
1188
+ time: number;
1274
1189
  /**
1275
- * The ping to the voice server in milliseconds.
1190
+ * The ping of the player.
1276
1191
  * @type {number}
1277
1192
  */
1278
1193
  ping: number;
1279
1194
  }
1280
1195
  /**
1281
- * The options to update the player.
1196
+ * The options for the player.
1282
1197
  */
1283
- interface UpdatePlayerInfo {
1198
+ interface PlayerOptions {
1284
1199
  /**
1285
- * The guild id associated with the player.
1200
+ * Guild id of the player.
1286
1201
  * @type {string}
1287
1202
  */
1288
1203
  guildId: string;
1289
1204
  /**
1290
- * The options to update the player.
1291
- * @type {LavalinkPlayOptions}
1205
+ * Voice channel id of the player.
1206
+ * @type {string}
1292
1207
  */
1293
- playerOptions: LavalinkPlayOptions;
1208
+ voiceId: string;
1294
1209
  /**
1295
- * Whether to replace the current track.
1210
+ * Volume of the player.
1211
+ * @type {number | undefined}
1212
+ * @default 100
1213
+ */
1214
+ volume?: number;
1215
+ /**
1216
+ * Set if the player should be deafened.
1296
1217
  * @type {boolean | undefined}
1297
- * @default false
1218
+ * @default true
1298
1219
  */
1299
- noReplace?: boolean;
1300
- }
1301
- /**
1302
- * The updated session of the current session.
1303
- */
1304
- interface LavalinkSession {
1220
+ selfDeaf?: boolean;
1305
1221
  /**
1306
- * Whather the session is resuming.
1307
- * @type {boolean}
1222
+ * Set if the player should be muted.
1223
+ * @type {boolean | undefined}
1224
+ * @default false
1308
1225
  */
1309
- resuming: boolean;
1226
+ selfMute?: boolean;
1310
1227
  /**
1311
- * The timeout for the session.
1312
- * @type {number}
1228
+ * Text channel id of the player.
1229
+ * @type {string | undefined}
1313
1230
  */
1314
- timeout: number;
1231
+ textId?: string;
1232
+ /**
1233
+ * Lavalink node of the player.
1234
+ * @type {NodeIdentifier}
1235
+ */
1236
+ node?: NodeIdentifier;
1315
1237
  }
1316
1238
  /**
1317
- * The rest options.
1239
+ * The options for playing a track with Lavalink.
1318
1240
  */
1319
- interface HoshimiRestOptions {
1241
+ interface LavalinkPlayOptions extends BasePlayOptions {
1320
1242
  /**
1321
- * The amount of time to wait for the player to resume. (in milliseconds)
1322
- * @type {number}
1323
- * @default 10000
1243
+ * Track to play.
1244
+ * @type {PartialLavalinkTrack | undefined}
1324
1245
  */
1325
- resumeTimeout?: number;
1246
+ track?: PartialLavalinkTrack;
1326
1247
  }
1327
1248
  /**
1328
- * The methods for decoding base64 encoded tracks.
1249
+ * The options for playing a track.
1329
1250
  */
1330
- interface DecodeMethods {
1251
+ interface PlayOptions extends BasePlayOptions {
1331
1252
  /**
1332
- *
1333
- * Decodes a single base64 encoded track.
1334
- * @param {string} track The base64 encoded track.
1335
- * @param {TrackRequester} requester The requester of the track.
1336
- * @return {Promise<Track>} The decoded track.
1337
- * @example
1338
- * ```ts
1339
- * const node = player.node;
1340
- * const track = await node.decode.single("base64EncodedTrack");
1341
- * console.log(track.info.title); // Track Title
1342
- * ```
1253
+ * Whether to replace the current track.
1254
+ * @type {boolean | undefined}
1255
+ * @default false
1343
1256
  */
1344
- single(track: string, requester: TrackRequester): Promise<Track>;
1257
+ noReplace?: boolean;
1345
1258
  /**
1346
- * Decodes multiple base64 encoded tracks.
1347
- * @param {string[]} tracks The base64 encoded tracks.
1348
- * @param {TrackRequester} requester The requester of the tracks.
1349
- * @return {Promise<Track[]>} The decoded tracks.
1350
- * @example
1351
- * ```ts
1352
- * const node = player.node;
1353
- * const tracks = await node.decode.multiple(["base64EncodedTrack1", "base64EncodedTrack2"]);
1354
- * console.log(tracks[0].info.title); // Track Title 1
1355
- * console.log(tracks[1].info.title); // Track Title 2
1356
- * ```
1259
+ * Track to play.
1260
+ * @type {Track | UnresolvedTrack | undefined}
1357
1261
  */
1358
- multiple(tracks: string[], requester: TrackRequester): Promise<Track[]>;
1262
+ track?: Track | UnresolvedTrack;
1359
1263
  }
1360
- /**
1361
- * The session of the node.
1362
- */
1363
- type NullableLavalinkSession = PickNullable<LavalinkSession, "timeout">;
1364
-
1365
- /**
1366
- * Class representing the REST for the node.
1367
- * @class Rest
1368
- */
1369
- declare class Rest {
1264
+ interface PlayerVoice {
1370
1265
  /**
1371
- * The URL for the REST.
1266
+ * The voice server token.
1372
1267
  * @type {string}
1373
1268
  */
1374
- readonly url: string;
1269
+ token: string;
1375
1270
  /**
1376
- * The version for the REST.
1271
+ * The voice server endpoint.
1377
1272
  * @type {string}
1378
1273
  */
1379
- readonly version: string;
1274
+ endpoint: string;
1380
1275
  /**
1381
- * The timeout for the REST.
1382
- * @type {number}
1276
+ * The voice server session id.
1277
+ * @type {string}
1383
1278
  */
1384
- readonly restTimeout: number;
1279
+ sessionId: string;
1385
1280
  /**
1386
- * The user agent for the REST.
1387
- * @type {UserAgent}
1281
+ * The voice server guild id.
1282
+ * @type {string | undefined}
1388
1283
  */
1389
- readonly userAgent: UserAgent;
1284
+ connected?: boolean;
1390
1285
  /**
1391
- * The node for the REST.
1392
- * @type {Node}
1286
+ * The voice server ping.
1287
+ * @type {number | undefined}
1393
1288
  */
1394
- readonly node: NodeStructure;
1289
+ ping?: number;
1290
+ }
1291
+ /**
1292
+ * The JSON representation of the player.
1293
+ */
1294
+ interface PlayerJson {
1395
1295
  /**
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
- * ```
1296
+ * The guild id of the player.
1297
+ * @type {string}
1411
1298
  */
1412
- constructor(node: NodeStructure);
1299
+ guildId: string;
1413
1300
  /**
1414
- * The REST URL to make requests.
1415
- * @type {string}
1301
+ * The volume of the player.
1302
+ * @type {number}
1416
1303
  */
1417
- get restUrl(): string;
1304
+ volume: number;
1418
1305
  /**
1419
- * The session id of the node.
1420
- * @type {string}
1306
+ * The self deaf state of the player.
1307
+ * @type {boolean}
1421
1308
  */
1422
- get sessionId(): string;
1309
+ selfDeaf: boolean;
1423
1310
  /**
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.
1311
+ * The self mute state of the player.
1312
+ * @type {boolean}
1428
1313
  */
1429
- request<T>(options: RestOptions): Promise<T | null>;
1314
+ selfMute: boolean;
1430
1315
  /**
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
- * ```
1316
+ * The voice settings for the player.
1317
+ * @type {LavalinkPlayerVoice}
1448
1318
  */
1449
- updatePlayer(data: Partial<UpdatePlayerInfo>): Promise<LavalinkPlayer | null>;
1319
+ voice: Nullable<LavalinkPlayerVoice>;
1450
1320
  /**
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
- * ```
1321
+ * The loop mode of the player.
1322
+ * @type {LoopMode}
1460
1323
  */
1461
- stopPlayer(guildId: string): Promise<LavalinkPlayer | null>;
1324
+ loop: LoopMode;
1462
1325
  /**
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
1326
+ * The options for the player.
1327
+ * @type {boolean}
1472
1328
  */
1473
- destroyPlayer(guildId: string): Promise<void>;
1329
+ options: PlayerOptions;
1474
1330
  /**
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
- * ```
1331
+ * The paused state of the player.
1332
+ * @type {boolean}
1485
1333
  */
1486
- updateSession(resuming: boolean, timeout?: number | null): Promise<LavalinkSession | null>;
1487
- }
1488
-
1489
- /**
1490
- * Class representing the DSPX Plugin filters for a player.
1491
- * @class DSPXPluginFilter
1492
- */
1493
- declare class DSPXPluginFilter {
1334
+ paused: boolean;
1494
1335
  /**
1495
- * The filter manager instance.
1496
- * @type {FilterManagerStructure}
1497
- * @readonly
1336
+ * The playing state of the player.
1337
+ * @type {boolean}
1498
1338
  */
1499
- readonly manager: FilterManagerStructure;
1339
+ playing: boolean;
1500
1340
  /**
1501
- * Create a new DSPXPluginFilter instance.
1502
- * @param {FilterManagerStructure} manager The filter manager instance.
1341
+ * The voice channel id of the player.
1342
+ * @type {string}
1503
1343
  */
1504
- constructor(manager: FilterManagerStructure);
1344
+ voiceId?: string;
1505
1345
  /**
1506
- *
1507
- * Set the low-pass filter with the given settings.
1508
- * @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXLowPass] The settings for the low-pass filter.
1509
- * @returns {Promise<this>} The instance of the filter manager.
1346
+ * The text channel id of the player.
1347
+ * @type {string | undefined}
1510
1348
  */
1511
- setLowPass(settings?: Partial<FilterPluginPassSettings>): Promise<this>;
1349
+ textId?: string;
1512
1350
  /**
1513
- *
1514
- * Set the high-pass filter with the given settings.
1515
- * @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXHighPass] The settings for the high-pass filter.
1516
- * @returns {Promise<this>} The instance of the filter manager.
1351
+ * The last position received from Lavalink.
1352
+ * @type {number}
1517
1353
  */
1518
- setHighPass(settings?: Partial<FilterPluginPassSettings>): Promise<this>;
1354
+ lastPosition: number;
1519
1355
  /**
1520
- *
1521
- * Set the normalization filter with the given settings.
1522
- * @param {NormalizationSettings} [settings=DefaultFilter.DSPXNormalization] The settings for the normalization filter.
1523
- * @returns {Promise<this>} The instance of the filter manager.
1356
+ * The timestamp when the last position change update happened.
1357
+ * @type {number | null}
1524
1358
  */
1525
- setNormalization(settings?: Partial<NormalizationSettings>): Promise<this>;
1359
+ lastPositionUpdate: number | null;
1526
1360
  /**
1527
- *
1528
- * Set the echo filter with the given settings.
1529
- * @param {EchoSettings} [settings=DefaultFilter.DSPXEcho] The settings for the echo filter.
1530
- * @returns {Promise<this>} The instance of the filter manager.
1361
+ * The current calculated position of the player.
1362
+ * @type {number}
1531
1363
  */
1532
- setEcho(settings?: Partial<EchoSettings>): Promise<this>;
1533
- }
1534
-
1535
- type NonLengthEchoSettings = Omit$1<EchoSettings, "echoLength">;
1536
- /**
1537
- * Class representing Lavalink plugin filters.
1538
- * @class LavalinkPluginFilter
1539
- */
1540
- declare class LavalinkPluginFilter {
1364
+ position: number;
1541
1365
  /**
1542
- * The filter manager instance.
1543
- * @type {FilterManagerStructure}
1544
- * @private
1545
- * @readonly
1366
+ * The timestamp when the player was created.
1367
+ * @type {number}
1546
1368
  */
1547
- private readonly manager;
1369
+ createdTimestamp: number;
1548
1370
  /**
1549
- * Creates an instance of LavalinkPluginFilter.
1550
- * @param {FilterManagerStructure} filters - The filter manager instance.
1371
+ * The ping of the player.
1372
+ * @type {number}
1551
1373
  */
1552
- constructor(filters: FilterManagerStructure);
1374
+ ping: number;
1553
1375
  /**
1554
- *
1555
- * Set the echo filter with the given settings.
1556
- * @param {Omit<EchoSettings, "echoLength">} [settings=DefaultFilter.PluginEcho] The settings for the echo filter.
1557
- * @returns {Promise<this>} The instance of the filter manager.
1376
+ * The queue of the player.
1377
+ * @type {QueueJson}
1558
1378
  */
1559
- setEcho(settings?: Partial<NonLengthEchoSettings>): Promise<this>;
1379
+ queue: QueueJson;
1560
1380
  /**
1561
- *
1562
- * Set the reverb filter with the given settings.
1563
- * @param {Partial<LavalinkFilterPluginReverbSettings>} [settings=DefaultFilter.PluginReverb] The settings for the reverb filter.
1564
- * @returns {Promise<this>} The instance of the filter manager.
1381
+ * The node of the player.
1382
+ * @type {NodeJson}
1565
1383
  */
1566
- setReverb(settings?: Partial<LavalinkFilterPluginReverbSettings>): Promise<this>;
1384
+ node: NodeJson;
1385
+ /**
1386
+ * The filter settings of the player.
1387
+ * @type {FilterSettings}
1388
+ */
1389
+ filters: FilterSettings;
1567
1390
  }
1568
-
1569
1391
  /**
1570
- * Class representing a filter manager for a player.
1571
- * @class FilterManager
1392
+ * The lyrics methods for the player.
1572
1393
  */
1573
- declare class FilterManager {
1394
+ interface LyricsMethods {
1574
1395
  /**
1575
- * The player this filter manager belongs to.
1576
- * @type {PlayerStructure}
1577
- * @public
1578
- * @readonly
1396
+ *
1397
+ * Get the current lyrics for the current track.
1398
+ * @param {boolean} [skipSource=false] Whether to skip the source or not.
1399
+ * @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
1400
+ * @example
1401
+ * ```ts
1402
+ * const player = manager.getPlayer("guildId");
1403
+ * const lyrics = await player.lyricsManager.current();
1404
+ * ```
1579
1405
  */
1580
- readonly player: PlayerStructure;
1406
+ current(skipSource?: boolean): Promise<LyricsResult | null>;
1581
1407
  /**
1582
- * The bands applied to the player.
1583
- * @type {EQBandSettings[]}
1584
- * @readonly
1408
+ *
1409
+ * Get the lyrics for a specific track.
1410
+ * @param {Track} track The track to get the lyrics for.
1411
+ * @param {boolean} [skipSource=false] Whether to skip the source or not.
1412
+ * @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
1413
+ * @example
1414
+ * ```ts
1415
+ * const player = manager.getPlayer("guildId");
1416
+ * const track = player.queue.current;
1417
+ * const lyrics = await player.lyrics.get(track);
1418
+ * ```
1585
1419
  */
1586
- readonly bands: EQBandSettings[];
1420
+ get(track: Track, skipSource?: boolean): Promise<LyricsResult | null>;
1587
1421
  /**
1588
- * The current filter settings applied to the player.
1589
- * @type {FilterSettings}
1590
- * @public
1422
+ *
1423
+ * Subscribe to the lyrics for a specific guild.
1424
+ * @param {boolean} [skipSource=false] Whether to skip the source or not.
1425
+ * @returns {Promise<void>} Let's start the sing session!
1426
+ * @example
1427
+ * ```ts
1428
+ * const player = manager.getPlayer("guildId");
1429
+ * await player.lyrics.subscribe();
1430
+ * ```
1591
1431
  */
1592
- data: FilterSettings;
1432
+ subscribe(skipSource?: boolean): Promise<void>;
1593
1433
  /**
1594
- * The enabled filters for the player.
1595
- * @type {EnabledPlayerFilters}
1434
+ *
1435
+ * Unsubscribe from the lyrics for a specific guild.
1436
+ * @returns {Promise<void>} Let's stop the sing session!
1437
+ * @example
1438
+ * ```ts
1439
+ * const player = manager.getPlayer("guildId");
1440
+ * await player.lyrics.unsubscribe();
1441
+ * ```
1596
1442
  */
1597
- filters: EnabledPlayerFilters;
1443
+ unsubscribe(): Promise<void>;
1444
+ }
1445
+ /**
1446
+ * The voice channel update options.
1447
+ */
1448
+ type VoiceChannelUpdate = Pick<PlayerOptions, "selfDeaf" | "voiceId" | "selfMute">;
1449
+ /**
1450
+ * The voice settings for the player.
1451
+ */
1452
+ type LavalinkPlayerVoice = Omit<PlayerVoice, "connected" | "ping">;
1453
+
1454
+ /**
1455
+ * Class representing a LyricsManager.
1456
+ * @class LyricsManager
1457
+ */
1458
+ declare class LyricsManager {
1598
1459
  /**
1599
- * The lavalink plugin filters manager.
1600
- * @type {LavalinkPluginFilter}
1460
+ * The node instance.
1461
+ * @type {NodeStructure}
1601
1462
  * @readonly
1602
1463
  */
1603
- readonly plugin: LavalinkPluginFilter;
1464
+ readonly node: NodeStructure;
1604
1465
  /**
1605
- * The DSPX plugin filters manager.
1606
- * @type {DSPXPluginFilter}
1607
- * @readonly
1466
+ * Create a new LyricsManager instance.
1467
+ * @param {NodeStructure} node The node instance.
1468
+ * @example
1469
+ * ```ts
1470
+ * const node = manager.nodeManager.get("nodeId");
1471
+ * const lyricsManager = new LyricsManager(node);
1472
+ * ```
1608
1473
  */
1609
- readonly dspx: DSPXPluginFilter;
1474
+ constructor(node: NodeStructure);
1610
1475
  /**
1611
1476
  *
1612
- * Creates a new filter manager.
1613
- * @param {PlayerStructure} player The player this filter manager belongs to.
1614
- */
1615
- constructor(player: PlayerStructure);
1616
- /**
1617
- * Resets all filters to their default values.
1618
- * @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
1477
+ * Get the current lyrics for the current track.
1478
+ * @param {boolean} skipSource Whether to skip the track source or not.
1479
+ * @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
1480
+ * @example
1481
+ * ```ts
1482
+ * const player = manager.getPlayer("guildId");
1483
+ * const lyrics = await player.lyricsManager.current();
1484
+ * ```
1619
1485
  */
1620
- reset(): Promise<this>;
1486
+ current(guildId: string, skipSource?: boolean): Promise<LyricsResult | null>;
1621
1487
  /**
1622
1488
  *
1623
- * Applies the current filters to the player.
1624
- * @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
1625
- */
1626
- apply(): Promise<this>;
1627
- /**
1628
- * Checks if the current filters are active.
1629
- * @param {TimescaleSettings} timescale The timescale settings to check against.
1630
- * @returns {void} Nothing!
1489
+ * Get the lyrics for a specific track.
1490
+ * @param {Track} track The track to get the lyrics for.
1491
+ * @param {boolean} skipSource Whether to skip the track source or not.
1492
+ * @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
1493
+ * @example
1494
+ * ```ts
1495
+ * const node = manager.nodeManager.get("nodeId");
1496
+ * const lyrics = await node.lyricsManager.get(track);
1497
+ * ```
1631
1498
  */
1632
- check(timescale?: TimescaleSettings): void;
1499
+ get(track: Track, skipSource?: boolean): Promise<LyricsResult | null>;
1633
1500
  /**
1634
1501
  *
1635
- * Checks if a specific filter is active.
1636
- * @param {FilterType} filter The filter type to check.
1637
- * @returns {boolean} True if the filter is active, false otherwise.
1502
+ * Subscribe to the lyrics for a specific guild.
1503
+ * @param {string} guildId The guild id to subscribe to.
1504
+ * @param {boolean} skipSource Whether to skip the track source or not.
1505
+ * @returns {Promise<void>} Let's start the sing session!
1506
+ * @example
1507
+ * ```ts
1508
+ * const node = manager.nodeManager.get("nodeId");
1509
+ * await node.lyricsManager.subscribe("guildId");
1510
+ * ```
1638
1511
  */
1639
- has(filter: FilterType): boolean;
1512
+ subscribe(guildId: string, skipSource?: boolean): Promise<void>;
1640
1513
  /**
1641
1514
  *
1642
- * Sets the volume for the player.
1643
- * @param {number} volume The volume level to set (between 0 and 5).
1644
- * @returns {Promise<this>} A promise that resolves to the player instance.
1515
+ * Unsubscribe from the lyrics for a specific guild.
1516
+ * @param {string} guildId The guild id to unsubscribe from.
1517
+ * @returns {Promise<void>} Let's stop the sing session!
1518
+ * @example
1519
+ * ```ts
1520
+ * const node = manager.nodeManager.get("nodeId");
1521
+ * await node.lyricsManager.unsubscribe("guildId");
1522
+ * ```
1645
1523
  */
1646
- setVolume(volume: number): Promise<this>;
1524
+ unsubscribe(guildId: string): Promise<void>;
1525
+ }
1526
+
1527
+ /**
1528
+ * Represents a collection that extends the built-in Map class.
1529
+ * @template K The type of the keys in the collection.
1530
+ * @template V The type of the values in the collection.
1531
+ */
1532
+ declare class Collection<K, V> extends Map<K, V> {
1647
1533
  /**
1648
- * Sets the audio output for the player.
1649
- * @param {AudioOutput} output The audio output to set.
1650
- * @returns {Promise<this>} A promise that resolves to the player instance.
1534
+ * Removes elements from the collection based on a filter function.
1535
+ * @param fn The filter function that determines which elements to remove.
1536
+ * @param thisArg The value to use as `this` when executing the filter function.
1537
+ * @returns The number of elements removed from the collection.
1538
+ * @example
1539
+ * const collection = new Collection<number, string>();
1540
+ * collection.set(1, 'one');
1541
+ * collection.set(2, 'two');
1542
+ * collection.set(3, 'three');
1543
+ * const removedCount = collection.sweep((value, key) => key % 2 === 0);
1544
+ * console.log(removedCount); // Output: 1
1545
+ * console.log(collection.size); // Output: 2
1651
1546
  */
1652
- setAudioOutput(output: AudioOutput): Promise<this>;
1547
+ sweep(fn: (value: V, key: K, collection: this) => unknown): number;
1653
1548
  /**
1654
- *
1655
- * Sets the speed for the player.
1656
- * @param {number} speed The speed to set (default is 1).
1657
- * @returns {Promise<this>} A promise that resolves to the player instance.
1549
+ * Creates a new array with the results of calling a provided function on every element in the collection.
1550
+ * @param fn The function that produces an element of the new array.
1551
+ * @param thisArg The value to use as `this` when executing the map function.
1552
+ * @returns A new array with the results of calling the provided function on every element in the collection.
1553
+ * @example
1554
+ * const collection = new Collection<number, string>();
1555
+ * collection.set(1, 'one');
1556
+ * collection.set(2, 'two');
1557
+ * collection.set(3, 'three');
1558
+ * const mappedArray = collection.map((value, key) => `${key}: ${value}`);
1559
+ * console.log(mappedArray); // Output: ['1: one', '2: two', '3: three']
1658
1560
  */
1659
- setSpeed(speed?: number): Promise<this>;
1561
+ map<T>(fn: (value: V, key: K, collection: this) => T): T[];
1660
1562
  /**
1661
- *
1662
- * Sets the rate for the player.
1663
- * @param {number} rate The rate to set (default is 1).
1664
- * @returns {Promise<this>} A promise that resolves to the player instance.
1563
+ * Creates a new array with all elements that pass the test implemented by the provided function.
1564
+ * @param fn The function to test each element of the collection.
1565
+ * @param thisArg The value to use as `this` when executing the filter function.
1566
+ * @returns A new array with the elements that pass the test.
1567
+ * @example
1568
+ * const collection = new Collection<number, string>();
1569
+ * collection.set(1, 'one');
1570
+ * collection.set(2, 'two');
1571
+ * collection.set(3, 'three');
1572
+ * const filteredArray = collection.filter((value, key) => key % 2 === 0);
1573
+ * console.log(filteredArray); // Output: ['two']
1665
1574
  */
1666
- setRate(rate?: number): Promise<this>;
1575
+ filter(fn: (value: V, key: K, collection: this) => boolean): V[];
1576
+ /**
1577
+ * Returns the value of the first element in the collection that satisfies the provided testing function.
1578
+ * @param fn The function to test each element of the collection.
1579
+ * @returns The value of the first element that passes the test. `undefined` if no element passes the test.
1580
+ * @example
1581
+ * const collection = new Collection<number, number>();
1582
+ * collection.set(1, 1);
1583
+ * collection.set(2, 2);
1584
+ * collection.set(3, 3);
1585
+ * const firstEvenValue = collection.find(value => value % 2 === 0);
1586
+ * console.log(firstEvenValue); // Output: 2
1587
+ */
1588
+ find(fn: (value: V, key: K, collection: this) => boolean): V | undefined;
1589
+ }
1590
+
1591
+ /**
1592
+ * Class representing a node manager.
1593
+ * @class NodeManager
1594
+ */
1595
+ declare class NodeManager {
1596
+ /**
1597
+ * The manager for the node.
1598
+ * @type {Hoshimi}
1599
+ * @readonly
1600
+ */
1601
+ readonly manager: Hoshimi;
1602
+ /**
1603
+ * The nodes for the manager.
1604
+ * @type {Collection<string, Node>}
1605
+ * @readonly
1606
+ */
1607
+ readonly nodes: Collection<string, NodeStructure>;
1667
1608
  /**
1668
1609
  *
1669
- * Sets the pitch for the player.
1670
- * @param {number} pitch The pitch
1671
- * @returns {Promise<this>} A promise that resolves to the player instance.
1610
+ * The constructor for the node manager.
1611
+ * @param {Hoshimi} manager The manager for the node.
1612
+ * @example
1613
+ * ```ts
1614
+ * const manager = new Hoshimi();
1615
+ * const nodeManager = new NodeManager(manager);
1616
+ *
1617
+ * console.log(nodeManager.nodes.size); // 0
1618
+ * ```
1672
1619
  */
1673
- setPitch(pitch?: number): Promise<this>;
1620
+ constructor(manager: Hoshimi);
1674
1621
  /**
1675
1622
  *
1676
- * Sets the EQ bands for the player.
1677
- * @param {RestOrArray<EQBandSettings>} bands The EQ band settings to set.
1678
- * @returns {Promise<this>} A promise that resolves to the instance of the manager.
1623
+ * Delete the node.
1624
+ * @param {NodeIdentifier} node The node or node id to delete.
1625
+ * @returns {boolean} If the node was deleted.
1626
+ * @example
1627
+ * ```ts
1628
+ * const node = manager.nodeManager.get("node1");
1629
+ * if (node) manager.nodeManager.delete(node.id); // true if the node was deleted
1630
+ * ```
1679
1631
  */
1680
- setEQBand(...bands: RestOrArray<EQBandSettings>): Promise<this>;
1632
+ delete(node: NodeIdentifier): boolean;
1681
1633
  /**
1682
1634
  *
1683
- * Clears all EQ bands for the player.
1684
- * @returns {Promise<this>} A promise that resolves to the instance of the manager.
1635
+ * Get the node by id.
1636
+ * @param {NodeIdentifier} node The node or node id to get.
1637
+ * @returns {NodeStructure | undefined} The node or undefined if not found.
1638
+ * @example
1639
+ * ```ts
1640
+ * const node = manager.nodeManager.get("node1");
1641
+ * if (node) {
1642
+ * console.log(node.id); // node1
1643
+ * } else {
1644
+ * console.log("Node not found");
1645
+ * }
1646
+ * ```
1685
1647
  */
1686
- clearEQBands(): Promise<this>;
1648
+ get(node: NodeIdentifier): NodeStructure | undefined;
1687
1649
  /**
1688
1650
  *
1689
- * Set the vibrato filter with the given settings.
1690
- * @param {TremoloSettings} [settings=DefaultFilterPreset.Vibrato] The settings for the vibrato filter.
1691
- * @returns {Promise<this>} The instance of the filter manager.
1651
+ * Create a new node.
1652
+ * @param {NodeOptions} options The options for the node.
1653
+ * @returns {NodeStructure} The created node.
1654
+ * @example
1655
+ * ```ts
1656
+ * const node = manager.nodeManager.create({
1657
+ * host: "localhost",
1658
+ * port: 2333,
1659
+ * password: "password",
1660
+ * secure: false,
1661
+ * });
1662
+ *
1663
+ * console.log(node.id); // localhost:2333
1692
1664
  */
1693
- setVibrato(settings?: Partial<TremoloSettings>): Promise<this>;
1665
+ create(options: NodeOptions): NodeStructure;
1694
1666
  /**
1695
1667
  *
1696
- * Set the tremolo filter with the given settings.
1697
- * @param {TremoloSettings} [settings=DefaultFilterPreset.Tremolo] The settings for the tremolo filter.
1698
- * @returns {Promise<this>} The instance of the filter manager.
1668
+ * Destroy a node.
1669
+ * @param {NodeIdentifier} node The node or node id to destroy.
1670
+ * @returns {void}
1671
+ * @example
1672
+ * ```ts
1673
+ * const node = manager.nodeManager.get("node1");
1674
+ * if (node) node.destroy();
1675
+ * ```
1699
1676
  */
1700
- setTremolo(settings?: Partial<TremoloSettings>): Promise<this>;
1677
+ destroy(node: NodeIdentifier): void;
1701
1678
  /**
1702
1679
  *
1703
- * Set the low-pass filter with the given settings.
1704
- * @param {LowPassSettings} [settings=DefaultFilterPreset.Lowpass] The settings for the low-pass filter.
1705
- * @returns {Promise<this>} The instance of the filter manager.
1680
+ * Reconnect a node.
1681
+ * @param {NodeIdentifier} node The node or node id to reconnect.
1682
+ * @returns {void}
1683
+ * @example
1684
+ * ```ts
1685
+ * const node = manager.nodeManager.get("node1");
1686
+ * if (node) node.reconnect();
1687
+ * ```
1706
1688
  */
1707
- setLowPass(settings?: Partial<LowPassSettings>): Promise<this>;
1689
+ reconnect(node: NodeIdentifier): void;
1708
1690
  /**
1709
- * Set the nightcore filter with the given settings.
1710
- * @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Nightcore] The settings for the nightcore filter.
1711
- * @returns {Promise<this>} The instance of the filter manager.
1691
+ *
1692
+ * Disconnect a node.
1693
+ * @param {NodeIdentifier} node The node or node id to disconnect.
1694
+ * @returns {void}
1695
+ * @example
1696
+ * ```ts
1697
+ * const node = manager.nodeManager.get("node1");
1698
+ * if (node) node.disconnect();
1699
+ * ```
1712
1700
  */
1713
- setNightcore(settings?: Partial<TimescaleSettings>): Promise<this>;
1701
+ disconnect(node: NodeIdentifier): void;
1714
1702
  /**
1715
1703
  *
1716
- * Set the vaporwave filter with the given settings.
1717
- * @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Vaporwave] The settings for the vaporwave filter.
1718
- * @returns {Promise<this>} The instance of the filter manager.
1704
+ * Connect a node.
1705
+ * @param {NodeIdentifier} node The node or node id to connect.
1706
+ * @returns {void}
1707
+ * @example
1708
+ * ```ts
1709
+ * const node = manager.nodeManager.get("node1");
1710
+ * if (node) node.connect();
1711
+ * ```
1719
1712
  */
1720
- setVaporwave(settings?: Partial<TimescaleSettings>): Promise<this>;
1713
+ connect(node: NodeIdentifier): void;
1721
1714
  /**
1722
1715
  *
1723
- * Set the karaoke filter with the given settings.
1724
- * @param {KaraokeSettings} [settings=DefaultFilterPreset.Karaoke] The settings for the karaoke filter.
1725
- * @returns {Promise<this>} The instance of the filter manager.
1716
+ * Get the least used node.
1717
+ * @returns {NodeStructure} The least used node.
1718
+ * @example
1719
+ * ```ts
1720
+ * const node = manager.nodeManager.getLeastUsed();
1721
+ * if (node) {
1722
+ * console.log(node.id); // node1
1723
+ * console.log(node.penalties); // the penalties of the node
1724
+ * console.log(node.state); // the state of the node
1725
+ * }
1726
+ * ```
1726
1727
  */
1727
- setKaraoke(settings?: Partial<KaraokeSettings>): Promise<this>;
1728
+ getLeastUsed(sortType?: NodeSortTypes): NodeStructure;
1728
1729
  /**
1729
1730
  *
1730
- * Set the distortion filter with the given settings.
1731
- * @param {Partial<DistortionSettings>} [settings=DefaultFilterPreset.Distortion] The settings for the distortion filter.
1732
- * @returns {Promise<this>} The instance of the filter manager.
1731
+ * Reconnect the nodes.
1732
+ * @returns {void}
1733
+ * @example
1734
+ * ```ts
1735
+ * const node = manager.nodeManager.get("node1");
1736
+ * if (node) node.reconnectAll();
1737
+ * ```
1733
1738
  */
1734
- setDistortion(settings?: Partial<DistortionSettings>): Promise<this>;
1739
+ reconnectAll(): void;
1735
1740
  /**
1736
- * Set the timescale filter with the given settings.
1737
- * @param {Partial<TimescaleSettings>} settings The timescale settings to set.
1738
- * @returns {Promise<this>} The instance of the filter manager.
1741
+ * Disconnect the nodes.
1742
+ * @returns {void}
1743
+ * @example
1744
+ * ```ts
1745
+ * const node = manager.nodeManager.get("node1");
1746
+ * if (node) node.disconnectAll();
1747
+ * ```
1739
1748
  */
1740
- setTimescale(settings: Partial<TimescaleSettings>): Promise<this>;
1749
+ disconnectAll(): void;
1750
+ /**
1751
+ * Connect the nodes.
1752
+ * @returns {void}
1753
+ * @example
1754
+ * ```ts
1755
+ * const node = manager.nodeManager.get("node1");
1756
+ * if (node) node.connect();
1757
+ * ```
1758
+ */
1759
+ connectAll(): void;
1760
+ /**
1761
+ * Destroy the nodes.
1762
+ * @returns {void}
1763
+ * @example
1764
+ * ```ts
1765
+ * const node = manager.nodeManager.get("node1");
1766
+ * if (node) node.destroy();
1767
+ * ```
1768
+ */
1769
+ destroyAll(): void;
1741
1770
  }
1742
1771
 
1743
1772
  /**
1744
- * Type representing the customizable player storage.
1745
- */
1746
- type StorageKeys = keyof CustomizablePlayerStorage | (string & {});
1747
- /**
1748
- * Type representing the customizable player storage values.
1749
- */
1750
- type StorageValues<V extends StorageKeys = StorageKeys> = V extends keyof CustomizablePlayerStorage ? CustomizablePlayerStorage[V] : unknown;
1751
- /**
1752
- * Class representing a player storage.
1753
- * @class PlayerStorage
1773
+ * The methods for http requests
1754
1774
  */
1755
- declare class PlayerStorage<K extends StorageKeys = StorageKeys, V extends StorageValues<K> = StorageValues<K>> {
1775
+ declare enum HttpMethods {
1756
1776
  /**
1757
- *
1758
- * Get the value for a key in the storage.
1759
- * @param {K} key The key to get the value for.
1760
- * @returns {V | undefined} The value for the key, or undefined if it doesn't exist.
1777
+ * The GET method requests a representation of the specified resource. Requests using GET should only retrieve data.
1778
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET
1779
+ * @type {string}
1761
1780
  */
1762
- get<K extends StorageKeys, V extends StorageValues<K>>(key: K): V | undefined;
1781
+ Get = "GET",
1763
1782
  /**
1764
- * Set the value for a key in the storage.
1765
- * @param {K} key The key to set the value for.
1766
- * @param {V} value The value to set for the key.
1783
+ * 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.
1784
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
1785
+ * @type {string}
1767
1786
  */
1768
- set<K extends StorageKeys, V extends StorageValues<K>>(key: K, value: V): void;
1787
+ Post = "POST",
1769
1788
  /**
1770
- * Check if the storage has a key.
1771
- * @param {K} key The key to check for.
1772
- * @returns {boolean} True if the storage has the key, false otherwise.
1789
+ * The PUT method replaces all current representations of the target resource with the request payload.
1790
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT
1791
+ * @type {string}
1773
1792
  */
1774
- has(key: K): boolean;
1793
+ Put = "PUT",
1775
1794
  /**
1776
- * Delete a key from the storage.
1777
- * @param {K} key The key to delete.
1778
- * @returns {boolean} True if the key was deleted, false otherwise.
1795
+ * The PATCH method is used to apply partial modifications to a resource.
1796
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH
1797
+ * @type {string}
1779
1798
  */
1780
- delete(key: K): boolean;
1799
+ Patch = "PATCH",
1781
1800
  /**
1782
- * Get all keys in the storage.
1783
- * @returns {K[]} The keys in the storage.
1784
- */
1785
- keys<K extends StorageKeys[]>(): K[];
1786
- /**
1787
- * Get all values in the storage.
1788
- * @returns {V[]} The values in the storage.
1789
- */
1790
- values<K extends StorageKeys[], V extends StorageValues<K[number]>>(): V[];
1791
- /**
1792
- * Get all entries in the storage.
1793
- * @returns {[K, V][]} The entries in the storage.
1801
+ * The DELETE method deletes the specified resource.
1802
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE
1803
+ * @type {string}
1794
1804
  */
1795
- entries<K extends StorageKeys[], V extends StorageValues<K[number]>>(): [K, V][];
1805
+ Delete = "DELETE",
1796
1806
  /**
1797
- *
1798
- * Get all key-value pairs in the storage.
1799
- * @returns {Record<K[number], V>} An object containing all key-value pairs in the storage, excluding internal keys.
1807
+ * The HEAD method asks for a response identical to that of a GET request, but without the response body.
1808
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD
1809
+ * @type {string}
1800
1810
  */
1801
- all<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Record<K[number], V>;
1811
+ Head = "HEAD"
1812
+ }
1813
+ declare enum RestPathType {
1802
1814
  /**
1803
- * Clear the storage.
1815
+ * The raw path of the request.
1816
+ * @type {string}
1804
1817
  */
1805
- clear(): void;
1818
+ Raw = "/",
1806
1819
  /**
1807
- * Get the size of the storage.
1808
- * @returns {number} The number of entries in the storage.
1820
+ * The versioned path v4 of the request.
1821
+ * @type {string}
1809
1822
  */
1810
- get size(): number;
1823
+ V4 = "/v4"
1811
1824
  }
1812
-
1813
1825
  /**
1814
- * Class representing a Hoshimi player.
1815
- * @class Player
1826
+ * The status codes for the REST.
1827
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
1816
1828
  */
1817
- declare class Player {
1829
+ declare enum HttpStatusCodes {
1818
1830
  /**
1819
- * The data for the player.
1820
- * @type {PlayerStorage}
1821
- * @readonly
1831
+ * The request has succeeded.
1832
+ * @type {number}
1822
1833
  */
1823
- readonly data: PlayerStorage;
1834
+ OK = 200,
1824
1835
  /**
1825
- * The options for the player.
1826
- * @type {PlayerOptions}
1827
- * @readonly
1836
+ * The request has been fulfilled and resulted in a new resource being created.
1837
+ * @type {number}
1828
1838
  */
1829
- readonly options: PlayerOptions;
1839
+ Created = 201,
1830
1840
  /**
1831
- * The manager for the player.
1832
- * @type {Hoshimi}
1833
- * @readonly
1841
+ * The request has been accepted for processing, but the processing has not been completed.
1842
+ * @type {number}
1834
1843
  */
1835
- readonly manager: Hoshimi;
1844
+ Accepted = 202,
1836
1845
  /**
1837
- * The queue for the player.
1838
- * @type {Queue}
1839
- * @readonly
1846
+ * The server successfully processed the request, but is not returning any content.
1847
+ * @type {number}
1840
1848
  */
1841
- readonly queue: QueueStructure;
1849
+ NoContent = 204,
1842
1850
  /**
1843
- * The filter manager for the player.
1844
- * @type {FilterManager}
1845
- * @readonly
1851
+ * The resource has been moved permanently to a new URI.
1852
+ * @type {number}
1846
1853
  */
1847
- readonly filterManager: FilterManager;
1854
+ MovedPermanently = 301,
1848
1855
  /**
1849
- * The node for the player.
1850
- * @type {NodeStructure}
1856
+ * The requested resource has been found at a different URI.
1857
+ * @type {number}
1851
1858
  */
1852
- node: NodeStructure;
1859
+ Found = 302,
1853
1860
  /**
1854
- * Check if the player is self deafened.
1855
- * @type {boolean}
1861
+ * The resource has not been modified since the last request.
1862
+ * @type {number}
1856
1863
  */
1857
- selfDeaf: boolean;
1864
+ NotModified = 304,
1858
1865
  /**
1859
- * Check if the player is self muted.
1860
- * @type {boolean}
1866
+ * The request cannot be processed due to bad syntax.
1867
+ * @type {number}
1861
1868
  */
1862
- selfMute: boolean;
1869
+ BadRequest = 400,
1863
1870
  /**
1864
- * Loop mode of the player.
1865
- * @type {LoopMode}
1866
- * @default LoopMode.Off
1871
+ * The request requires user authentication.
1872
+ * @type {number}
1867
1873
  */
1868
- loop: LoopMode;
1874
+ Unauthorized = 401,
1869
1875
  /**
1870
- * Check if the player is playing.
1871
- * @type {boolean}
1872
- * @default false
1876
+ * The request was valid, but the server is refusing action.
1877
+ * @type {number}
1873
1878
  */
1874
- playing: boolean;
1879
+ Forbidden = 403,
1875
1880
  /**
1876
- * Check if the player is paused.
1877
- * @type {boolean}
1878
- * @default false
1881
+ * The server cannot find the requested resource.
1882
+ * @type {number}
1879
1883
  */
1880
- paused: boolean;
1884
+ NotFound = 404,
1881
1885
  /**
1882
- * Check if the player is connected.
1883
- * @type {boolean}
1884
- * @default false
1886
+ * The request method is known by the server but has been disabled and cannot be used.
1887
+ * @type {number}
1885
1888
  */
1886
- connected: boolean;
1889
+ MethodNotAllowed = 405,
1887
1890
  /**
1888
- * Volume of the player.
1891
+ * The server timed out waiting for the request.
1889
1892
  * @type {number}
1890
- * @default 100
1891
1893
  */
1892
- volume: number;
1894
+ RequestTimeout = 408,
1893
1895
  /**
1894
- * Guild ig of the player.
1895
- * @type {string}
1896
+ * The request could not be completed due to a conflict with the current state of the resource.
1897
+ * @type {number}
1896
1898
  */
1897
- guildId: string;
1899
+ Conflict = 409,
1898
1900
  /**
1899
- * Voice channel idof the player.
1900
- * @type {string | undefined}
1901
+ * The requested resource is no longer available and will not be available again.
1902
+ * @type {number}
1901
1903
  */
1902
- voiceId: string | undefined;
1904
+ Gone = 410,
1903
1905
  /**
1904
- * Text channel id of the player.
1905
- * @type {string | undefined}
1906
+ * The user has sent too many requests in a given amount of time.
1907
+ * @type {number}
1906
1908
  */
1907
- textId: string | undefined;
1909
+ TooManyRequests = 429,
1908
1910
  /**
1909
- * The ping of the player.
1911
+ * A generic error message, given when no more specific message is suitable.
1910
1912
  * @type {number}
1911
1913
  */
1912
- ping: number;
1914
+ InternalServerError = 500,
1913
1915
  /**
1914
- * The timestamp when the player was created.
1916
+ * The server does not recognize the request method or lacks the ability to fulfill it.
1915
1917
  * @type {number}
1916
1918
  */
1917
- createdTimestamp: number;
1919
+ NotImplemented = 501,
1918
1920
  /**
1919
- * The position of the player.
1921
+ * The server was acting as a gateway and received an invalid response.
1920
1922
  * @type {number}
1921
1923
  */
1922
- position: number;
1924
+ BadGateway = 502,
1923
1925
  /**
1924
- * The voice connection details.
1925
- * @type {PlayerVoice}
1926
+ * The server is currently unavailable (overloaded or down).
1927
+ * @type {number}
1926
1928
  */
1927
- voice: Nullable<LavalinkPlayerVoice>;
1929
+ ServiceUnavailable = 503,
1928
1930
  /**
1929
- *
1930
- * Create a new player.
1931
- * @param {Hoshimi} manager The manager for the player.
1932
- * @param {PlayOptions} options The options for the player.
1933
- * @example
1934
- * ```ts
1935
- * const player = new Player(manager, {
1936
- * guildId: "guildId",
1937
- * voiceId: "voiceId",
1938
- * textId: "textId",
1939
- * selfDeaf: true,
1940
- * selfMute: false,
1941
- * volume: 100,
1942
- * });
1943
- *
1944
- * console.log(player.guildId); // guildId
1945
- * console.log(player.voiceId); // voiceId
1946
- * console.log(player.textId); // textId
1931
+ * The server did not receive a timely response from an upstream server.
1932
+ * @type {number}
1947
1933
  */
1948
- constructor(manager: Hoshimi, options: PlayerOptions);
1934
+ GatewayTimeout = 504
1935
+ }
1936
+ /**
1937
+ * The options for the REST.
1938
+ */
1939
+ interface RestOptions {
1949
1940
  /**
1950
- * The lyrics methods for the player.
1951
- * @type {LyricsMethods}
1952
- * @readonly
1941
+ * The endpoint for the REST.
1942
+ * @type {string}
1953
1943
  */
1954
- readonly lyrics: LyricsMethods;
1944
+ endpoint: `/${string}`;
1955
1945
  /**
1956
- *
1957
- * Search for a track or playlist.
1958
- * @param {SearchOptions} options The options for the search.
1959
- * @returns {Promise<QueryResult>} The search result.
1960
- * @example
1961
- * ```ts
1962
- * const player = manager.getPlayer("guildId");
1963
- * const result = await player.search({
1964
- * query: "track name",
1965
- * engine: SearchEngine.Youtube,
1966
- * requester: {},
1967
- * });
1968
- *
1969
- * console.log(result) // the search result
1970
- * ```
1946
+ * The method for the REST.
1947
+ * @type {HttpMethods}
1971
1948
  */
1972
- search(options: SearchOptions): Promise<QueryResult>;
1949
+ method?: HttpMethods;
1973
1950
  /**
1974
- *
1975
- * Play the next track in the queue.
1976
- * @param {number} [to=0] The amount of tracks to skip.
1977
- * @param {boolean} [throwError=true] Whether to throw an error if there are no tracks to skip.
1978
- * @returns {Promise<void>}
1979
- * @throws {PlayerError} If there are no tracks to skip.
1980
- * @example
1981
- * ```ts
1982
- * const player = manager.getPlayer("guildId");
1983
- * player.skip(2); // skip 2 tracks
1984
- * player.skip(); // skip 1 track
1985
- * ```
1951
+ * The headers for the REST.
1952
+ * @type {Record<string, string>}
1986
1953
  */
1987
- skip(to?: number, throwError?: boolean): Promise<void>;
1954
+ headers?: Record<string, string>;
1988
1955
  /**
1989
- *
1990
- * Seek to a specific position in the current track.
1991
- * @param {number} position The position to seek to in milliseconds.
1992
- * @returns {Promise<void>}
1993
- * @throws {PlayerError} If the position is invalid.
1994
- * @example
1995
- * ```ts
1996
- * const player = manager.getPlayer("guildId");
1997
- * player.seek(30000); // seek to 30 seconds
1998
- * ```
1956
+ * The body for the REST.
1957
+ * @type {Record<string, unknown> | string | undefined}
1999
1958
  */
2000
- seek(position: number): Promise<void>;
1959
+ body?: Record<string, unknown> | string;
2001
1960
  /**
2002
- *
2003
- * Disconnect the player from the voice channel.
2004
- * @returns {Promise<this>} The player instance.
2005
- * @example
2006
- * ```ts
2007
- * const player = manager.getPlayer("guildId");
2008
- * player.disconnect();
2009
- * ```
2010
- */
2011
- disconnect(): Promise<this>;
1961
+ * The query parameters for the REST.
1962
+ * @type {Record<string, string>}
1963
+ */
1964
+ params?: Record<string, string>;
2012
1965
  /**
2013
- *
2014
- * Destroy and disconnect the player.
2015
- * @param {DestroyReasons} [reason] The reason for destroying the player.
2016
- * @returns {Promise<void>}
2017
- * @example
2018
- * ```ts
2019
- * const player = manager.getPlayer("guildId");
2020
- * player.destroy(DestroyReasons.Stop);
2021
- * ```
1966
+ * The path type for the REST.
1967
+ * @type {RestPathType}
2022
1968
  */
2023
- destroy(reason?: DestroyReasons): Promise<boolean>;
1969
+ pathType?: RestPathType;
1970
+ }
1971
+ /**
1972
+ * The fetch options for the request.
1973
+ */
1974
+ interface FetchOptions extends Omit<RestOptions, "endpoint" | "body"> {
2024
1975
  /**
2025
- *
2026
- * Play a track in the player.
2027
- * @param {Partial<PlayOptions>} [options] The options to play the track.
2028
- * @returns {Promise<void>}
2029
- * @throws {PlayerError} If there are no tracks to play.
2030
- * @example
2031
- * ```ts
2032
- * const player = manager.getPlayer("guildId");
2033
- *
2034
- * player.play({
2035
- * track: track,
2036
- * noReplace: true,
2037
- * });
2038
- * ```
1976
+ * The signal for the request.
2039
1977
  */
2040
- play(options?: Partial<PlayOptions>): Promise<void>;
1978
+ signal: AbortSignal;
2041
1979
  /**
2042
- * Connect the player to the voice channel.
2043
- * @returns {Promise<this>} The player instance.
2044
- * @example
2045
- * ```ts
2046
- * const player = manager.getPlayer("guildId");
2047
- * player.connect();
2048
- * ```
1980
+ * The stringified body for the request.
2049
1981
  */
2050
- connect(): Promise<this>;
1982
+ body?: string;
1983
+ }
1984
+ /**
1985
+ * The error for the REST.
1986
+ */
1987
+ interface LavalinkRestError {
2051
1988
  /**
2052
- *
2053
- * Stop the player from playing.
2054
- * @param {boolean} [destroy=true] Whether to destroy the player or not.
2055
- * @returns {Promise<void>}
2056
- * @example
2057
- * ```ts
2058
- * const player = manager.getPlayer("guildId");
2059
- * player.stop();
2060
- * ```
1989
+ * The timestamp for the REST.
1990
+ * @type {number}
2061
1991
  */
2062
- stop(destroy?: boolean): Promise<void>;
1992
+ timestamp: number;
2063
1993
  /**
2064
- *
2065
- * Pause or resume the player.
2066
- * @returns {Promise<void>}
2067
- * @example
2068
- * ```ts
2069
- * const player = manager.getPlayer("guildId");
2070
- * player.setPaused();
2071
- * ```
1994
+ * The status for the REST.
1995
+ * @type {number}
2072
1996
  */
2073
- setPaused(paused?: boolean): Promise<boolean>;
1997
+ status: number;
2074
1998
  /**
2075
- *
2076
- * Set the volume of the player.
2077
- * @param {number} volume The volume to set.
2078
- * @returns {Promise<void>}
2079
- * @example
2080
- * ```ts
2081
- * const player = manager.getPlayer("guildId");
2082
- * player.setVolume(50); // set the volume to 50%
2083
- * ```
1999
+ * The error for the REST.
2000
+ * @type {string}
2084
2001
  */
2085
- setVolume(volume: number): Promise<void>;
2002
+ error: string;
2086
2003
  /**
2087
- *
2088
- * Set the loop mode of the player.
2089
- * @param {LoopMode} mode The loop mode to set.
2090
- * @throws {PlayerError} If the loop mode is invalid.
2091
- * @example
2092
- * ```ts
2093
- * const player = manager.getPlayer("guildId");
2094
- * player.setLoop(LoopMode.Track);
2095
- * ```
2004
+ * The trace for the REST.
2005
+ * @type {string}
2096
2006
  */
2097
- setLoop(mode: LoopMode): this;
2007
+ trace?: string;
2098
2008
  /**
2099
- * Set the voice of the player.
2100
- * @param {Partial<VoiceChannelUpdate>} voice The voice state to set.
2101
- * @returns {Promise<void>}
2102
- * @example
2103
- * ```ts
2104
- * const player = manager.getPlayer("guildId");
2105
- * player.setVoice({ voiceId: "newVoiceId" });
2106
- * ```
2009
+ * The message for the REST.
2010
+ * @type {string}
2107
2011
  */
2108
- setVoice(voice: Partial<VoiceChannelUpdate>): Promise<void>;
2012
+ message: string;
2109
2013
  /**
2110
- *
2111
- * Change the node the player is connected to.
2112
- * @param {NodeIdentifier} node The node to change to.
2113
- * @returns {Promise<void>} A promise that resolves when the node has been changed.
2114
- * @throws {PlayerError} If the target node is not found, not connected, or missing source managers.
2115
- * @example
2116
- * ```ts
2117
- * const player = manager.getPlayer("guildId");
2118
- * player.move("newNodeId");
2119
- * ```
2014
+ * The path for the REST.
2015
+ * @type {string}
2120
2016
  */
2121
- move(node: NodeIdentifier): Promise<void>;
2017
+ path: string;
2018
+ }
2019
+ /**
2020
+ * The player response from the Lavalink REST API.
2021
+ */
2022
+ interface LavalinkPlayer {
2122
2023
  /**
2123
- * Update the player with new data.
2124
- * @param {NonGuildUpdatePlayerInfo} data The data to update the player with.
2125
- * @returns {Promise<LavalinkPlayer | null>} The updated player data.
2024
+ * The guild ID associated with the player.
2025
+ * @type {string}
2126
2026
  */
2127
- updatePlayer(data: NonGuildUpdatePlayerInfo): Promise<LavalinkPlayer | null>;
2027
+ guildId: string;
2128
2028
  /**
2129
- *
2130
- * Return the player as a json object.
2131
- * @returns {PlayerJson}
2132
- * @example
2133
- * ```ts
2134
- * const player = manager.getPlayer("guildId");
2135
- * const json = player.toJSON();
2136
- * console.log(json); // the player as a json object
2137
- * ```
2029
+ * The track currently being played.
2030
+ * @type {LavalinkTrack}
2138
2031
  */
2139
- toJSON(): PlayerJson;
2032
+ track?: LavalinkTrack;
2033
+ /**
2034
+ * The volume of the player.
2035
+ * @type {number}
2036
+ */
2037
+ volume: number;
2038
+ /**
2039
+ * Whether the player is paused.
2040
+ * @type {boolean}
2041
+ */
2042
+ paused: boolean;
2043
+ /**
2044
+ * The voice connection details.
2045
+ * @type {LavalinkPlayerVoice}
2046
+ */
2047
+ voice: LavalinkPlayerVoice;
2048
+ /**
2049
+ * The filter options applied to the player.
2050
+ * @type {FilterSettings}
2051
+ */
2052
+ filters: FilterSettings;
2053
+ /**
2054
+ * The state of the player.
2055
+ * @type {LavalinkPlayerState}
2056
+ */
2057
+ state: LavalinkPlayerState;
2140
2058
  }
2141
2059
  /**
2142
- * Type representing the update player information without guildId.
2060
+ * The state of the player.
2143
2061
  */
2144
- type NonGuildUpdatePlayerInfo = Omit<UpdatePlayerInfo, "guildId">;
2062
+ interface LavalinkPlayerState {
2063
+ /**
2064
+ * The time since the connection was established.
2065
+ * @type {number}
2066
+ */
2067
+ time: number;
2068
+ /**
2069
+ * The position of the current track in milliseconds.
2070
+ * @type {number}
2071
+ */
2072
+ position: number;
2073
+ /**
2074
+ * Whether the player is connected to the voice channel.
2075
+ * @type {boolean}
2076
+ */
2077
+ connected: boolean;
2078
+ /**
2079
+ * The ping to the voice server in milliseconds.
2080
+ * @type {number}
2081
+ */
2082
+ ping: number;
2083
+ }
2145
2084
  /**
2146
- * Interface representing the customizable player storage.
2085
+ * The options to update the player.
2147
2086
  */
2148
- interface CustomizablePlayerStorage {
2087
+ interface UpdatePlayerInfo {
2088
+ /**
2089
+ * The guild id associated with the player.
2090
+ * @type {string}
2091
+ */
2092
+ guildId: string;
2093
+ /**
2094
+ * The options to update the player.
2095
+ * @type {LavalinkPlayOptions}
2096
+ */
2097
+ playerOptions: LavalinkPlayOptions;
2098
+ /**
2099
+ * Whether to replace the current track.
2100
+ * @type {boolean | undefined}
2101
+ * @default false
2102
+ */
2103
+ noReplace?: boolean;
2149
2104
  }
2150
-
2151
2105
  /**
2152
- * Class representing a storage manager.
2153
- * @abstract
2154
- * @class StorageManager
2155
- * @example
2156
- * ```ts
2157
- * class MyStorageManager extends StorageManager {};
2158
- *
2159
- * const storage = new MyStorageManager();
2160
- * storage.set("key", "value");
2161
- *
2162
- * const value = await storage.get("key");
2163
- * console.log(value); // "value"
2164
- * ```
2106
+ * The updated session of the current session.
2165
2107
  */
2166
- declare abstract class StorageAdapter<T extends QueueJson = QueueJson> {
2108
+ interface LavalinkSession {
2109
+ /**
2110
+ * Whather the session is resuming.
2111
+ * @type {boolean}
2112
+ */
2113
+ resuming: boolean;
2114
+ /**
2115
+ * The timeout for the session.
2116
+ * @type {number}
2117
+ */
2118
+ timeout: number;
2119
+ }
2120
+ /**
2121
+ * The rest options.
2122
+ */
2123
+ interface HoshimiRestOptions {
2124
+ /**
2125
+ * The amount of time to wait for the player to resume. (in milliseconds)
2126
+ * @type {number}
2127
+ * @default 10000
2128
+ */
2129
+ resumeTimeout?: number;
2130
+ }
2131
+ /**
2132
+ * The methods for decoding base64 encoded tracks.
2133
+ */
2134
+ interface DecodeMethods {
2167
2135
  /**
2168
2136
  *
2169
- * Get the value using the key.
2170
- * @param {string} key The key to get the value from.
2171
- * @returns {Awaitable<T | undefined>} The value of the key.
2137
+ * Decodes a single base64 encoded track.
2138
+ * @param {string} track The base64 encoded track.
2139
+ * @param {TrackRequester} requester The requester of the track.
2140
+ * @return {Promise<Track>} The decoded track.
2172
2141
  * @example
2173
2142
  * ```ts
2174
- * const value = await storage.get("key");
2175
- * console.log(value); // "value"
2143
+ * const node = player.node;
2144
+ * const track = await node.decode.single("base64EncodedTrack");
2145
+ * console.log(track.info.title); // Track Title
2176
2146
  * ```
2177
2147
  */
2178
- abstract get(key: string): Awaitable<T | undefined>;
2148
+ single(track: string, requester: TrackRequester): Promise<Track>;
2179
2149
  /**
2180
- *
2181
- * Set the value using the key.
2182
- * @param {string} key The key to set the value to.
2183
- * @param {unknown} value The value to set.
2184
- * @returns {Awaitable<void>} Did you know this can be async?
2150
+ * Decodes multiple base64 encoded tracks.
2151
+ * @param {string[]} tracks The base64 encoded tracks.
2152
+ * @param {TrackRequester} requester The requester of the tracks.
2153
+ * @return {Promise<Track[]>} The decoded tracks.
2185
2154
  * @example
2186
2155
  * ```ts
2187
- * await storage.set("key", "value");
2156
+ * const node = player.node;
2157
+ * const tracks = await node.decode.multiple(["base64EncodedTrack1", "base64EncodedTrack2"]);
2158
+ * console.log(tracks[0].info.title); // Track Title 1
2159
+ * console.log(tracks[1].info.title); // Track Title 2
2188
2160
  * ```
2189
2161
  */
2190
- abstract set(key: string, value: T): Awaitable<void>;
2162
+ multiple(tracks: string[], requester: TrackRequester): Promise<Track[]>;
2163
+ }
2164
+ /**
2165
+ * The session of the node.
2166
+ */
2167
+ type NullableLavalinkSession = PickNullable<LavalinkSession, "timeout">;
2168
+
2169
+ /**
2170
+ * Class representing the REST for the node.
2171
+ * @class Rest
2172
+ */
2173
+ declare class Rest {
2174
+ /**
2175
+ * The URL for the REST.
2176
+ * @type {string}
2177
+ */
2178
+ readonly url: string;
2179
+ /**
2180
+ * The version for the REST.
2181
+ * @type {string}
2182
+ */
2183
+ readonly version: string;
2184
+ /**
2185
+ * The timeout for the REST.
2186
+ * @type {number}
2187
+ */
2188
+ readonly restTimeout: number;
2189
+ /**
2190
+ * The user agent for the REST.
2191
+ * @type {UserAgent}
2192
+ */
2193
+ readonly userAgent: UserAgent;
2194
+ /**
2195
+ * The node for the REST.
2196
+ * @type {Node}
2197
+ */
2198
+ readonly node: NodeStructure;
2191
2199
  /**
2192
2200
  *
2193
- * Delete the value using the key.
2194
- * @param {string} key The key to delete the value from.
2195
- * @returns {Awaitable<boolean>} Returns true if the key was deleted.
2201
+ * Create a new REST.
2202
+ * @param {NodeStructure} node The node for the REST.
2196
2203
  * @example
2197
2204
  * ```ts
2198
- * const success = await storage.delete("key");
2199
- * console.log(success); // true
2205
+ * const node = new Node({
2206
+ * host: "localhost",
2207
+ * port: 2333,
2208
+ * password: "youshallnotpass",
2209
+ * secure: false,
2210
+ * });
2211
+ *
2212
+ * const rest = new Rest(node);
2213
+ * console.log(rest.restUrl); // http://localhost:2333/v4
2200
2214
  * ```
2201
2215
  */
2202
- abstract delete(key: string): Awaitable<boolean>;
2216
+ constructor(node: NodeStructure);
2203
2217
  /**
2204
- * Clear the storage.
2205
- * @returns {Awaitable<void>} Scary, right?
2218
+ * The REST URL to make requests.
2219
+ * @type {string}
2220
+ */
2221
+ get restUrl(): string;
2222
+ /**
2223
+ * The session id of the node.
2224
+ * @type {string}
2225
+ */
2226
+ get sessionId(): string;
2227
+ /**
2228
+ *
2229
+ * Make a request to the node.
2230
+ * @param {RestOptions} options The options to make the request.
2231
+ * @returns {Promise<T | null>} The response from the node.
2232
+ */
2233
+ request<T>(options: RestOptions): Promise<T | null>;
2234
+ /**
2235
+ *
2236
+ * Update the player data.
2237
+ * @param {Partial<UpdatePlayerInfo>} data The player data to update.
2238
+ * @returns {LavalinkPlayer | null} The updated player data.
2206
2239
  * @example
2207
2240
  * ```ts
2208
- * await storage.clear();
2241
+ * const player = await node.rest.updatePlayer({
2242
+ * guildId: "guildId",
2243
+ * noReplace: true,
2244
+ * playerOptions: {
2245
+ * paused: false,
2246
+ * track: { encoded: "encoded track" },
2247
+ * },
2248
+ * });
2249
+ *
2250
+ * console.log(player); // The updated lavalink player data
2209
2251
  * ```
2210
2252
  */
2211
- abstract clear(): Awaitable<void>;
2253
+ updatePlayer(data: Partial<UpdatePlayerInfo>): Promise<LavalinkPlayer | null>;
2212
2254
  /**
2213
- * Check if the storage has the key.
2214
- * @param {string} key The key to check.
2215
- * @returns {Awaitable<boolean>} Return true if the key exists.
2255
+ *
2256
+ * Stop the track in player for the guild.
2257
+ * @param {string} guildId the guild id to stop the player
2258
+ * @returns {Promise<LavalinkPlayer | null>} The updated player data.
2216
2259
  * @example
2217
2260
  * ```ts
2218
- * const exists = await storage.has("key");
2219
- * console.log(exists); // true
2261
+ * const player = await node.rest.stopPlayer("guildId");
2262
+ * if (player) console.log(player); // The lavalink player
2220
2263
  * ```
2221
2264
  */
2222
- abstract has(key: string): Awaitable<boolean>;
2265
+ stopPlayer(guildId: string): Promise<LavalinkPlayer | null>;
2223
2266
  /**
2224
2267
  *
2225
- * Parse the value.
2226
- * @param {unknown} value The value to parse.
2227
- * @returns {T} The parsed value.
2268
+ * Destroy the player for the guild.
2269
+ * @param {string} guildId The guild id to destroy the player.
2270
+ * @returns {Promise<void>} The updated player data.
2228
2271
  * @example
2229
2272
  * ```ts
2230
- * const parsed = await storage.parse<{ key: string }>("{'key':'value'}");
2231
- * console.log(parsed); // { key: "value" }
2273
+ * await node.rest.destroyPlayer("guildId");
2232
2274
  * ```
2275
+ * @example
2233
2276
  */
2234
- abstract parse(value: unknown): Awaitable<T>;
2277
+ destroyPlayer(guildId: string): Promise<void>;
2235
2278
  /**
2236
2279
  *
2237
- * Stringify the value.
2238
- * @param {unknown} value The value to stringify.
2239
- * @returns {R} The stringified value.
2280
+ * Update the session for the node
2281
+ * @param {boolean} resuming Enable resuming for the session.
2282
+ * @param {number | null} timeout The timeout for the session.
2283
+ * @returns {Promise<LavalinkSession | null>} The updated session data.
2240
2284
  * @example
2241
2285
  * ```ts
2242
- * const stringified = await storage.stringify({ key: "value" });
2243
- * console.log(stringified); // "{'key':'value'}"
2286
+ * const session = await node.rest.updateSession(true, 10000);
2287
+ * if (session) console.log(session); // The lavalink session data
2244
2288
  * ```
2245
2289
  */
2246
- abstract stringify<R = string>(value: unknown): Awaitable<R>;
2290
+ updateSession(resuming: boolean, timeout?: number | null): Promise<LavalinkSession | null>;
2247
2291
  }
2248
2292
 
2249
2293
  /**
2250
- * The queue options.
2294
+ * Class representing the DSPX Plugin filters for a player.
2295
+ * @class DSPXPluginFilter
2251
2296
  */
2252
- interface HoshimiQueueOptions {
2253
- /**
2254
- * The maximum amount of tracks that can be saved in the queue.
2255
- * @type {number}
2256
- * @default 25
2257
- */
2258
- maxPreviousTracks?: number;
2297
+ declare class DSPXPluginFilter {
2259
2298
  /**
2260
- *
2261
- * The function to use for autoplay.
2262
- * @param {Player} player The player.
2263
- * @param {HoshimiTrack | null} lastTrack The last track played.
2299
+ * The filter manager instance.
2300
+ * @type {FilterManagerStructure}
2301
+ * @readonly
2264
2302
  */
2265
- autoplayFn?(player: PlayerStructure, lastTrack: HoshimiTrack | null): Awaitable<void>;
2303
+ readonly manager: FilterManagerStructure;
2266
2304
  /**
2267
- * Enable the auto play for the queue. (By default, only supports `youtube` and `spotify`, add more with your own function)
2268
- * @type {boolean}
2269
- * @default false
2305
+ * Create a new DSPXPluginFilter instance.
2306
+ * @param {FilterManagerStructure} manager The filter manager instance.
2270
2307
  */
2271
- autoPlay?: boolean;
2308
+ constructor(manager: FilterManagerStructure);
2272
2309
  /**
2273
- * The storage manager to use for the queue.
2274
- * @type {StorageAdapter}
2275
- * @default {MemoryAdapter}
2310
+ *
2311
+ * Set the low-pass filter with the given settings.
2312
+ * @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXLowPass] The settings for the low-pass filter.
2313
+ * @returns {Promise<this>} The instance of the filter manager.
2276
2314
  */
2277
- storage?: StorageAdapter;
2278
- }
2279
- /**
2280
- * The queue json.
2281
- */
2282
- interface QueueJson {
2315
+ setLowPass(settings?: Partial<FilterPluginPassSettings>): Promise<this>;
2283
2316
  /**
2284
- * The tracks of the queue.
2285
- * @type {HoshimiTrack[]}
2317
+ *
2318
+ * Set the high-pass filter with the given settings.
2319
+ * @param {FilterPluginPassSettings} [settings=DefaultFilter.DSPXHighPass] The settings for the high-pass filter.
2320
+ * @returns {Promise<this>} The instance of the filter manager.
2286
2321
  */
2287
- tracks: HoshimiTrack[];
2322
+ setHighPass(settings?: Partial<FilterPluginPassSettings>): Promise<this>;
2288
2323
  /**
2289
- * The previous tracks of the queue.
2290
- * @type {Track[]}
2324
+ *
2325
+ * Set the normalization filter with the given settings.
2326
+ * @param {NormalizationSettings} [settings=DefaultFilter.DSPXNormalization] The settings for the normalization filter.
2327
+ * @returns {Promise<this>} The instance of the filter manager.
2291
2328
  */
2292
- history: Track[];
2329
+ setNormalization(settings?: Partial<NormalizationSettings>): Promise<this>;
2293
2330
  /**
2294
- * The current track of the queue.
2295
- * @type {Track | null}
2331
+ *
2332
+ * Set the echo filter with the given settings.
2333
+ * @param {EchoSettings} [settings=DefaultFilter.DSPXEcho] The settings for the echo filter.
2334
+ * @returns {Promise<this>} The instance of the filter manager.
2296
2335
  */
2297
- current: Track | null;
2336
+ setEcho(settings?: Partial<EchoSettings>): Promise<this>;
2298
2337
  }
2299
2338
 
2339
+ type NonLengthEchoSettings = Omit$1<EchoSettings, "echoLength">;
2300
2340
  /**
2301
- * Class representing the queue utils.
2302
- * @class QueueUtils
2341
+ * Class representing Lavalink plugin filters.
2342
+ * @class LavalinkPluginFilter
2303
2343
  */
2304
- declare class QueueUtils {
2344
+ declare class LavalinkPluginFilter {
2305
2345
  /**
2306
- *
2307
- * Constructor of the queue utils.
2308
- * @param {QueueStructure} queue The queue instance.
2346
+ * The filter manager instance.
2347
+ * @type {FilterManagerStructure}
2348
+ * @private
2349
+ * @readonly
2309
2350
  */
2310
- constructor(queue: QueueStructure);
2351
+ private readonly manager;
2311
2352
  /**
2312
- *
2313
- * Save the queue.
2314
- * @returns {Awaitable<void>}
2315
- * @example
2316
- * ```ts
2317
- * await player.queue.utils.save();
2318
- * ```
2353
+ * Creates an instance of LavalinkPluginFilter.
2354
+ * @param {FilterManagerStructure} filters - The filter manager instance.
2319
2355
  */
2320
- save(): Awaitable<void>;
2356
+ constructor(filters: FilterManagerStructure);
2321
2357
  /**
2322
2358
  *
2323
- * Destroy the queue.
2324
- * @returns {Promise<void>}
2325
- * @example
2326
- * ```ts
2327
- * await player.queue.utils.destroy();
2328
- * ```
2359
+ * Set the echo filter with the given settings.
2360
+ * @param {Omit<EchoSettings, "echoLength">} [settings=DefaultFilter.PluginEcho] The settings for the echo filter.
2361
+ * @returns {Promise<this>} The instance of the filter manager.
2329
2362
  */
2330
- destroy(): Awaitable<boolean>;
2363
+ setEcho(settings?: Partial<NonLengthEchoSettings>): Promise<this>;
2331
2364
  /**
2332
2365
  *
2333
- * Sync the queue.
2334
- * @returns {Awaitable<void>}
2335
- * @example
2336
- * ```ts
2337
- * await player.queue.utils.sync();
2338
- * ```
2366
+ * Set the reverb filter with the given settings.
2367
+ * @param {Partial<LavalinkFilterPluginReverbSettings>} [settings=DefaultFilter.PluginReverb] The settings for the reverb filter.
2368
+ * @returns {Promise<this>} The instance of the filter manager.
2339
2369
  */
2340
- sync(override?: boolean, syncCurrent?: boolean): Promise<void>;
2370
+ setReverb(settings?: Partial<LavalinkFilterPluginReverbSettings>): Promise<this>;
2341
2371
  }
2342
2372
 
2343
2373
  /**
2344
- * Class representing a queue.
2345
- * @class Queue
2374
+ * Class representing a filter manager for a player.
2375
+ * @class FilterManager
2346
2376
  */
2347
- declare class Queue {
2377
+ declare class FilterManager {
2348
2378
  /**
2349
- * Tracks of the queue.
2350
- * @type {HoshimiTrack[]}
2379
+ * The player this filter manager belongs to.
2380
+ * @type {PlayerStructure}
2381
+ * @public
2382
+ * @readonly
2351
2383
  */
2352
- tracks: HoshimiTrack[];
2384
+ readonly player: PlayerStructure;
2353
2385
  /**
2354
- * Previous tracks of the queue.
2355
- * @type {Track[]}
2386
+ * The bands applied to the player.
2387
+ * @type {EQBandSettings[]}
2388
+ * @readonly
2356
2389
  */
2357
- history: Track[];
2390
+ readonly bands: EQBandSettings[];
2358
2391
  /**
2359
- * Current track of the queue.
2360
- * @type {Track | null}
2392
+ * The current filter settings applied to the player.
2393
+ * @type {FilterSettings}
2394
+ * @public
2361
2395
  */
2362
- current: Track | null;
2396
+ data: FilterSettings;
2363
2397
  /**
2364
- * The player instance.
2365
- * @type {PlayerStructure}
2398
+ * The enabled filters for the player.
2399
+ * @type {EnabledPlayerFilters}
2366
2400
  */
2367
- readonly player: PlayerStructure;
2401
+ filters: EnabledPlayerFilters;
2368
2402
  /**
2369
- * The queue utils instance.
2370
- * @type {QueueUtils}
2403
+ * The lavalink plugin filters manager.
2404
+ * @type {LavalinkPluginFilter}
2371
2405
  * @readonly
2372
2406
  */
2373
- readonly utils: QueueUtils;
2374
- /**
2375
- *
2376
- * Constructor of the queue.
2377
- * @param {PlayerStructure} player Player instance.
2378
- * @example
2379
- * ```ts
2380
- * const player = new Player();
2381
- * const queue = new Queue(player);
2382
- *
2383
- * console.log(queue.size); // 0
2384
- * queue.add(track);
2385
- * console.log(queue.size); // 1
2386
- * ```
2387
- */
2388
- constructor(player: PlayerStructure);
2407
+ readonly plugin: LavalinkPluginFilter;
2389
2408
  /**
2390
- * Get the track size of the queue.
2391
- * @type {number}
2392
- * @returns {number} The track size of the queue.
2409
+ * The DSPX plugin filters manager.
2410
+ * @type {DSPXPluginFilter}
2393
2411
  * @readonly
2394
- * @example
2395
- * ```ts
2396
- * const queue = player.queue;
2397
- *
2398
- * console.log(queue.size); // 0
2399
- * queue.add(track);
2400
- *
2401
- * console.log(queue.size); // 1
2402
- * queue.add([track1, track2]);
2403
- *
2404
- * console.log(queue.size); // 3
2405
- * queue.shift();
2406
- * console.log(queue.size); // 2
2407
- *
2408
- * queue.clear();
2409
- * console.log(queue.size); // 0
2410
- * ```
2411
2412
  */
2412
- get size(): number;
2413
+ readonly dspx: DSPXPluginFilter;
2413
2414
  /**
2414
- * Get the total track size of the queue (Includes the current track).
2415
- * @type {number}
2416
- * @returns {number} The total track size of the queue.
2417
- * @readonly
2418
- * @example
2419
- * ```ts
2420
- * const queue = player.queue;
2421
- *
2422
- * console.log(queue.totalSize); // 0
2423
- * queue.add(track);
2424
- *
2425
- * console.log(queue.totalSize); // 1
2426
- * queue.add([track1, track2]);
2427
2415
  *
2428
- * console.log(queue.totalSize); // 3
2429
- * queue.shift();
2430
- * console.log(queue.totalSize); // 2
2431
- *
2432
- * queue.clear();
2433
- * console.log(queue.totalSize); // 0
2434
- * ```
2416
+ * Creates a new filter manager.
2417
+ * @param {PlayerStructure} player The player this filter manager belongs to.
2435
2418
  */
2436
- get totalSize(): number;
2419
+ constructor(player: PlayerStructure);
2437
2420
  /**
2438
- *
2439
- * Check if the queue is empty.
2440
- * @type {boolean}
2441
- * @returns {boolean} True if the queue is empty.
2442
- * @readonly
2443
- * @example
2444
- * ```ts
2445
- * const queue = player.queue;
2446
- *
2447
- * console.log(queue.isEmpty()); // true
2448
- * queue.add(track);
2449
- *
2450
- * console.log(queue.isEmpty()); // false
2451
- * queue.clear();
2452
- *
2453
- * console.log(queue.isEmpty()); // true
2454
- * ```
2421
+ * Resets all filters to their default values.
2422
+ * @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
2455
2423
  */
2456
- isEmpty(): boolean;
2424
+ reset(): Promise<this>;
2457
2425
  /**
2458
2426
  *
2459
- * Get the previous track of the queue.
2460
- * @param {boolean} [remove=false] Whether to remove the track from the previous queue.
2461
- * @returns {Track | null} The previous track of the queue.
2462
- * @example
2463
- * ```ts
2464
- * const queue = player.queue;
2465
- *
2466
- * console.log(queue.previous()); // null
2467
- * queue.add(track);
2468
- * queue.add(track2);
2469
- *
2470
- * console.log(queue.previous()); // track
2471
- * console.log(queue.previous(true)); // track and remove it from the previous tracks
2472
- * ```
2427
+ * Applies the current filters to the player.
2428
+ * @returns {Promise<this>} A promise that resolves to the instance of the filter manager.
2473
2429
  */
2474
- previous(remove?: boolean): Track | null;
2430
+ apply(): Promise<this>;
2475
2431
  /**
2476
- *
2477
- * Add a track or tracks to the queue.
2478
- * @param {Track | Track[]} track The track or tracks to add.
2479
- * @param {number} [position] The position to add the track or tracks.
2480
- * @returns {this} The queue instance.
2481
- * @example
2482
- * ```ts
2483
- * const queue = player.queue;
2484
- *
2485
- * console.log(queue.size); // 0
2486
- *
2487
- * queue.add(track);
2488
- * console.log(queue.size); // 1
2489
- *
2490
- * queue.add([track1, track2]);
2491
- * console.log(queue.size); // 3
2492
- *
2493
- * queue.add(track3, 1);
2494
- * console.log(queue.size); // 4
2495
- * console.log(queue.tracks); // [track1, track3, track2, track]
2496
- * ```
2432
+ * Checks if the current filters are active.
2433
+ * @param {TimescaleSettings} timescale The timescale settings to check against.
2434
+ * @returns {void} Nothing!
2497
2435
  */
2498
- add(track: HoshimiTrack | HoshimiTrack[], position?: number): this;
2436
+ check(timescale?: TimescaleSettings): void;
2499
2437
  /**
2500
2438
  *
2501
- * Get the first track of the queue.
2502
- * @returns {HoshimiTrack | null} The first track of the queue.
2503
- * @example
2504
- * ```ts
2505
- * const queue = player.queue;
2506
- *
2507
- * console.log(queue.shift()); // null
2508
- * queue.add(track);
2509
- *
2510
- * console.log(queue.shift()); // track
2511
- * queue.add(track2);
2512
- * ```
2439
+ * Checks if a specific filter is active.
2440
+ * @param {FilterType} filter The filter type to check.
2441
+ * @returns {boolean} True if the filter is active, false otherwise.
2513
2442
  */
2514
- shift(): HoshimiTrack | null;
2443
+ has(filter: FilterType): boolean;
2515
2444
  /**
2516
2445
  *
2517
- * Add tracks to the beginning of the queue.
2518
- * @param {Track[]} tracks The tracks to add.
2519
- * @returns {this} The queue instance.
2520
- * @example
2521
- * ```ts
2522
- * const queue = player.queue;
2523
- *
2524
- * console.log(queue.size); // 0
2525
- * queue.unshift(track);
2526
- *
2527
- * console.log(queue.size); // 1
2528
- * queue.unshift([track1, track2]);
2529
- *
2530
- * console.log(queue.size); // 3
2531
- * console.log(queue.tracks); // [track1, track2, track]
2532
- * ```
2446
+ * Sets the volume for the player.
2447
+ * @param {number} volume The volume level to set (between 0 and 5).
2448
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2533
2449
  */
2534
- unshift(...tracks: Track[]): this;
2450
+ setVolume(volume: number): Promise<this>;
2535
2451
  /**
2536
- *
2537
- * Shuffle the queue.
2538
- * @returns {this} The queue instance.
2539
- * @example
2540
- * ```ts
2541
- * const queue = player.queue;
2542
- *
2543
- * console.log(queue.size); // 0
2544
- * queue.add(track);
2545
- * queue.add([track1, track2]);
2546
- *
2547
- * console.log(queue.size); // 3
2548
- * console.log(queue.tracks); // [track, track1, track2]
2549
- *
2550
- * queue.shuffle();
2551
- * console.log(queue.tracks); // [track2, track, track1]
2552
- * ```
2452
+ * Sets the audio output for the player.
2453
+ * @param {AudioOutput} output The audio output to set.
2454
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2553
2455
  */
2554
- shuffle(): this;
2456
+ setAudioOutput(output: AudioOutput): Promise<this>;
2555
2457
  /**
2556
2458
  *
2557
- * Clear the queue.
2558
- * @returns {this} The queue instance.
2559
- * @example
2560
- * ```ts
2561
- * const queue = player.queue;
2562
- *
2563
- * console.log(queue.size); // 0
2564
- * queue.add(track);
2565
- * queue.add([track1, track2]);
2459
+ * Sets the speed for the player.
2460
+ * @param {number} speed The speed to set (default is 1).
2461
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2462
+ */
2463
+ setSpeed(speed?: number): Promise<this>;
2464
+ /**
2566
2465
  *
2567
- * console.log(queue.size); // 3
2568
- * queue.clear();
2569
- * console.log(queue.size); // 0
2570
- * ```
2466
+ * Sets the rate for the player.
2467
+ * @param {number} rate The rate to set (default is 1).
2468
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2571
2469
  */
2572
- clear(): this;
2470
+ setRate(rate?: number): Promise<this>;
2573
2471
  /**
2574
2472
  *
2575
- * Move a track to a specific position in the queue.
2576
- * @param {Track} track The track to move.
2577
- * @param {number} to The position to move.
2578
- * @returns {this} The queue instance.
2473
+ * Sets the pitch for the player.
2474
+ * @param {number} pitch The pitch
2475
+ * @returns {Promise<this>} A promise that resolves to the player instance.
2579
2476
  */
2580
- move(track: Track, to: number): this;
2477
+ setPitch(pitch?: number): Promise<this>;
2581
2478
  /**
2582
2479
  *
2583
- * Delete tracks from the queue.
2584
- * @param {number} start The start index.
2585
- * @param {number} deleteCount The number of tracks to delete.
2586
- * @param {Track | Track[]} [tracks] The tracks to add.
2587
- * @returns {this} The queue instance.
2480
+ * Sets the EQ bands for the player.
2481
+ * @param {RestOrArray<EQBandSettings>} bands The EQ band settings to set.
2482
+ * @returns {Promise<this>} A promise that resolves to the instance of the manager.
2588
2483
  */
2589
- splice(start: number, deleteCount: number, tracks?: HoshimiTrack | HoshimiTrack[]): this;
2484
+ setEQBand(...bands: RestOrArray<EQBandSettings>): Promise<this>;
2590
2485
  /**
2591
2486
  *
2592
- * Convert the queue to a JSON object.
2593
- * @returns {QueueJson} The queue JSON object.
2487
+ * Clears all EQ bands for the player.
2488
+ * @returns {Promise<this>} A promise that resolves to the instance of the manager.
2594
2489
  */
2595
- toJSON(): QueueJson;
2596
- }
2597
-
2598
- /**
2599
- * The structure for the Player class.
2600
- */
2601
- type PlayerStructure = InferCustomStructure<Player, "Player">;
2602
- /**
2603
- * The structure for the Rest class.
2604
- */
2605
- type RestStructure = InferCustomStructure<Rest, "Rest">;
2606
- /**
2607
- * The structure for the Node class.
2608
- */
2609
- type NodeStructure = InferCustomStructure<Node, "Node">;
2610
- /**
2611
- * The structure for the Queue class.
2612
- */
2613
- type QueueStructure = InferCustomStructure<Queue, "Queue">;
2614
- /**
2615
- * The structure for the LyricsManager class.
2616
- */
2617
- type LyricsManagerStructure = InferCustomStructure<LyricsManager, "LyricsManager">;
2618
- /**
2619
- * The structure for the NodeManager class.
2620
- */
2621
- type NodeManagerStructure = InferCustomStructure<NodeManager, "NodeManager">;
2622
- /**
2623
- * The structure for the FilterManager class.
2624
- */
2625
- type FilterManagerStructure = InferCustomStructure<FilterManager, "FilterManager">;
2626
- /**
2627
- * The structures of the Hoshimi classes.
2628
- */
2629
- declare const Structures: {
2630
- Player(manager: Hoshimi, options: PlayerOptions): PlayerStructure;
2631
- Rest(node: Node): RestStructure;
2632
- Node(nodeManager: NodeManager, options: NodeOptions): NodeStructure;
2633
- Queue(player: Player): QueueStructure;
2634
- LyricsManager(node: Node): LyricsManagerStructure;
2635
- NodeManager(manager: Hoshimi): NodeManagerStructure;
2636
- FilterManager(player: Player): FilterManagerStructure;
2637
- };
2638
- /**
2639
- * Infers the custom structure for a given class.
2640
- */
2641
- type InferCustomStructure<T, N extends string> = CustomizableStructures extends Record<N, infer P> ? P : T;
2642
-
2643
- /**
2644
- * Class representing a Hoshimi track.
2645
- * @class Track
2646
- * @implements {LavalinkTrack}
2647
- */
2648
- declare class Track implements LavalinkTrack {
2490
+ clearEQBands(): Promise<this>;
2649
2491
  /**
2650
- * The base64 encoded track.
2651
- * @type {string}
2492
+ *
2493
+ * Set the vibrato filter with the given settings.
2494
+ * @param {TremoloSettings} [settings=DefaultFilterPreset.Vibrato] The settings for the vibrato filter.
2495
+ * @returns {Promise<this>} The instance of the filter manager.
2652
2496
  */
2653
- readonly encoded: string;
2497
+ setVibrato(settings?: Partial<TremoloSettings>): Promise<this>;
2654
2498
  /**
2655
- * The track info.
2656
- * @type {TrackInfo}
2499
+ *
2500
+ * Set the tremolo filter with the given settings.
2501
+ * @param {TremoloSettings} [settings=DefaultFilterPreset.Tremolo] The settings for the tremolo filter.
2502
+ * @returns {Promise<this>} The instance of the filter manager.
2657
2503
  */
2658
- readonly info: TrackInfo;
2504
+ setTremolo(settings?: Partial<TremoloSettings>): Promise<this>;
2659
2505
  /**
2660
- * The plugin info of the track.
2661
- * @type {PluginInfo}
2506
+ *
2507
+ * Set the low-pass filter with the given settings.
2508
+ * @param {LowPassSettings} [settings=DefaultFilterPreset.Lowpass] The settings for the low-pass filter.
2509
+ * @returns {Promise<this>} The instance of the filter manager.
2662
2510
  */
2663
- readonly pluginInfo: PluginInfo;
2511
+ setLowPass(settings?: Partial<LowPassSettings>): Promise<this>;
2664
2512
  /**
2665
- * The track user data.
2666
- * @type {Record<string, unknown>}
2513
+ * Set the nightcore filter with the given settings.
2514
+ * @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Nightcore] The settings for the nightcore filter.
2515
+ * @returns {Promise<this>} The instance of the filter manager.
2667
2516
  */
2668
- userData: Record<string, unknown>;
2517
+ setNightcore(settings?: Partial<TimescaleSettings>): Promise<this>;
2669
2518
  /**
2670
- * The requester of the track.
2671
- * @type {TrackRequester}
2519
+ *
2520
+ * Set the vaporwave filter with the given settings.
2521
+ * @param {Partial<TimescaleSettings>} [settings=DefaultFilterPreset.Vaporwave] The settings for the vaporwave filter.
2522
+ * @returns {Promise<this>} The instance of the filter manager.
2672
2523
  */
2673
- requester: TrackRequester;
2524
+ setVaporwave(settings?: Partial<TimescaleSettings>): Promise<this>;
2674
2525
  /**
2675
- * The constructor for the track.
2676
- * @param {LavalinkTrack} track The track to construct the track from.
2677
- * @param {TrackRequester} requester The requester of the track.
2678
- * @example
2679
- * ```ts
2680
- * const track = new Track({
2681
- * encoded: "base64",
2682
- * info: {
2683
- * title: "Track Title",
2684
- * uri: "https://example.com",
2685
- * duration: 300000,
2686
- * },
2687
- * // the rest of the track info
2688
- * }, requester);
2689
2526
  *
2690
- * console.log(track.encoded); // the track encoded in base64
2691
- * ```
2527
+ * Set the karaoke filter with the given settings.
2528
+ * @param {KaraokeSettings} [settings=DefaultFilterPreset.Karaoke] The settings for the karaoke filter.
2529
+ * @returns {Promise<this>} The instance of the filter manager.
2692
2530
  */
2693
- constructor(track: LavalinkTrack | null, requester?: TrackRequester);
2531
+ setKaraoke(settings?: Partial<KaraokeSettings>): Promise<this>;
2694
2532
  /**
2695
2533
  *
2696
- * Get the hyperlink of the track.
2697
- * @param {boolean} [embedable=true] Whether the hyperlink should be embedable or not.
2698
- * @returns {string} The hyperlink of the track.
2699
- * @example
2700
- * ```ts
2701
- * const track = queue.current;
2702
- * console.log(track.toHyperlink()); // [Track Title](https://example.com)
2703
- * console.log(track.toHyperlink(false)); // [Track Title](<https://example.com>)
2704
- * ```
2534
+ * Set the distortion filter with the given settings.
2535
+ * @param {Partial<DistortionSettings>} [settings=DefaultFilterPreset.Distortion] The settings for the distortion filter.
2536
+ * @returns {Promise<this>} The instance of the filter manager.
2705
2537
  */
2706
- toHyperlink(embedable?: boolean): string;
2538
+ setDistortion(settings?: Partial<DistortionSettings>): Promise<this>;
2539
+ /**
2540
+ * Set the timescale filter with the given settings.
2541
+ * @param {Partial<TimescaleSettings>} settings The timescale settings to set.
2542
+ * @returns {Promise<this>} The instance of the filter manager.
2543
+ */
2544
+ setTimescale(settings: Partial<TimescaleSettings>): Promise<this>;
2545
+ /**
2546
+ * Convert the filter settings to a JSON object.
2547
+ * @returns {FilterSettings} The filter settings as a JSON object.
2548
+ */
2549
+ toJSON(): FilterSettings;
2707
2550
  }
2551
+
2708
2552
  /**
2709
- * Class representing an unresolved track.
2710
- * @class UnresolvedTrack
2711
- * @implements {UnresolvedLavalinkTrack}
2553
+ * Type representing the customizable player storage.
2712
2554
  */
2713
- declare class UnresolvedTrack implements UnresolvedLavalinkTrack {
2555
+ type StorageKeys = keyof CustomizablePlayerStorage | (string & {});
2556
+ /**
2557
+ * Type representing the customizable player storage values.
2558
+ */
2559
+ type StorageValues<V extends StorageKeys = StorageKeys> = V extends keyof CustomizablePlayerStorage ? CustomizablePlayerStorage[V] : unknown;
2560
+ /**
2561
+ * Class representing a player storage.
2562
+ * @class PlayerStorage
2563
+ */
2564
+ declare class PlayerStorage<K extends StorageKeys = StorageKeys, V extends StorageValues<K> = StorageValues<K>> {
2714
2565
  /**
2715
- * The base64 encoded track.
2716
- * @type {string | undefined}
2566
+ *
2567
+ * Get the value for a key in the storage.
2568
+ * @param {K} key The key to get the value for.
2569
+ * @returns {V | undefined} The value for the key, or undefined if it doesn't exist.
2717
2570
  */
2718
- readonly encoded?: string;
2571
+ get<K extends StorageKeys, V extends StorageValues<K>>(key: K): V | undefined;
2719
2572
  /**
2720
- * The track info.
2721
- * @type {UnresolvedTrackInfo}
2573
+ * Set the value for a key in the storage.
2574
+ * @param {K} key The key to set the value for.
2575
+ * @param {V} value The value to set for the key.
2722
2576
  */
2723
- readonly info: UnresolvedTrackInfo;
2577
+ set<K extends StorageKeys, V extends StorageValues<K>>(key: K, value: V): void;
2724
2578
  /**
2725
- * The plugin info of the track.
2726
- * @type {Partial<PluginInfo>}
2579
+ * Check if the storage has a key.
2580
+ * @param {K} key The key to check for.
2581
+ * @returns {boolean} True if the storage has the key, false otherwise.
2727
2582
  */
2728
- readonly pluginInfo?: Partial<PluginInfo>;
2583
+ has(key: K): boolean;
2729
2584
  /**
2730
- * The track user data.
2731
- * @type {Record<string, unknown> | undefined}
2585
+ * Delete a key from the storage.
2586
+ * @param {K} key The key to delete.
2587
+ * @returns {boolean} True if the key was deleted, false otherwise.
2732
2588
  */
2733
- userData?: Record<string, unknown>;
2589
+ delete(key: K): boolean;
2734
2590
  /**
2735
- * The requester of the track.
2736
- * @type {TrackRequester | undefined}
2591
+ * Get all keys in the storage.
2592
+ * @returns {K[]} The keys in the storage.
2737
2593
  */
2738
- requester: TrackRequester;
2594
+ keys<K extends StorageKeys[]>(): K[];
2739
2595
  /**
2740
- * The constructor for the track.
2741
- * @param {UnresolvedLavalinkTrack} track The track to construct the track from.
2742
- * @param {TrackRequester} requester The requester of the track.
2743
- * @example
2744
- * ```ts
2745
- * const track = new UnresolvedTrack({
2746
- * encoded: "base64",
2747
- * info: {
2748
- * title: "Track Title",
2749
- * },
2750
- * // the rest of the track info
2751
- * }, requester);
2752
- *
2753
- * console.log(track.encoded); // the track encoded in base64
2754
- * ```
2596
+ * Get all values in the storage.
2597
+ * @returns {V[]} The values in the storage.
2755
2598
  */
2756
- constructor(track: UnresolvedLavalinkTrack, requester: TrackRequester);
2599
+ values<K extends StorageKeys[], V extends StorageValues<K[number]>>(): V[];
2757
2600
  /**
2758
- * Resolves the track to a playable track.
2759
- * @param {PlayerStructure} player The player to resolve the track for.
2760
- * @returns {Promise<Track>} The resolved track.
2761
- * @throws {ResolveError} If the track cannot be resolved.
2601
+ * Get all entries in the storage.
2602
+ * @returns {[K, V][]} The entries in the storage.
2762
2603
  */
2763
- resolve(player: PlayerStructure): Promise<Track>;
2764
- }
2765
- /**
2766
- * Type representing a Hoshimi track, which can be either a resolved or unresolved track.
2767
- */
2768
- type HoshimiTrack = Track | UnresolvedTrack;
2769
- /**
2770
- * Interface representing an extendable track.
2771
- */
2772
- interface CustomizableTrack {
2604
+ entries<K extends StorageKeys[], V extends StorageValues<K[number]>>(): [K, V][];
2605
+ /**
2606
+ *
2607
+ * Get all key-value pairs in the storage.
2608
+ * @returns {Record<K[number], V>} An object containing all key-value pairs in the storage, excluding internal keys.
2609
+ */
2610
+ all<K extends StorageKeys[], V extends StorageValues<K[number]>>(): Record<K[number], V>;
2611
+ /**
2612
+ * Clear the storage.
2613
+ */
2614
+ clear(): void;
2615
+ /**
2616
+ * Get the size of the storage.
2617
+ * @returns {number} The number of entries in the storage.
2618
+ */
2619
+ get size(): number;
2773
2620
  }
2774
- /**
2775
- * The requester of the track.
2776
- */
2777
- type TrackRequester = Inferable<CustomizableTrack, "requester">;
2778
2621
 
2779
2622
  /**
2780
- * Partial Lavalink track type.
2623
+ * Type representing a nullable voice channel update.
2781
2624
  */
2782
- type PartialLavalinkTrack = Partial<Nullable<LavalinkTrack>>;
2625
+ type NullableVoiceChannelUpdate = Partial<Nullable<VoiceChannelUpdate>>;
2783
2626
  /**
2784
- * The base options for playing a track.
2627
+ * Class representing a Hoshimi player.
2628
+ * @class Player
2785
2629
  */
2786
- interface BasePlayOptions {
2787
- /**
2788
- * The position to start the track.
2789
- * @type {number | undefined}
2790
- */
2791
- position?: number;
2792
- /**
2793
- * The position to end the track.
2794
- * @type {number | undefined}
2795
- */
2796
- endTime?: number;
2630
+ declare class Player {
2797
2631
  /**
2798
- * The pause state of the player.
2799
- * @type {boolean | undefined}
2632
+ * The data for the player.
2633
+ * @type {PlayerStorage}
2634
+ * @readonly
2800
2635
  */
2801
- paused?: boolean;
2636
+ readonly data: PlayerStorage;
2802
2637
  /**
2803
- * The volume of the player.
2804
- * @type {number | undefined}
2638
+ * The options for the player.
2639
+ * @type {PlayerOptions}
2640
+ * @readonly
2805
2641
  */
2806
- volume?: number;
2642
+ readonly options: PlayerOptions;
2807
2643
  /**
2808
- * The filters for the player.
2809
- * @type {Partial<FilterSettings> | undefined}
2644
+ * The manager for the player.
2645
+ * @type {Hoshimi}
2646
+ * @readonly
2810
2647
  */
2811
- filters?: Partial<FilterSettings>;
2648
+ readonly manager: Hoshimi;
2812
2649
  /**
2813
- * The voice settings for the player.
2814
- * @type {LavalinkPlayerVoice | undefined}
2650
+ * The queue for the player.
2651
+ * @type {Queue}
2652
+ * @readonly
2815
2653
  */
2816
- voice?: LavalinkPlayerVoice;
2817
- }
2818
- /**
2819
- * The types of loop modes.
2820
- */
2821
- declare enum LoopMode {
2654
+ readonly queue: QueueStructure;
2822
2655
  /**
2823
- * Loop mode for repeating the current track.
2656
+ * The filter manager for the player.
2657
+ * @type {FilterManager}
2658
+ * @readonly
2824
2659
  */
2825
- Track = 1,
2660
+ readonly filterManager: FilterManager;
2826
2661
  /**
2827
- * Loop mode for repeating the queue.
2662
+ * The node for the player.
2663
+ * @type {NodeStructure}
2828
2664
  */
2829
- Queue = 2,
2665
+ node: NodeStructure;
2830
2666
  /**
2831
- * Loop mode for repeating nothing.
2667
+ * Check if the player is self deafened.
2668
+ * @type {boolean}
2832
2669
  */
2833
- Off = 3
2834
- }
2835
- /**
2836
- * The types of player events.
2837
- */
2838
- declare enum PlayerEventType {
2670
+ selfDeaf: boolean;
2839
2671
  /**
2840
- * Event type for when a track starts.
2672
+ * Check if the player is self muted.
2673
+ * @type {boolean}
2841
2674
  */
2842
- TrackStart = "TrackStartEvent",
2675
+ selfMute: boolean;
2843
2676
  /**
2844
- * Event type for when a track ends.
2677
+ * Loop mode of the player.
2678
+ * @type {LoopMode}
2679
+ * @default LoopMode.Off
2845
2680
  */
2846
- TrackEnd = "TrackEndEvent",
2681
+ loop: LoopMode;
2847
2682
  /**
2848
- * Event type for when a track encounters an exception.
2683
+ * Check if the player is playing.
2684
+ * @type {boolean}
2685
+ * @default false
2849
2686
  */
2850
- TrackException = "TrackExceptionEvent",
2687
+ playing: boolean;
2851
2688
  /**
2852
- * Event type for when a track gets stuck.
2689
+ * Check if the player is paused.
2690
+ * @type {boolean}
2691
+ * @default false
2853
2692
  */
2854
- TrackStuck = "TrackStuckEvent",
2693
+ paused: boolean;
2855
2694
  /**
2856
- * Event type for when lyrics are found.
2695
+ * Check if the player is connected.
2696
+ * @type {boolean}
2697
+ * @default false
2857
2698
  */
2858
- LyricsFound = "LyricsFoundEvent",
2699
+ connected: boolean;
2859
2700
  /**
2860
- * Event type for when lyrics are not found.
2701
+ * Volume of the player.
2702
+ * @type {number}
2703
+ * @default 100
2861
2704
  */
2862
- LyricsNotFound = "LyricsNotFoundEvent",
2705
+ volume: number;
2863
2706
  /**
2864
- * Event type for when a lyrics line is sent.
2707
+ * Guild ig of the player.
2708
+ * @type {string}
2865
2709
  */
2866
- LyricsLine = "LyricsLineEvent",
2710
+ guildId: string;
2867
2711
  /**
2868
- * Event type for when the WebSocket connection is closed.
2712
+ * Voice channel idof the player.
2713
+ * @type {string | undefined}
2869
2714
  */
2870
- WebsocketClosed = "WebSocketClosedEvent"
2871
- }
2872
- /**
2873
- * The reasons a track can end.
2874
- */
2875
- declare enum TrackEndReason {
2715
+ voiceId: string | undefined;
2876
2716
  /**
2877
- * The track ended normally.
2717
+ * Text channel id of the player.
2718
+ * @type {string | undefined}
2878
2719
  */
2879
- Finished = "finished",
2720
+ textId: string | undefined;
2880
2721
  /**
2881
- * The track fails to load.
2722
+ * The ping of the player.
2723
+ * @type {number}
2882
2724
  */
2883
- LoadFailed = "loadFailed",
2725
+ ping: number;
2884
2726
  /**
2885
- * The track was stopped.
2727
+ * The timestamp when the player was created.
2728
+ * @type {number}
2886
2729
  */
2887
- Stopped = "stopped",
2730
+ createdTimestamp: number;
2888
2731
  /**
2889
- * The track was replaced.
2732
+ * The last position received from Lavalink.
2733
+ * @type {number}
2890
2734
  */
2891
- Replaced = "replaced",
2735
+ lastPosition: number;
2892
2736
  /**
2893
- * The track was cleaned up.
2737
+ * The timestamp when the last position change update happened.
2738
+ * @type {number | null}
2894
2739
  */
2895
- Cleanup = "cleanup"
2896
- }
2897
- /**
2898
- * The base interface for player events.
2899
- */
2900
- interface PlayerEvent {
2740
+ lastPositionUpdate: number | null;
2901
2741
  /**
2902
- * The operation code for the event.
2903
- * @type {OpCodes.Event}
2742
+ * The current calculated position of the player.
2743
+ * @type {number}
2744
+ * @readonly
2904
2745
  */
2905
- op: OpCodes.Event;
2746
+ get position(): number;
2906
2747
  /**
2907
- * The guild ID associated with the event.
2908
- * @type {string}
2748
+ * The voice connection details.
2749
+ * @type {PlayerVoice}
2909
2750
  */
2910
- guildId: string;
2911
- }
2912
- /**
2913
- * The event for when a track starts playing.
2914
- */
2915
- interface TrackStartEvent extends PlayerEvent {
2751
+ voice: Nullable<LavalinkPlayerVoice>;
2916
2752
  /**
2917
- * The type of the event.
2918
- * @type {PlayerEventType.TrackStart}
2753
+ *
2754
+ * Create a new player.
2755
+ * @param {Hoshimi} manager The manager for the player.
2756
+ * @param {PlayOptions} options The options for the player.
2757
+ * @example
2758
+ * ```ts
2759
+ * const player = new Player(manager, {
2760
+ * guildId: "guildId",
2761
+ * voiceId: "voiceId",
2762
+ * textId: "textId",
2763
+ * selfDeaf: true,
2764
+ * selfMute: false,
2765
+ * volume: 100,
2766
+ * });
2767
+ *
2768
+ * console.log(player.guildId); // guildId
2769
+ * console.log(player.voiceId); // voiceId
2770
+ * console.log(player.textId); // textId
2919
2771
  */
2920
- type: PlayerEventType.TrackStart;
2772
+ constructor(manager: Hoshimi, options: PlayerOptions);
2921
2773
  /**
2922
- * The track that started playing.
2923
- * @type {LavalinkTrack}
2774
+ * The lyrics methods for the player.
2775
+ * @type {LyricsMethods}
2776
+ * @readonly
2924
2777
  */
2925
- track: LavalinkTrack;
2926
- }
2927
- /**
2928
- * The event for when a track ends.
2929
- */
2930
- interface TrackEndEvent extends PlayerEvent {
2778
+ readonly lyrics: LyricsMethods;
2931
2779
  /**
2932
- * The type of the event.
2933
- * @type {PlayerEventType.TrackEnd}
2780
+ *
2781
+ * Search for a track or playlist.
2782
+ * @param {SearchOptions} options The options for the search.
2783
+ * @returns {Promise<QueryResult>} The search result.
2784
+ * @example
2785
+ * ```ts
2786
+ * const player = manager.getPlayer("guildId");
2787
+ * const result = await player.search({
2788
+ * query: "track name",
2789
+ * engine: SearchEngine.Youtube,
2790
+ * requester: {},
2791
+ * });
2792
+ *
2793
+ * console.log(result) // the search result
2794
+ * ```
2934
2795
  */
2935
- type: PlayerEventType.TrackEnd;
2796
+ search(options: SearchOptions): Promise<QueryResult>;
2936
2797
  /**
2937
- * The track that ended.
2938
- * @type {LavalinkTrack}
2798
+ *
2799
+ * Play the next track in the queue.
2800
+ * @param {number} [to=0] The amount of tracks to skip.
2801
+ * @param {boolean} [throwError=true] Whether to throw an error if there are no tracks to skip.
2802
+ * @returns {Promise<void>}
2803
+ * @throws {PlayerError} If there are no tracks to skip.
2804
+ * @example
2805
+ * ```ts
2806
+ * const player = manager.getPlayer("guildId");
2807
+ * player.skip(2); // skip 2 tracks
2808
+ * player.skip(); // skip 1 track
2809
+ * ```
2939
2810
  */
2940
- track: LavalinkTrack;
2811
+ skip(to?: number, throwError?: boolean): Promise<void>;
2941
2812
  /**
2942
- * The reason the track ended.
2943
- * @type {TrackEndReason}
2813
+ *
2814
+ * Seek to a specific position in the current track.
2815
+ * @param {number} position The position to seek to in milliseconds.
2816
+ * @returns {Promise<void>}
2817
+ * @throws {PlayerError} If the position is invalid.
2818
+ * @example
2819
+ * ```ts
2820
+ * const player = manager.getPlayer("guildId");
2821
+ * player.seek(30000); // seek to 30 seconds
2822
+ * ```
2944
2823
  */
2945
- reason: TrackEndReason;
2946
- }
2947
- /**
2948
- * The event for when a track gets stuck.
2949
- */
2950
- interface TrackStuckEvent extends PlayerEvent {
2824
+ seek(position: number): Promise<void>;
2951
2825
  /**
2952
- * The type of the event.
2953
- * @type {PlayerEventType.TrackStuck}
2826
+ *
2827
+ * Disconnect the player from the voice channel.
2828
+ * @returns {Promise<this>} The player instance.
2829
+ * @example
2830
+ * ```ts
2831
+ * const player = manager.getPlayer("guildId");
2832
+ * player.disconnect();
2833
+ * ```
2954
2834
  */
2955
- type: PlayerEventType.TrackStuck;
2835
+ disconnect(): Promise<this>;
2956
2836
  /**
2957
- * The track that got stuck.
2958
- * @type {LavalinkTrack}
2837
+ *
2838
+ * Destroy and disconnect the player.
2839
+ * @param {DestroyReasons} [reason] The reason for destroying the player.
2840
+ * @returns {Promise<void>}
2841
+ * @example
2842
+ * ```ts
2843
+ * const player = manager.getPlayer("guildId");
2844
+ * player.destroy(DestroyReasons.Stop);
2845
+ * ```
2959
2846
  */
2960
- track: LavalinkTrack;
2847
+ destroy(reason?: DestroyReasons): Promise<boolean>;
2961
2848
  /**
2962
- * The threshold in milliseconds.
2963
- * @type {number}
2849
+ *
2850
+ * Play a track in the player.
2851
+ * @param {Partial<PlayOptions>} [options] The options to play the track.
2852
+ * @returns {Promise<void>}
2853
+ * @throws {PlayerError} If there are no tracks to play.
2854
+ * @example
2855
+ * ```ts
2856
+ * const player = manager.getPlayer("guildId");
2857
+ *
2858
+ * player.play({
2859
+ * track: track,
2860
+ * noReplace: true,
2861
+ * });
2862
+ * ```
2964
2863
  */
2965
- thresholdMs: number;
2966
- }
2967
- /**
2968
- * The event for when a track encounters an exception.
2969
- */
2970
- interface TrackExceptionEvent extends PlayerEvent {
2864
+ play(options?: Partial<PlayOptions>): Promise<void>;
2971
2865
  /**
2972
- * The type of the event.
2973
- * @type {PlayerEventType.TrackException}
2866
+ * Connect the player to the voice channel.
2867
+ * @returns {Promise<this>} The player instance.
2868
+ * @example
2869
+ * ```ts
2870
+ * const player = manager.getPlayer("guildId");
2871
+ * player.connect();
2872
+ * ```
2974
2873
  */
2975
- type: PlayerEventType.TrackException;
2874
+ connect(): Promise<this>;
2976
2875
  /**
2977
- * The exception that occurred.
2978
- * @type {Exception}
2876
+ *
2877
+ * Stop the player from playing.
2878
+ * @param {boolean} [destroy=true] Whether to destroy the player or not.
2879
+ * @returns {Promise<void>}
2880
+ * @example
2881
+ * ```ts
2882
+ * const player = manager.getPlayer("guildId");
2883
+ * player.stop();
2884
+ * ```
2979
2885
  */
2980
- exception: Exception;
2981
- }
2982
- /**
2983
- * The event for when the WebSocket connection is closed.
2984
- */
2985
- interface WebSocketClosedEvent extends PlayerEvent {
2886
+ stop(destroy?: boolean): Promise<void>;
2986
2887
  /**
2987
- * The type of the event.
2988
- * @type {PlayerEventType.WebsocketClosed}
2888
+ *
2889
+ * Pause or resume the player.
2890
+ * @returns {Promise<void>}
2891
+ * @example
2892
+ * ```ts
2893
+ * const player = manager.getPlayer("guildId");
2894
+ * player.setPaused();
2895
+ * ```
2989
2896
  */
2990
- type: PlayerEventType.WebsocketClosed;
2897
+ setPaused(paused?: boolean): Promise<boolean>;
2991
2898
  /**
2992
- * The close code.
2993
- * @type {number}
2899
+ *
2900
+ * Set the volume of the player.
2901
+ * @param {number} volume The volume to set.
2902
+ * @returns {Promise<void>}
2903
+ * @example
2904
+ * ```ts
2905
+ * const player = manager.getPlayer("guildId");
2906
+ * player.setVolume(50); // set the volume to 50%
2907
+ * ```
2994
2908
  */
2995
- code: number;
2909
+ setVolume(volume: number): Promise<void>;
2996
2910
  /**
2997
- * Whether the connection was closed by the remote.
2998
- * @type {boolean}
2911
+ *
2912
+ * Set the loop mode of the player.
2913
+ * @param {LoopMode} mode The loop mode to set.
2914
+ * @throws {PlayerError} If the loop mode is invalid.
2915
+ * @example
2916
+ * ```ts
2917
+ * const player = manager.getPlayer("guildId");
2918
+ * player.setLoop(LoopMode.Track);
2919
+ * ```
2999
2920
  */
3000
- byRemote: boolean;
2921
+ setLoop(mode: LoopMode): this;
3001
2922
  /**
3002
- * The reason for the closure.
3003
- * @type {string}
2923
+ * Set the voice of the player.
2924
+ * @param {NullableVoiceChannelUpdate} options The voice state to set.
2925
+ * @returns {Promise<void>}
2926
+ * @example
2927
+ * ```ts
2928
+ * const player = manager.getPlayer("guildId");
2929
+ * player.setVoice({ voiceId: "newVoiceId" });
2930
+ * ```
3004
2931
  */
3005
- reason: string;
3006
- }
3007
- /**
3008
- * The event for when lyrics are found.
3009
- */
3010
- interface LyricsFoundEvent extends PlayerEvent {
2932
+ setVoice(options?: NullableVoiceChannelUpdate): Promise<void>;
3011
2933
  /**
3012
- * The type of the event.
3013
- * @type {PlayerEventType.LyricsFound}
2934
+ *
2935
+ * Change the node the player is connected to.
2936
+ * @param {NodeIdentifier} node The node to change to.
2937
+ * @returns {Promise<void>} A promise that resolves when the node has been changed.
2938
+ * @throws {PlayerError} If the target node is not found, not connected, or missing source managers.
2939
+ * @example
2940
+ * ```ts
2941
+ * const player = manager.getPlayer("guildId");
2942
+ * player.move("newNodeId");
2943
+ * ```
3014
2944
  */
3015
- type: PlayerEventType.LyricsFound;
2945
+ move(node: NodeIdentifier): Promise<void>;
3016
2946
  /**
3017
- * The guild id associated with the event.
3018
- * @type {string}
2947
+ * Update the player with new data.
2948
+ * @param {NonGuildUpdatePlayerInfo} data The data to update the player with.
2949
+ * @returns {Promise<LavalinkPlayer | null>} The updated player data.
3019
2950
  */
3020
- guildId: string;
2951
+ updatePlayer(data: NonGuildUpdatePlayerInfo): Promise<LavalinkPlayer | null>;
3021
2952
  /**
3022
- * The lyrics result of the event.
3023
- * @type {LyricsResult}
2953
+ *
2954
+ * Return the player as a json object.
2955
+ * @returns {PlayerJson}
2956
+ * @example
2957
+ * ```ts
2958
+ * const player = manager.getPlayer("guildId");
2959
+ * const json = player.toJSON();
2960
+ * console.log(json); // the player as a json object
2961
+ * ```
3024
2962
  */
3025
- lyrics: LyricsResult;
2963
+ toJSON(): PlayerJson;
3026
2964
  }
3027
2965
  /**
3028
- * The event for when lyrics are not found.
2966
+ * Type representing the update player information without guildId.
3029
2967
  */
3030
- interface LyricsNotFoundEvent extends PlayerEvent {
3031
- /**
3032
- * The type of the event.
3033
- * @type {PlayerEventType.LyricsNotFound}
3034
- */
3035
- type: PlayerEventType.LyricsNotFound;
3036
- /**
3037
- * The guild id associated with the event.
3038
- * @type {string}
3039
- */
3040
- guildId: string;
3041
- }
2968
+ type NonGuildUpdatePlayerInfo = Omit<UpdatePlayerInfo, "guildId">;
3042
2969
  /**
3043
- * The event for when a lyrics line is sent.
2970
+ * Interface representing the customizable player storage.
3044
2971
  */
3045
- interface LyricsLineEvent extends PlayerEvent {
3046
- /**
3047
- * The type of the event.
3048
- * @type {PlayerEventType.LyricsLine}
3049
- */
3050
- type: PlayerEventType.LyricsLine;
3051
- /**
3052
- * The guild id associated with the event.
3053
- * @type {string}
3054
- */
3055
- guildId: string;
3056
- /**
3057
- * The line index of the lyrics line.
3058
- * @type {number}
3059
- */
3060
- lineIndex: number;
3061
- /**
3062
- * The lyrics line of the event.
3063
- * @type {LyricsLine}
3064
- */
3065
- line: LyricsLine;
3066
- /**
3067
- * Returns if the line was skipped.
3068
- * @type {boolean}
3069
- */
3070
- skipped: boolean;
2972
+ interface CustomizablePlayerStorage {
3071
2973
  }
2974
+
3072
2975
  /**
3073
- * The update for the player state.
2976
+ * Class representing the queue utils.
2977
+ * @class QueueUtils
3074
2978
  */
3075
- interface PlayerUpdate {
2979
+ declare class QueueUtils {
3076
2980
  /**
3077
- * The operation code for the update.
3078
- * @type {OpCodes.PlayerUpdate}
2981
+ *
2982
+ * Constructor of the queue utils.
2983
+ * @param {QueueStructure} queue The queue instance.
3079
2984
  */
3080
- op: OpCodes.PlayerUpdate;
2985
+ constructor(queue: QueueStructure);
3081
2986
  /**
3082
- * The guild ID associated with the update.
3083
- * @type {string}
2987
+ *
2988
+ * Save the queue.
2989
+ * @returns {Awaitable<void>}
2990
+ * @example
2991
+ * ```ts
2992
+ * await player.queue.utils.save();
2993
+ * ```
3084
2994
  */
3085
- guildId: string;
2995
+ save(): Awaitable<void>;
3086
2996
  /**
3087
- * The state of the player.
3088
- * @type {PlayerUpdateState}
2997
+ *
2998
+ * Destroy the queue.
2999
+ * @returns {Promise<void>}
3000
+ * @example
3001
+ * ```ts
3002
+ * await player.queue.utils.destroy();
3003
+ * ```
3004
+ */
3005
+ destroy(): Awaitable<boolean>;
3006
+ /**
3007
+ *
3008
+ * Sync the queue.
3009
+ * @returns {Awaitable<void>}
3010
+ * @example
3011
+ * ```ts
3012
+ * await player.queue.utils.sync();
3013
+ * ```
3089
3014
  */
3090
- state: PlayerUpdateState;
3015
+ sync(override?: boolean, syncCurrent?: boolean): Promise<void>;
3091
3016
  }
3092
- interface PlayerUpdateState {
3017
+
3018
+ /**
3019
+ * Class representing a queue.
3020
+ * @class Queue
3021
+ */
3022
+ declare class Queue {
3093
3023
  /**
3094
- * Whether the player is connected.
3095
- * @type {boolean}
3024
+ * Tracks of the queue.
3025
+ * @type {HoshimiTrack[]}
3096
3026
  */
3097
- connected: boolean;
3027
+ tracks: HoshimiTrack[];
3098
3028
  /**
3099
- * The position of the track.
3100
- * @type {number}
3029
+ * Previous tracks of the queue.
3030
+ * @type {Track[]}
3101
3031
  */
3102
- position: number;
3032
+ history: Track[];
3103
3033
  /**
3104
- * The time of the update.
3105
- * @type {number}
3034
+ * Current track of the queue.
3035
+ * @type {Track | null}
3106
3036
  */
3107
- time: number;
3037
+ current: Track | null;
3108
3038
  /**
3109
- * The ping of the player.
3110
- * @type {number}
3039
+ * The player instance.
3040
+ * @type {PlayerStructure}
3111
3041
  */
3112
- ping: number;
3113
- }
3114
- /**
3115
- * The options for the player.
3116
- */
3117
- interface PlayerOptions {
3042
+ readonly player: PlayerStructure;
3118
3043
  /**
3119
- * Guild id of the player.
3120
- * @type {string}
3044
+ * The queue utils instance.
3045
+ * @type {QueueUtils}
3046
+ * @readonly
3121
3047
  */
3122
- guildId: string;
3048
+ readonly utils: QueueUtils;
3123
3049
  /**
3124
- * Voice channel id of the player.
3125
- * @type {string}
3050
+ *
3051
+ * Constructor of the queue.
3052
+ * @param {PlayerStructure} player Player instance.
3053
+ * @example
3054
+ * ```ts
3055
+ * const player = new Player();
3056
+ * const queue = new Queue(player);
3057
+ *
3058
+ * console.log(queue.size); // 0
3059
+ * queue.add(track);
3060
+ * console.log(queue.size); // 1
3061
+ * ```
3126
3062
  */
3127
- voiceId: string;
3063
+ constructor(player: PlayerStructure);
3128
3064
  /**
3129
- * Volume of the player.
3130
- * @type {number | undefined}
3131
- * @default 100
3065
+ * Get the track size of the queue.
3066
+ * @type {number}
3067
+ * @returns {number} The track size of the queue.
3068
+ * @readonly
3069
+ * @example
3070
+ * ```ts
3071
+ * const queue = player.queue;
3072
+ *
3073
+ * console.log(queue.size); // 0
3074
+ * queue.add(track);
3075
+ *
3076
+ * console.log(queue.size); // 1
3077
+ * queue.add([track1, track2]);
3078
+ *
3079
+ * console.log(queue.size); // 3
3080
+ * queue.shift();
3081
+ * console.log(queue.size); // 2
3082
+ *
3083
+ * queue.clear();
3084
+ * console.log(queue.size); // 0
3085
+ * ```
3132
3086
  */
3133
- volume?: number;
3087
+ get size(): number;
3134
3088
  /**
3135
- * Set if the player should be deafened.
3136
- * @type {boolean | undefined}
3137
- * @default true
3089
+ * Get the total track size of the queue (Includes the current track).
3090
+ * @type {number}
3091
+ * @returns {number} The total track size of the queue.
3092
+ * @readonly
3093
+ * @example
3094
+ * ```ts
3095
+ * const queue = player.queue;
3096
+ *
3097
+ * console.log(queue.totalSize); // 0
3098
+ * queue.add(track);
3099
+ *
3100
+ * console.log(queue.totalSize); // 1
3101
+ * queue.add([track1, track2]);
3102
+ *
3103
+ * console.log(queue.totalSize); // 3
3104
+ * queue.shift();
3105
+ * console.log(queue.totalSize); // 2
3106
+ *
3107
+ * queue.clear();
3108
+ * console.log(queue.totalSize); // 0
3109
+ * ```
3138
3110
  */
3139
- selfDeaf?: boolean;
3111
+ get totalSize(): number;
3140
3112
  /**
3141
- * Set if the player should be muted.
3142
- * @type {boolean | undefined}
3143
- * @default false
3113
+ *
3114
+ * Check if the queue is empty.
3115
+ * @type {boolean}
3116
+ * @returns {boolean} True if the queue is empty.
3117
+ * @readonly
3118
+ * @example
3119
+ * ```ts
3120
+ * const queue = player.queue;
3121
+ *
3122
+ * console.log(queue.isEmpty()); // true
3123
+ * queue.add(track);
3124
+ *
3125
+ * console.log(queue.isEmpty()); // false
3126
+ * queue.clear();
3127
+ *
3128
+ * console.log(queue.isEmpty()); // true
3129
+ * ```
3144
3130
  */
3145
- selfMute?: boolean;
3131
+ isEmpty(): boolean;
3146
3132
  /**
3147
- * Text channel id of the player.
3148
- * @type {string | undefined}
3133
+ *
3134
+ * Build a track from a Lavalink track or unresolved Lavalink track.
3135
+ * @param {LavalinkTrack | UnresolvedLavalinkTrack} track The track to build.
3136
+ * @param {TrackRequester} requester The requester of the track.
3137
+ * @returns {Promise<Track>} The built track.
3138
+ * @example
3139
+ * ```ts
3140
+ * const queue = player.queue;
3141
+ * const lavalinkTrack = {...} // some lavalink track
3142
+ * const track = await queue.build(lavalinkTrack, author);
3143
+ *
3144
+ * console.log(track.info.title); // The title of the track
3145
+ * ```
3149
3146
  */
3150
- textId?: string;
3147
+ build(track: LavalinkTrack | UnresolvedLavalinkTrack | HoshimiTrack, requester: TrackRequester): Promise<Track>;
3151
3148
  /**
3152
- * Lavalink node of the player.
3153
- * @type {NodeIdentifier}
3149
+ *
3150
+ * Get the previous track of the queue.
3151
+ * @param {boolean} [remove=false] Whether to remove the track from the previous queue.
3152
+ * @returns {Promise<Track | null>} The previous track of the queue.
3153
+ * @example
3154
+ * ```ts
3155
+ * const queue = player.queue;
3156
+ *
3157
+ * console.log(await queue.previous()); // null
3158
+ * queue.add(track);
3159
+ * queue.add(track2);
3160
+ *
3161
+ * console.log(await queue.previous()); // track
3162
+ * console.log(await queue.previous(true)); // track and remove it from the previous tracks
3163
+ * ```
3154
3164
  */
3155
- node?: NodeIdentifier;
3156
- }
3157
- /**
3158
- * The options for playing a track with Lavalink.
3159
- */
3160
- interface LavalinkPlayOptions extends BasePlayOptions {
3165
+ previous(remove?: boolean): Promise<Track | null>;
3161
3166
  /**
3162
- * Track to play.
3163
- * @type {PartialLavalinkTrack | undefined}
3167
+ *
3168
+ * Add a track or tracks to the queue.
3169
+ * @param {Track | Track[]} track The track or tracks to add.
3170
+ * @param {number} [position] The position to add the track or tracks.
3171
+ * @returns {Promise<this>} The queue instance.
3172
+ * @example
3173
+ * ```ts
3174
+ * const queue = player.queue;
3175
+ *
3176
+ * console.log(queue.size); // 0
3177
+ *
3178
+ * await queue.add(track);
3179
+ * console.log(queue.size); // 1
3180
+ *
3181
+ * await queue.add([track1, track2]);
3182
+ * console.log(queue.size); // 3
3183
+ *
3184
+ * await queue.add(track3, 1);
3185
+ * console.log(queue.size); // 4
3186
+ * console.log(queue.tracks); // [track1, track3, track2, track]
3187
+ * ```
3164
3188
  */
3165
- track?: PartialLavalinkTrack;
3166
- }
3167
- /**
3168
- * The options for playing a track.
3169
- */
3170
- interface PlayOptions extends BasePlayOptions {
3189
+ add(track: HoshimiTrack | HoshimiTrack[], position?: number): Promise<this>;
3171
3190
  /**
3172
- * Whether to replace the current track.
3173
- * @type {boolean | undefined}
3174
- * @default false
3191
+ *
3192
+ * Get the first track of the queue.
3193
+ * @returns {Promise<HoshimiTrack | null>} The first track of the queue.
3194
+ * @example
3195
+ * ```ts
3196
+ * const queue = player.queue;
3197
+ *
3198
+ * console.log(await queue.shift()); // null
3199
+ * await queue.add(track);
3200
+ *
3201
+ * console.log(await queue.shift()); // track
3202
+ * await queue.add(track2);
3203
+ * ```
3175
3204
  */
3176
- noReplace?: boolean;
3205
+ shift(): Promise<HoshimiTrack | null>;
3177
3206
  /**
3178
- * Track to play.
3179
- * @type {Track | UnresolvedTrack | undefined}
3207
+ *
3208
+ * Add tracks to the beginning of the queue.
3209
+ * @param {Track[]} tracks The tracks to add.
3210
+ * @returns {Promise<this>} The queue instance.
3211
+ * @example
3212
+ * ```ts
3213
+ * const queue = player.queue;
3214
+ *
3215
+ * console.log(queue.size); // 0
3216
+ * await queue.unshift(track);
3217
+ *
3218
+ * console.log(queue.size); // 1
3219
+ * await queue.unshift(track1, track2);
3220
+ *
3221
+ * console.log(queue.size); // 3
3222
+ * console.log(queue.tracks); // [track1, track2, track]
3223
+ * ```
3180
3224
  */
3181
- track?: Track | UnresolvedTrack;
3182
- }
3183
- interface PlayerVoice {
3225
+ unshift(...tracks: Track[]): Promise<this>;
3184
3226
  /**
3185
- * The voice server token.
3186
- * @type {string}
3227
+ *
3228
+ * Shuffle the queue.
3229
+ * @returns {Promise<this>} The queue instance.
3230
+ * @example
3231
+ * ```ts
3232
+ * const queue = player.queue;
3233
+ *
3234
+ * console.log(queue.size); // 0
3235
+ * await queue.add(track);
3236
+ * await queue.add(track1, track2);
3237
+ *
3238
+ * console.log(queue.size); // 3
3239
+ * console.log(queue.tracks); // [track, track1, track2]
3240
+ *
3241
+ * await queue.shuffle();
3242
+ * console.log(queue.tracks); // [track2, track, track1]
3243
+ * ```
3187
3244
  */
3188
- token: string;
3245
+ shuffle(): Promise<this>;
3189
3246
  /**
3190
- * The voice server endpoint.
3191
- * @type {string}
3247
+ *
3248
+ * Clear the queue.
3249
+ * @returns {Promise<this>} The queue instance.
3250
+ * @example
3251
+ * ```ts
3252
+ * const queue = player.queue;
3253
+ *
3254
+ * console.log(queue.size); // 0
3255
+ * await queue.add(track);
3256
+ * await queue.add(track1, track2);
3257
+ *
3258
+ * console.log(queue.size); // 3
3259
+ * await queue.clear();
3260
+ * console.log(queue.size); // 0
3261
+ * ```
3192
3262
  */
3193
- endpoint: string;
3263
+ clear(): Promise<this>;
3194
3264
  /**
3195
- * The voice server session id.
3196
- * @type {string}
3265
+ *
3266
+ * Move a track to a specific position in the queue.
3267
+ * @param {Track} track The track to move.
3268
+ * @param {number} to The position to move.
3269
+ * @returns {Promise<this>} The queue instance.
3197
3270
  */
3198
- sessionId: string;
3271
+ move(track: Track, to: number): Promise<this>;
3199
3272
  /**
3200
- * The voice server guild id.
3201
- * @type {string | undefined}
3273
+ *
3274
+ * Delete tracks from the queue.
3275
+ * @param {number} start The start index.
3276
+ * @param {number} deleteCount The number of tracks to delete.
3277
+ * @param {Track | Track[]} [tracks] The tracks to add.
3278
+ * @returns {Promise<this>} The queue instance.
3202
3279
  */
3203
- connected?: boolean;
3280
+ splice(start: number, deleteCount: number, tracks?: HoshimiTrack | HoshimiTrack[]): Promise<this>;
3204
3281
  /**
3205
- * The voice server ping.
3206
- * @type {number | undefined}
3282
+ *
3283
+ * Convert the queue to a JSON object.
3284
+ * @returns {QueueJson} The queue JSON object.
3207
3285
  */
3208
- ping?: number;
3286
+ toJSON(): QueueJson;
3209
3287
  }
3288
+
3210
3289
  /**
3211
- * The JSON representation of the player.
3290
+ * The structure for the Player class.
3212
3291
  */
3213
- interface PlayerJson {
3292
+ type PlayerStructure = InferCustomStructure<Player, "Player">;
3293
+ /**
3294
+ * The structure for the Rest class.
3295
+ */
3296
+ type RestStructure = InferCustomStructure<Rest, "Rest">;
3297
+ /**
3298
+ * The structure for the Node class.
3299
+ */
3300
+ type NodeStructure = InferCustomStructure<Node, "Node">;
3301
+ /**
3302
+ * The structure for the Queue class.
3303
+ */
3304
+ type QueueStructure = InferCustomStructure<Queue, "Queue">;
3305
+ /**
3306
+ * The structure for the LyricsManager class.
3307
+ */
3308
+ type LyricsManagerStructure = InferCustomStructure<LyricsManager, "LyricsManager">;
3309
+ /**
3310
+ * The structure for the NodeManager class.
3311
+ */
3312
+ type NodeManagerStructure = InferCustomStructure<NodeManager, "NodeManager">;
3313
+ /**
3314
+ * The structure for the FilterManager class.
3315
+ */
3316
+ type FilterManagerStructure = InferCustomStructure<FilterManager, "FilterManager">;
3317
+ /**
3318
+ * The structures of the Hoshimi classes.
3319
+ */
3320
+ declare const Structures: {
3321
+ Player(manager: Hoshimi, options: PlayerOptions): PlayerStructure;
3322
+ Rest(node: Node): RestStructure;
3323
+ Node(nodeManager: NodeManager, options: NodeOptions): NodeStructure;
3324
+ Queue(player: Player): QueueStructure;
3325
+ LyricsManager(node: Node): LyricsManagerStructure;
3326
+ NodeManager(manager: Hoshimi): NodeManagerStructure;
3327
+ FilterManager(player: Player): FilterManagerStructure;
3328
+ };
3329
+ /**
3330
+ * Infers the custom structure for a given class.
3331
+ */
3332
+ type InferCustomStructure<T, N extends string> = CustomizableStructures extends Record<N, infer P> ? P : T;
3333
+
3334
+ /**
3335
+ * Class representing a Hoshimi track.
3336
+ * @class Track
3337
+ * @implements {LavalinkTrack}
3338
+ */
3339
+ declare class Track implements LavalinkTrack {
3214
3340
  /**
3215
- * The guild id of the player.
3341
+ * The base64 encoded track.
3216
3342
  * @type {string}
3217
3343
  */
3218
- guildId: string;
3219
- /**
3220
- * The volume of the player.
3221
- * @type {number}
3222
- */
3223
- volume: number;
3224
- /**
3225
- * The self deaf state of the player.
3226
- * @type {boolean}
3227
- */
3228
- selfDeaf: boolean;
3229
- /**
3230
- * The self mute state of the player.
3231
- * @type {boolean}
3232
- */
3233
- selfMute: boolean;
3344
+ readonly encoded: string;
3234
3345
  /**
3235
- * The voice settings for the player.
3236
- * @type {LavalinkPlayerVoice}
3346
+ * The track info.
3347
+ * @type {TrackInfo}
3237
3348
  */
3238
- voice: Nullable<LavalinkPlayerVoice>;
3349
+ readonly info: TrackInfo;
3239
3350
  /**
3240
- * The loop mode of the player.
3241
- * @type {LoopMode}
3351
+ * The plugin info of the track.
3352
+ * @type {PluginInfo}
3242
3353
  */
3243
- loop: LoopMode;
3354
+ readonly pluginInfo: PluginInfo;
3244
3355
  /**
3245
- * The options for the player.
3246
- * @type {boolean}
3356
+ * The track user data.
3357
+ * @type {TrackUserData}
3247
3358
  */
3248
- options: PlayerOptions;
3359
+ userData: TrackUserData;
3249
3360
  /**
3250
- * The paused state of the player.
3251
- * @type {boolean}
3361
+ * The requester of the track.
3362
+ * @type {TrackRequester}
3252
3363
  */
3253
- paused: boolean;
3364
+ requester: TrackRequester;
3254
3365
  /**
3255
- * The playing state of the player.
3256
- * @type {boolean}
3366
+ * The constructor for the track.
3367
+ * @param {LavalinkTrack} track The track to construct the track from.
3368
+ * @param {TrackRequester} requester The requester of the track.
3369
+ * @example
3370
+ * ```ts
3371
+ * const track = new Track({
3372
+ * encoded: "base64",
3373
+ * info: {
3374
+ * title: "Track Title",
3375
+ * uri: "https://example.com",
3376
+ * duration: 300000,
3377
+ * },
3378
+ * // the rest of the track info
3379
+ * }, requester);
3380
+ *
3381
+ * console.log(track.encoded); // the track encoded in base64
3382
+ * ```
3257
3383
  */
3258
- playing: boolean;
3384
+ constructor(track: LavalinkTrack | null, requester?: TrackRequester);
3259
3385
  /**
3260
- * The voice channel id of the player.
3261
- * @type {string}
3386
+ *
3387
+ * Get the hyperlink of the track.
3388
+ * @param {boolean} [embedable=true] Whether the hyperlink should be embedable or not.
3389
+ * @returns {string} The hyperlink of the track.
3390
+ * @example
3391
+ * ```ts
3392
+ * const track = queue.current;
3393
+ * console.log(track.toHyperlink()); // [Track Title](https://example.com)
3394
+ * console.log(track.toHyperlink(false)); // [Track Title](<https://example.com>)
3395
+ * ```
3262
3396
  */
3263
- voiceId?: string;
3397
+ toHyperlink(embedable?: boolean): string;
3398
+ }
3399
+ /**
3400
+ * Class representing an unresolved track.
3401
+ * @class UnresolvedTrack
3402
+ * @implements {UnresolvedLavalinkTrack}
3403
+ */
3404
+ declare class UnresolvedTrack implements UnresolvedLavalinkTrack {
3264
3405
  /**
3265
- * The text channel id of the player.
3406
+ * The base64 encoded track.
3266
3407
  * @type {string | undefined}
3267
3408
  */
3268
- textId?: string;
3409
+ readonly encoded?: string;
3269
3410
  /**
3270
- * The queue of the player.
3271
- * @type {QueueJson | undefined}
3411
+ * The track info.
3412
+ * @type {UnresolvedTrackInfo}
3272
3413
  */
3273
- queue?: QueueJson;
3414
+ readonly info: UnresolvedTrackInfo;
3274
3415
  /**
3275
- * The node of the player.
3276
- * @type {NodeJson | undefined}
3416
+ * The plugin info of the track.
3417
+ * @type {Partial<PluginInfo>}
3277
3418
  */
3278
- node?: NodeJson;
3279
- }
3280
- /**
3281
- * The lyrics methods for the player.
3282
- */
3283
- interface LyricsMethods {
3419
+ readonly pluginInfo?: Partial<PluginInfo>;
3284
3420
  /**
3285
- *
3286
- * Get the current lyrics for the current track.
3287
- * @param {boolean} [skipSource=false] Whether to skip the source or not.
3288
- * @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
3289
- * @example
3290
- * ```ts
3291
- * const player = manager.getPlayer("guildId");
3292
- * const lyrics = await player.lyricsManager.current();
3293
- * ```
3421
+ * The track user data.
3422
+ * @type {TrackUserData | undefined}
3294
3423
  */
3295
- current(skipSource?: boolean): Promise<LyricsResult | null>;
3424
+ userData?: TrackUserData;
3296
3425
  /**
3297
- *
3298
- * Get the lyrics for a specific track.
3299
- * @param {Track} track The track to get the lyrics for.
3300
- * @param {boolean} [skipSource=false] Whether to skip the source or not.
3301
- * @returns {Promise<LyricsResult | null>} The lyrics result or null if not found.
3302
- * @example
3303
- * ```ts
3304
- * const player = manager.getPlayer("guildId");
3305
- * const track = player.queue.current;
3306
- * const lyrics = await player.lyrics.get(track);
3307
- * ```
3426
+ * The requester of the track.
3427
+ * @type {TrackRequester | undefined}
3308
3428
  */
3309
- get(track: Track, skipSource?: boolean): Promise<LyricsResult | null>;
3429
+ requester: TrackRequester;
3310
3430
  /**
3311
- *
3312
- * Subscribe to the lyrics for a specific guild.
3313
- * @param {boolean} [skipSource=false] Whether to skip the source or not.
3314
- * @returns {Promise<void>} Let's start the sing session!
3431
+ * The constructor for the track.
3432
+ * @param {UnresolvedLavalinkTrack} track The track to construct the track from.
3433
+ * @param {TrackRequester} requester The requester of the track.
3315
3434
  * @example
3316
3435
  * ```ts
3317
- * const player = manager.getPlayer("guildId");
3318
- * await player.lyrics.subscribe();
3436
+ * const track = new UnresolvedTrack({
3437
+ * encoded: "base64",
3438
+ * info: {
3439
+ * title: "Track Title",
3440
+ * },
3441
+ * // the rest of the track info
3442
+ * }, requester);
3443
+ *
3444
+ * console.log(track.encoded); // the track encoded in base64
3319
3445
  * ```
3320
3446
  */
3321
- subscribe(skipSource?: boolean): Promise<void>;
3447
+ constructor(track: UnresolvedLavalinkTrack, requester?: TrackRequester);
3322
3448
  /**
3323
- *
3324
- * Unsubscribe from the lyrics for a specific guild.
3325
- * @returns {Promise<void>} Let's stop the sing session!
3326
- * @example
3327
- * ```ts
3328
- * const player = manager.getPlayer("guildId");
3329
- * await player.lyrics.unsubscribe();
3330
- * ```
3449
+ * Resolves the track to a playable track.
3450
+ * @param {PlayerStructure} player The player to resolve the track for.
3451
+ * @returns {Promise<Track>} The resolved track.
3452
+ * @throws {ResolveError} If the track cannot be resolved.
3331
3453
  */
3332
- unsubscribe(): Promise<void>;
3454
+ resolve(player: PlayerStructure): Promise<Track>;
3333
3455
  }
3334
3456
  /**
3335
- * The voice channel update options.
3457
+ * Type representing a Hoshimi track, which can be either a resolved or unresolved track.
3336
3458
  */
3337
- type VoiceChannelUpdate = Pick<PlayerOptions, "selfDeaf" | "voiceId" | "selfMute">;
3459
+ type HoshimiTrack = Track | UnresolvedTrack;
3338
3460
  /**
3339
- * The voice settings for the player.
3461
+ * Interface representing an extendable track.
3340
3462
  */
3341
- type LavalinkPlayerVoice = Omit<PlayerVoice, "connected" | "ping">;
3463
+ interface CustomizableTrack {
3464
+ }
3465
+ /**
3466
+ * The requester of the track.
3467
+ */
3468
+ type TrackRequester = Inferable<CustomizableTrack, "requester">;
3469
+ /**
3470
+ * The user data of the track.
3471
+ */
3472
+ type TrackUserData = Inferable<CustomizableTrack, "userData">;
3342
3473
 
3343
3474
  /**
3344
3475
  * The states.
@@ -3908,9 +4039,9 @@ interface LavalinkTrack {
3908
4039
  info: TrackInfo;
3909
4040
  /**
3910
4041
  * The user data of the track.
3911
- * @type {Record<string, unknown> | undefined}
4042
+ * @type {TrackUserData | undefined}
3912
4043
  */
3913
- userData?: Record<string, unknown>;
4044
+ userData?: TrackUserData;
3914
4045
  }
3915
4046
  interface UnresolvedLavalinkTrack {
3916
4047
  /**
@@ -3930,9 +4061,9 @@ interface UnresolvedLavalinkTrack {
3930
4061
  pluginInfo?: Partial<PluginInfo>;
3931
4062
  /**
3932
4063
  * The user data of the track.
3933
- * @type {Record<string, unknown> | undefined}
4064
+ * @type {TrackUserData | undefined}
3934
4065
  */
3935
- userData?: Record<string, unknown>;
4066
+ userData?: TrackUserData;
3936
4067
  }
3937
4068
  /**
3938
4069
  * The track information.
@@ -5122,6 +5253,10 @@ declare enum Events {
5122
5253
  * Emitted when the player is destroyed.
5123
5254
  */
5124
5255
  PlayerDestroy = "playerDestroy",
5256
+ /**
5257
+ * Emitted when the player has an error.
5258
+ */
5259
+ PlayerError = "playerError",
5125
5260
  /**
5126
5261
  * Emitted when a track starts playing.
5127
5262
  */
@@ -5190,7 +5325,15 @@ declare enum DestroyReasons {
5190
5325
  /**
5191
5326
  * The player was destroyed because the voice channel was deleted.
5192
5327
  */
5193
- VoiceChannelDeleted = "Player-VoiceChannelDeleted"
5328
+ VoiceChannelDeleted = "Player-VoiceChannelDeleted",
5329
+ /**
5330
+ * The player was destroyed because it left the voice channel.
5331
+ */
5332
+ VoiceChannelLeft = "Player-VoiceChannelLeft",
5333
+ /**
5334
+ * The player was destroyed because it failed to reconnect.
5335
+ */
5336
+ ReconnectFailed = "Player-ReconnectFailed"
5194
5337
  }
5195
5338
  /**
5196
5339
  * The client data for the manager.
@@ -5289,6 +5432,11 @@ interface HoshimiOptions {
5289
5432
  * @type {HoshimiRestOptions}
5290
5433
  */
5291
5434
  restOptions?: HoshimiRestOptions;
5435
+ /**
5436
+ * The player options to use.
5437
+ * @type {HoshimiPlayerOptions}
5438
+ */
5439
+ playerOptions?: HoshimiPlayerOptions;
5292
5440
  }
5293
5441
  /**
5294
5442
  * The events for the manager.
@@ -5371,6 +5519,12 @@ interface HoshimiEvents {
5371
5519
  * @param {string} reason The reason for the destroy.
5372
5520
  */
5373
5521
  playerDestroy: [player: PlayerStructure, reason: string];
5522
+ /**
5523
+ * Emitted when the player has an error.
5524
+ * @param {PlayerStructure} player The player that emitted the event.
5525
+ * @param {Error | unknown} error The error that was emitted.
5526
+ */
5527
+ playerError: [player: PlayerStructure, error: Error | unknown];
5374
5528
  /**
5375
5529
  * Emitted when a track starts playing.
5376
5530
  * @param {PlayerStructure} player The player that emitted the event.
@@ -5753,10 +5907,24 @@ declare class Hoshimi extends EventEmitter<RawEvents> {
5753
5907
  * resumeByLibrary: false,
5754
5908
  * },
5755
5909
  * queueOptions: {
5756
- * maxPreviousTracks: 25,
5757
- * autoplayFn: autoplayFn,
5758
- * autoPlay: false,
5910
+ * maxHistory: 25,
5911
+ * autoplayFn: autoplayFn,
5912
+ * autoPlay: false,
5913
+ * storage: new MemoryAdapter(),
5914
+ * requesterFn: defaultRequesterFn,
5759
5915
  * },
5916
+ * playerOptions: {
5917
+ * onDisconnect: {
5918
+ * autoDestroy: false,
5919
+ * autoReconnect: false,
5920
+ * autoQueue: false,
5921
+ * },
5922
+ * onError: {
5923
+ * autoDestroy: false,
5924
+ * autoSkip: false,
5925
+ * autoStop: false,
5926
+ * },
5927
+ * },
5760
5928
  * });
5761
5929
  *
5762
5930
  * console.log(manager); // The manager instance
@@ -5890,4 +6058,4 @@ declare class MemoryAdapter<T extends QueueJson = QueueJson> extends StorageAdap
5890
6058
  stringify<R = string>(value: unknown): R;
5891
6059
  }
5892
6060
 
5893
- export { AudioOutput, type Awaitable, type ChannelDelete, type ChannelDeletePacket, type ChannelMixSettings, type ClientData, type CustomizablePlayerStorage, type CustomizableStructures, type CustomizableTrack, DSPXPluginFilter, DebugLevels, type DecodeMethods, type DeepRequired, DestroyReasons, type DistortionSettings, type EQBandSettings, type EchoSettings, type EnabledDSPXPluginFilters, type EnabledLavalinkFilters, type EnabledPlayerFilters, Events, type Exception, type FetchOptions, FilterManager, type FilterManagerStructure, type FilterPluginPassSettings, type FilterSettings, FilterType, type FreqSettings, type GatewayPayload, type GatewaySendPayload, Hoshimi, type HoshimiEvents, type HoshimiNodeOptions, type HoshimiOptions, type HoshimiQueueOptions, type HoshimiRestOptions, type HoshimiTrack, HttpMethods, HttpStatusCodes, 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, MemoryAdapter, Node, type NodeCpu, type NodeDestroyInfo, NodeDestroyReasons, type NodeDisconnectInfo, NodeError, type NodeFrameStats, type NodeIdentifier, type NodeInfo, type NodeInfoGit, type NodeInfoPlugin, type NodeInfoVersion, type NodeJson, 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, type PlayerOptions, type PlayerStructure, type PlayerUpdate, type PlayerUpdateState, type PlayerVoice, type Playlist, type PlaylistInfo, type PluginFilterSettings, type PluginInfo, PluginInfoType, PluginNames, type QueryResult, Queue, type QueueJson, type QueueStructure, type Ready, ResolveError, Rest, type RestOptions, type RestOrArray, RestPathType, type RestStructure, type ResumableHeaders, type RotationSettings, SearchEngines, type SearchOptions, type SearchQuery, Severity, SourceNames, State, type Stats, StorageAdapter, StorageError, Structures, type TimescaleSettings, Track, type TrackEndEvent, TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackRequester, type TrackStartEvent, type TrackStuckEvent, type TremoloSettings, type UnresolvedLavalinkTrack, UnresolvedTrack, type UnresolvedTrackInfo, type UpdatePlayerInfo, type UserAgent, type VoiceChannelUpdate, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, WebsocketCloseCodes, createHoshimi };
6061
+ export { AudioOutput, type Awaitable, type ChannelDelete, type ChannelDeletePacket, type ChannelMixSettings, type ClientData, type CustomizablePlayerStorage, type CustomizableStructures, type CustomizableTrack, DSPXPluginFilter, DebugLevels, type DecodeMethods, type DeepRequired, DestroyReasons, type DistortionSettings, type EQBandSettings, type EchoSettings, type EnabledDSPXPluginFilters, type EnabledLavalinkFilters, type EnabledPlayerFilters, Events, type Exception, type FetchOptions, FilterManager, type FilterManagerStructure, type FilterPluginPassSettings, type FilterSettings, FilterType, type FreqSettings, type GatewayPayload, type GatewaySendPayload, Hoshimi, type HoshimiEvents, type HoshimiNodeOptions, type HoshimiOptions, type HoshimiPlayerOptions, type HoshimiQueueOptions, type HoshimiRestOptions, type HoshimiTrack, HttpMethods, HttpStatusCodes, 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, MemoryAdapter, Node, type NodeCpu, type NodeDestroyInfo, NodeDestroyReasons, type NodeDisconnectInfo, NodeError, type NodeFrameStats, type NodeIdentifier, type NodeInfo, type NodeInfoGit, type NodeInfoPlugin, type NodeInfoVersion, type NodeJson, 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, type PlayerOptions, type PlayerStructure, type PlayerUpdate, type PlayerUpdateState, type PlayerVoice, type Playlist, type PlaylistInfo, type PluginFilterSettings, type PluginInfo, PluginInfoType, PluginNames, type QueryResult, Queue, type QueueJson, type QueueStructure, type Ready, ResolveError, Rest, type RestOptions, type RestOrArray, RestPathType, type RestStructure, type ResumableHeaders, type RotationSettings, SearchEngines, type SearchOptions, type SearchQuery, Severity, SourceNames, State, type Stats, StorageAdapter, StorageError, 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, type UserAgent, type VoiceChannelUpdate, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, WebsocketCloseCodes, createHoshimi };