lavalink-client 1.2.5 → 2.0.0
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 +51 -0
- package/dist/cjs/structures/LavalinkManager.d.ts +2 -0
- package/dist/cjs/structures/LavalinkManager.js +3 -0
- package/dist/cjs/structures/Node.d.ts +42 -4
- package/dist/cjs/structures/Node.js +42 -14
- package/dist/cjs/structures/NodeManager.d.ts +12 -2
- package/dist/cjs/structures/NodeManager.js +1 -1
- package/dist/cjs/structures/Player.d.ts +25 -10
- package/dist/cjs/structures/Player.js +51 -23
- package/dist/cjs/structures/Track.d.ts +7 -1
- package/dist/cjs/structures/Utils.d.ts +75 -19
- package/dist/esm/structures/LavalinkManager.d.ts +2 -0
- package/dist/esm/structures/LavalinkManager.js +3 -0
- package/dist/esm/structures/Node.d.ts +42 -4
- package/dist/esm/structures/Node.js +42 -14
- package/dist/esm/structures/NodeManager.d.ts +12 -2
- package/dist/esm/structures/NodeManager.js +1 -1
- package/dist/esm/structures/Player.d.ts +25 -10
- package/dist/esm/structures/Player.js +51 -23
- package/dist/esm/structures/Track.d.ts +7 -1
- package/dist/esm/structures/Utils.d.ts +75 -19
- package/dist/types/structures/LavalinkManager.d.ts +2 -0
- package/dist/types/structures/Node.d.ts +42 -4
- package/dist/types/structures/NodeManager.d.ts +12 -2
- package/dist/types/structures/Player.d.ts +25 -10
- package/dist/types/structures/Track.d.ts +7 -1
- package/dist/types/structures/Utils.d.ts +75 -19
- package/package.json +1 -1
|
@@ -119,15 +119,38 @@ export class Player {
|
|
|
119
119
|
* Play the next track from the queue / a specific track, with playoptions for Lavalink
|
|
120
120
|
* @param options
|
|
121
121
|
*/
|
|
122
|
-
async play(options) {
|
|
122
|
+
async play(options = {}) {
|
|
123
123
|
if (this.get("internal_queueempty")) {
|
|
124
124
|
clearTimeout(this.get("internal_queueempty"));
|
|
125
125
|
this.set("internal_queueempty", undefined);
|
|
126
126
|
}
|
|
127
|
-
if
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
// if clientTrack provided, play it
|
|
128
|
+
if (options?.clientTrack && (this.LavalinkManager.utils.isTrack(options?.clientTrack) || this.LavalinkManager.utils.isUnresolvedTrack(options.clientTrack))) {
|
|
129
|
+
if (this.LavalinkManager.utils.isUnresolvedTrack(options.clientTrack))
|
|
130
|
+
await options.clientTrack.resolve(this);
|
|
131
|
+
if (typeof options.track.userData === "object")
|
|
132
|
+
options.clientTrack.userData = { ...(options?.clientTrack.userData || {}), ...(options.track.userData || {}) };
|
|
133
|
+
await this.queue.add(options?.clientTrack, 0);
|
|
134
|
+
await queueTrackEnd(this);
|
|
135
|
+
}
|
|
136
|
+
else if (options?.track?.encoded) {
|
|
137
|
+
// handle play encoded options manually // TODO let it resolve by lavalink!
|
|
138
|
+
const track = await this.node.decode.singleTrack(options.track?.encoded, options.track?.requester || this.queue?.current?.requester || this.queue.previous?.[0]?.requester || this.queue.tracks?.[0]?.requester || this.LavalinkManager.options.client);
|
|
139
|
+
if (typeof options.track.userData === "object")
|
|
140
|
+
track.userData = { ...(track.userData || {}), ...(options.track.userData || {}) };
|
|
141
|
+
if (track)
|
|
142
|
+
this.queue.add(track, 0);
|
|
143
|
+
await queueTrackEnd(this);
|
|
144
|
+
}
|
|
145
|
+
else if (options?.track?.identifier) {
|
|
146
|
+
// handle play identifier options manually // TODO let it resolve by lavalink!
|
|
147
|
+
const res = await this.search({
|
|
148
|
+
query: options?.track?.identifier
|
|
149
|
+
}, options?.track?.identifier || this.queue?.current?.requester || this.queue.previous?.[0]?.requester || this.queue.tracks?.[0]?.requester || this.LavalinkManager.options.client);
|
|
150
|
+
if (typeof options.track.userData === "object")
|
|
151
|
+
res.tracks[0].userData = { ...(res.tracks[0].userData || {}), ...(options.track.userData || {}) };
|
|
152
|
+
if (res.tracks[0])
|
|
153
|
+
this.queue.add(res.tracks[0], 0);
|
|
131
154
|
await queueTrackEnd(this);
|
|
132
155
|
}
|
|
133
156
|
if (!this.queue.current && this.queue.tracks.length)
|
|
@@ -136,20 +159,22 @@ export class Player {
|
|
|
136
159
|
try {
|
|
137
160
|
// resolve the unresolved track
|
|
138
161
|
await this.queue.current.resolve(this);
|
|
162
|
+
if (typeof options.track.userData === "object")
|
|
163
|
+
this.queue.current.userData = { ...(this.queue.current.userData || {}), ...(options.track.userData || {}) };
|
|
139
164
|
}
|
|
140
165
|
catch (error) {
|
|
141
166
|
this.LavalinkManager.emit("trackError", this, this.queue.current, error);
|
|
167
|
+
if (options && "clientTrack" in options)
|
|
168
|
+
delete options.clientTrack;
|
|
142
169
|
if (options && "track" in options)
|
|
143
170
|
delete options.track;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (this.queue.tracks[0])
|
|
171
|
+
// try to play the next track if possible
|
|
172
|
+
if (this.LavalinkManager.options?.autoSkipOnResolveError === true && this.queue.tracks[0])
|
|
147
173
|
return this.play(options);
|
|
148
174
|
return this;
|
|
149
175
|
}
|
|
150
176
|
}
|
|
151
|
-
|
|
152
|
-
if (!track)
|
|
177
|
+
if (!this.queue.current)
|
|
153
178
|
throw new Error(`There is no Track in the Queue, nor provided in the PlayOptions`);
|
|
154
179
|
if (typeof options?.volume === "number" && !isNaN(options?.volume)) {
|
|
155
180
|
this.volume = Math.max(Math.min(options?.volume, 500), 0);
|
|
@@ -159,24 +184,27 @@ export class Player {
|
|
|
159
184
|
this.lavalinkVolume = Math.round(vol);
|
|
160
185
|
options.volume = this.lavalinkVolume;
|
|
161
186
|
}
|
|
162
|
-
const finalOptions = {
|
|
163
|
-
|
|
187
|
+
const finalOptions = Object.fromEntries(Object.entries({
|
|
188
|
+
track: {
|
|
189
|
+
encoded: this.queue.current?.encoded || null,
|
|
190
|
+
// identifier: options.identifier,
|
|
191
|
+
userData: options?.track?.userData || {},
|
|
192
|
+
},
|
|
164
193
|
volume: this.lavalinkVolume,
|
|
165
|
-
position: 0,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
194
|
+
position: options?.position ?? 0,
|
|
195
|
+
endTime: options?.endTime ?? undefined,
|
|
196
|
+
filters: options?.filters ?? undefined,
|
|
197
|
+
paused: options?.paused ?? undefined,
|
|
198
|
+
voice: options?.voice ?? undefined
|
|
199
|
+
}).filter(v => typeof v[1] !== "undefined"));
|
|
200
|
+
if ((typeof finalOptions.position !== "undefined" && isNaN(finalOptions.position)) || (typeof finalOptions.position === "number" && (finalOptions.position < 0 || finalOptions.position >= this.queue.current.info.duration)))
|
|
171
201
|
throw new Error("PlayerOption#position must be a positive number, less than track's duration");
|
|
172
202
|
if ((typeof finalOptions.volume !== "undefined" && isNaN(finalOptions.volume) || (typeof finalOptions.volume === "number" && finalOptions.volume < 0)))
|
|
173
203
|
throw new Error("PlayerOption#volume must be a positive number");
|
|
174
|
-
if ((typeof finalOptions.endTime !== "undefined" && isNaN(finalOptions.endTime)) || (typeof finalOptions.endTime === "number" && (finalOptions.endTime < 0 || finalOptions.endTime >=
|
|
204
|
+
if ((typeof finalOptions.endTime !== "undefined" && isNaN(finalOptions.endTime)) || (typeof finalOptions.endTime === "number" && (finalOptions.endTime < 0 || finalOptions.endTime >= this.queue.current.info.duration)))
|
|
175
205
|
throw new Error("PlayerOption#endTime must be a positive number, less than track's duration");
|
|
176
206
|
if (typeof finalOptions.position === "number" && typeof finalOptions.endTime === "number" && finalOptions.endTime < finalOptions.position)
|
|
177
207
|
throw new Error("PlayerOption#endTime must be bigger than PlayerOption#position");
|
|
178
|
-
if ("noReplace" in finalOptions)
|
|
179
|
-
delete finalOptions.noReplace;
|
|
180
208
|
const now = performance.now();
|
|
181
209
|
await this.node.updatePlayer({
|
|
182
210
|
guildId: this.guildId,
|
|
@@ -302,7 +330,7 @@ export class Player {
|
|
|
302
330
|
if (!this.playing)
|
|
303
331
|
return await this.play();
|
|
304
332
|
const now = performance.now();
|
|
305
|
-
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: {
|
|
333
|
+
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { track: { encoded: null } } });
|
|
306
334
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
307
335
|
return this;
|
|
308
336
|
}
|
|
@@ -322,7 +350,7 @@ export class Player {
|
|
|
322
350
|
this.set("internal_autoplayStopPlaying", undefined);
|
|
323
351
|
const now = performance.now();
|
|
324
352
|
// send to lavalink, that it should stop playing
|
|
325
|
-
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: {
|
|
353
|
+
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { track: { encoded: null } } });
|
|
326
354
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
327
355
|
return this;
|
|
328
356
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Player } from "./Player";
|
|
1
|
+
import { anyObject, Player } from "./Player";
|
|
2
2
|
import { Base64 } from "./Utils";
|
|
3
3
|
/** Sourcenames provided by lavalink server */
|
|
4
4
|
export type LavalinkSourceNames = "youtube" | "youtubemusic" | "soundcloud" | "bandcamp" | "twitch";
|
|
@@ -89,6 +89,8 @@ export interface LavalinkTrack {
|
|
|
89
89
|
info: LavalinkTrackInfo;
|
|
90
90
|
/** Plugin Information from Lavalink */
|
|
91
91
|
pluginInfo: Partial<PluginInfo>;
|
|
92
|
+
/** The userData Object from when you provide to the lavalink request */
|
|
93
|
+
userData?: anyObject;
|
|
92
94
|
}
|
|
93
95
|
export interface Track {
|
|
94
96
|
/** The Base 64 encoded String */
|
|
@@ -99,6 +101,8 @@ export interface Track {
|
|
|
99
101
|
pluginInfo: Partial<PluginInfo>;
|
|
100
102
|
/** The Track's Requester */
|
|
101
103
|
requester?: unknown;
|
|
104
|
+
/** The userData Object from when you provide to the lavalink request */
|
|
105
|
+
userData?: anyObject;
|
|
102
106
|
}
|
|
103
107
|
export interface UnresolvedTrackInfo extends Partial<TrackInfo> {
|
|
104
108
|
/** Required */
|
|
@@ -117,6 +121,8 @@ export interface UnresolvedTrack {
|
|
|
117
121
|
info: UnresolvedTrackInfo;
|
|
118
122
|
/** Plugin Information from Lavalink */
|
|
119
123
|
pluginInfo: Partial<PluginInfo>;
|
|
124
|
+
/** The userData Object from when you provide to the lavalink request */
|
|
125
|
+
userData?: anyObject;
|
|
120
126
|
/** The Track's Requester */
|
|
121
127
|
requester?: unknown;
|
|
122
128
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LavalinkFilterData } from "./Filters";
|
|
2
2
|
import { LavalinkManager } from "./LavalinkManager";
|
|
3
3
|
import { LavalinkNode, LavalinkNodeOptions, NodeStats } from "./Node";
|
|
4
|
-
import {
|
|
4
|
+
import { LavalinkPlayOptions, Player } from "./Player";
|
|
5
5
|
import { LavalinkTrack, PluginInfo, Track, UnresolvedQuery, UnresolvedTrack } from "./Track";
|
|
6
6
|
export declare const TrackSymbol: unique symbol;
|
|
7
7
|
export declare const UnresolvedTrackSymbol: unique symbol;
|
|
@@ -247,17 +247,29 @@ export type State = "CONNECTED" | "CONNECTING" | "DISCONNECTED" | "DISCONNECTING
|
|
|
247
247
|
export type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | SponsorBlockSegmentEventType;
|
|
248
248
|
export type TrackEndReason = "finished" | "loadFailed" | "stopped" | "replaced" | "cleanup";
|
|
249
249
|
export interface InvalidLavalinkRestRequest {
|
|
250
|
+
/** Rest Request Data for when it was made */
|
|
250
251
|
timestamp: number;
|
|
252
|
+
/** Status of the request */
|
|
251
253
|
status: number;
|
|
254
|
+
/** Specific Errro which was sent */
|
|
252
255
|
error: string;
|
|
256
|
+
/** Specific Message which was created */
|
|
253
257
|
message?: string;
|
|
258
|
+
/** The specific error trace from the request */
|
|
259
|
+
trace?: unknown;
|
|
260
|
+
/** Path of where it's from */
|
|
254
261
|
path: string;
|
|
255
262
|
}
|
|
256
263
|
export interface LavalinkPlayerVoice {
|
|
264
|
+
/** The Voice Token */
|
|
257
265
|
token: string;
|
|
266
|
+
/** The Voice Server Endpoint */
|
|
258
267
|
endpoint: string;
|
|
268
|
+
/** The Voice SessionId */
|
|
259
269
|
sessionId: string;
|
|
270
|
+
/** Wether or not the player is connected */
|
|
260
271
|
connected?: boolean;
|
|
272
|
+
/** The Ping to the voice server */
|
|
261
273
|
ping?: number;
|
|
262
274
|
}
|
|
263
275
|
export interface LavalinkPlayerVoiceOptions extends Omit<LavalinkPlayerVoice, 'connected' | 'ping'> {
|
|
@@ -296,84 +308,121 @@ export interface RoutePlanner {
|
|
|
296
308
|
};
|
|
297
309
|
}
|
|
298
310
|
export interface Session {
|
|
311
|
+
/** Wether or not session is resuming or not */
|
|
299
312
|
resuming: boolean;
|
|
313
|
+
/** For how long a session is lasting while not connected */
|
|
300
314
|
timeout: number;
|
|
301
315
|
}
|
|
302
316
|
export interface GuildShardPayload {
|
|
303
317
|
/** The OP code */
|
|
304
318
|
op: number;
|
|
319
|
+
/** Data to send */
|
|
305
320
|
d: {
|
|
321
|
+
/** Guild id to apply voice settings */
|
|
306
322
|
guild_id: string;
|
|
323
|
+
/** channel to move/connect to, or null to leave it */
|
|
307
324
|
channel_id: string | null;
|
|
325
|
+
/** wether or not mute yourself */
|
|
308
326
|
self_mute: boolean;
|
|
327
|
+
/** wether or not deafen yourself */
|
|
309
328
|
self_deaf: boolean;
|
|
310
329
|
};
|
|
311
330
|
}
|
|
312
331
|
export interface PlayerUpdateInfo {
|
|
332
|
+
/** guild id of the player */
|
|
313
333
|
guildId: string;
|
|
314
|
-
|
|
334
|
+
/** Player options to provide to lavalink */
|
|
335
|
+
playerOptions: LavalinkPlayOptions;
|
|
336
|
+
/** Whether or not replace the current track with the new one (true is recommended) */
|
|
315
337
|
noReplace?: boolean;
|
|
316
338
|
}
|
|
317
339
|
export interface LavalinkPlayer {
|
|
340
|
+
/** Guild Id of the player */
|
|
318
341
|
guildId: string;
|
|
319
|
-
track
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
identifier: string;
|
|
323
|
-
title: string;
|
|
324
|
-
author: string;
|
|
325
|
-
length: number;
|
|
326
|
-
artworkUrl: string | null;
|
|
327
|
-
uri: string;
|
|
328
|
-
sourceName: string;
|
|
329
|
-
isSeekable: boolean;
|
|
330
|
-
isStream: boolean;
|
|
331
|
-
isrc: string | null;
|
|
332
|
-
position?: number;
|
|
333
|
-
};
|
|
334
|
-
};
|
|
342
|
+
/** IF playing a track, all of the track information */
|
|
343
|
+
track?: LavalinkTrack;
|
|
344
|
+
/** Lavalink volume (mind volumedecrementer) */
|
|
335
345
|
volume: number;
|
|
346
|
+
/** Wether it's paused or not */
|
|
336
347
|
paused: boolean;
|
|
348
|
+
/** Voice Endpoint data */
|
|
337
349
|
voice: LavalinkPlayerVoice;
|
|
350
|
+
/** All Audio Filters */
|
|
338
351
|
filters: Partial<LavalinkFilterData>;
|
|
352
|
+
/** Lavalink-Voice-State Variables */
|
|
353
|
+
state: {
|
|
354
|
+
/** Time since connection established */
|
|
355
|
+
time: number;
|
|
356
|
+
/** Position of the track */
|
|
357
|
+
position: number;
|
|
358
|
+
/** COnnected or not */
|
|
359
|
+
connected: boolean;
|
|
360
|
+
/** Ping to voice server */
|
|
361
|
+
ping: number;
|
|
362
|
+
};
|
|
339
363
|
}
|
|
340
364
|
export interface ChannelDeletePacket {
|
|
365
|
+
/** Packet key for channel delete */
|
|
341
366
|
t: "CHANNEL_DELETE";
|
|
367
|
+
/** data which is sent and relevant */
|
|
342
368
|
d: {
|
|
369
|
+
/** guild id */
|
|
343
370
|
guild_id: string;
|
|
371
|
+
/** Channel id */
|
|
344
372
|
id: string;
|
|
345
373
|
};
|
|
346
374
|
}
|
|
347
375
|
export interface VoiceState {
|
|
376
|
+
/** OP key from lavalink */
|
|
348
377
|
op: "voiceUpdate";
|
|
378
|
+
/** GuildId provided by lavalink */
|
|
349
379
|
guildId: string;
|
|
380
|
+
/** Event data */
|
|
350
381
|
event: VoiceServer;
|
|
382
|
+
/** Session Id of the voice connection */
|
|
351
383
|
sessionId?: string;
|
|
384
|
+
/** guild id of the voice channel */
|
|
352
385
|
guild_id: string;
|
|
386
|
+
/** user id from the voice connection */
|
|
353
387
|
user_id: string;
|
|
388
|
+
/** Session Id of the voice connection */
|
|
354
389
|
session_id: string;
|
|
390
|
+
/** Voice Channel Id */
|
|
355
391
|
channel_id: string;
|
|
356
392
|
}
|
|
393
|
+
/** The Base64 decodes tring by lavalink */
|
|
357
394
|
export type Base64 = string;
|
|
358
395
|
export interface VoiceServer {
|
|
396
|
+
/** Voice Token */
|
|
359
397
|
token: string;
|
|
398
|
+
/** Guild Id of the voice server connection */
|
|
360
399
|
guild_id: string;
|
|
400
|
+
/** Server Endpoint */
|
|
361
401
|
endpoint: string;
|
|
362
402
|
}
|
|
363
403
|
export interface VoicePacket {
|
|
404
|
+
/** Voice Packet Keys to send */
|
|
364
405
|
t?: "VOICE_SERVER_UPDATE" | "VOICE_STATE_UPDATE";
|
|
406
|
+
/** Voice Packets to send */
|
|
365
407
|
d: VoiceState | VoiceServer;
|
|
366
408
|
}
|
|
367
409
|
export interface NodeMessage extends NodeStats {
|
|
410
|
+
/** The type of the event */
|
|
368
411
|
type: PlayerEventType;
|
|
412
|
+
/** what ops are applying to that event */
|
|
369
413
|
op: "stats" | "playerUpdate" | "event";
|
|
414
|
+
/** The specific guild id for that message */
|
|
370
415
|
guildId: string;
|
|
371
416
|
}
|
|
372
417
|
export declare function queueTrackEnd(player: Player): Promise<Track>;
|
|
418
|
+
/** Specific types to filter for lavasearch, will be filtered to correct types */
|
|
373
419
|
export type LavaSearchType = "track" | "album" | "artist" | "playlist" | "text" | "tracks" | "albums" | "artists" | "playlists" | "texts";
|
|
374
420
|
export interface LavaSearchFilteredResponse {
|
|
421
|
+
/** The Information of a playlist provided by lavasearch */
|
|
375
422
|
info: PlaylistInfo;
|
|
423
|
+
/** additional plugin information */
|
|
376
424
|
pluginInfo: PluginInfo;
|
|
425
|
+
/** List of tracks */
|
|
377
426
|
tracks: Track[];
|
|
378
427
|
}
|
|
379
428
|
export interface LavaSearchResponse {
|
|
@@ -393,13 +442,20 @@ export interface LavaSearchResponse {
|
|
|
393
442
|
/** Addition result data provided by plugins */
|
|
394
443
|
pluginInfo: PluginInfo;
|
|
395
444
|
}
|
|
445
|
+
/** SearchQuery Object for raw lavalink requests */
|
|
396
446
|
export type SearchQuery = {
|
|
447
|
+
/** lavalink search Query / identifier string */
|
|
397
448
|
query: string;
|
|
449
|
+
/** Source to append to the search query string */
|
|
398
450
|
source?: SearchPlatform;
|
|
399
|
-
} | string;
|
|
451
|
+
} | /** Our just the search query / identifier string */ string;
|
|
452
|
+
/** SearchQuery Object for Lavalink LavaSearch Plugin requests */
|
|
400
453
|
export type LavaSearchQuery = {
|
|
454
|
+
/** lavalink search Query / identifier string */
|
|
401
455
|
query: string;
|
|
456
|
+
/** Source to append to the search query string */
|
|
402
457
|
source: LavaSrcSearchPlatformBase;
|
|
458
|
+
/** The Types to filter the search to */
|
|
403
459
|
types?: LavaSearchType[];
|
|
404
460
|
};
|
|
405
461
|
export {};
|
|
@@ -56,6 +56,8 @@ export interface ManagerOptions {
|
|
|
56
56
|
playerOptions?: ManagerPlayerOptions;
|
|
57
57
|
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
58
58
|
autoSkip?: boolean;
|
|
59
|
+
/** If it should skip to the next Track if track.resolve errors while trying to play a track. */
|
|
60
|
+
autoSkipOnResolveError?: boolean;
|
|
59
61
|
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
|
60
62
|
emitNewSongsOnly?: boolean;
|
|
61
63
|
/** Only allow link requests with links either matching some of that regExp or including some of that string */
|
|
@@ -78,29 +78,49 @@ export interface NodeStats extends BaseNodeStats {
|
|
|
78
78
|
frameStats: FrameStats;
|
|
79
79
|
}
|
|
80
80
|
export interface LavalinkInfo {
|
|
81
|
+
/** The version of this Lavalink server */
|
|
81
82
|
version: VersionObject;
|
|
83
|
+
/** The millisecond unix timestamp when this Lavalink jar was built */
|
|
82
84
|
buildTime: number;
|
|
85
|
+
/** The git information of this Lavalink server */
|
|
83
86
|
git: GitObject;
|
|
87
|
+
/** The JVM version this Lavalink server runs on */
|
|
84
88
|
jvm: string;
|
|
89
|
+
/** The Lavaplayer version being used by this server */
|
|
85
90
|
lavaplayer: string;
|
|
91
|
+
/** The enabled source managers for this server */
|
|
86
92
|
sourceManagers: string[];
|
|
93
|
+
/** The enabled filters for this server */
|
|
87
94
|
filters: string[];
|
|
95
|
+
/** The enabled plugins for this server */
|
|
88
96
|
plugins: PluginObject[];
|
|
89
97
|
}
|
|
90
98
|
export interface VersionObject {
|
|
99
|
+
/** The full version string of this Lavalink server */
|
|
91
100
|
semver: string;
|
|
101
|
+
/** The major version of this Lavalink server */
|
|
92
102
|
major: number;
|
|
103
|
+
/** The minor version of this Lavalink server */
|
|
93
104
|
minor: number;
|
|
105
|
+
/** The patch version of this Lavalink server */
|
|
94
106
|
patch: internal;
|
|
107
|
+
/** The pre-release version according to semver as a . separated list of identifiers */
|
|
95
108
|
preRelease?: string;
|
|
109
|
+
/** The build metadata according to semver as a . separated list of identifiers */
|
|
110
|
+
build?: string;
|
|
96
111
|
}
|
|
97
112
|
export interface GitObject {
|
|
113
|
+
/** The branch this Lavalink server was built on */
|
|
98
114
|
branch: string;
|
|
115
|
+
/** The commit this Lavalink server was built on */
|
|
99
116
|
commit: string;
|
|
117
|
+
/** The millisecond unix timestamp for when the commit was created */
|
|
100
118
|
commitTime: string;
|
|
101
119
|
}
|
|
102
120
|
export interface PluginObject {
|
|
121
|
+
/** The name of the plugin */
|
|
103
122
|
name: string;
|
|
123
|
+
/** The version of the plugin */
|
|
104
124
|
version: string;
|
|
105
125
|
}
|
|
106
126
|
export declare class LavalinkNode {
|
|
@@ -110,6 +130,11 @@ export declare class LavalinkNode {
|
|
|
110
130
|
calls: number;
|
|
111
131
|
stats: NodeStats;
|
|
112
132
|
sessionId?: string | null;
|
|
133
|
+
/** Wether the node resuming is enabled or not */
|
|
134
|
+
resuming: {
|
|
135
|
+
enabled: boolean;
|
|
136
|
+
timeout: number | null;
|
|
137
|
+
};
|
|
113
138
|
/** Actual Lavalink Information of the Node */
|
|
114
139
|
info: LavalinkInfo | null;
|
|
115
140
|
/** The Node Manager of this Node */
|
|
@@ -126,10 +151,17 @@ export declare class LavalinkNode {
|
|
|
126
151
|
private version;
|
|
127
152
|
/**
|
|
128
153
|
* Create a new Node
|
|
129
|
-
* @param options
|
|
130
|
-
* @param manager
|
|
154
|
+
* @param options Lavalink Node Options
|
|
155
|
+
* @param manager Node Manager
|
|
131
156
|
*/
|
|
132
157
|
constructor(options: LavalinkNodeOptions, manager: NodeManager);
|
|
158
|
+
/**
|
|
159
|
+
* Raw Request util function
|
|
160
|
+
* @param endpoint endpoint string
|
|
161
|
+
* @param modify modify the request
|
|
162
|
+
* @returns
|
|
163
|
+
*/
|
|
164
|
+
private rawRequest;
|
|
133
165
|
/**
|
|
134
166
|
* Makes an API call to the Node
|
|
135
167
|
* @param endpoint The endpoint that we will make the call to
|
|
@@ -137,8 +169,14 @@ export declare class LavalinkNode {
|
|
|
137
169
|
* @returns The returned data
|
|
138
170
|
*/
|
|
139
171
|
request(endpoint: string, modify?: ModifyRequest, parseAsText?: boolean): Promise<unknown>;
|
|
172
|
+
/**
|
|
173
|
+
* Search something raw on the node, please note only add tracks to players of that node
|
|
174
|
+
* @param query SearchQuery Object
|
|
175
|
+
* @param requestUser Request User for creating the player(s)
|
|
176
|
+
* @returns Searchresult
|
|
177
|
+
*/
|
|
140
178
|
search(query: SearchQuery, requestUser: unknown): Promise<SearchResult>;
|
|
141
|
-
lavaSearch(query: LavaSearchQuery, requestUser: unknown): Promise<SearchResult | LavaSearchResponse>;
|
|
179
|
+
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<SearchResult | LavaSearchResponse>;
|
|
142
180
|
/**
|
|
143
181
|
* Update the Player State on the Lavalink Server
|
|
144
182
|
* @param data
|
|
@@ -179,7 +217,7 @@ export declare class LavalinkNode {
|
|
|
179
217
|
* @param resuming Whether resuming is enabled for this session or not
|
|
180
218
|
* @param timeout The timeout in seconds (default is 60s)
|
|
181
219
|
*/
|
|
182
|
-
updateSession(resuming?: boolean, timeout?: number): Promise<Session>;
|
|
220
|
+
updateSession(resuming?: boolean, timeout?: number): Promise<InvalidLavalinkRestRequest | Session>;
|
|
183
221
|
/**
|
|
184
222
|
* Decode Track or Tracks
|
|
185
223
|
*/
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { EventEmitter } from "stream";
|
|
3
|
-
import { LavalinkNode, LavalinkNodeOptions } from "./Node";
|
|
4
3
|
import { LavalinkManager } from "./LavalinkManager";
|
|
5
|
-
import {
|
|
4
|
+
import { LavalinkNode, LavalinkNodeOptions } from "./Node";
|
|
6
5
|
import { DestroyReasonsType } from "./Player";
|
|
6
|
+
import { LavalinkPlayer, MiniMap } from "./Utils";
|
|
7
7
|
type LavalinkNodeIdentifier = string;
|
|
8
8
|
interface NodeManagerEvents {
|
|
9
9
|
/**
|
|
@@ -44,6 +44,16 @@ interface NodeManagerEvents {
|
|
|
44
44
|
* @event Manager.nodeManager#raw
|
|
45
45
|
*/
|
|
46
46
|
"raw": (node: LavalinkNode, payload: unknown) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Emits when the node connects resumed. You then need to create all players within this event for your usecase.
|
|
49
|
+
* Aka for that you need to be able to save player data like vc channel + text channel in a db and then sync it again
|
|
50
|
+
* @event Manager.nodeManager#nodeResumed
|
|
51
|
+
*/
|
|
52
|
+
"resumed": (node: LavalinkNode, paylaod: {
|
|
53
|
+
resumed: true;
|
|
54
|
+
sessionId: string;
|
|
55
|
+
op: "ready";
|
|
56
|
+
}, players: LavalinkPlayer[]) => void;
|
|
47
57
|
}
|
|
48
58
|
export declare interface NodeManager {
|
|
49
59
|
on<U extends keyof NodeManagerEvents>(event: U, listener: NodeManagerEvents[U]): this;
|
|
@@ -3,7 +3,7 @@ import { LavalinkManager } from "./LavalinkManager";
|
|
|
3
3
|
import { LavalinkNode, SponsorBlockSegment } from "./Node";
|
|
4
4
|
import { Queue } from "./Queue";
|
|
5
5
|
import { Track, UnresolvedTrack } from "./Track";
|
|
6
|
-
import { LavalinkPlayerVoiceOptions, LavaSearchQuery, SearchQuery } from "./Utils";
|
|
6
|
+
import { Base64, LavalinkPlayerVoiceOptions, LavaSearchQuery, SearchQuery } from "./Utils";
|
|
7
7
|
type PlayerDestroyReasons = "QueueEmpty" | "NodeDestroy" | "NodeDeleted" | "LavalinkNoVoice" | "NodeReconnectFail" | "PlayerReconnectFail" | "Disconnected" | "ChannelDeleted" | "ReconnectAllNodes" | "DisconnectAllNodes";
|
|
8
8
|
export type DestroyReasonsType = PlayerDestroyReasons | string;
|
|
9
9
|
export declare const DestroyReasons: Record<PlayerDestroyReasons, PlayerDestroyReasons>;
|
|
@@ -51,27 +51,42 @@ export interface PlayerOptions {
|
|
|
51
51
|
/** If a volume should be applied via filters instead of lavalink-volume */
|
|
52
52
|
applyVolumeAsFilter?: boolean;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
encodedTrack?: string | null;
|
|
59
|
-
/** Encoded Track to use&search, instead of the queue system (yt only)... */
|
|
60
|
-
identifier?: string;
|
|
54
|
+
export type anyObject = {
|
|
55
|
+
[key: string | number]: string | number | null | anyObject;
|
|
56
|
+
};
|
|
57
|
+
export interface BasePlayOptions {
|
|
61
58
|
/** The position to start the track. */
|
|
62
59
|
position?: number;
|
|
63
60
|
/** The position to end the track. */
|
|
64
61
|
endTime?: number;
|
|
65
|
-
/** Whether to not replace the track if a play payload is sent. */
|
|
66
|
-
noReplace?: boolean;
|
|
67
62
|
/** If to start "paused" */
|
|
68
63
|
paused?: boolean;
|
|
69
64
|
/** The Volume to start with */
|
|
70
65
|
volume?: number;
|
|
71
66
|
/** The Lavalink Filters to use | only with the new REST API */
|
|
72
67
|
filters?: Partial<LavalinkFilterData>;
|
|
68
|
+
/** Voice Update for Lavalink */
|
|
73
69
|
voice?: LavalinkPlayerVoiceOptions;
|
|
74
70
|
}
|
|
71
|
+
export interface LavalinkPlayOptions extends BasePlayOptions {
|
|
72
|
+
/** Which Track to play | don't provide, if it should pick from the Queue */
|
|
73
|
+
track?: {
|
|
74
|
+
/** The track encoded base64 string to use instead of the one from the queue system */
|
|
75
|
+
encoded?: Base64 | null;
|
|
76
|
+
/** The identifier of the track to use */
|
|
77
|
+
identifier?: string;
|
|
78
|
+
/** Custom User Data for the track to provide, will then be on the userData object from the track */
|
|
79
|
+
userData?: anyObject;
|
|
80
|
+
/** The Track requester for when u provide encodedTrack / identifer */
|
|
81
|
+
requester?: unknown;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export interface PlayOptions extends LavalinkPlayOptions {
|
|
85
|
+
/** Whether to not replace the track if a play payload is sent. */
|
|
86
|
+
noReplace?: boolean;
|
|
87
|
+
/** Which Track to play | don't provide, if it should pick from the Queue */
|
|
88
|
+
clientTrack?: Track | UnresolvedTrack;
|
|
89
|
+
}
|
|
75
90
|
export interface Player {
|
|
76
91
|
filterManager: FilterManager;
|
|
77
92
|
LavalinkManager: LavalinkManager;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Player } from "./Player";
|
|
1
|
+
import { anyObject, Player } from "./Player";
|
|
2
2
|
import { Base64 } from "./Utils";
|
|
3
3
|
/** Sourcenames provided by lavalink server */
|
|
4
4
|
export type LavalinkSourceNames = "youtube" | "youtubemusic" | "soundcloud" | "bandcamp" | "twitch";
|
|
@@ -89,6 +89,8 @@ export interface LavalinkTrack {
|
|
|
89
89
|
info: LavalinkTrackInfo;
|
|
90
90
|
/** Plugin Information from Lavalink */
|
|
91
91
|
pluginInfo: Partial<PluginInfo>;
|
|
92
|
+
/** The userData Object from when you provide to the lavalink request */
|
|
93
|
+
userData?: anyObject;
|
|
92
94
|
}
|
|
93
95
|
export interface Track {
|
|
94
96
|
/** The Base 64 encoded String */
|
|
@@ -99,6 +101,8 @@ export interface Track {
|
|
|
99
101
|
pluginInfo: Partial<PluginInfo>;
|
|
100
102
|
/** The Track's Requester */
|
|
101
103
|
requester?: unknown;
|
|
104
|
+
/** The userData Object from when you provide to the lavalink request */
|
|
105
|
+
userData?: anyObject;
|
|
102
106
|
}
|
|
103
107
|
export interface UnresolvedTrackInfo extends Partial<TrackInfo> {
|
|
104
108
|
/** Required */
|
|
@@ -117,6 +121,8 @@ export interface UnresolvedTrack {
|
|
|
117
121
|
info: UnresolvedTrackInfo;
|
|
118
122
|
/** Plugin Information from Lavalink */
|
|
119
123
|
pluginInfo: Partial<PluginInfo>;
|
|
124
|
+
/** The userData Object from when you provide to the lavalink request */
|
|
125
|
+
userData?: anyObject;
|
|
120
126
|
/** The Track's Requester */
|
|
121
127
|
requester?: unknown;
|
|
122
128
|
}
|