lavalink-client 2.9.8 → 2.9.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/dist/index.cjs +36 -5
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +36 -5
- package/dist/index.mjs +36 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -589,11 +589,12 @@ var QueueSymbol = /* @__PURE__ */ Symbol("LC-Queue");
|
|
|
589
589
|
var NodeSymbol = /* @__PURE__ */ Symbol("LC-Node");
|
|
590
590
|
var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
591
591
|
function parseLavalinkConnUrl(connectionUrl) {
|
|
592
|
-
if (!connectionUrl.startsWith("lavalink://"))
|
|
593
|
-
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://'`);
|
|
592
|
+
if (!connectionUrl.startsWith("lavalink://") && !connectionUrl.startsWith("nodelink://"))
|
|
593
|
+
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://' or 'nodelink://'`);
|
|
594
594
|
const parsed = new import_node_url.URL(connectionUrl);
|
|
595
595
|
return {
|
|
596
596
|
authorization: parsed.password,
|
|
597
|
+
nodeType: connectionUrl.startsWith("lavalink://") ? "Lavalink" : "NodeLink",
|
|
597
598
|
id: parsed.username,
|
|
598
599
|
host: parsed.hostname,
|
|
599
600
|
port: Number(parsed.port)
|
|
@@ -3137,6 +3138,36 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3137
3138
|
}
|
|
3138
3139
|
this.nodeType = "NodeLink";
|
|
3139
3140
|
}
|
|
3141
|
+
/**
|
|
3142
|
+
* Uses the gapless feature to set the next track to be played.
|
|
3143
|
+
* @param player current player
|
|
3144
|
+
* @param track if no track provided, it will use the next track from queue
|
|
3145
|
+
*/
|
|
3146
|
+
async setNextTrackGapLess(player, track) {
|
|
3147
|
+
if (!this.sessionId) throw new Error("The Lavalink Node is either not ready, or not up to date!");
|
|
3148
|
+
const nextTrack = track || player.queue.tracks[0];
|
|
3149
|
+
if (!nextTrack) throw new Error("No track provided");
|
|
3150
|
+
await this.updatePlayer({
|
|
3151
|
+
guildId: player.guildId,
|
|
3152
|
+
// @ts-expect-error - nextTrack is not a valid property of LavalinkPlayOptions but for NodeLink it is
|
|
3153
|
+
playerOptions: { nextTrack: { encoded: nextTrack.encoded, userData: nextTrack.userData || {} } }
|
|
3154
|
+
});
|
|
3155
|
+
return true;
|
|
3156
|
+
}
|
|
3157
|
+
/**
|
|
3158
|
+
* Retrieves the meaning of a track.
|
|
3159
|
+
* @param track
|
|
3160
|
+
* @returns {MeaningResponse}
|
|
3161
|
+
* @link {https://nodelink.js.org/docs/api/nodelink-features#meaning-system}
|
|
3162
|
+
*/
|
|
3163
|
+
async getMeaning(track) {
|
|
3164
|
+
if (!this.sessionId) throw new Error("The Lavalink Node is either not ready, or not up to date!");
|
|
3165
|
+
const encodedTrack = track?.encoded;
|
|
3166
|
+
if (!encodedTrack) throw new Error("No track provided");
|
|
3167
|
+
return await this.request(`/meaning?encodedTrack=${encodedTrack}`, (m) => {
|
|
3168
|
+
m.method = "GET";
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3140
3171
|
/**
|
|
3141
3172
|
* Adds a new audio track to be mixed over the current playback.
|
|
3142
3173
|
* @param player The player to add the mixer layer to.
|
|
@@ -3154,7 +3185,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3154
3185
|
//identifier: trackToAdd.info?.identifier, // atm not supported
|
|
3155
3186
|
userData: trackToAdd.userData
|
|
3156
3187
|
},
|
|
3157
|
-
volume:
|
|
3188
|
+
volume: volume / 100
|
|
3158
3189
|
});
|
|
3159
3190
|
});
|
|
3160
3191
|
}
|
|
@@ -3181,7 +3212,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3181
3212
|
await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/mix/${mixId}`, (m) => {
|
|
3182
3213
|
m.method = "PATCH";
|
|
3183
3214
|
m.body = safeStringify({
|
|
3184
|
-
volume:
|
|
3215
|
+
volume: volume / 100
|
|
3185
3216
|
});
|
|
3186
3217
|
});
|
|
3187
3218
|
return true;
|
|
@@ -3353,7 +3384,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3353
3384
|
*/
|
|
3354
3385
|
async loadDirectStream(track, volume, position, filters) {
|
|
3355
3386
|
let requestPath = `/loadstream?encodedTrack=${track.encoded}`;
|
|
3356
|
-
if (volume && volume > 0 && volume <= 100) requestPath += `&volume=${
|
|
3387
|
+
if (volume && volume > 0 && volume <= 100) requestPath += `&volume=${volume / 100}`;
|
|
3357
3388
|
if (position && position > 0) requestPath += `&position=${position}`;
|
|
3358
3389
|
if (filters) requestPath += `&filters=${typeof filters === "object" ? safeStringify(filters) : filters}`;
|
|
3359
3390
|
const res = await this.rawRequest(requestPath, (m) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -404,12 +404,13 @@ declare const UnresolvedTrackSymbol: unique symbol;
|
|
|
404
404
|
declare const QueueSymbol: unique symbol;
|
|
405
405
|
declare const NodeSymbol: unique symbol;
|
|
406
406
|
/**
|
|
407
|
-
* Parses Node Connection Url: "lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>"
|
|
407
|
+
* Parses Node Connection Url: "lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>" or "nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>"
|
|
408
408
|
* @param connectionUrl
|
|
409
409
|
* @returns
|
|
410
410
|
*/
|
|
411
411
|
declare function parseLavalinkConnUrl(connectionUrl: string): {
|
|
412
412
|
authorization: string;
|
|
413
|
+
nodeType: NodeTypes;
|
|
413
414
|
id: string;
|
|
414
415
|
host: string;
|
|
415
416
|
port: number;
|
|
@@ -1513,6 +1514,17 @@ type YoutubeOAuthResponse = {
|
|
|
1513
1514
|
scope: string;
|
|
1514
1515
|
token_type: string;
|
|
1515
1516
|
};
|
|
1517
|
+
type MeaningResponse = {
|
|
1518
|
+
loadType: "meaning";
|
|
1519
|
+
data: {
|
|
1520
|
+
title: string;
|
|
1521
|
+
description: string;
|
|
1522
|
+
paragraphs: string[];
|
|
1523
|
+
url: string;
|
|
1524
|
+
provider: string;
|
|
1525
|
+
type: string;
|
|
1526
|
+
};
|
|
1527
|
+
};
|
|
1516
1528
|
|
|
1517
1529
|
/** Ability to manipulate fetch requests */
|
|
1518
1530
|
type ModifyRequest = (options: RequestInit & {
|
|
@@ -2881,6 +2893,19 @@ declare class Player {
|
|
|
2881
2893
|
declare class NodeLinkNode extends LavalinkNode {
|
|
2882
2894
|
nodeType: "NodeLink";
|
|
2883
2895
|
constructor(options: LavalinkNodeOptions, manager: NodeManager);
|
|
2896
|
+
/**
|
|
2897
|
+
* Uses the gapless feature to set the next track to be played.
|
|
2898
|
+
* @param player current player
|
|
2899
|
+
* @param track if no track provided, it will use the next track from queue
|
|
2900
|
+
*/
|
|
2901
|
+
setNextTrackGapLess(player: Player, track?: Track | UnresolvedTrack): Promise<boolean>;
|
|
2902
|
+
/**
|
|
2903
|
+
* Retrieves the meaning of a track.
|
|
2904
|
+
* @param track
|
|
2905
|
+
* @returns {MeaningResponse}
|
|
2906
|
+
* @link {https://nodelink.js.org/docs/api/nodelink-features#meaning-system}
|
|
2907
|
+
*/
|
|
2908
|
+
getMeaning(track?: Track | UnresolvedTrack): Promise<MeaningResponse>;
|
|
2884
2909
|
/**
|
|
2885
2910
|
* Adds a new audio track to be mixed over the current playback.
|
|
2886
2911
|
* @param player The player to add the mixer layer to.
|
package/dist/index.d.ts
CHANGED
|
@@ -404,12 +404,13 @@ declare const UnresolvedTrackSymbol: unique symbol;
|
|
|
404
404
|
declare const QueueSymbol: unique symbol;
|
|
405
405
|
declare const NodeSymbol: unique symbol;
|
|
406
406
|
/**
|
|
407
|
-
* Parses Node Connection Url: "lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>"
|
|
407
|
+
* Parses Node Connection Url: "lavalink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>" or "nodelink://<nodeId>:<nodeAuthorization(Password)>@<NodeHost>:<NodePort>"
|
|
408
408
|
* @param connectionUrl
|
|
409
409
|
* @returns
|
|
410
410
|
*/
|
|
411
411
|
declare function parseLavalinkConnUrl(connectionUrl: string): {
|
|
412
412
|
authorization: string;
|
|
413
|
+
nodeType: NodeTypes;
|
|
413
414
|
id: string;
|
|
414
415
|
host: string;
|
|
415
416
|
port: number;
|
|
@@ -1513,6 +1514,17 @@ type YoutubeOAuthResponse = {
|
|
|
1513
1514
|
scope: string;
|
|
1514
1515
|
token_type: string;
|
|
1515
1516
|
};
|
|
1517
|
+
type MeaningResponse = {
|
|
1518
|
+
loadType: "meaning";
|
|
1519
|
+
data: {
|
|
1520
|
+
title: string;
|
|
1521
|
+
description: string;
|
|
1522
|
+
paragraphs: string[];
|
|
1523
|
+
url: string;
|
|
1524
|
+
provider: string;
|
|
1525
|
+
type: string;
|
|
1526
|
+
};
|
|
1527
|
+
};
|
|
1516
1528
|
|
|
1517
1529
|
/** Ability to manipulate fetch requests */
|
|
1518
1530
|
type ModifyRequest = (options: RequestInit & {
|
|
@@ -2881,6 +2893,19 @@ declare class Player {
|
|
|
2881
2893
|
declare class NodeLinkNode extends LavalinkNode {
|
|
2882
2894
|
nodeType: "NodeLink";
|
|
2883
2895
|
constructor(options: LavalinkNodeOptions, manager: NodeManager);
|
|
2896
|
+
/**
|
|
2897
|
+
* Uses the gapless feature to set the next track to be played.
|
|
2898
|
+
* @param player current player
|
|
2899
|
+
* @param track if no track provided, it will use the next track from queue
|
|
2900
|
+
*/
|
|
2901
|
+
setNextTrackGapLess(player: Player, track?: Track | UnresolvedTrack): Promise<boolean>;
|
|
2902
|
+
/**
|
|
2903
|
+
* Retrieves the meaning of a track.
|
|
2904
|
+
* @param track
|
|
2905
|
+
* @returns {MeaningResponse}
|
|
2906
|
+
* @link {https://nodelink.js.org/docs/api/nodelink-features#meaning-system}
|
|
2907
|
+
*/
|
|
2908
|
+
getMeaning(track?: Track | UnresolvedTrack): Promise<MeaningResponse>;
|
|
2884
2909
|
/**
|
|
2885
2910
|
* Adds a new audio track to be mixed over the current playback.
|
|
2886
2911
|
* @param player The player to add the mixer layer to.
|
package/dist/index.js
CHANGED
|
@@ -525,11 +525,12 @@ var QueueSymbol = /* @__PURE__ */ Symbol("LC-Queue");
|
|
|
525
525
|
var NodeSymbol = /* @__PURE__ */ Symbol("LC-Node");
|
|
526
526
|
var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
527
527
|
function parseLavalinkConnUrl(connectionUrl) {
|
|
528
|
-
if (!connectionUrl.startsWith("lavalink://"))
|
|
529
|
-
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://'`);
|
|
528
|
+
if (!connectionUrl.startsWith("lavalink://") && !connectionUrl.startsWith("nodelink://"))
|
|
529
|
+
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://' or 'nodelink://'`);
|
|
530
530
|
const parsed = new URL2(connectionUrl);
|
|
531
531
|
return {
|
|
532
532
|
authorization: parsed.password,
|
|
533
|
+
nodeType: connectionUrl.startsWith("lavalink://") ? "Lavalink" : "NodeLink",
|
|
533
534
|
id: parsed.username,
|
|
534
535
|
host: parsed.hostname,
|
|
535
536
|
port: Number(parsed.port)
|
|
@@ -3073,6 +3074,36 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3073
3074
|
}
|
|
3074
3075
|
this.nodeType = "NodeLink";
|
|
3075
3076
|
}
|
|
3077
|
+
/**
|
|
3078
|
+
* Uses the gapless feature to set the next track to be played.
|
|
3079
|
+
* @param player current player
|
|
3080
|
+
* @param track if no track provided, it will use the next track from queue
|
|
3081
|
+
*/
|
|
3082
|
+
async setNextTrackGapLess(player, track) {
|
|
3083
|
+
if (!this.sessionId) throw new Error("The Lavalink Node is either not ready, or not up to date!");
|
|
3084
|
+
const nextTrack = track || player.queue.tracks[0];
|
|
3085
|
+
if (!nextTrack) throw new Error("No track provided");
|
|
3086
|
+
await this.updatePlayer({
|
|
3087
|
+
guildId: player.guildId,
|
|
3088
|
+
// @ts-expect-error - nextTrack is not a valid property of LavalinkPlayOptions but for NodeLink it is
|
|
3089
|
+
playerOptions: { nextTrack: { encoded: nextTrack.encoded, userData: nextTrack.userData || {} } }
|
|
3090
|
+
});
|
|
3091
|
+
return true;
|
|
3092
|
+
}
|
|
3093
|
+
/**
|
|
3094
|
+
* Retrieves the meaning of a track.
|
|
3095
|
+
* @param track
|
|
3096
|
+
* @returns {MeaningResponse}
|
|
3097
|
+
* @link {https://nodelink.js.org/docs/api/nodelink-features#meaning-system}
|
|
3098
|
+
*/
|
|
3099
|
+
async getMeaning(track) {
|
|
3100
|
+
if (!this.sessionId) throw new Error("The Lavalink Node is either not ready, or not up to date!");
|
|
3101
|
+
const encodedTrack = track?.encoded;
|
|
3102
|
+
if (!encodedTrack) throw new Error("No track provided");
|
|
3103
|
+
return await this.request(`/meaning?encodedTrack=${encodedTrack}`, (m) => {
|
|
3104
|
+
m.method = "GET";
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3076
3107
|
/**
|
|
3077
3108
|
* Adds a new audio track to be mixed over the current playback.
|
|
3078
3109
|
* @param player The player to add the mixer layer to.
|
|
@@ -3090,7 +3121,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3090
3121
|
//identifier: trackToAdd.info?.identifier, // atm not supported
|
|
3091
3122
|
userData: trackToAdd.userData
|
|
3092
3123
|
},
|
|
3093
|
-
volume:
|
|
3124
|
+
volume: volume / 100
|
|
3094
3125
|
});
|
|
3095
3126
|
});
|
|
3096
3127
|
}
|
|
@@ -3117,7 +3148,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3117
3148
|
await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/mix/${mixId}`, (m) => {
|
|
3118
3149
|
m.method = "PATCH";
|
|
3119
3150
|
m.body = safeStringify({
|
|
3120
|
-
volume:
|
|
3151
|
+
volume: volume / 100
|
|
3121
3152
|
});
|
|
3122
3153
|
});
|
|
3123
3154
|
return true;
|
|
@@ -3289,7 +3320,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3289
3320
|
*/
|
|
3290
3321
|
async loadDirectStream(track, volume, position, filters) {
|
|
3291
3322
|
let requestPath = `/loadstream?encodedTrack=${track.encoded}`;
|
|
3292
|
-
if (volume && volume > 0 && volume <= 100) requestPath += `&volume=${
|
|
3323
|
+
if (volume && volume > 0 && volume <= 100) requestPath += `&volume=${volume / 100}`;
|
|
3293
3324
|
if (position && position > 0) requestPath += `&position=${position}`;
|
|
3294
3325
|
if (filters) requestPath += `&filters=${typeof filters === "object" ? safeStringify(filters) : filters}`;
|
|
3295
3326
|
const res = await this.rawRequest(requestPath, (m) => {
|
package/dist/index.mjs
CHANGED
|
@@ -525,11 +525,12 @@ var QueueSymbol = /* @__PURE__ */ Symbol("LC-Queue");
|
|
|
525
525
|
var NodeSymbol = /* @__PURE__ */ Symbol("LC-Node");
|
|
526
526
|
var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
527
527
|
function parseLavalinkConnUrl(connectionUrl) {
|
|
528
|
-
if (!connectionUrl.startsWith("lavalink://"))
|
|
529
|
-
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://'`);
|
|
528
|
+
if (!connectionUrl.startsWith("lavalink://") && !connectionUrl.startsWith("nodelink://"))
|
|
529
|
+
throw new Error(`ConnectionUrl (${connectionUrl}) must start with 'lavalink://' or 'nodelink://'`);
|
|
530
530
|
const parsed = new URL2(connectionUrl);
|
|
531
531
|
return {
|
|
532
532
|
authorization: parsed.password,
|
|
533
|
+
nodeType: connectionUrl.startsWith("lavalink://") ? "Lavalink" : "NodeLink",
|
|
533
534
|
id: parsed.username,
|
|
534
535
|
host: parsed.hostname,
|
|
535
536
|
port: Number(parsed.port)
|
|
@@ -3073,6 +3074,36 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3073
3074
|
}
|
|
3074
3075
|
this.nodeType = "NodeLink";
|
|
3075
3076
|
}
|
|
3077
|
+
/**
|
|
3078
|
+
* Uses the gapless feature to set the next track to be played.
|
|
3079
|
+
* @param player current player
|
|
3080
|
+
* @param track if no track provided, it will use the next track from queue
|
|
3081
|
+
*/
|
|
3082
|
+
async setNextTrackGapLess(player, track) {
|
|
3083
|
+
if (!this.sessionId) throw new Error("The Lavalink Node is either not ready, or not up to date!");
|
|
3084
|
+
const nextTrack = track || player.queue.tracks[0];
|
|
3085
|
+
if (!nextTrack) throw new Error("No track provided");
|
|
3086
|
+
await this.updatePlayer({
|
|
3087
|
+
guildId: player.guildId,
|
|
3088
|
+
// @ts-expect-error - nextTrack is not a valid property of LavalinkPlayOptions but for NodeLink it is
|
|
3089
|
+
playerOptions: { nextTrack: { encoded: nextTrack.encoded, userData: nextTrack.userData || {} } }
|
|
3090
|
+
});
|
|
3091
|
+
return true;
|
|
3092
|
+
}
|
|
3093
|
+
/**
|
|
3094
|
+
* Retrieves the meaning of a track.
|
|
3095
|
+
* @param track
|
|
3096
|
+
* @returns {MeaningResponse}
|
|
3097
|
+
* @link {https://nodelink.js.org/docs/api/nodelink-features#meaning-system}
|
|
3098
|
+
*/
|
|
3099
|
+
async getMeaning(track) {
|
|
3100
|
+
if (!this.sessionId) throw new Error("The Lavalink Node is either not ready, or not up to date!");
|
|
3101
|
+
const encodedTrack = track?.encoded;
|
|
3102
|
+
if (!encodedTrack) throw new Error("No track provided");
|
|
3103
|
+
return await this.request(`/meaning?encodedTrack=${encodedTrack}`, (m) => {
|
|
3104
|
+
m.method = "GET";
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3076
3107
|
/**
|
|
3077
3108
|
* Adds a new audio track to be mixed over the current playback.
|
|
3078
3109
|
* @param player The player to add the mixer layer to.
|
|
@@ -3090,7 +3121,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3090
3121
|
//identifier: trackToAdd.info?.identifier, // atm not supported
|
|
3091
3122
|
userData: trackToAdd.userData
|
|
3092
3123
|
},
|
|
3093
|
-
volume:
|
|
3124
|
+
volume: volume / 100
|
|
3094
3125
|
});
|
|
3095
3126
|
});
|
|
3096
3127
|
}
|
|
@@ -3117,7 +3148,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3117
3148
|
await this.request(`/sessions/${this.sessionId}/players/${player.guildId}/mix/${mixId}`, (m) => {
|
|
3118
3149
|
m.method = "PATCH";
|
|
3119
3150
|
m.body = safeStringify({
|
|
3120
|
-
volume:
|
|
3151
|
+
volume: volume / 100
|
|
3121
3152
|
});
|
|
3122
3153
|
});
|
|
3123
3154
|
return true;
|
|
@@ -3289,7 +3320,7 @@ var NodeLinkNode = class extends LavalinkNode {
|
|
|
3289
3320
|
*/
|
|
3290
3321
|
async loadDirectStream(track, volume, position, filters) {
|
|
3291
3322
|
let requestPath = `/loadstream?encodedTrack=${track.encoded}`;
|
|
3292
|
-
if (volume && volume > 0 && volume <= 100) requestPath += `&volume=${
|
|
3323
|
+
if (volume && volume > 0 && volume <= 100) requestPath += `&volume=${volume / 100}`;
|
|
3293
3324
|
if (position && position > 0) requestPath += `&position=${position}`;
|
|
3294
3325
|
if (filters) requestPath += `&filters=${typeof filters === "object" ? safeStringify(filters) : filters}`;
|
|
3295
3326
|
const res = await this.rawRequest(requestPath, (m) => {
|
package/package.json
CHANGED