lavalink-client 2.7.5 → 2.7.7

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
@@ -1959,6 +1959,66 @@ interface PlayOptions extends LavalinkPlayOptions {
1959
1959
  clientTrack?: Track | UnresolvedTrack;
1960
1960
  }
1961
1961
 
1962
+ type NodeLinkEventTypes = "PlayerCreatedEvent" | "PlayerDestroyedEvent" | "PlayerConnectedEvent" | "PlayerReconnectingEvent" | "VolumeChangedEvent" | "FiltersChangedEvent" | "SeekEvent" | "PauseEvent" | "ConnectionStatusEvent" | "MixStartedEvent" | "MixEndedEvent";
1963
+ interface NodeLinkBaseEvent {
1964
+ op: "event";
1965
+ type: NodeLinkEventTypes;
1966
+ guildId: string;
1967
+ }
1968
+ interface PlayerCreatedEvent extends NodeLinkBaseEvent {
1969
+ type: "PlayerCreatedEvent";
1970
+ }
1971
+ interface PlayerDestroyedEvent extends NodeLinkBaseEvent {
1972
+ type: "PlayerDestroyedEvent";
1973
+ }
1974
+ interface PlayerConnectedEvent extends NodeLinkBaseEvent {
1975
+ type: "PlayerConnectedEvent";
1976
+ }
1977
+ interface PlayerReconnectingEvent extends NodeLinkBaseEvent {
1978
+ type: "PlayerReconnectingEvent";
1979
+ }
1980
+ interface VolumeChangedEvent extends NodeLinkBaseEvent {
1981
+ type: "VolumeChangedEvent";
1982
+ /** New volume level (0-1000) */
1983
+ volume: number;
1984
+ }
1985
+ interface FiltersChangedEvent extends NodeLinkBaseEvent {
1986
+ type: "FiltersChangedEvent";
1987
+ filters: LavalinkFilterData;
1988
+ }
1989
+ interface SeekEvent extends NodeLinkBaseEvent {
1990
+ type: "SeekEvent";
1991
+ /** New position in milliseconds */
1992
+ position: number;
1993
+ }
1994
+ interface PauseEvent extends NodeLinkBaseEvent {
1995
+ type: "PauseEvent";
1996
+ /** Whether playback is now paused (true) or resumed (false) */
1997
+ paused: boolean;
1998
+ }
1999
+ interface ConnectionStatusEvent extends NodeLinkBaseEvent {
2000
+ type: "ConnectionStatusEvent";
2001
+ /** Current connection status */
2002
+ connected: boolean;
2003
+ }
2004
+ interface MixStartedEvent extends NodeLinkBaseEvent {
2005
+ type: "MixStartedEvent";
2006
+ /** Unique identifier for the mix layer */
2007
+ mixId: string;
2008
+ /** Full track information of the mixed layer */
2009
+ track: LavalinkTrack;
2010
+ /** Volume of the mixed layer (0.0 to 1.0) */
2011
+ volume: number;
2012
+ }
2013
+ interface MixEndedEvent extends NodeLinkBaseEvent {
2014
+ type: "MixEndedEvent";
2015
+ /** Unique identifier for the mix layer */
2016
+ mixId: string;
2017
+ /** Reason the mix layer ended (FINISHED, REMOVED, ERROR, MAIN_ENDED) */
2018
+ reason: "FINISHED" | "REMOVED" | "ERROR" | "MAIN_ENDED" | string;
2019
+ }
2020
+ type NodeLinkEventPayload<T extends NodeLinkEventTypes> = T extends "PlayerCreatedEvent" ? PlayerCreatedEvent : T extends "PlayerDestroyedEvent" ? PlayerDestroyedEvent : T extends "PlayerConnectedEvent" ? PlayerConnectedEvent : T extends "PlayerReconnectingEvent" ? PlayerReconnectingEvent : T extends "VolumeChangedEvent" ? VolumeChangedEvent : T extends "FiltersChangedEvent" ? FiltersChangedEvent : T extends "SeekEvent" ? SeekEvent : T extends "PauseEvent" ? PauseEvent : T extends "ConnectionStatusEvent" ? ConnectionStatusEvent : T extends "MixStartedEvent" ? MixStartedEvent : T extends "MixEndedEvent" ? MixEndedEvent : never;
2021
+
1962
2022
  /** Ability to manipulate fetch requests */
1963
2023
  type ModifyRequest = (options: RequestInit & {
1964
2024
  path: string;
@@ -2050,12 +2110,41 @@ interface BaseNodeStats {
2050
2110
  /** The frame stats for the node. */
2051
2111
  frameStats: FrameStats;
2052
2112
  }
2113
+ interface NodeLinkConnectionMetrics {
2114
+ status: string;
2115
+ metrics: {
2116
+ speed: {
2117
+ bps: number;
2118
+ kbps: number;
2119
+ mbps: number;
2120
+ };
2121
+ downloadedBytes: number;
2122
+ durationSeconds: number;
2123
+ timestamp: number;
2124
+ };
2125
+ }
2053
2126
  /**
2054
2127
  * Interface for nodeStats from lavalink
2055
2128
  */
2056
2129
  interface NodeStats extends BaseNodeStats {
2057
2130
  /** The frame stats for the node. */
2058
2131
  frameStats: FrameStats;
2132
+ /** something from nodeLink https://nodelink.js.org/docs/differences#detailed-statistics */
2133
+ detailedStats?: {
2134
+ api: {
2135
+ /** e.g. { "/v4/loadtracks": 150, "/v4/info": 5 } */
2136
+ requests: Record<string, number>;
2137
+ errors: unknown;
2138
+ };
2139
+ /** e.g. { "youtube": 150, "soundcloud": 5 } */
2140
+ sources: Record<string, number>;
2141
+ playback: {
2142
+ /** e.g. { "TrackStartEvent": 150, "TrackEndEvent": 5 } */
2143
+ events: Record<string, number>;
2144
+ };
2145
+ /** and potential others */
2146
+ [key: string]: unknown;
2147
+ };
2059
2148
  }
2060
2149
  /**
2061
2150
  * Entire lavalink information object from lavalink
@@ -2077,6 +2166,8 @@ interface LavalinkInfo {
2077
2166
  filters: string[];
2078
2167
  /** The enabled plugins for this server */
2079
2168
  plugins: PluginObject[];
2169
+ /** Something from NodeLink: https://nodelink.js.org/docs/differences#server-info */
2170
+ isNodelink?: boolean;
2080
2171
  }
2081
2172
  /**
2082
2173
  * Lavalink's version object from lavalink
@@ -2193,6 +2284,25 @@ interface NodeManagerEvents {
2193
2284
  sessionId: string;
2194
2285
  op: "ready";
2195
2286
  }, players: LavalinkPlayer[] | InvalidLavalinkRestRequest) => void;
2287
+ /**
2288
+ * Event Handler for Nodelink specific events https://nodelink.js.org/docs/api/websocket Fully typed and generic based on the eventName.
2289
+ * @event Manager.nodeManager#nodeLinkEvent
2290
+ * @example
2291
+ *
2292
+ * ```ts
2293
+ * this.nodeManager.on("nodeLinkEvent", (node, event, player, track, payload) => {
2294
+ * if (event === "SeekEvent") {
2295
+ * console.log("new position:", payload.position);
2296
+ * }
2297
+ * if (event === "FiltersChangedEvent") {
2298
+ * console.log("new filters state", payload.filters);
2299
+ * }
2300
+ * });
2301
+ * ```
2302
+ */
2303
+ "nodeLinkEvent": (...args: {
2304
+ [K in NodeLinkEventTypes]: [node: LavalinkNode, event: K, player: Player, track: Track | null, payload: NodeLinkEventPayload<K>];
2305
+ }[NodeLinkEventTypes]) => void;
2196
2306
  }
2197
2307
  declare enum ReconnectionState {
2198
2308
  IDLE = "IDLE",
@@ -2565,6 +2675,16 @@ declare class LavalinkNode {
2565
2675
  * ```
2566
2676
  */
2567
2677
  fetchStats(): Promise<BaseNodeStats>;
2678
+ /**
2679
+ * Request NodeLink connection metrics. https://nodelink.js.org/docs/differences#connection-metrics
2680
+ * @returns the connection metrics of the node
2681
+ *
2682
+ * @example
2683
+ * ```ts
2684
+ * const connectionMetrics = await player.node.fetchConnectionMetrics();
2685
+ * ```
2686
+ */
2687
+ fetchConnectionMetrics(): Promise<NodeLinkConnectionMetrics>;
2568
2688
  /**
2569
2689
  * Request Lavalink version.
2570
2690
  * @returns the current used lavalink version
@@ -2680,6 +2800,14 @@ declare class LavalinkNode {
2680
2800
  private message;
2681
2801
  /** @private middleware util function for handling all kind of events from websocket */
2682
2802
  private handleEvent;
2803
+ /**
2804
+ * nodeLink specific events handling https://nodelink.js.org/docs/api/websocket#incoming-events-server--client
2805
+ * @param eventName
2806
+ * @param player
2807
+ * @param track
2808
+ * @param payload
2809
+ */
2810
+ private nodeLinkEventHandler;
2683
2811
  private getTrackOfPayload;
2684
2812
  /** @private util function for handling trackStart event */
2685
2813
  private trackStart;
@@ -3387,4 +3515,4 @@ declare const LavalinkPlugins: {
3387
3515
  /** Lavalink Sources regexes for url validations */
3388
3516
  declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
3389
3517
 
3390
- export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol, type Opaque, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerFilters, type PlayerJson, type PlayerOptions, type PlayerUpdateInfo, type PlaylistInfo, type PluginInfo, type PluginObject, Queue, type QueueChangesWatcher, QueueSaver, type QueueStoreManager, QueueSymbol, ReconnectionState, type RepeatMode, type RequiredManagerOptions, type RotationFilter, type RoutePlanner, type RoutePlannerTypes, type SearchPlatform, type SearchQuery, type SearchResult, type Session, type Severity, SourceLinksRegexes, type SourceNames, type SourcesRegex, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, type StoredQueue, type TimescaleFilter, type Track, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackStartEvent, type TrackStuckEvent, TrackSymbol, type TremoloFilter, type UnresolvedQuery, type UnresolvedSearchResult, type UnresolvedTrack, type UnresolvedTrackInfo, UnresolvedTrackSymbol, type VersionObject, type VibratoFilter, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, type anyObject, audioOutputsData, parseLavalinkConnUrl, queueTrackEnd, safeStringify, validSponsorBlocks };
3518
+ export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, type NodeLinkConnectionMetrics, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol, type Opaque, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerFilters, type PlayerJson, type PlayerOptions, type PlayerUpdateInfo, type PlaylistInfo, type PluginInfo, type PluginObject, Queue, type QueueChangesWatcher, QueueSaver, type QueueStoreManager, QueueSymbol, ReconnectionState, type RepeatMode, type RequiredManagerOptions, type RotationFilter, type RoutePlanner, type RoutePlannerTypes, type SearchPlatform, type SearchQuery, type SearchResult, type Session, type Severity, SourceLinksRegexes, type SourceNames, type SourcesRegex, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, type StoredQueue, type TimescaleFilter, type Track, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackStartEvent, type TrackStuckEvent, TrackSymbol, type TremoloFilter, type UnresolvedQuery, type UnresolvedSearchResult, type UnresolvedTrack, type UnresolvedTrackInfo, UnresolvedTrackSymbol, type VersionObject, type VibratoFilter, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, type anyObject, audioOutputsData, parseLavalinkConnUrl, queueTrackEnd, safeStringify, validSponsorBlocks };
package/dist/index.d.ts CHANGED
@@ -1959,6 +1959,66 @@ interface PlayOptions extends LavalinkPlayOptions {
1959
1959
  clientTrack?: Track | UnresolvedTrack;
1960
1960
  }
1961
1961
 
1962
+ type NodeLinkEventTypes = "PlayerCreatedEvent" | "PlayerDestroyedEvent" | "PlayerConnectedEvent" | "PlayerReconnectingEvent" | "VolumeChangedEvent" | "FiltersChangedEvent" | "SeekEvent" | "PauseEvent" | "ConnectionStatusEvent" | "MixStartedEvent" | "MixEndedEvent";
1963
+ interface NodeLinkBaseEvent {
1964
+ op: "event";
1965
+ type: NodeLinkEventTypes;
1966
+ guildId: string;
1967
+ }
1968
+ interface PlayerCreatedEvent extends NodeLinkBaseEvent {
1969
+ type: "PlayerCreatedEvent";
1970
+ }
1971
+ interface PlayerDestroyedEvent extends NodeLinkBaseEvent {
1972
+ type: "PlayerDestroyedEvent";
1973
+ }
1974
+ interface PlayerConnectedEvent extends NodeLinkBaseEvent {
1975
+ type: "PlayerConnectedEvent";
1976
+ }
1977
+ interface PlayerReconnectingEvent extends NodeLinkBaseEvent {
1978
+ type: "PlayerReconnectingEvent";
1979
+ }
1980
+ interface VolumeChangedEvent extends NodeLinkBaseEvent {
1981
+ type: "VolumeChangedEvent";
1982
+ /** New volume level (0-1000) */
1983
+ volume: number;
1984
+ }
1985
+ interface FiltersChangedEvent extends NodeLinkBaseEvent {
1986
+ type: "FiltersChangedEvent";
1987
+ filters: LavalinkFilterData;
1988
+ }
1989
+ interface SeekEvent extends NodeLinkBaseEvent {
1990
+ type: "SeekEvent";
1991
+ /** New position in milliseconds */
1992
+ position: number;
1993
+ }
1994
+ interface PauseEvent extends NodeLinkBaseEvent {
1995
+ type: "PauseEvent";
1996
+ /** Whether playback is now paused (true) or resumed (false) */
1997
+ paused: boolean;
1998
+ }
1999
+ interface ConnectionStatusEvent extends NodeLinkBaseEvent {
2000
+ type: "ConnectionStatusEvent";
2001
+ /** Current connection status */
2002
+ connected: boolean;
2003
+ }
2004
+ interface MixStartedEvent extends NodeLinkBaseEvent {
2005
+ type: "MixStartedEvent";
2006
+ /** Unique identifier for the mix layer */
2007
+ mixId: string;
2008
+ /** Full track information of the mixed layer */
2009
+ track: LavalinkTrack;
2010
+ /** Volume of the mixed layer (0.0 to 1.0) */
2011
+ volume: number;
2012
+ }
2013
+ interface MixEndedEvent extends NodeLinkBaseEvent {
2014
+ type: "MixEndedEvent";
2015
+ /** Unique identifier for the mix layer */
2016
+ mixId: string;
2017
+ /** Reason the mix layer ended (FINISHED, REMOVED, ERROR, MAIN_ENDED) */
2018
+ reason: "FINISHED" | "REMOVED" | "ERROR" | "MAIN_ENDED" | string;
2019
+ }
2020
+ type NodeLinkEventPayload<T extends NodeLinkEventTypes> = T extends "PlayerCreatedEvent" ? PlayerCreatedEvent : T extends "PlayerDestroyedEvent" ? PlayerDestroyedEvent : T extends "PlayerConnectedEvent" ? PlayerConnectedEvent : T extends "PlayerReconnectingEvent" ? PlayerReconnectingEvent : T extends "VolumeChangedEvent" ? VolumeChangedEvent : T extends "FiltersChangedEvent" ? FiltersChangedEvent : T extends "SeekEvent" ? SeekEvent : T extends "PauseEvent" ? PauseEvent : T extends "ConnectionStatusEvent" ? ConnectionStatusEvent : T extends "MixStartedEvent" ? MixStartedEvent : T extends "MixEndedEvent" ? MixEndedEvent : never;
2021
+
1962
2022
  /** Ability to manipulate fetch requests */
1963
2023
  type ModifyRequest = (options: RequestInit & {
1964
2024
  path: string;
@@ -2050,12 +2110,41 @@ interface BaseNodeStats {
2050
2110
  /** The frame stats for the node. */
2051
2111
  frameStats: FrameStats;
2052
2112
  }
2113
+ interface NodeLinkConnectionMetrics {
2114
+ status: string;
2115
+ metrics: {
2116
+ speed: {
2117
+ bps: number;
2118
+ kbps: number;
2119
+ mbps: number;
2120
+ };
2121
+ downloadedBytes: number;
2122
+ durationSeconds: number;
2123
+ timestamp: number;
2124
+ };
2125
+ }
2053
2126
  /**
2054
2127
  * Interface for nodeStats from lavalink
2055
2128
  */
2056
2129
  interface NodeStats extends BaseNodeStats {
2057
2130
  /** The frame stats for the node. */
2058
2131
  frameStats: FrameStats;
2132
+ /** something from nodeLink https://nodelink.js.org/docs/differences#detailed-statistics */
2133
+ detailedStats?: {
2134
+ api: {
2135
+ /** e.g. { "/v4/loadtracks": 150, "/v4/info": 5 } */
2136
+ requests: Record<string, number>;
2137
+ errors: unknown;
2138
+ };
2139
+ /** e.g. { "youtube": 150, "soundcloud": 5 } */
2140
+ sources: Record<string, number>;
2141
+ playback: {
2142
+ /** e.g. { "TrackStartEvent": 150, "TrackEndEvent": 5 } */
2143
+ events: Record<string, number>;
2144
+ };
2145
+ /** and potential others */
2146
+ [key: string]: unknown;
2147
+ };
2059
2148
  }
2060
2149
  /**
2061
2150
  * Entire lavalink information object from lavalink
@@ -2077,6 +2166,8 @@ interface LavalinkInfo {
2077
2166
  filters: string[];
2078
2167
  /** The enabled plugins for this server */
2079
2168
  plugins: PluginObject[];
2169
+ /** Something from NodeLink: https://nodelink.js.org/docs/differences#server-info */
2170
+ isNodelink?: boolean;
2080
2171
  }
2081
2172
  /**
2082
2173
  * Lavalink's version object from lavalink
@@ -2193,6 +2284,25 @@ interface NodeManagerEvents {
2193
2284
  sessionId: string;
2194
2285
  op: "ready";
2195
2286
  }, players: LavalinkPlayer[] | InvalidLavalinkRestRequest) => void;
2287
+ /**
2288
+ * Event Handler for Nodelink specific events https://nodelink.js.org/docs/api/websocket Fully typed and generic based on the eventName.
2289
+ * @event Manager.nodeManager#nodeLinkEvent
2290
+ * @example
2291
+ *
2292
+ * ```ts
2293
+ * this.nodeManager.on("nodeLinkEvent", (node, event, player, track, payload) => {
2294
+ * if (event === "SeekEvent") {
2295
+ * console.log("new position:", payload.position);
2296
+ * }
2297
+ * if (event === "FiltersChangedEvent") {
2298
+ * console.log("new filters state", payload.filters);
2299
+ * }
2300
+ * });
2301
+ * ```
2302
+ */
2303
+ "nodeLinkEvent": (...args: {
2304
+ [K in NodeLinkEventTypes]: [node: LavalinkNode, event: K, player: Player, track: Track | null, payload: NodeLinkEventPayload<K>];
2305
+ }[NodeLinkEventTypes]) => void;
2196
2306
  }
2197
2307
  declare enum ReconnectionState {
2198
2308
  IDLE = "IDLE",
@@ -2565,6 +2675,16 @@ declare class LavalinkNode {
2565
2675
  * ```
2566
2676
  */
2567
2677
  fetchStats(): Promise<BaseNodeStats>;
2678
+ /**
2679
+ * Request NodeLink connection metrics. https://nodelink.js.org/docs/differences#connection-metrics
2680
+ * @returns the connection metrics of the node
2681
+ *
2682
+ * @example
2683
+ * ```ts
2684
+ * const connectionMetrics = await player.node.fetchConnectionMetrics();
2685
+ * ```
2686
+ */
2687
+ fetchConnectionMetrics(): Promise<NodeLinkConnectionMetrics>;
2568
2688
  /**
2569
2689
  * Request Lavalink version.
2570
2690
  * @returns the current used lavalink version
@@ -2680,6 +2800,14 @@ declare class LavalinkNode {
2680
2800
  private message;
2681
2801
  /** @private middleware util function for handling all kind of events from websocket */
2682
2802
  private handleEvent;
2803
+ /**
2804
+ * nodeLink specific events handling https://nodelink.js.org/docs/api/websocket#incoming-events-server--client
2805
+ * @param eventName
2806
+ * @param player
2807
+ * @param track
2808
+ * @param payload
2809
+ */
2810
+ private nodeLinkEventHandler;
2683
2811
  private getTrackOfPayload;
2684
2812
  /** @private util function for handling trackStart event */
2685
2813
  private trackStart;
@@ -3387,4 +3515,4 @@ declare const LavalinkPlugins: {
3387
3515
  /** Lavalink Sources regexes for url validations */
3388
3516
  declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
3389
3517
 
3390
- export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol, type Opaque, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerFilters, type PlayerJson, type PlayerOptions, type PlayerUpdateInfo, type PlaylistInfo, type PluginInfo, type PluginObject, Queue, type QueueChangesWatcher, QueueSaver, type QueueStoreManager, QueueSymbol, ReconnectionState, type RepeatMode, type RequiredManagerOptions, type RotationFilter, type RoutePlanner, type RoutePlannerTypes, type SearchPlatform, type SearchQuery, type SearchResult, type Session, type Severity, SourceLinksRegexes, type SourceNames, type SourcesRegex, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, type StoredQueue, type TimescaleFilter, type Track, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackStartEvent, type TrackStuckEvent, TrackSymbol, type TremoloFilter, type UnresolvedQuery, type UnresolvedSearchResult, type UnresolvedTrack, type UnresolvedTrackInfo, UnresolvedTrackSymbol, type VersionObject, type VibratoFilter, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, type anyObject, audioOutputsData, parseLavalinkConnUrl, queueTrackEnd, safeStringify, validSponsorBlocks };
3518
+ export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, type DeepRequired, DefaultQueueStore, DefaultSources, DestroyReasons, type DestroyReasonsType, DisconnectReasons, type DisconnectReasonsType, type DistortionFilter, type DuncteSearchPlatform, type EQBand, EQList, type Exception, type FailingAddress, type FilterData, FilterManager, type FloatNumber, type FrameStats, type GitObject, type GuildShardPayload, type IntegerNumber, type InvalidLavalinkRestRequest, type JioSaavnSearchPlatform, type KaraokeFilter, type LavaSearchFilteredResponse, type LavaSearchQuery, type LavaSearchResponse, type LavaSearchType, type LavaSrcSearchPlatform, type LavaSrcSearchPlatformBase, type LavalinkClientSearchPlatform, type LavalinkClientSearchPlatformResolve, type LavalinkFilterData, type LavalinkInfo, LavalinkManager, type LavalinkManagerEvents, LavalinkNode, type LavalinkNodeIdentifier, type LavalinkNodeOptions, type LavalinkPlayOptions, type LavalinkPlayer, type LavalinkPlayerVoice, type LavalinkPlayerVoiceOptions, type LavalinkPlugin_JioSaavn_SourceNames, type LavalinkPlugin_LavaSrc_SourceNames, LavalinkPlugins, type LavalinkSearchPlatform, type LavalinkSourceNames, type LavalinkTrack, type LavalinkTrackInfo, type LoadTypes, type LowPassFilter, type LyricsEvent, type LyricsEventType, type LyricsFoundEvent, type LyricsLine, type LyricsLineEvent, type LyricsNotFoundEvent, type LyricsResult, type ManagerOptions, type ManagerPlayerOptions, type ManagerQueueOptions, ManagerUtils, type MemoryStats, MiniMap, type MiniMapConstructor, type ModifyRequest, type NodeLinkConnectionMetrics, NodeManager, type NodeManagerEvents, type NodeMessage, type NodeStats, NodeSymbol, type Opaque, type PlayOptions, Player, type PlayerEvent, type PlayerEventType, type PlayerEvents, type PlayerFilters, type PlayerJson, type PlayerOptions, type PlayerUpdateInfo, type PlaylistInfo, type PluginInfo, type PluginObject, Queue, type QueueChangesWatcher, QueueSaver, type QueueStoreManager, QueueSymbol, ReconnectionState, type RepeatMode, type RequiredManagerOptions, type RotationFilter, type RoutePlanner, type RoutePlannerTypes, type SearchPlatform, type SearchQuery, type SearchResult, type Session, type Severity, SourceLinksRegexes, type SourceNames, type SourcesRegex, type SponsorBlockChapterStarted, type SponsorBlockChaptersLoaded, type SponsorBlockSegment, type SponsorBlockSegmentEventType, type SponsorBlockSegmentEvents, type SponsorBlockSegmentSkipped, type SponsorBlockSegmentsLoaded, type State, type StoredQueue, type TimescaleFilter, type Track, type TrackEndEvent, type TrackEndReason, type TrackExceptionEvent, type TrackInfo, type TrackStartEvent, type TrackStuckEvent, TrackSymbol, type TremoloFilter, type UnresolvedQuery, type UnresolvedSearchResult, type UnresolvedTrack, type UnresolvedTrackInfo, UnresolvedTrackSymbol, type VersionObject, type VibratoFilter, type VoicePacket, type VoiceServer, type VoiceState, type WebSocketClosedEvent, type anyObject, audioOutputsData, parseLavalinkConnUrl, queueTrackEnd, safeStringify, validSponsorBlocks };
package/dist/index.js CHANGED
@@ -1070,6 +1070,17 @@ var LavalinkNode = class {
1070
1070
  used: 0
1071
1071
  },
1072
1072
  uptime: 0,
1073
+ /** something from nodeLink https://nodelink.js.org/docs/differences#detailed-statistics */
1074
+ detailedStats: {
1075
+ api: {
1076
+ requests: {},
1077
+ errors: {}
1078
+ },
1079
+ sources: {},
1080
+ playback: {
1081
+ events: {}
1082
+ }
1083
+ },
1073
1084
  frameStats: {
1074
1085
  deficit: 0,
1075
1086
  nulled: 0,
@@ -1752,6 +1763,19 @@ var LavalinkNode = class {
1752
1763
  async fetchStats() {
1753
1764
  return await this.request(`/stats`);
1754
1765
  }
1766
+ /**
1767
+ * Request NodeLink connection metrics. https://nodelink.js.org/docs/differences#connection-metrics
1768
+ * @returns the connection metrics of the node
1769
+ *
1770
+ * @example
1771
+ * ```ts
1772
+ * const connectionMetrics = await player.node.fetchConnectionMetrics();
1773
+ * ```
1774
+ */
1775
+ async fetchConnectionMetrics() {
1776
+ if (this.info && !this.info.isNodelink) throw new Error("There is no Information about wether you are using NodeLink instead of Lavalink, so this function won't work");
1777
+ return await this.request(`/connection`);
1778
+ }
1755
1779
  /**
1756
1780
  * Request Lavalink version.
1757
1781
  * @returns the current used lavalink version
@@ -2006,6 +2030,7 @@ var LavalinkNode = class {
2006
2030
  const errorString = `Lavalink Node (${this.restAddress}) does not provide any /${this.version}/info`;
2007
2031
  throw new Error(errorString);
2008
2032
  }
2033
+ this.info.isNodelink = !!this.info.isNodelink;
2009
2034
  this.NodeManager.emit("connect", this);
2010
2035
  }
2011
2036
  /** @private util function for handling closing events from websocket */
@@ -2132,6 +2157,23 @@ var LavalinkNode = class {
2132
2157
  if (!payload?.guildId) return;
2133
2158
  const player = this._LManager.getPlayer(payload.guildId);
2134
2159
  if (!player) return;
2160
+ const NodeLinkEventType = payload.type;
2161
+ const NodeLinkExclusiveEvents = [
2162
+ "PlayerCreatedEvent",
2163
+ "PlayerDestroyedEvent",
2164
+ "PlayerConnectedEvent",
2165
+ "PlayerReconnectingEvent",
2166
+ "VolumeChangedEvent",
2167
+ "FiltersChangedEvent",
2168
+ "SeekEvent",
2169
+ "PauseEvent",
2170
+ "ConnectionStatusEvent",
2171
+ "MixStartedEvent",
2172
+ "MixEndedEvent"
2173
+ ];
2174
+ if (NodeLinkExclusiveEvents.includes(NodeLinkEventType) && (!this.info || this.info.isNodelink)) {
2175
+ return this.nodeLinkEventHandler(NodeLinkEventType, player, player.queue.current, payload);
2176
+ }
2135
2177
  switch (payload.type) {
2136
2178
  case "TrackStartEvent":
2137
2179
  this.trackStart(player, player.queue.current, payload);
@@ -2175,6 +2217,16 @@ var LavalinkNode = class {
2175
2217
  }
2176
2218
  return;
2177
2219
  }
2220
+ /**
2221
+ * nodeLink specific events handling https://nodelink.js.org/docs/api/websocket#incoming-events-server--client
2222
+ * @param eventName
2223
+ * @param player
2224
+ * @param track
2225
+ * @param payload
2226
+ */
2227
+ async nodeLinkEventHandler(eventName, player, track, payload) {
2228
+ this.NodeManager.emit("nodeLinkEvent", this, eventName, player, track, payload);
2229
+ }
2178
2230
  getTrackOfPayload(payload) {
2179
2231
  return "track" in payload ? this._LManager.utils.buildTrack(payload.track, void 0) : null;
2180
2232
  }
package/dist/index.mjs CHANGED
@@ -1009,6 +1009,17 @@ var LavalinkNode = class {
1009
1009
  used: 0
1010
1010
  },
1011
1011
  uptime: 0,
1012
+ /** something from nodeLink https://nodelink.js.org/docs/differences#detailed-statistics */
1013
+ detailedStats: {
1014
+ api: {
1015
+ requests: {},
1016
+ errors: {}
1017
+ },
1018
+ sources: {},
1019
+ playback: {
1020
+ events: {}
1021
+ }
1022
+ },
1012
1023
  frameStats: {
1013
1024
  deficit: 0,
1014
1025
  nulled: 0,
@@ -1691,6 +1702,19 @@ var LavalinkNode = class {
1691
1702
  async fetchStats() {
1692
1703
  return await this.request(`/stats`);
1693
1704
  }
1705
+ /**
1706
+ * Request NodeLink connection metrics. https://nodelink.js.org/docs/differences#connection-metrics
1707
+ * @returns the connection metrics of the node
1708
+ *
1709
+ * @example
1710
+ * ```ts
1711
+ * const connectionMetrics = await player.node.fetchConnectionMetrics();
1712
+ * ```
1713
+ */
1714
+ async fetchConnectionMetrics() {
1715
+ if (this.info && !this.info.isNodelink) throw new Error("There is no Information about wether you are using NodeLink instead of Lavalink, so this function won't work");
1716
+ return await this.request(`/connection`);
1717
+ }
1694
1718
  /**
1695
1719
  * Request Lavalink version.
1696
1720
  * @returns the current used lavalink version
@@ -1945,6 +1969,7 @@ var LavalinkNode = class {
1945
1969
  const errorString = `Lavalink Node (${this.restAddress}) does not provide any /${this.version}/info`;
1946
1970
  throw new Error(errorString);
1947
1971
  }
1972
+ this.info.isNodelink = !!this.info.isNodelink;
1948
1973
  this.NodeManager.emit("connect", this);
1949
1974
  }
1950
1975
  /** @private util function for handling closing events from websocket */
@@ -2071,6 +2096,23 @@ var LavalinkNode = class {
2071
2096
  if (!payload?.guildId) return;
2072
2097
  const player = this._LManager.getPlayer(payload.guildId);
2073
2098
  if (!player) return;
2099
+ const NodeLinkEventType = payload.type;
2100
+ const NodeLinkExclusiveEvents = [
2101
+ "PlayerCreatedEvent",
2102
+ "PlayerDestroyedEvent",
2103
+ "PlayerConnectedEvent",
2104
+ "PlayerReconnectingEvent",
2105
+ "VolumeChangedEvent",
2106
+ "FiltersChangedEvent",
2107
+ "SeekEvent",
2108
+ "PauseEvent",
2109
+ "ConnectionStatusEvent",
2110
+ "MixStartedEvent",
2111
+ "MixEndedEvent"
2112
+ ];
2113
+ if (NodeLinkExclusiveEvents.includes(NodeLinkEventType) && (!this.info || this.info.isNodelink)) {
2114
+ return this.nodeLinkEventHandler(NodeLinkEventType, player, player.queue.current, payload);
2115
+ }
2074
2116
  switch (payload.type) {
2075
2117
  case "TrackStartEvent":
2076
2118
  this.trackStart(player, player.queue.current, payload);
@@ -2114,6 +2156,16 @@ var LavalinkNode = class {
2114
2156
  }
2115
2157
  return;
2116
2158
  }
2159
+ /**
2160
+ * nodeLink specific events handling https://nodelink.js.org/docs/api/websocket#incoming-events-server--client
2161
+ * @param eventName
2162
+ * @param player
2163
+ * @param track
2164
+ * @param payload
2165
+ */
2166
+ async nodeLinkEventHandler(eventName, player, track, payload) {
2167
+ this.NodeManager.emit("nodeLinkEvent", this, eventName, player, track, payload);
2168
+ }
2117
2169
  getTrackOfPayload(payload) {
2118
2170
  return "track" in payload ? this._LManager.utils.buildTrack(payload.track, void 0) : null;
2119
2171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lavalink-client",
3
- "version": "2.7.5",
3
+ "version": "2.7.7",
4
4
  "description": "Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",