lavalink-client 2.5.8 → 2.5.10
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/README.md +310 -704
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +33 -1
- package/dist/index.mjs +33 -1
- package/package.json +6 -1
package/dist/index.d.mts
CHANGED
|
@@ -850,6 +850,14 @@ declare class Player {
|
|
|
850
850
|
* ```
|
|
851
851
|
*/
|
|
852
852
|
changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
|
|
853
|
+
/**
|
|
854
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
855
|
+
* @param node the id of the node to move to
|
|
856
|
+
* @returns the player
|
|
857
|
+
* @throws RangeError if there is no available nodes.
|
|
858
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
859
|
+
*/
|
|
860
|
+
moveNode(node?: string): Promise<string | this>;
|
|
853
861
|
/** Converts the Player including Queue to a Json state */
|
|
854
862
|
toJSON(): PlayerJson;
|
|
855
863
|
}
|
|
@@ -2745,6 +2753,10 @@ interface ManagerPlayerOptions {
|
|
|
2745
2753
|
};
|
|
2746
2754
|
useUnresolvedData?: boolean;
|
|
2747
2755
|
}
|
|
2756
|
+
type DeepRequired<T> = {
|
|
2757
|
+
[K in keyof T]-?: NonNullable<T[K]> extends object ? DeepRequired<NonNullable<T[K]>> : NonNullable<T[K]>;
|
|
2758
|
+
};
|
|
2759
|
+
type RequiredManagerOptions = DeepRequired<ManagerOptions>;
|
|
2748
2760
|
/** Manager Options used to create the manager */
|
|
2749
2761
|
interface ManagerOptions {
|
|
2750
2762
|
/** The Node Options, for all Nodes! (on init) */
|
|
@@ -2759,6 +2771,8 @@ interface ManagerOptions {
|
|
|
2759
2771
|
playerOptions?: ManagerPlayerOptions;
|
|
2760
2772
|
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
2761
2773
|
autoSkip?: boolean;
|
|
2774
|
+
/** If it should automatically move the player to the next node when node is down */
|
|
2775
|
+
autoMove?: boolean;
|
|
2762
2776
|
/** If it should skip to the next Track if track.resolve errors while trying to play a track. */
|
|
2763
2777
|
autoSkipOnResolveError?: boolean;
|
|
2764
2778
|
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
|
@@ -3033,4 +3047,4 @@ declare const LavalinkPlugins: {
|
|
|
3033
3047
|
/** Lavalink Sources regexes for url validations */
|
|
3034
3048
|
declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
|
|
3035
3049
|
|
|
3036
|
-
export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, 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, type RepeatMode, 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 };
|
|
3050
|
+
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, 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
|
@@ -850,6 +850,14 @@ declare class Player {
|
|
|
850
850
|
* ```
|
|
851
851
|
*/
|
|
852
852
|
changeNode(newNode: LavalinkNode | string, checkSources?: boolean): Promise<string>;
|
|
853
|
+
/**
|
|
854
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
855
|
+
* @param node the id of the node to move to
|
|
856
|
+
* @returns the player
|
|
857
|
+
* @throws RangeError if there is no available nodes.
|
|
858
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
859
|
+
*/
|
|
860
|
+
moveNode(node?: string): Promise<string | this>;
|
|
853
861
|
/** Converts the Player including Queue to a Json state */
|
|
854
862
|
toJSON(): PlayerJson;
|
|
855
863
|
}
|
|
@@ -2745,6 +2753,10 @@ interface ManagerPlayerOptions {
|
|
|
2745
2753
|
};
|
|
2746
2754
|
useUnresolvedData?: boolean;
|
|
2747
2755
|
}
|
|
2756
|
+
type DeepRequired<T> = {
|
|
2757
|
+
[K in keyof T]-?: NonNullable<T[K]> extends object ? DeepRequired<NonNullable<T[K]>> : NonNullable<T[K]>;
|
|
2758
|
+
};
|
|
2759
|
+
type RequiredManagerOptions = DeepRequired<ManagerOptions>;
|
|
2748
2760
|
/** Manager Options used to create the manager */
|
|
2749
2761
|
interface ManagerOptions {
|
|
2750
2762
|
/** The Node Options, for all Nodes! (on init) */
|
|
@@ -2759,6 +2771,8 @@ interface ManagerOptions {
|
|
|
2759
2771
|
playerOptions?: ManagerPlayerOptions;
|
|
2760
2772
|
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
2761
2773
|
autoSkip?: boolean;
|
|
2774
|
+
/** If it should automatically move the player to the next node when node is down */
|
|
2775
|
+
autoMove?: boolean;
|
|
2762
2776
|
/** If it should skip to the next Track if track.resolve errors while trying to play a track. */
|
|
2763
2777
|
autoSkipOnResolveError?: boolean;
|
|
2764
2778
|
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
|
@@ -3033,4 +3047,4 @@ declare const LavalinkPlugins: {
|
|
|
3033
3047
|
/** Lavalink Sources regexes for url validations */
|
|
3034
3048
|
declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
|
|
3035
3049
|
|
|
3036
|
-
export { type AudioOutputs, type Awaitable, type Base64, type BaseNodeStats, type BasePlayOptions, type BotClientOptions, type CPUStats, type ChannelDeletePacket, type ChannelMixFilter, type ClientCustomSearchPlatformUtils, type ClientSearchPlatform, DebugEvents, 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, type RepeatMode, 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 };
|
|
3050
|
+
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, 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
|
@@ -1896,6 +1896,14 @@ var LavalinkNode = class {
|
|
|
1896
1896
|
this.reconnect();
|
|
1897
1897
|
}
|
|
1898
1898
|
}
|
|
1899
|
+
this.NodeManager.LavalinkManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
|
|
1900
|
+
if (!this.NodeManager.LavalinkManager.options.autoMove) return p.playing = false;
|
|
1901
|
+
if (this.NodeManager.LavalinkManager.options.autoMove) {
|
|
1902
|
+
if (this.NodeManager.nodes.filter((n) => n.connected).size === 0)
|
|
1903
|
+
return p.playing = false;
|
|
1904
|
+
p.moveNode();
|
|
1905
|
+
}
|
|
1906
|
+
});
|
|
1899
1907
|
}
|
|
1900
1908
|
/** @private util function for handling error events from websocket */
|
|
1901
1909
|
error(error) {
|
|
@@ -4344,6 +4352,26 @@ var Player = class {
|
|
|
4344
4352
|
this.set("internal_nodeChanging", void 0);
|
|
4345
4353
|
}
|
|
4346
4354
|
}
|
|
4355
|
+
/**
|
|
4356
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
4357
|
+
* @param node the id of the node to move to
|
|
4358
|
+
* @returns the player
|
|
4359
|
+
* @throws RangeError if there is no available nodes.
|
|
4360
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
4361
|
+
*/
|
|
4362
|
+
async moveNode(node) {
|
|
4363
|
+
try {
|
|
4364
|
+
if (!node) node = Array.from(this.LavalinkManager.nodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.node.options.id).id;
|
|
4365
|
+
if (!node || !this.LavalinkManager.nodeManager.nodes.get(node)) throw new RangeError("No nodes are available.");
|
|
4366
|
+
if (this.node.options.id === node) return this;
|
|
4367
|
+
this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, { state: "log", message: `Player.moveNode() was executed, trying to move from "${this.node.id}" to "${node}"`, functionLayer: "Player > moveNode()" });
|
|
4368
|
+
const updateNode = this.LavalinkManager.nodeManager.nodes.get(node);
|
|
4369
|
+
if (!updateNode) throw new RangeError("No nodes are available.");
|
|
4370
|
+
return await this.changeNode(updateNode);
|
|
4371
|
+
} catch (error) {
|
|
4372
|
+
throw new Error(`Failed to move the node: ${error}`);
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4347
4375
|
/** Converts the Player including Queue to a Json state */
|
|
4348
4376
|
toJSON() {
|
|
4349
4377
|
return {
|
|
@@ -4433,13 +4461,16 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
4433
4461
|
* @returns
|
|
4434
4462
|
*/
|
|
4435
4463
|
applyOptions(options) {
|
|
4436
|
-
|
|
4464
|
+
const optionsToAssign = {
|
|
4465
|
+
...options,
|
|
4466
|
+
// allow users to apply other options if they need to.
|
|
4437
4467
|
client: {
|
|
4438
4468
|
...options?.client,
|
|
4439
4469
|
id: options?.client?.id,
|
|
4440
4470
|
username: options?.client?.username ?? "lavalink-client"
|
|
4441
4471
|
},
|
|
4442
4472
|
sendToShard: options?.sendToShard,
|
|
4473
|
+
autoMove: options?.autoMove ?? false,
|
|
4443
4474
|
nodes: options?.nodes,
|
|
4444
4475
|
playerOptions: {
|
|
4445
4476
|
applyVolumeAsFilter: options?.playerOptions?.applyVolumeAsFilter ?? false,
|
|
@@ -4487,6 +4518,7 @@ var LavalinkManager = class extends import_events2.EventEmitter {
|
|
|
4487
4518
|
}
|
|
4488
4519
|
}
|
|
4489
4520
|
};
|
|
4521
|
+
this.options = optionsToAssign;
|
|
4490
4522
|
return;
|
|
4491
4523
|
}
|
|
4492
4524
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1836,6 +1836,14 @@ var LavalinkNode = class {
|
|
|
1836
1836
|
this.reconnect();
|
|
1837
1837
|
}
|
|
1838
1838
|
}
|
|
1839
|
+
this.NodeManager.LavalinkManager.players.filter((p) => p?.node?.options?.id === this?.options?.id).forEach((p) => {
|
|
1840
|
+
if (!this.NodeManager.LavalinkManager.options.autoMove) return p.playing = false;
|
|
1841
|
+
if (this.NodeManager.LavalinkManager.options.autoMove) {
|
|
1842
|
+
if (this.NodeManager.nodes.filter((n) => n.connected).size === 0)
|
|
1843
|
+
return p.playing = false;
|
|
1844
|
+
p.moveNode();
|
|
1845
|
+
}
|
|
1846
|
+
});
|
|
1839
1847
|
}
|
|
1840
1848
|
/** @private util function for handling error events from websocket */
|
|
1841
1849
|
error(error) {
|
|
@@ -4284,6 +4292,26 @@ var Player = class {
|
|
|
4284
4292
|
this.set("internal_nodeChanging", void 0);
|
|
4285
4293
|
}
|
|
4286
4294
|
}
|
|
4295
|
+
/**
|
|
4296
|
+
* Move the player to a different node. If no node is provided, it will find the least used node that is not the same as the current node.
|
|
4297
|
+
* @param node the id of the node to move to
|
|
4298
|
+
* @returns the player
|
|
4299
|
+
* @throws RangeError if there is no available nodes.
|
|
4300
|
+
* @throws Error if the node to move to is the same as the current node.
|
|
4301
|
+
*/
|
|
4302
|
+
async moveNode(node) {
|
|
4303
|
+
try {
|
|
4304
|
+
if (!node) node = Array.from(this.LavalinkManager.nodeManager.leastUsedNodes("playingPlayers")).find((n) => n.connected && n.options.id !== this.node.options.id).id;
|
|
4305
|
+
if (!node || !this.LavalinkManager.nodeManager.nodes.get(node)) throw new RangeError("No nodes are available.");
|
|
4306
|
+
if (this.node.options.id === node) return this;
|
|
4307
|
+
this.LavalinkManager.emit("debug", "PlayerChangeNode" /* PlayerChangeNode */, { state: "log", message: `Player.moveNode() was executed, trying to move from "${this.node.id}" to "${node}"`, functionLayer: "Player > moveNode()" });
|
|
4308
|
+
const updateNode = this.LavalinkManager.nodeManager.nodes.get(node);
|
|
4309
|
+
if (!updateNode) throw new RangeError("No nodes are available.");
|
|
4310
|
+
return await this.changeNode(updateNode);
|
|
4311
|
+
} catch (error) {
|
|
4312
|
+
throw new Error(`Failed to move the node: ${error}`);
|
|
4313
|
+
}
|
|
4314
|
+
}
|
|
4287
4315
|
/** Converts the Player including Queue to a Json state */
|
|
4288
4316
|
toJSON() {
|
|
4289
4317
|
return {
|
|
@@ -4373,13 +4401,16 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
4373
4401
|
* @returns
|
|
4374
4402
|
*/
|
|
4375
4403
|
applyOptions(options) {
|
|
4376
|
-
|
|
4404
|
+
const optionsToAssign = {
|
|
4405
|
+
...options,
|
|
4406
|
+
// allow users to apply other options if they need to.
|
|
4377
4407
|
client: {
|
|
4378
4408
|
...options?.client,
|
|
4379
4409
|
id: options?.client?.id,
|
|
4380
4410
|
username: options?.client?.username ?? "lavalink-client"
|
|
4381
4411
|
},
|
|
4382
4412
|
sendToShard: options?.sendToShard,
|
|
4413
|
+
autoMove: options?.autoMove ?? false,
|
|
4383
4414
|
nodes: options?.nodes,
|
|
4384
4415
|
playerOptions: {
|
|
4385
4416
|
applyVolumeAsFilter: options?.playerOptions?.applyVolumeAsFilter ?? false,
|
|
@@ -4427,6 +4458,7 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
4427
4458
|
}
|
|
4428
4459
|
}
|
|
4429
4460
|
};
|
|
4461
|
+
this.options = optionsToAssign;
|
|
4430
4462
|
return;
|
|
4431
4463
|
}
|
|
4432
4464
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lavalink-client",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.10",
|
|
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",
|
|
@@ -72,5 +72,10 @@
|
|
|
72
72
|
"engines": {
|
|
73
73
|
"node": ">=18.0.0",
|
|
74
74
|
"bun": ">=1.1.27"
|
|
75
|
+
},
|
|
76
|
+
"pnpm": {
|
|
77
|
+
"onlyBuiltDependencies": [
|
|
78
|
+
"esbuild"
|
|
79
|
+
]
|
|
75
80
|
}
|
|
76
81
|
}
|