lavalink-client 2.9.5 → 2.9.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.cjs +122 -147
- package/dist/index.d.cts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.js +122 -147
- package/dist/index.mjs +122 -147
- package/package.json +4 -2
package/dist/index.cjs
CHANGED
|
@@ -2000,6 +2000,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
2000
2000
|
/**
|
|
2001
2001
|
* subscribe to lyrics updates for a guild
|
|
2002
2002
|
* @param guildId the guild id of the player
|
|
2003
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
2003
2004
|
* @returns request data of the request
|
|
2004
2005
|
*
|
|
2005
2006
|
* @example
|
|
@@ -2009,15 +2010,18 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
2009
2010
|
* // const lyrics = await player.subscribeLyrics();
|
|
2010
2011
|
* ```
|
|
2011
2012
|
*/
|
|
2012
|
-
subscribe: async (guildId) => {
|
|
2013
|
+
subscribe: async (guildId, skipTrackSource) => {
|
|
2013
2014
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
2014
2015
|
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin"))
|
|
2015
2016
|
throw new RangeError(
|
|
2016
2017
|
`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`
|
|
2017
2018
|
);
|
|
2018
|
-
return await this.request(
|
|
2019
|
-
|
|
2020
|
-
|
|
2019
|
+
return await this.request(
|
|
2020
|
+
`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource ?? false}`,
|
|
2021
|
+
(options) => {
|
|
2022
|
+
options.method = "POST";
|
|
2023
|
+
}
|
|
2024
|
+
);
|
|
2021
2025
|
},
|
|
2022
2026
|
/**
|
|
2023
2027
|
* unsubscribe from lyrics updates for a guild
|
|
@@ -5390,6 +5394,15 @@ var Player = class {
|
|
|
5390
5394
|
get(key) {
|
|
5391
5395
|
return this.data[key];
|
|
5392
5396
|
}
|
|
5397
|
+
/**
|
|
5398
|
+
* Delete specific custom data.
|
|
5399
|
+
* @param key
|
|
5400
|
+
*/
|
|
5401
|
+
deleteData(key) {
|
|
5402
|
+
if (key.startsWith("internal_")) return this;
|
|
5403
|
+
delete this.data[key];
|
|
5404
|
+
return this;
|
|
5405
|
+
}
|
|
5393
5406
|
/**
|
|
5394
5407
|
* CLears all the custom data.
|
|
5395
5408
|
*/
|
|
@@ -5915,15 +5928,16 @@ var Player = class {
|
|
|
5915
5928
|
return await this.node.lyrics.get(track, skipTrackSource);
|
|
5916
5929
|
}
|
|
5917
5930
|
/**
|
|
5918
|
-
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
5931
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events}
|
|
5932
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
5919
5933
|
* @returns The unsubscribe function
|
|
5920
5934
|
* @example
|
|
5921
5935
|
* ```ts
|
|
5922
5936
|
* const lyrics = await player.subscribeLyrics();
|
|
5923
5937
|
* ```
|
|
5924
5938
|
*/
|
|
5925
|
-
subscribeLyrics() {
|
|
5926
|
-
return this.node.lyrics.subscribe(this.guildId);
|
|
5939
|
+
subscribeLyrics(skipTrackSource) {
|
|
5940
|
+
return this.node.lyrics.subscribe(this.guildId, skipTrackSource);
|
|
5927
5941
|
}
|
|
5928
5942
|
/**
|
|
5929
5943
|
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
@@ -6110,7 +6124,7 @@ var Player = class {
|
|
|
6110
6124
|
};
|
|
6111
6125
|
|
|
6112
6126
|
// src/structures/LavalinkManager.ts
|
|
6113
|
-
var LavalinkManager = class extends import_node_events2.EventEmitter {
|
|
6127
|
+
var LavalinkManager = class _LavalinkManager extends import_node_events2.EventEmitter {
|
|
6114
6128
|
/**
|
|
6115
6129
|
* Emit an event
|
|
6116
6130
|
* @param event The event to emit
|
|
@@ -6279,6 +6293,17 @@ var LavalinkManager = class extends import_node_events2.EventEmitter {
|
|
|
6279
6293
|
if (!this.options?.advancedOptions?.enableDebugEvents) return;
|
|
6280
6294
|
this.emit("debug", name, eventData);
|
|
6281
6295
|
}
|
|
6296
|
+
static _noAudioDebugPrefix = "Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, ";
|
|
6297
|
+
/**
|
|
6298
|
+
* Emits NoAudioDebug and optionally logs to console when debugOptions.noAudio is enabled.
|
|
6299
|
+
*/
|
|
6300
|
+
_debugNoAudio(state, functionLayer, messages, ...consoleArgs) {
|
|
6301
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, { state, functionLayer, message: messages.message });
|
|
6302
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) {
|
|
6303
|
+
const consoleMsg = messages.consoleMessage ?? messages.message;
|
|
6304
|
+
console.debug(_LavalinkManager._noAudioDebugPrefix + consoleMsg, ...consoleArgs);
|
|
6305
|
+
}
|
|
6306
|
+
}
|
|
6282
6307
|
/**
|
|
6283
6308
|
* Create the Lavalink Manager
|
|
6284
6309
|
* @param options
|
|
@@ -6510,28 +6535,22 @@ var LavalinkManager = class extends import_node_events2.EventEmitter {
|
|
|
6510
6535
|
*/
|
|
6511
6536
|
async sendRawData(data) {
|
|
6512
6537
|
if (!this.initiated) {
|
|
6513
|
-
this.
|
|
6514
|
-
state: "log",
|
|
6538
|
+
this._debugNoAudio("log", "LavalinkManager > sendRawData()", {
|
|
6515
6539
|
message: "Manager is not initated yet",
|
|
6516
|
-
|
|
6540
|
+
consoleMessage: "manager is not initated yet"
|
|
6517
6541
|
});
|
|
6518
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6519
|
-
console.debug(
|
|
6520
|
-
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, manager is not initated yet"
|
|
6521
|
-
);
|
|
6522
6542
|
return;
|
|
6523
6543
|
}
|
|
6524
6544
|
if (!("t" in data)) {
|
|
6525
|
-
this.
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
);
|
|
6545
|
+
this._debugNoAudio(
|
|
6546
|
+
"error",
|
|
6547
|
+
"LavalinkManager > sendRawData()",
|
|
6548
|
+
{
|
|
6549
|
+
message: "No 't' in payload-data of the raw event:",
|
|
6550
|
+
consoleMessage: "no 't' in payload-data of the raw event:"
|
|
6551
|
+
},
|
|
6552
|
+
data
|
|
6553
|
+
);
|
|
6535
6554
|
return;
|
|
6536
6555
|
}
|
|
6537
6556
|
if ("CHANNEL_DELETE" === data.t) {
|
|
@@ -6544,132 +6563,94 @@ var LavalinkManager = class extends import_node_events2.EventEmitter {
|
|
|
6544
6563
|
if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
|
|
6545
6564
|
const update = "d" in data ? data.d : data;
|
|
6546
6565
|
if (!update) {
|
|
6547
|
-
this.
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
|
|
6555
|
-
|
|
6556
|
-
);
|
|
6566
|
+
this._debugNoAudio(
|
|
6567
|
+
"warn",
|
|
6568
|
+
"LavalinkManager > sendRawData()",
|
|
6569
|
+
{
|
|
6570
|
+
message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
|
|
6571
|
+
consoleMessage: "no update data found in payload:"
|
|
6572
|
+
},
|
|
6573
|
+
data
|
|
6574
|
+
);
|
|
6557
6575
|
return;
|
|
6558
6576
|
}
|
|
6559
6577
|
if (!("token" in update) && !("session_id" in update)) {
|
|
6560
|
-
this.
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
);
|
|
6578
|
+
this._debugNoAudio(
|
|
6579
|
+
"error",
|
|
6580
|
+
"LavalinkManager > sendRawData()",
|
|
6581
|
+
{
|
|
6582
|
+
message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
|
|
6583
|
+
consoleMessage: "no 'token' nor 'session_id' found in payload:"
|
|
6584
|
+
},
|
|
6585
|
+
data
|
|
6586
|
+
);
|
|
6570
6587
|
return;
|
|
6571
6588
|
}
|
|
6572
6589
|
const player = this.getPlayer(update.guild_id);
|
|
6573
6590
|
if (!player) {
|
|
6574
|
-
this.
|
|
6575
|
-
|
|
6576
|
-
|
|
6577
|
-
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6583
|
-
);
|
|
6591
|
+
this._debugNoAudio(
|
|
6592
|
+
"warn",
|
|
6593
|
+
"LavalinkManager > sendRawData()",
|
|
6594
|
+
{
|
|
6595
|
+
message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
|
|
6596
|
+
consoleMessage: "No Lavalink Player found via key: 'guild_id' of update-data:"
|
|
6597
|
+
},
|
|
6598
|
+
update
|
|
6599
|
+
);
|
|
6584
6600
|
return;
|
|
6585
6601
|
}
|
|
6586
6602
|
if (player.get("internal_destroystatus") === true) {
|
|
6587
|
-
this.
|
|
6588
|
-
|
|
6589
|
-
message: `Player is in a destroying state. can't signal the voice states`,
|
|
6590
|
-
functionLayer: "LavalinkManager > sendRawData()"
|
|
6603
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6604
|
+
message: "Player is in a destroying state. can't signal the voice states"
|
|
6591
6605
|
});
|
|
6592
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6593
|
-
console.debug(
|
|
6594
|
-
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Player is in a destroying state. can't signal the voice states"
|
|
6595
|
-
);
|
|
6596
6606
|
return;
|
|
6597
6607
|
}
|
|
6598
6608
|
if ("token" in update) {
|
|
6599
6609
|
if (!player.node?.sessionId) throw new Error("Lavalink Node is either not ready or not up to date");
|
|
6600
6610
|
const sessionId2Use = player.voice?.sessionId || ("sessionId" in update ? update.sessionId : void 0);
|
|
6601
6611
|
const channelId2Use = player.voice?.channelId || ("channel_id" in update ? update.channel_id : void 0);
|
|
6612
|
+
const voiceData = {
|
|
6613
|
+
token: update.token,
|
|
6614
|
+
endpoint: update.endpoint,
|
|
6615
|
+
sessionId: sessionId2Use,
|
|
6616
|
+
channelId: channelId2Use
|
|
6617
|
+
};
|
|
6602
6618
|
if (!sessionId2Use) {
|
|
6603
|
-
this.
|
|
6604
|
-
|
|
6605
|
-
|
|
6606
|
-
|
|
6607
|
-
|
|
6608
|
-
|
|
6609
|
-
|
|
6610
|
-
|
|
6611
|
-
|
|
6612
|
-
voice: {
|
|
6613
|
-
token: update.token,
|
|
6614
|
-
endpoint: update.endpoint,
|
|
6615
|
-
sessionId: sessionId2Use,
|
|
6616
|
-
channelId: channelId2Use
|
|
6617
|
-
},
|
|
6618
|
-
update,
|
|
6619
|
-
playerVoice: player.voice
|
|
6620
|
-
}
|
|
6621
|
-
);
|
|
6619
|
+
this._debugNoAudio(
|
|
6620
|
+
"error",
|
|
6621
|
+
"LavalinkManager > sendRawData()",
|
|
6622
|
+
{
|
|
6623
|
+
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6624
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing sessionId"
|
|
6625
|
+
},
|
|
6626
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6627
|
+
);
|
|
6622
6628
|
} else if (!channelId2Use) {
|
|
6623
|
-
this.
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
voice: {
|
|
6633
|
-
token: update.token,
|
|
6634
|
-
endpoint: update.endpoint,
|
|
6635
|
-
sessionId: sessionId2Use,
|
|
6636
|
-
channelId: channelId2Use
|
|
6637
|
-
},
|
|
6638
|
-
update,
|
|
6639
|
-
playerVoice: player.voice
|
|
6640
|
-
}
|
|
6641
|
-
);
|
|
6629
|
+
this._debugNoAudio(
|
|
6630
|
+
"error",
|
|
6631
|
+
"LavalinkManager > sendRawData()",
|
|
6632
|
+
{
|
|
6633
|
+
message: `Can't send updatePlayer for voice token session - Missing channelId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6634
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing channelId"
|
|
6635
|
+
},
|
|
6636
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6637
|
+
);
|
|
6642
6638
|
} else {
|
|
6643
6639
|
await player.node.updatePlayer({
|
|
6644
6640
|
guildId: player.guildId,
|
|
6645
6641
|
playerOptions: {
|
|
6646
|
-
voice:
|
|
6647
|
-
token: update.token,
|
|
6648
|
-
endpoint: update.endpoint,
|
|
6649
|
-
sessionId: sessionId2Use,
|
|
6650
|
-
channelId: channelId2Use
|
|
6651
|
-
}
|
|
6642
|
+
voice: voiceData
|
|
6652
6643
|
}
|
|
6653
6644
|
});
|
|
6654
|
-
this.
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
voice: {
|
|
6664
|
-
token: update.token,
|
|
6665
|
-
endpoint: update.endpoint,
|
|
6666
|
-
sessionId: sessionId2Use,
|
|
6667
|
-
channelId: channelId2Use
|
|
6668
|
-
},
|
|
6669
|
-
playerVoice: player.voice,
|
|
6670
|
-
update
|
|
6671
|
-
}
|
|
6672
|
-
);
|
|
6645
|
+
this._debugNoAudio(
|
|
6646
|
+
"log",
|
|
6647
|
+
"LavalinkManager > sendRawData()",
|
|
6648
|
+
{
|
|
6649
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6650
|
+
consoleMessage: "Sent updatePlayer for voice token session"
|
|
6651
|
+
},
|
|
6652
|
+
{ voice: voiceData, playerVoice: player.voice, update }
|
|
6653
|
+
);
|
|
6673
6654
|
}
|
|
6674
6655
|
return;
|
|
6675
6656
|
}
|
|
@@ -6681,36 +6662,30 @@ var LavalinkManager = class extends import_node_events2.EventEmitter {
|
|
|
6681
6662
|
update.user_id
|
|
6682
6663
|
);
|
|
6683
6664
|
}
|
|
6684
|
-
this.
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
);
|
|
6665
|
+
this._debugNoAudio(
|
|
6666
|
+
"warn",
|
|
6667
|
+
"LavalinkManager > sendRawData()",
|
|
6668
|
+
{
|
|
6669
|
+
message: `voice update user is not equal to provided client id of the LavalinkManager.options.client.id :: user: "${update.user_id}" manager client id: "${this.options?.client.id}"`,
|
|
6670
|
+
consoleMessage: "voice update user is not equal to provided client id of the manageroptions#client#id"
|
|
6671
|
+
},
|
|
6672
|
+
"user:",
|
|
6673
|
+
update.user_id,
|
|
6674
|
+
"manager client id:",
|
|
6675
|
+
this.options?.client.id
|
|
6676
|
+
);
|
|
6697
6677
|
return;
|
|
6698
6678
|
}
|
|
6699
6679
|
if (update.channel_id) {
|
|
6700
6680
|
if (player.voiceChannelId !== update.channel_id)
|
|
6701
6681
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
6702
6682
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
6703
|
-
player.voice.channelId = update.channel_id;
|
|
6683
|
+
player.voice.channelId = update.channel_id || player.voice.channelId;
|
|
6704
6684
|
if (!player.voice.sessionId) {
|
|
6705
|
-
this.
|
|
6706
|
-
state: "warn",
|
|
6685
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6707
6686
|
message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
|
|
6708
|
-
|
|
6687
|
+
consoleMessage: `Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`
|
|
6709
6688
|
});
|
|
6710
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6711
|
-
console.debug(
|
|
6712
|
-
`Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`
|
|
6713
|
-
);
|
|
6714
6689
|
}
|
|
6715
6690
|
player.voiceChannelId = update.channel_id;
|
|
6716
6691
|
player.options.voiceChannelId = update.channel_id;
|
package/dist/index.d.cts
CHANGED
|
@@ -952,6 +952,8 @@ interface VoiceServer {
|
|
|
952
952
|
guild_id: string;
|
|
953
953
|
/** Server Endpoint */
|
|
954
954
|
endpoint: string;
|
|
955
|
+
/** Voice Channel Id (Lavalink v4 DAVE support) */
|
|
956
|
+
channel_id?: string;
|
|
955
957
|
}
|
|
956
958
|
interface VoicePacket {
|
|
957
959
|
/** Voice Packet Keys to send */
|
|
@@ -2688,6 +2690,11 @@ declare class Player {
|
|
|
2688
2690
|
* @param key
|
|
2689
2691
|
*/
|
|
2690
2692
|
get<T>(key: string): T;
|
|
2693
|
+
/**
|
|
2694
|
+
* Delete specific custom data.
|
|
2695
|
+
* @param key
|
|
2696
|
+
*/
|
|
2697
|
+
deleteData(key: string): this;
|
|
2691
2698
|
/**
|
|
2692
2699
|
* CLears all the custom data.
|
|
2693
2700
|
*/
|
|
@@ -2813,14 +2820,15 @@ declare class Player {
|
|
|
2813
2820
|
*/
|
|
2814
2821
|
getLyrics(track: Track, skipTrackSource?: boolean): Promise<LyricsResult>;
|
|
2815
2822
|
/**
|
|
2816
|
-
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
2823
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events}
|
|
2824
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
2817
2825
|
* @returns The unsubscribe function
|
|
2818
2826
|
* @example
|
|
2819
2827
|
* ```ts
|
|
2820
2828
|
* const lyrics = await player.subscribeLyrics();
|
|
2821
2829
|
* ```
|
|
2822
2830
|
*/
|
|
2823
|
-
subscribeLyrics(): Promise<unknown>;
|
|
2831
|
+
subscribeLyrics(skipTrackSource?: boolean): Promise<unknown>;
|
|
2824
2832
|
/**
|
|
2825
2833
|
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
2826
2834
|
* @returns The unsubscribe function
|
|
@@ -3342,6 +3350,7 @@ declare class LavalinkNode {
|
|
|
3342
3350
|
/**
|
|
3343
3351
|
* subscribe to lyrics updates for a guild
|
|
3344
3352
|
* @param guildId the guild id of the player
|
|
3353
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
3345
3354
|
* @returns request data of the request
|
|
3346
3355
|
*
|
|
3347
3356
|
* @example
|
|
@@ -3351,7 +3360,7 @@ declare class LavalinkNode {
|
|
|
3351
3360
|
* // const lyrics = await player.subscribeLyrics();
|
|
3352
3361
|
* ```
|
|
3353
3362
|
*/
|
|
3354
|
-
subscribe: (guildId: string) => Promise<unknown>;
|
|
3363
|
+
subscribe: (guildId: string, skipTrackSource?: boolean) => Promise<unknown>;
|
|
3355
3364
|
/**
|
|
3356
3365
|
* unsubscribe from lyrics updates for a guild
|
|
3357
3366
|
* @param guildId the guild id of the player
|
|
@@ -4096,6 +4105,11 @@ declare class LavalinkManager<CustomPlayerT extends Player = Player> extends Eve
|
|
|
4096
4105
|
* @param eventData event data
|
|
4097
4106
|
*/
|
|
4098
4107
|
private _emitDebugEvent;
|
|
4108
|
+
private static readonly _noAudioDebugPrefix;
|
|
4109
|
+
/**
|
|
4110
|
+
* Emits NoAudioDebug and optionally logs to console when debugOptions.noAudio is enabled.
|
|
4111
|
+
*/
|
|
4112
|
+
private _debugNoAudio;
|
|
4099
4113
|
/**
|
|
4100
4114
|
* Create the Lavalink Manager
|
|
4101
4115
|
* @param options
|
package/dist/index.d.ts
CHANGED
|
@@ -952,6 +952,8 @@ interface VoiceServer {
|
|
|
952
952
|
guild_id: string;
|
|
953
953
|
/** Server Endpoint */
|
|
954
954
|
endpoint: string;
|
|
955
|
+
/** Voice Channel Id (Lavalink v4 DAVE support) */
|
|
956
|
+
channel_id?: string;
|
|
955
957
|
}
|
|
956
958
|
interface VoicePacket {
|
|
957
959
|
/** Voice Packet Keys to send */
|
|
@@ -2688,6 +2690,11 @@ declare class Player {
|
|
|
2688
2690
|
* @param key
|
|
2689
2691
|
*/
|
|
2690
2692
|
get<T>(key: string): T;
|
|
2693
|
+
/**
|
|
2694
|
+
* Delete specific custom data.
|
|
2695
|
+
* @param key
|
|
2696
|
+
*/
|
|
2697
|
+
deleteData(key: string): this;
|
|
2691
2698
|
/**
|
|
2692
2699
|
* CLears all the custom data.
|
|
2693
2700
|
*/
|
|
@@ -2813,14 +2820,15 @@ declare class Player {
|
|
|
2813
2820
|
*/
|
|
2814
2821
|
getLyrics(track: Track, skipTrackSource?: boolean): Promise<LyricsResult>;
|
|
2815
2822
|
/**
|
|
2816
|
-
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
2823
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events}
|
|
2824
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
2817
2825
|
* @returns The unsubscribe function
|
|
2818
2826
|
* @example
|
|
2819
2827
|
* ```ts
|
|
2820
2828
|
* const lyrics = await player.subscribeLyrics();
|
|
2821
2829
|
* ```
|
|
2822
2830
|
*/
|
|
2823
|
-
subscribeLyrics(): Promise<unknown>;
|
|
2831
|
+
subscribeLyrics(skipTrackSource?: boolean): Promise<unknown>;
|
|
2824
2832
|
/**
|
|
2825
2833
|
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
2826
2834
|
* @returns The unsubscribe function
|
|
@@ -3342,6 +3350,7 @@ declare class LavalinkNode {
|
|
|
3342
3350
|
/**
|
|
3343
3351
|
* subscribe to lyrics updates for a guild
|
|
3344
3352
|
* @param guildId the guild id of the player
|
|
3353
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
3345
3354
|
* @returns request data of the request
|
|
3346
3355
|
*
|
|
3347
3356
|
* @example
|
|
@@ -3351,7 +3360,7 @@ declare class LavalinkNode {
|
|
|
3351
3360
|
* // const lyrics = await player.subscribeLyrics();
|
|
3352
3361
|
* ```
|
|
3353
3362
|
*/
|
|
3354
|
-
subscribe: (guildId: string) => Promise<unknown>;
|
|
3363
|
+
subscribe: (guildId: string, skipTrackSource?: boolean) => Promise<unknown>;
|
|
3355
3364
|
/**
|
|
3356
3365
|
* unsubscribe from lyrics updates for a guild
|
|
3357
3366
|
* @param guildId the guild id of the player
|
|
@@ -4096,6 +4105,11 @@ declare class LavalinkManager<CustomPlayerT extends Player = Player> extends Eve
|
|
|
4096
4105
|
* @param eventData event data
|
|
4097
4106
|
*/
|
|
4098
4107
|
private _emitDebugEvent;
|
|
4108
|
+
private static readonly _noAudioDebugPrefix;
|
|
4109
|
+
/**
|
|
4110
|
+
* Emits NoAudioDebug and optionally logs to console when debugOptions.noAudio is enabled.
|
|
4111
|
+
*/
|
|
4112
|
+
private _debugNoAudio;
|
|
4099
4113
|
/**
|
|
4100
4114
|
* Create the Lavalink Manager
|
|
4101
4115
|
* @param options
|
package/dist/index.js
CHANGED
|
@@ -1936,6 +1936,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1936
1936
|
/**
|
|
1937
1937
|
* subscribe to lyrics updates for a guild
|
|
1938
1938
|
* @param guildId the guild id of the player
|
|
1939
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
1939
1940
|
* @returns request data of the request
|
|
1940
1941
|
*
|
|
1941
1942
|
* @example
|
|
@@ -1945,15 +1946,18 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1945
1946
|
* // const lyrics = await player.subscribeLyrics();
|
|
1946
1947
|
* ```
|
|
1947
1948
|
*/
|
|
1948
|
-
subscribe: async (guildId) => {
|
|
1949
|
+
subscribe: async (guildId, skipTrackSource) => {
|
|
1949
1950
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1950
1951
|
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin"))
|
|
1951
1952
|
throw new RangeError(
|
|
1952
1953
|
`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`
|
|
1953
1954
|
);
|
|
1954
|
-
return await this.request(
|
|
1955
|
-
|
|
1956
|
-
|
|
1955
|
+
return await this.request(
|
|
1956
|
+
`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource ?? false}`,
|
|
1957
|
+
(options) => {
|
|
1958
|
+
options.method = "POST";
|
|
1959
|
+
}
|
|
1960
|
+
);
|
|
1957
1961
|
},
|
|
1958
1962
|
/**
|
|
1959
1963
|
* unsubscribe from lyrics updates for a guild
|
|
@@ -5326,6 +5330,15 @@ var Player = class {
|
|
|
5326
5330
|
get(key) {
|
|
5327
5331
|
return this.data[key];
|
|
5328
5332
|
}
|
|
5333
|
+
/**
|
|
5334
|
+
* Delete specific custom data.
|
|
5335
|
+
* @param key
|
|
5336
|
+
*/
|
|
5337
|
+
deleteData(key) {
|
|
5338
|
+
if (key.startsWith("internal_")) return this;
|
|
5339
|
+
delete this.data[key];
|
|
5340
|
+
return this;
|
|
5341
|
+
}
|
|
5329
5342
|
/**
|
|
5330
5343
|
* CLears all the custom data.
|
|
5331
5344
|
*/
|
|
@@ -5851,15 +5864,16 @@ var Player = class {
|
|
|
5851
5864
|
return await this.node.lyrics.get(track, skipTrackSource);
|
|
5852
5865
|
}
|
|
5853
5866
|
/**
|
|
5854
|
-
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
5867
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events}
|
|
5868
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
5855
5869
|
* @returns The unsubscribe function
|
|
5856
5870
|
* @example
|
|
5857
5871
|
* ```ts
|
|
5858
5872
|
* const lyrics = await player.subscribeLyrics();
|
|
5859
5873
|
* ```
|
|
5860
5874
|
*/
|
|
5861
|
-
subscribeLyrics() {
|
|
5862
|
-
return this.node.lyrics.subscribe(this.guildId);
|
|
5875
|
+
subscribeLyrics(skipTrackSource) {
|
|
5876
|
+
return this.node.lyrics.subscribe(this.guildId, skipTrackSource);
|
|
5863
5877
|
}
|
|
5864
5878
|
/**
|
|
5865
5879
|
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
@@ -6046,7 +6060,7 @@ var Player = class {
|
|
|
6046
6060
|
};
|
|
6047
6061
|
|
|
6048
6062
|
// src/structures/LavalinkManager.ts
|
|
6049
|
-
var LavalinkManager = class extends EventEmitter2 {
|
|
6063
|
+
var LavalinkManager = class _LavalinkManager extends EventEmitter2 {
|
|
6050
6064
|
/**
|
|
6051
6065
|
* Emit an event
|
|
6052
6066
|
* @param event The event to emit
|
|
@@ -6215,6 +6229,17 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6215
6229
|
if (!this.options?.advancedOptions?.enableDebugEvents) return;
|
|
6216
6230
|
this.emit("debug", name, eventData);
|
|
6217
6231
|
}
|
|
6232
|
+
static _noAudioDebugPrefix = "Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, ";
|
|
6233
|
+
/**
|
|
6234
|
+
* Emits NoAudioDebug and optionally logs to console when debugOptions.noAudio is enabled.
|
|
6235
|
+
*/
|
|
6236
|
+
_debugNoAudio(state, functionLayer, messages, ...consoleArgs) {
|
|
6237
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, { state, functionLayer, message: messages.message });
|
|
6238
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) {
|
|
6239
|
+
const consoleMsg = messages.consoleMessage ?? messages.message;
|
|
6240
|
+
console.debug(_LavalinkManager._noAudioDebugPrefix + consoleMsg, ...consoleArgs);
|
|
6241
|
+
}
|
|
6242
|
+
}
|
|
6218
6243
|
/**
|
|
6219
6244
|
* Create the Lavalink Manager
|
|
6220
6245
|
* @param options
|
|
@@ -6446,28 +6471,22 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6446
6471
|
*/
|
|
6447
6472
|
async sendRawData(data) {
|
|
6448
6473
|
if (!this.initiated) {
|
|
6449
|
-
this.
|
|
6450
|
-
state: "log",
|
|
6474
|
+
this._debugNoAudio("log", "LavalinkManager > sendRawData()", {
|
|
6451
6475
|
message: "Manager is not initated yet",
|
|
6452
|
-
|
|
6476
|
+
consoleMessage: "manager is not initated yet"
|
|
6453
6477
|
});
|
|
6454
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6455
|
-
console.debug(
|
|
6456
|
-
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, manager is not initated yet"
|
|
6457
|
-
);
|
|
6458
6478
|
return;
|
|
6459
6479
|
}
|
|
6460
6480
|
if (!("t" in data)) {
|
|
6461
|
-
this.
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
);
|
|
6481
|
+
this._debugNoAudio(
|
|
6482
|
+
"error",
|
|
6483
|
+
"LavalinkManager > sendRawData()",
|
|
6484
|
+
{
|
|
6485
|
+
message: "No 't' in payload-data of the raw event:",
|
|
6486
|
+
consoleMessage: "no 't' in payload-data of the raw event:"
|
|
6487
|
+
},
|
|
6488
|
+
data
|
|
6489
|
+
);
|
|
6471
6490
|
return;
|
|
6472
6491
|
}
|
|
6473
6492
|
if ("CHANNEL_DELETE" === data.t) {
|
|
@@ -6480,132 +6499,94 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6480
6499
|
if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
|
|
6481
6500
|
const update = "d" in data ? data.d : data;
|
|
6482
6501
|
if (!update) {
|
|
6483
|
-
this.
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
);
|
|
6502
|
+
this._debugNoAudio(
|
|
6503
|
+
"warn",
|
|
6504
|
+
"LavalinkManager > sendRawData()",
|
|
6505
|
+
{
|
|
6506
|
+
message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
|
|
6507
|
+
consoleMessage: "no update data found in payload:"
|
|
6508
|
+
},
|
|
6509
|
+
data
|
|
6510
|
+
);
|
|
6493
6511
|
return;
|
|
6494
6512
|
}
|
|
6495
6513
|
if (!("token" in update) && !("session_id" in update)) {
|
|
6496
|
-
this.
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
);
|
|
6514
|
+
this._debugNoAudio(
|
|
6515
|
+
"error",
|
|
6516
|
+
"LavalinkManager > sendRawData()",
|
|
6517
|
+
{
|
|
6518
|
+
message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
|
|
6519
|
+
consoleMessage: "no 'token' nor 'session_id' found in payload:"
|
|
6520
|
+
},
|
|
6521
|
+
data
|
|
6522
|
+
);
|
|
6506
6523
|
return;
|
|
6507
6524
|
}
|
|
6508
6525
|
const player = this.getPlayer(update.guild_id);
|
|
6509
6526
|
if (!player) {
|
|
6510
|
-
this.
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
);
|
|
6527
|
+
this._debugNoAudio(
|
|
6528
|
+
"warn",
|
|
6529
|
+
"LavalinkManager > sendRawData()",
|
|
6530
|
+
{
|
|
6531
|
+
message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
|
|
6532
|
+
consoleMessage: "No Lavalink Player found via key: 'guild_id' of update-data:"
|
|
6533
|
+
},
|
|
6534
|
+
update
|
|
6535
|
+
);
|
|
6520
6536
|
return;
|
|
6521
6537
|
}
|
|
6522
6538
|
if (player.get("internal_destroystatus") === true) {
|
|
6523
|
-
this.
|
|
6524
|
-
|
|
6525
|
-
message: `Player is in a destroying state. can't signal the voice states`,
|
|
6526
|
-
functionLayer: "LavalinkManager > sendRawData()"
|
|
6539
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6540
|
+
message: "Player is in a destroying state. can't signal the voice states"
|
|
6527
6541
|
});
|
|
6528
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6529
|
-
console.debug(
|
|
6530
|
-
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Player is in a destroying state. can't signal the voice states"
|
|
6531
|
-
);
|
|
6532
6542
|
return;
|
|
6533
6543
|
}
|
|
6534
6544
|
if ("token" in update) {
|
|
6535
6545
|
if (!player.node?.sessionId) throw new Error("Lavalink Node is either not ready or not up to date");
|
|
6536
6546
|
const sessionId2Use = player.voice?.sessionId || ("sessionId" in update ? update.sessionId : void 0);
|
|
6537
6547
|
const channelId2Use = player.voice?.channelId || ("channel_id" in update ? update.channel_id : void 0);
|
|
6548
|
+
const voiceData = {
|
|
6549
|
+
token: update.token,
|
|
6550
|
+
endpoint: update.endpoint,
|
|
6551
|
+
sessionId: sessionId2Use,
|
|
6552
|
+
channelId: channelId2Use
|
|
6553
|
+
};
|
|
6538
6554
|
if (!sessionId2Use) {
|
|
6539
|
-
this.
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
voice: {
|
|
6549
|
-
token: update.token,
|
|
6550
|
-
endpoint: update.endpoint,
|
|
6551
|
-
sessionId: sessionId2Use,
|
|
6552
|
-
channelId: channelId2Use
|
|
6553
|
-
},
|
|
6554
|
-
update,
|
|
6555
|
-
playerVoice: player.voice
|
|
6556
|
-
}
|
|
6557
|
-
);
|
|
6555
|
+
this._debugNoAudio(
|
|
6556
|
+
"error",
|
|
6557
|
+
"LavalinkManager > sendRawData()",
|
|
6558
|
+
{
|
|
6559
|
+
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6560
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing sessionId"
|
|
6561
|
+
},
|
|
6562
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6563
|
+
);
|
|
6558
6564
|
} else if (!channelId2Use) {
|
|
6559
|
-
this.
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
voice: {
|
|
6569
|
-
token: update.token,
|
|
6570
|
-
endpoint: update.endpoint,
|
|
6571
|
-
sessionId: sessionId2Use,
|
|
6572
|
-
channelId: channelId2Use
|
|
6573
|
-
},
|
|
6574
|
-
update,
|
|
6575
|
-
playerVoice: player.voice
|
|
6576
|
-
}
|
|
6577
|
-
);
|
|
6565
|
+
this._debugNoAudio(
|
|
6566
|
+
"error",
|
|
6567
|
+
"LavalinkManager > sendRawData()",
|
|
6568
|
+
{
|
|
6569
|
+
message: `Can't send updatePlayer for voice token session - Missing channelId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6570
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing channelId"
|
|
6571
|
+
},
|
|
6572
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6573
|
+
);
|
|
6578
6574
|
} else {
|
|
6579
6575
|
await player.node.updatePlayer({
|
|
6580
6576
|
guildId: player.guildId,
|
|
6581
6577
|
playerOptions: {
|
|
6582
|
-
voice:
|
|
6583
|
-
token: update.token,
|
|
6584
|
-
endpoint: update.endpoint,
|
|
6585
|
-
sessionId: sessionId2Use,
|
|
6586
|
-
channelId: channelId2Use
|
|
6587
|
-
}
|
|
6578
|
+
voice: voiceData
|
|
6588
6579
|
}
|
|
6589
6580
|
});
|
|
6590
|
-
this.
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
voice: {
|
|
6600
|
-
token: update.token,
|
|
6601
|
-
endpoint: update.endpoint,
|
|
6602
|
-
sessionId: sessionId2Use,
|
|
6603
|
-
channelId: channelId2Use
|
|
6604
|
-
},
|
|
6605
|
-
playerVoice: player.voice,
|
|
6606
|
-
update
|
|
6607
|
-
}
|
|
6608
|
-
);
|
|
6581
|
+
this._debugNoAudio(
|
|
6582
|
+
"log",
|
|
6583
|
+
"LavalinkManager > sendRawData()",
|
|
6584
|
+
{
|
|
6585
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6586
|
+
consoleMessage: "Sent updatePlayer for voice token session"
|
|
6587
|
+
},
|
|
6588
|
+
{ voice: voiceData, playerVoice: player.voice, update }
|
|
6589
|
+
);
|
|
6609
6590
|
}
|
|
6610
6591
|
return;
|
|
6611
6592
|
}
|
|
@@ -6617,36 +6598,30 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6617
6598
|
update.user_id
|
|
6618
6599
|
);
|
|
6619
6600
|
}
|
|
6620
|
-
this.
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
);
|
|
6601
|
+
this._debugNoAudio(
|
|
6602
|
+
"warn",
|
|
6603
|
+
"LavalinkManager > sendRawData()",
|
|
6604
|
+
{
|
|
6605
|
+
message: `voice update user is not equal to provided client id of the LavalinkManager.options.client.id :: user: "${update.user_id}" manager client id: "${this.options?.client.id}"`,
|
|
6606
|
+
consoleMessage: "voice update user is not equal to provided client id of the manageroptions#client#id"
|
|
6607
|
+
},
|
|
6608
|
+
"user:",
|
|
6609
|
+
update.user_id,
|
|
6610
|
+
"manager client id:",
|
|
6611
|
+
this.options?.client.id
|
|
6612
|
+
);
|
|
6633
6613
|
return;
|
|
6634
6614
|
}
|
|
6635
6615
|
if (update.channel_id) {
|
|
6636
6616
|
if (player.voiceChannelId !== update.channel_id)
|
|
6637
6617
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
6638
6618
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
6639
|
-
player.voice.channelId = update.channel_id;
|
|
6619
|
+
player.voice.channelId = update.channel_id || player.voice.channelId;
|
|
6640
6620
|
if (!player.voice.sessionId) {
|
|
6641
|
-
this.
|
|
6642
|
-
state: "warn",
|
|
6621
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6643
6622
|
message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
|
|
6644
|
-
|
|
6623
|
+
consoleMessage: `Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`
|
|
6645
6624
|
});
|
|
6646
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6647
|
-
console.debug(
|
|
6648
|
-
`Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`
|
|
6649
|
-
);
|
|
6650
6625
|
}
|
|
6651
6626
|
player.voiceChannelId = update.channel_id;
|
|
6652
6627
|
player.options.voiceChannelId = update.channel_id;
|
package/dist/index.mjs
CHANGED
|
@@ -1936,6 +1936,7 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1936
1936
|
/**
|
|
1937
1937
|
* subscribe to lyrics updates for a guild
|
|
1938
1938
|
* @param guildId the guild id of the player
|
|
1939
|
+
* @param skipTrackSource wether to skip the track source or not
|
|
1939
1940
|
* @returns request data of the request
|
|
1940
1941
|
*
|
|
1941
1942
|
* @example
|
|
@@ -1945,15 +1946,18 @@ var LavalinkNode = class _LavalinkNode {
|
|
|
1945
1946
|
* // const lyrics = await player.subscribeLyrics();
|
|
1946
1947
|
* ```
|
|
1947
1948
|
*/
|
|
1948
|
-
subscribe: async (guildId) => {
|
|
1949
|
+
subscribe: async (guildId, skipTrackSource) => {
|
|
1949
1950
|
if (!this.sessionId) throw new Error("the Lavalink-Node is either not ready, or not up to date!");
|
|
1950
1951
|
if (this._checkForPlugins && !this.info?.plugins?.find?.((v) => v.name === "lavalyrics-plugin"))
|
|
1951
1952
|
throw new RangeError(
|
|
1952
1953
|
`there is no lavalyrics-plugin available in the lavalink node (required for lyrics): ${this.id}`
|
|
1953
1954
|
);
|
|
1954
|
-
return await this.request(
|
|
1955
|
-
|
|
1956
|
-
|
|
1955
|
+
return await this.request(
|
|
1956
|
+
`/sessions/${this.sessionId}/players/${guildId}/lyrics/subscribe?skipTrackSource=${skipTrackSource ?? false}`,
|
|
1957
|
+
(options) => {
|
|
1958
|
+
options.method = "POST";
|
|
1959
|
+
}
|
|
1960
|
+
);
|
|
1957
1961
|
},
|
|
1958
1962
|
/**
|
|
1959
1963
|
* unsubscribe from lyrics updates for a guild
|
|
@@ -5326,6 +5330,15 @@ var Player = class {
|
|
|
5326
5330
|
get(key) {
|
|
5327
5331
|
return this.data[key];
|
|
5328
5332
|
}
|
|
5333
|
+
/**
|
|
5334
|
+
* Delete specific custom data.
|
|
5335
|
+
* @param key
|
|
5336
|
+
*/
|
|
5337
|
+
deleteData(key) {
|
|
5338
|
+
if (key.startsWith("internal_")) return this;
|
|
5339
|
+
delete this.data[key];
|
|
5340
|
+
return this;
|
|
5341
|
+
}
|
|
5329
5342
|
/**
|
|
5330
5343
|
* CLears all the custom data.
|
|
5331
5344
|
*/
|
|
@@ -5851,15 +5864,16 @@ var Player = class {
|
|
|
5851
5864
|
return await this.node.lyrics.get(track, skipTrackSource);
|
|
5852
5865
|
}
|
|
5853
5866
|
/**
|
|
5854
|
-
* Subscribe to the lyrics event on a specific guild to active live lyrics events
|
|
5867
|
+
* Subscribe to the lyrics event on a specific guild to active live lyrics events}
|
|
5868
|
+
* @param skipTrackSource If true, it will not try to get the lyrics from the track source
|
|
5855
5869
|
* @returns The unsubscribe function
|
|
5856
5870
|
* @example
|
|
5857
5871
|
* ```ts
|
|
5858
5872
|
* const lyrics = await player.subscribeLyrics();
|
|
5859
5873
|
* ```
|
|
5860
5874
|
*/
|
|
5861
|
-
subscribeLyrics() {
|
|
5862
|
-
return this.node.lyrics.subscribe(this.guildId);
|
|
5875
|
+
subscribeLyrics(skipTrackSource) {
|
|
5876
|
+
return this.node.lyrics.subscribe(this.guildId, skipTrackSource);
|
|
5863
5877
|
}
|
|
5864
5878
|
/**
|
|
5865
5879
|
* Unsubscribe from the lyrics event on a specific guild to disable live lyrics events
|
|
@@ -6046,7 +6060,7 @@ var Player = class {
|
|
|
6046
6060
|
};
|
|
6047
6061
|
|
|
6048
6062
|
// src/structures/LavalinkManager.ts
|
|
6049
|
-
var LavalinkManager = class extends EventEmitter2 {
|
|
6063
|
+
var LavalinkManager = class _LavalinkManager extends EventEmitter2 {
|
|
6050
6064
|
/**
|
|
6051
6065
|
* Emit an event
|
|
6052
6066
|
* @param event The event to emit
|
|
@@ -6215,6 +6229,17 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6215
6229
|
if (!this.options?.advancedOptions?.enableDebugEvents) return;
|
|
6216
6230
|
this.emit("debug", name, eventData);
|
|
6217
6231
|
}
|
|
6232
|
+
static _noAudioDebugPrefix = "Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, ";
|
|
6233
|
+
/**
|
|
6234
|
+
* Emits NoAudioDebug and optionally logs to console when debugOptions.noAudio is enabled.
|
|
6235
|
+
*/
|
|
6236
|
+
_debugNoAudio(state, functionLayer, messages, ...consoleArgs) {
|
|
6237
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, { state, functionLayer, message: messages.message });
|
|
6238
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) {
|
|
6239
|
+
const consoleMsg = messages.consoleMessage ?? messages.message;
|
|
6240
|
+
console.debug(_LavalinkManager._noAudioDebugPrefix + consoleMsg, ...consoleArgs);
|
|
6241
|
+
}
|
|
6242
|
+
}
|
|
6218
6243
|
/**
|
|
6219
6244
|
* Create the Lavalink Manager
|
|
6220
6245
|
* @param options
|
|
@@ -6446,28 +6471,22 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6446
6471
|
*/
|
|
6447
6472
|
async sendRawData(data) {
|
|
6448
6473
|
if (!this.initiated) {
|
|
6449
|
-
this.
|
|
6450
|
-
state: "log",
|
|
6474
|
+
this._debugNoAudio("log", "LavalinkManager > sendRawData()", {
|
|
6451
6475
|
message: "Manager is not initated yet",
|
|
6452
|
-
|
|
6476
|
+
consoleMessage: "manager is not initated yet"
|
|
6453
6477
|
});
|
|
6454
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6455
|
-
console.debug(
|
|
6456
|
-
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, manager is not initated yet"
|
|
6457
|
-
);
|
|
6458
6478
|
return;
|
|
6459
6479
|
}
|
|
6460
6480
|
if (!("t" in data)) {
|
|
6461
|
-
this.
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
);
|
|
6481
|
+
this._debugNoAudio(
|
|
6482
|
+
"error",
|
|
6483
|
+
"LavalinkManager > sendRawData()",
|
|
6484
|
+
{
|
|
6485
|
+
message: "No 't' in payload-data of the raw event:",
|
|
6486
|
+
consoleMessage: "no 't' in payload-data of the raw event:"
|
|
6487
|
+
},
|
|
6488
|
+
data
|
|
6489
|
+
);
|
|
6471
6490
|
return;
|
|
6472
6491
|
}
|
|
6473
6492
|
if ("CHANNEL_DELETE" === data.t) {
|
|
@@ -6480,132 +6499,94 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6480
6499
|
if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
|
|
6481
6500
|
const update = "d" in data ? data.d : data;
|
|
6482
6501
|
if (!update) {
|
|
6483
|
-
this.
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
);
|
|
6502
|
+
this._debugNoAudio(
|
|
6503
|
+
"warn",
|
|
6504
|
+
"LavalinkManager > sendRawData()",
|
|
6505
|
+
{
|
|
6506
|
+
message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
|
|
6507
|
+
consoleMessage: "no update data found in payload:"
|
|
6508
|
+
},
|
|
6509
|
+
data
|
|
6510
|
+
);
|
|
6493
6511
|
return;
|
|
6494
6512
|
}
|
|
6495
6513
|
if (!("token" in update) && !("session_id" in update)) {
|
|
6496
|
-
this.
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
);
|
|
6514
|
+
this._debugNoAudio(
|
|
6515
|
+
"error",
|
|
6516
|
+
"LavalinkManager > sendRawData()",
|
|
6517
|
+
{
|
|
6518
|
+
message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
|
|
6519
|
+
consoleMessage: "no 'token' nor 'session_id' found in payload:"
|
|
6520
|
+
},
|
|
6521
|
+
data
|
|
6522
|
+
);
|
|
6506
6523
|
return;
|
|
6507
6524
|
}
|
|
6508
6525
|
const player = this.getPlayer(update.guild_id);
|
|
6509
6526
|
if (!player) {
|
|
6510
|
-
this.
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
);
|
|
6527
|
+
this._debugNoAudio(
|
|
6528
|
+
"warn",
|
|
6529
|
+
"LavalinkManager > sendRawData()",
|
|
6530
|
+
{
|
|
6531
|
+
message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
|
|
6532
|
+
consoleMessage: "No Lavalink Player found via key: 'guild_id' of update-data:"
|
|
6533
|
+
},
|
|
6534
|
+
update
|
|
6535
|
+
);
|
|
6520
6536
|
return;
|
|
6521
6537
|
}
|
|
6522
6538
|
if (player.get("internal_destroystatus") === true) {
|
|
6523
|
-
this.
|
|
6524
|
-
|
|
6525
|
-
message: `Player is in a destroying state. can't signal the voice states`,
|
|
6526
|
-
functionLayer: "LavalinkManager > sendRawData()"
|
|
6539
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6540
|
+
message: "Player is in a destroying state. can't signal the voice states"
|
|
6527
6541
|
});
|
|
6528
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6529
|
-
console.debug(
|
|
6530
|
-
"Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Player is in a destroying state. can't signal the voice states"
|
|
6531
|
-
);
|
|
6532
6542
|
return;
|
|
6533
6543
|
}
|
|
6534
6544
|
if ("token" in update) {
|
|
6535
6545
|
if (!player.node?.sessionId) throw new Error("Lavalink Node is either not ready or not up to date");
|
|
6536
6546
|
const sessionId2Use = player.voice?.sessionId || ("sessionId" in update ? update.sessionId : void 0);
|
|
6537
6547
|
const channelId2Use = player.voice?.channelId || ("channel_id" in update ? update.channel_id : void 0);
|
|
6548
|
+
const voiceData = {
|
|
6549
|
+
token: update.token,
|
|
6550
|
+
endpoint: update.endpoint,
|
|
6551
|
+
sessionId: sessionId2Use,
|
|
6552
|
+
channelId: channelId2Use
|
|
6553
|
+
};
|
|
6538
6554
|
if (!sessionId2Use) {
|
|
6539
|
-
this.
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
voice: {
|
|
6549
|
-
token: update.token,
|
|
6550
|
-
endpoint: update.endpoint,
|
|
6551
|
-
sessionId: sessionId2Use,
|
|
6552
|
-
channelId: channelId2Use
|
|
6553
|
-
},
|
|
6554
|
-
update,
|
|
6555
|
-
playerVoice: player.voice
|
|
6556
|
-
}
|
|
6557
|
-
);
|
|
6555
|
+
this._debugNoAudio(
|
|
6556
|
+
"error",
|
|
6557
|
+
"LavalinkManager > sendRawData()",
|
|
6558
|
+
{
|
|
6559
|
+
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6560
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing sessionId"
|
|
6561
|
+
},
|
|
6562
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6563
|
+
);
|
|
6558
6564
|
} else if (!channelId2Use) {
|
|
6559
|
-
this.
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
voice: {
|
|
6569
|
-
token: update.token,
|
|
6570
|
-
endpoint: update.endpoint,
|
|
6571
|
-
sessionId: sessionId2Use,
|
|
6572
|
-
channelId: channelId2Use
|
|
6573
|
-
},
|
|
6574
|
-
update,
|
|
6575
|
-
playerVoice: player.voice
|
|
6576
|
-
}
|
|
6577
|
-
);
|
|
6565
|
+
this._debugNoAudio(
|
|
6566
|
+
"error",
|
|
6567
|
+
"LavalinkManager > sendRawData()",
|
|
6568
|
+
{
|
|
6569
|
+
message: `Can't send updatePlayer for voice token session - Missing channelId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6570
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing channelId"
|
|
6571
|
+
},
|
|
6572
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6573
|
+
);
|
|
6578
6574
|
} else {
|
|
6579
6575
|
await player.node.updatePlayer({
|
|
6580
6576
|
guildId: player.guildId,
|
|
6581
6577
|
playerOptions: {
|
|
6582
|
-
voice:
|
|
6583
|
-
token: update.token,
|
|
6584
|
-
endpoint: update.endpoint,
|
|
6585
|
-
sessionId: sessionId2Use,
|
|
6586
|
-
channelId: channelId2Use
|
|
6587
|
-
}
|
|
6578
|
+
voice: voiceData
|
|
6588
6579
|
}
|
|
6589
6580
|
});
|
|
6590
|
-
this.
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
voice: {
|
|
6600
|
-
token: update.token,
|
|
6601
|
-
endpoint: update.endpoint,
|
|
6602
|
-
sessionId: sessionId2Use,
|
|
6603
|
-
channelId: channelId2Use
|
|
6604
|
-
},
|
|
6605
|
-
playerVoice: player.voice,
|
|
6606
|
-
update
|
|
6607
|
-
}
|
|
6608
|
-
);
|
|
6581
|
+
this._debugNoAudio(
|
|
6582
|
+
"log",
|
|
6583
|
+
"LavalinkManager > sendRawData()",
|
|
6584
|
+
{
|
|
6585
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6586
|
+
consoleMessage: "Sent updatePlayer for voice token session"
|
|
6587
|
+
},
|
|
6588
|
+
{ voice: voiceData, playerVoice: player.voice, update }
|
|
6589
|
+
);
|
|
6609
6590
|
}
|
|
6610
6591
|
return;
|
|
6611
6592
|
}
|
|
@@ -6617,36 +6598,30 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6617
6598
|
update.user_id
|
|
6618
6599
|
);
|
|
6619
6600
|
}
|
|
6620
|
-
this.
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
);
|
|
6601
|
+
this._debugNoAudio(
|
|
6602
|
+
"warn",
|
|
6603
|
+
"LavalinkManager > sendRawData()",
|
|
6604
|
+
{
|
|
6605
|
+
message: `voice update user is not equal to provided client id of the LavalinkManager.options.client.id :: user: "${update.user_id}" manager client id: "${this.options?.client.id}"`,
|
|
6606
|
+
consoleMessage: "voice update user is not equal to provided client id of the manageroptions#client#id"
|
|
6607
|
+
},
|
|
6608
|
+
"user:",
|
|
6609
|
+
update.user_id,
|
|
6610
|
+
"manager client id:",
|
|
6611
|
+
this.options?.client.id
|
|
6612
|
+
);
|
|
6633
6613
|
return;
|
|
6634
6614
|
}
|
|
6635
6615
|
if (update.channel_id) {
|
|
6636
6616
|
if (player.voiceChannelId !== update.channel_id)
|
|
6637
6617
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
6638
6618
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
6639
|
-
player.voice.channelId = update.channel_id;
|
|
6619
|
+
player.voice.channelId = update.channel_id || player.voice.channelId;
|
|
6640
6620
|
if (!player.voice.sessionId) {
|
|
6641
|
-
this.
|
|
6642
|
-
state: "warn",
|
|
6621
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6643
6622
|
message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
|
|
6644
|
-
|
|
6623
|
+
consoleMessage: `Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`
|
|
6645
6624
|
});
|
|
6646
|
-
if (this.options?.advancedOptions?.debugOptions?.noAudio === true)
|
|
6647
|
-
console.debug(
|
|
6648
|
-
`Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`
|
|
6649
|
-
);
|
|
6650
6625
|
}
|
|
6651
6626
|
player.voiceChannelId = update.channel_id;
|
|
6652
6627
|
player.options.voiceChannelId = update.channel_id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lavalink-client",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.7",
|
|
4
4
|
"description": "Easy, flexible and feature-rich lavalink@v4 Client. Both for Beginners and Proficients. - Supports NodeLink@v3 too.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advanced",
|
|
@@ -39,8 +39,10 @@
|
|
|
39
39
|
"exports": {
|
|
40
40
|
".": {
|
|
41
41
|
"types": "./dist/index.d.ts",
|
|
42
|
+
"bun": "./dist/index.mjs",
|
|
42
43
|
"require": "./dist/index.cjs",
|
|
43
|
-
"import": "./dist/index.mjs"
|
|
44
|
+
"import": "./dist/index.mjs",
|
|
45
|
+
"default": "./dist/index.mjs"
|
|
44
46
|
}
|
|
45
47
|
},
|
|
46
48
|
"publishConfig": {
|