lavalink-client 2.9.4 → 2.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6772 -0
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +116 -220
- package/dist/index.mjs +101 -140
- package/package.json +5 -4
package/dist/index.mjs
CHANGED
|
@@ -6046,7 +6046,7 @@ var Player = class {
|
|
|
6046
6046
|
};
|
|
6047
6047
|
|
|
6048
6048
|
// src/structures/LavalinkManager.ts
|
|
6049
|
-
var LavalinkManager = class extends EventEmitter2 {
|
|
6049
|
+
var LavalinkManager = class _LavalinkManager extends EventEmitter2 {
|
|
6050
6050
|
/**
|
|
6051
6051
|
* Emit an event
|
|
6052
6052
|
* @param event The event to emit
|
|
@@ -6215,6 +6215,17 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6215
6215
|
if (!this.options?.advancedOptions?.enableDebugEvents) return;
|
|
6216
6216
|
this.emit("debug", name, eventData);
|
|
6217
6217
|
}
|
|
6218
|
+
static _noAudioDebugPrefix = "Lavalink-Client-Debug | NO-AUDIO [::] sendRawData function, ";
|
|
6219
|
+
/**
|
|
6220
|
+
* Emits NoAudioDebug and optionally logs to console when debugOptions.noAudio is enabled.
|
|
6221
|
+
*/
|
|
6222
|
+
_debugNoAudio(state, functionLayer, messages, ...consoleArgs) {
|
|
6223
|
+
this._emitDebugEvent("NoAudioDebug" /* NoAudioDebug */, { state, functionLayer, message: messages.message });
|
|
6224
|
+
if (this.options?.advancedOptions?.debugOptions?.noAudio === true) {
|
|
6225
|
+
const consoleMsg = messages.consoleMessage ?? messages.message;
|
|
6226
|
+
console.debug(_LavalinkManager._noAudioDebugPrefix + consoleMsg, ...consoleArgs);
|
|
6227
|
+
}
|
|
6228
|
+
}
|
|
6218
6229
|
/**
|
|
6219
6230
|
* Create the Lavalink Manager
|
|
6220
6231
|
* @param options
|
|
@@ -6446,28 +6457,22 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6446
6457
|
*/
|
|
6447
6458
|
async sendRawData(data) {
|
|
6448
6459
|
if (!this.initiated) {
|
|
6449
|
-
this.
|
|
6450
|
-
state: "log",
|
|
6460
|
+
this._debugNoAudio("log", "LavalinkManager > sendRawData()", {
|
|
6451
6461
|
message: "Manager is not initated yet",
|
|
6452
|
-
|
|
6462
|
+
consoleMessage: "manager is not initated yet"
|
|
6453
6463
|
});
|
|
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
6464
|
return;
|
|
6459
6465
|
}
|
|
6460
6466
|
if (!("t" in data)) {
|
|
6461
|
-
this.
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
);
|
|
6467
|
+
this._debugNoAudio(
|
|
6468
|
+
"error",
|
|
6469
|
+
"LavalinkManager > sendRawData()",
|
|
6470
|
+
{
|
|
6471
|
+
message: "No 't' in payload-data of the raw event:",
|
|
6472
|
+
consoleMessage: "no 't' in payload-data of the raw event:"
|
|
6473
|
+
},
|
|
6474
|
+
data
|
|
6475
|
+
);
|
|
6471
6476
|
return;
|
|
6472
6477
|
}
|
|
6473
6478
|
if ("CHANNEL_DELETE" === data.t) {
|
|
@@ -6480,132 +6485,94 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6480
6485
|
if (["VOICE_STATE_UPDATE", "VOICE_SERVER_UPDATE"].includes(data.t)) {
|
|
6481
6486
|
const update = "d" in data ? data.d : data;
|
|
6482
6487
|
if (!update) {
|
|
6483
|
-
this.
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
);
|
|
6488
|
+
this._debugNoAudio(
|
|
6489
|
+
"warn",
|
|
6490
|
+
"LavalinkManager > sendRawData()",
|
|
6491
|
+
{
|
|
6492
|
+
message: `No Update data found in payload :: ${safeStringify(data, 2)}`,
|
|
6493
|
+
consoleMessage: "no update data found in payload:"
|
|
6494
|
+
},
|
|
6495
|
+
data
|
|
6496
|
+
);
|
|
6493
6497
|
return;
|
|
6494
6498
|
}
|
|
6495
6499
|
if (!("token" in update) && !("session_id" in update)) {
|
|
6496
|
-
this.
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
);
|
|
6500
|
+
this._debugNoAudio(
|
|
6501
|
+
"error",
|
|
6502
|
+
"LavalinkManager > sendRawData()",
|
|
6503
|
+
{
|
|
6504
|
+
message: `No 'token' nor 'session_id' found in payload :: ${safeStringify(data, 2)}`,
|
|
6505
|
+
consoleMessage: "no 'token' nor 'session_id' found in payload:"
|
|
6506
|
+
},
|
|
6507
|
+
data
|
|
6508
|
+
);
|
|
6506
6509
|
return;
|
|
6507
6510
|
}
|
|
6508
6511
|
const player = this.getPlayer(update.guild_id);
|
|
6509
6512
|
if (!player) {
|
|
6510
|
-
this.
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
);
|
|
6513
|
+
this._debugNoAudio(
|
|
6514
|
+
"warn",
|
|
6515
|
+
"LavalinkManager > sendRawData()",
|
|
6516
|
+
{
|
|
6517
|
+
message: `No Lavalink Player found via key: 'guild_id' of update-data :: ${safeStringify(update, 2)}`,
|
|
6518
|
+
consoleMessage: "No Lavalink Player found via key: 'guild_id' of update-data:"
|
|
6519
|
+
},
|
|
6520
|
+
update
|
|
6521
|
+
);
|
|
6520
6522
|
return;
|
|
6521
6523
|
}
|
|
6522
6524
|
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()"
|
|
6525
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6526
|
+
message: "Player is in a destroying state. can't signal the voice states"
|
|
6527
6527
|
});
|
|
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
6528
|
return;
|
|
6533
6529
|
}
|
|
6534
6530
|
if ("token" in update) {
|
|
6535
6531
|
if (!player.node?.sessionId) throw new Error("Lavalink Node is either not ready or not up to date");
|
|
6536
6532
|
const sessionId2Use = player.voice?.sessionId || ("sessionId" in update ? update.sessionId : void 0);
|
|
6537
6533
|
const channelId2Use = player.voice?.channelId || ("channel_id" in update ? update.channel_id : void 0);
|
|
6534
|
+
const voiceData = {
|
|
6535
|
+
token: update.token,
|
|
6536
|
+
endpoint: update.endpoint,
|
|
6537
|
+
sessionId: sessionId2Use,
|
|
6538
|
+
channelId: channelId2Use
|
|
6539
|
+
};
|
|
6538
6540
|
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
|
-
);
|
|
6541
|
+
this._debugNoAudio(
|
|
6542
|
+
"error",
|
|
6543
|
+
"LavalinkManager > sendRawData()",
|
|
6544
|
+
{
|
|
6545
|
+
message: `Can't send updatePlayer for voice token session - Missing sessionId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6546
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing sessionId"
|
|
6547
|
+
},
|
|
6548
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6549
|
+
);
|
|
6558
6550
|
} 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
|
-
);
|
|
6551
|
+
this._debugNoAudio(
|
|
6552
|
+
"error",
|
|
6553
|
+
"LavalinkManager > sendRawData()",
|
|
6554
|
+
{
|
|
6555
|
+
message: `Can't send updatePlayer for voice token session - Missing channelId :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6556
|
+
consoleMessage: "Can't send updatePlayer for voice token session - Missing channelId"
|
|
6557
|
+
},
|
|
6558
|
+
{ voice: voiceData, update, playerVoice: player.voice }
|
|
6559
|
+
);
|
|
6578
6560
|
} else {
|
|
6579
6561
|
await player.node.updatePlayer({
|
|
6580
6562
|
guildId: player.guildId,
|
|
6581
6563
|
playerOptions: {
|
|
6582
|
-
voice:
|
|
6583
|
-
token: update.token,
|
|
6584
|
-
endpoint: update.endpoint,
|
|
6585
|
-
sessionId: sessionId2Use,
|
|
6586
|
-
channelId: channelId2Use
|
|
6587
|
-
}
|
|
6564
|
+
voice: voiceData
|
|
6588
6565
|
}
|
|
6589
6566
|
});
|
|
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
|
-
);
|
|
6567
|
+
this._debugNoAudio(
|
|
6568
|
+
"log",
|
|
6569
|
+
"LavalinkManager > sendRawData()",
|
|
6570
|
+
{
|
|
6571
|
+
message: `Sent updatePlayer for voice token session :: ${safeStringify({ voice: voiceData, update, playerVoice: player.voice }, 2)}`,
|
|
6572
|
+
consoleMessage: "Sent updatePlayer for voice token session"
|
|
6573
|
+
},
|
|
6574
|
+
{ voice: voiceData, playerVoice: player.voice, update }
|
|
6575
|
+
);
|
|
6609
6576
|
}
|
|
6610
6577
|
return;
|
|
6611
6578
|
}
|
|
@@ -6617,36 +6584,30 @@ var LavalinkManager = class extends EventEmitter2 {
|
|
|
6617
6584
|
update.user_id
|
|
6618
6585
|
);
|
|
6619
6586
|
}
|
|
6620
|
-
this.
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
|
|
6626
|
-
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
);
|
|
6587
|
+
this._debugNoAudio(
|
|
6588
|
+
"warn",
|
|
6589
|
+
"LavalinkManager > sendRawData()",
|
|
6590
|
+
{
|
|
6591
|
+
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}"`,
|
|
6592
|
+
consoleMessage: "voice update user is not equal to provided client id of the manageroptions#client#id"
|
|
6593
|
+
},
|
|
6594
|
+
"user:",
|
|
6595
|
+
update.user_id,
|
|
6596
|
+
"manager client id:",
|
|
6597
|
+
this.options?.client.id
|
|
6598
|
+
);
|
|
6633
6599
|
return;
|
|
6634
6600
|
}
|
|
6635
6601
|
if (update.channel_id) {
|
|
6636
6602
|
if (player.voiceChannelId !== update.channel_id)
|
|
6637
6603
|
this.emit("playerMove", player, player.voiceChannelId, update.channel_id);
|
|
6638
6604
|
player.voice.sessionId = update.session_id || player.voice.sessionId;
|
|
6639
|
-
player.voice.channelId = update.channel_id;
|
|
6605
|
+
player.voice.channelId = update.channel_id || player.voice.channelId;
|
|
6640
6606
|
if (!player.voice.sessionId) {
|
|
6641
|
-
this.
|
|
6642
|
-
state: "warn",
|
|
6607
|
+
this._debugNoAudio("warn", "LavalinkManager > sendRawData()", {
|
|
6643
6608
|
message: `Function to assing sessionId provided, but no found in Payload: ${safeStringify({ update, playerVoice: player.voice }, 2)}`,
|
|
6644
|
-
|
|
6609
|
+
consoleMessage: `Function to assing sessionId provided, but no found in Payload: ${safeStringify(update, 2)}`
|
|
6645
6610
|
});
|
|
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
6611
|
}
|
|
6651
6612
|
player.voiceChannelId = update.channel_id;
|
|
6652
6613
|
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.6",
|
|
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",
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"type": "module",
|
|
36
|
-
"main": "./dist/index.
|
|
36
|
+
"main": "./dist/index.cjs",
|
|
37
37
|
"module": "./dist/index.mjs",
|
|
38
38
|
"types": "./dist/index.d.ts",
|
|
39
39
|
"exports": {
|
|
40
40
|
".": {
|
|
41
41
|
"types": "./dist/index.d.ts",
|
|
42
|
-
"
|
|
42
|
+
"bun": "./dist/index.mjs",
|
|
43
|
+
"require": "./dist/index.cjs",
|
|
43
44
|
"import": "./dist/index.mjs",
|
|
44
|
-
"default": "./dist/index.
|
|
45
|
+
"default": "./dist/index.mjs"
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
48
|
"publishConfig": {
|