lavalink-client 2.1.7 → 2.2.1
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 +87 -1
- package/dist/cjs/structures/CustomSearches/BandCampSearch.js +3 -2
- package/dist/cjs/structures/Filters.d.ts +1 -1
- package/dist/cjs/structures/Filters.js +5 -5
- package/dist/cjs/structures/LavalinkManager.d.ts +23 -5
- package/dist/cjs/structures/LavalinkManager.js +15 -1
- package/dist/cjs/structures/LavalinkManagerStatics.d.ts +3 -0
- package/dist/cjs/structures/LavalinkManagerStatics.js +8 -1
- package/dist/cjs/structures/Node.d.ts +317 -35
- package/dist/cjs/structures/Node.js +330 -85
- package/dist/cjs/structures/NodeManager.d.ts +1 -1
- package/dist/cjs/structures/Player.d.ts +44 -8
- package/dist/cjs/structures/Player.js +35 -27
- package/dist/cjs/structures/Queue.js +1 -1
- package/dist/cjs/structures/Utils.d.ts +5 -2
- package/dist/cjs/structures/Utils.js +7 -4
- package/dist/esm/structures/CustomSearches/BandCampSearch.js +2 -1
- package/dist/esm/structures/Filters.d.ts +1 -1
- package/dist/esm/structures/Filters.js +5 -5
- package/dist/esm/structures/LavalinkManager.d.ts +23 -5
- package/dist/esm/structures/LavalinkManager.js +15 -1
- package/dist/esm/structures/LavalinkManagerStatics.d.ts +3 -0
- package/dist/esm/structures/LavalinkManagerStatics.js +8 -1
- package/dist/esm/structures/Node.d.ts +317 -35
- package/dist/esm/structures/Node.js +330 -85
- package/dist/esm/structures/NodeManager.d.ts +1 -1
- package/dist/esm/structures/Player.d.ts +44 -8
- package/dist/esm/structures/Player.js +35 -27
- package/dist/esm/structures/Queue.js +1 -1
- package/dist/esm/structures/Utils.d.ts +5 -2
- package/dist/esm/structures/Utils.js +7 -4
- package/dist/types/structures/Filters.d.ts +1 -1
- package/dist/types/structures/LavalinkManager.d.ts +23 -5
- package/dist/types/structures/LavalinkManagerStatics.d.ts +3 -0
- package/dist/types/structures/Node.d.ts +317 -35
- package/dist/types/structures/NodeManager.d.ts +1 -1
- package/dist/types/structures/Player.d.ts +44 -8
- package/dist/types/structures/Utils.d.ts +5 -2
- package/package.json +5 -4
|
@@ -5,7 +5,7 @@ import { LavalinkNode, LavalinkNodeOptions } from "./Node";
|
|
|
5
5
|
import { DestroyReasonsType } from "./Player";
|
|
6
6
|
import { LavalinkPlayer, MiniMap } from "./Utils";
|
|
7
7
|
type LavalinkNodeIdentifier = string;
|
|
8
|
-
interface NodeManagerEvents {
|
|
8
|
+
export interface NodeManagerEvents {
|
|
9
9
|
/**
|
|
10
10
|
* Emitted when a Node is created.
|
|
11
11
|
* @event Manager.nodeManager#create
|
|
@@ -4,28 +4,58 @@ import { LavalinkNode, SponsorBlockSegment } from "./Node";
|
|
|
4
4
|
import { Queue } from "./Queue";
|
|
5
5
|
import { Track, UnresolvedTrack } from "./Track";
|
|
6
6
|
import { Base64, LavalinkPlayerVoiceOptions, LavaSearchQuery, SearchQuery } from "./Utils";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare enum DestroyReasons {
|
|
8
|
+
QueueEmpty = "QueueEmpty",
|
|
9
|
+
NodeDestroy = "NodeDestroy",
|
|
10
|
+
NodeDeleted = "NodeDeleted",
|
|
11
|
+
LavalinkNoVoice = "LavalinkNoVoice",
|
|
12
|
+
NodeReconnectFail = "NodeReconnectFail",
|
|
13
|
+
Disconnected = "Disconnected",
|
|
14
|
+
PlayerReconnectFail = "PlayerReconnectFail",
|
|
15
|
+
ChannelDeleted = "ChannelDeleted",
|
|
16
|
+
DisconnectAllNodes = "DisconnectAllNodes",
|
|
17
|
+
ReconnectAllNodes = "ReconnectAllNodes"
|
|
18
|
+
}
|
|
19
|
+
export type DestroyReasonsType = keyof typeof DestroyReasons | string;
|
|
10
20
|
export interface PlayerJson {
|
|
21
|
+
/** Guild Id where the player was playing in */
|
|
11
22
|
guildId: string;
|
|
23
|
+
/** Options provided to the player */
|
|
12
24
|
options: PlayerOptions;
|
|
25
|
+
/** Voice Channel Id the player was playing in */
|
|
13
26
|
voiceChannelId: string;
|
|
27
|
+
/** Text Channel Id the player was synced to */
|
|
14
28
|
textChannelId?: string;
|
|
29
|
+
/** Position the player was at */
|
|
15
30
|
position: number;
|
|
31
|
+
/** Lavalink's position the player was at */
|
|
16
32
|
lastPosition: number;
|
|
33
|
+
/** Last time the position was sent from lavalink */
|
|
34
|
+
lastPositionChange: number;
|
|
35
|
+
/** Volume in % from the player (without volumeDecrementer) */
|
|
17
36
|
volume: number;
|
|
37
|
+
/** Real Volume used in lavalink (with the volumeDecrementer) */
|
|
18
38
|
lavalinkVolume: number;
|
|
39
|
+
/** The repeatmode from the player */
|
|
19
40
|
repeatMode: RepeatMode;
|
|
41
|
+
/** Pause state */
|
|
20
42
|
paused: boolean;
|
|
43
|
+
/** Wether the player was playing or not */
|
|
21
44
|
playing: boolean;
|
|
45
|
+
/** When the player was created */
|
|
22
46
|
createdTimeStamp?: number;
|
|
47
|
+
/** All current used fitlers Data */
|
|
23
48
|
filters: FilterData;
|
|
49
|
+
/** The player's ping object */
|
|
24
50
|
ping: {
|
|
51
|
+
/** Ping to the voice websocket server */
|
|
25
52
|
ws: number;
|
|
53
|
+
/** Avg. calc. Ping to the lavalink server */
|
|
26
54
|
lavalink: number;
|
|
27
55
|
};
|
|
56
|
+
/** Equalizer Bands used in lavalink */
|
|
28
57
|
equalizer: EQBand[];
|
|
58
|
+
/** The Id of the last used node */
|
|
29
59
|
nodeId?: string;
|
|
30
60
|
}
|
|
31
61
|
export type RepeatMode = "queue" | "track" | "off";
|
|
@@ -88,10 +118,15 @@ export interface PlayOptions extends LavalinkPlayOptions {
|
|
|
88
118
|
clientTrack?: Track | UnresolvedTrack;
|
|
89
119
|
}
|
|
90
120
|
export interface Player {
|
|
121
|
+
/** Filter Manager per player */
|
|
91
122
|
filterManager: FilterManager;
|
|
123
|
+
/** circular reference to the lavalink Manager from the Player for easier use */
|
|
92
124
|
LavalinkManager: LavalinkManager;
|
|
125
|
+
/** Player options currently used, mutation doesn't affect player's state */
|
|
93
126
|
options: PlayerOptions;
|
|
127
|
+
/** The lavalink node assigned the the player, don't change it manually */
|
|
94
128
|
node: LavalinkNode;
|
|
129
|
+
/** The queue from the player */
|
|
95
130
|
queue: Queue;
|
|
96
131
|
}
|
|
97
132
|
export declare class Player {
|
|
@@ -117,7 +152,9 @@ export declare class Player {
|
|
|
117
152
|
/** The Volume Lavalink actually is outputting */
|
|
118
153
|
lavalinkVolume: number;
|
|
119
154
|
/** The current Positin of the player (Calculated) */
|
|
120
|
-
position: number;
|
|
155
|
+
get position(): number;
|
|
156
|
+
/** The timestamp when the last position change update happened */
|
|
157
|
+
lastPositionChange: number;
|
|
121
158
|
/** The current Positin of the player (from Lavalink) */
|
|
122
159
|
lastPosition: number;
|
|
123
160
|
/** When the player was created [Timestamp in Ms] (from lavalink) */
|
|
@@ -163,7 +200,7 @@ export declare class Player {
|
|
|
163
200
|
* @param ignoreVolumeDecrementer If it should ignore the volumedecrementer option
|
|
164
201
|
*/
|
|
165
202
|
setVolume(volume: number, ignoreVolumeDecrementer?: boolean): Promise<this>;
|
|
166
|
-
lavaSearch(query: LavaSearchQuery, requestUser: unknown): Promise<import("./Utils").SearchResult | import("./Utils").LavaSearchResponse>;
|
|
203
|
+
lavaSearch(query: LavaSearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Utils").SearchResult | import("./Utils").LavaSearchResponse>;
|
|
167
204
|
setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
|
|
168
205
|
getSponsorBlock(): Promise<SponsorBlockSegment[]>;
|
|
169
206
|
deleteSponsorBlock(): Promise<void>;
|
|
@@ -172,7 +209,7 @@ export declare class Player {
|
|
|
172
209
|
* @param query Query for your data
|
|
173
210
|
* @param requestUser
|
|
174
211
|
*/
|
|
175
|
-
search(query: SearchQuery, requestUser: unknown): Promise<import("./Utils").SearchResult | import("./Utils").UnresolvedSearchResult>;
|
|
212
|
+
search(query: SearchQuery, requestUser: unknown, throwOnEmpty?: boolean): Promise<import("./Utils").SearchResult | import("./Utils").UnresolvedSearchResult>;
|
|
176
213
|
/**
|
|
177
214
|
* Pause the player
|
|
178
215
|
*/
|
|
@@ -220,7 +257,7 @@ export declare class Player {
|
|
|
220
257
|
/**
|
|
221
258
|
* Destroy the player and disconnect from the voice channel
|
|
222
259
|
*/
|
|
223
|
-
destroy(reason?: string, disconnect?: boolean): Promise<this>;
|
|
260
|
+
destroy(reason?: DestroyReasons | string, disconnect?: boolean): Promise<this>;
|
|
224
261
|
/**
|
|
225
262
|
* Move the player on a different Audio-Node
|
|
226
263
|
* @param newNode New Node / New Node Id
|
|
@@ -229,4 +266,3 @@ export declare class Player {
|
|
|
229
266
|
/** Converts the Player including Queue to a Json state */
|
|
230
267
|
toJSON(): PlayerJson;
|
|
231
268
|
}
|
|
232
|
-
export {};
|
|
@@ -2,18 +2,20 @@ import { bandCampSearch } from "./CustomSearches/BandCampSearch";
|
|
|
2
2
|
import { FilterManager } from "./Filters";
|
|
3
3
|
import { Queue, QueueSaver } from "./Queue";
|
|
4
4
|
import { queueTrackEnd } from "./Utils";
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
export var DestroyReasons;
|
|
6
|
+
(function (DestroyReasons) {
|
|
7
|
+
DestroyReasons["QueueEmpty"] = "QueueEmpty";
|
|
8
|
+
DestroyReasons["NodeDestroy"] = "NodeDestroy";
|
|
9
|
+
DestroyReasons["NodeDeleted"] = "NodeDeleted";
|
|
10
|
+
DestroyReasons["LavalinkNoVoice"] = "LavalinkNoVoice";
|
|
11
|
+
DestroyReasons["NodeReconnectFail"] = "NodeReconnectFail";
|
|
12
|
+
DestroyReasons["Disconnected"] = "Disconnected";
|
|
13
|
+
DestroyReasons["PlayerReconnectFail"] = "PlayerReconnectFail";
|
|
14
|
+
DestroyReasons["ChannelDeleted"] = "ChannelDeleted";
|
|
15
|
+
DestroyReasons["DisconnectAllNodes"] = "DisconnectAllNodes";
|
|
16
|
+
DestroyReasons["ReconnectAllNodes"] = "ReconnectAllNodes";
|
|
17
|
+
})(DestroyReasons || (DestroyReasons = {}));
|
|
18
|
+
;
|
|
17
19
|
export class Player {
|
|
18
20
|
/** The Guild Id of the Player */
|
|
19
21
|
guildId;
|
|
@@ -39,7 +41,11 @@ export class Player {
|
|
|
39
41
|
/** The Volume Lavalink actually is outputting */
|
|
40
42
|
lavalinkVolume = 100;
|
|
41
43
|
/** The current Positin of the player (Calculated) */
|
|
42
|
-
position
|
|
44
|
+
get position() {
|
|
45
|
+
return this.lastPosition + (this.lastPositionChange ? Date.now() - this.lastPositionChange : 0);
|
|
46
|
+
}
|
|
47
|
+
/** The timestamp when the last position change update happened */
|
|
48
|
+
lastPositionChange = null;
|
|
43
49
|
/** The current Positin of the player (from Lavalink) */
|
|
44
50
|
lastPosition = 0;
|
|
45
51
|
/** When the player was created [Timestamp in Ms] (from lavalink) */
|
|
@@ -129,17 +135,17 @@ export class Player {
|
|
|
129
135
|
if (options?.clientTrack && (this.LavalinkManager.utils.isTrack(options?.clientTrack) || this.LavalinkManager.utils.isUnresolvedTrack(options.clientTrack))) {
|
|
130
136
|
if (this.LavalinkManager.utils.isUnresolvedTrack(options.clientTrack))
|
|
131
137
|
await options.clientTrack.resolve(this);
|
|
132
|
-
if (typeof options.track.userData === "object")
|
|
133
|
-
options.clientTrack.userData = { ...(options?.clientTrack.userData || {}), ...(options.track
|
|
138
|
+
if ((typeof options.track?.userData === "object" || typeof options.clientTrack?.userData === "object") && options.clientTrack)
|
|
139
|
+
options.clientTrack.userData = { ...(options?.clientTrack.userData || {}), ...(options.track?.userData || {}) };
|
|
134
140
|
await this.queue.add(options?.clientTrack, 0);
|
|
135
141
|
return await this.skip();
|
|
136
142
|
}
|
|
137
143
|
else if (options?.track?.encoded) {
|
|
138
144
|
// handle play encoded options manually // TODO let it resolve by lavalink!
|
|
139
145
|
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);
|
|
140
|
-
if (typeof options.track.userData === "object")
|
|
141
|
-
track.userData = { ...(track.userData || {}), ...(options.track.userData || {}) };
|
|
142
146
|
if (track) {
|
|
147
|
+
if (typeof options.track?.userData === "object")
|
|
148
|
+
track.userData = { ...(track.userData || {}), ...(options.track.userData || {}) };
|
|
143
149
|
replaced = true;
|
|
144
150
|
this.queue.add(track, 0);
|
|
145
151
|
await queueTrackEnd(this);
|
|
@@ -150,9 +156,9 @@ export class Player {
|
|
|
150
156
|
const res = await this.search({
|
|
151
157
|
query: options?.track?.identifier
|
|
152
158
|
}, options?.track?.requester || this.queue?.current?.requester || this.queue.previous?.[0]?.requester || this.queue.tracks?.[0]?.requester || this.LavalinkManager.options.client);
|
|
153
|
-
if (typeof options.track.userData === "object")
|
|
154
|
-
res.tracks[0].userData = { ...(res.tracks[0].userData || {}), ...(options.track.userData || {}) };
|
|
155
159
|
if (res.tracks[0]) {
|
|
160
|
+
if (typeof options.track?.userData === "object")
|
|
161
|
+
res.tracks[0].userData = { ...(res.tracks[0].userData || {}), ...(options.track.userData || {}) };
|
|
156
162
|
replaced = true;
|
|
157
163
|
this.queue.add(res.tracks[0], 0);
|
|
158
164
|
await queueTrackEnd(this);
|
|
@@ -164,8 +170,8 @@ export class Player {
|
|
|
164
170
|
try {
|
|
165
171
|
// resolve the unresolved track
|
|
166
172
|
await this.queue.current.resolve(this);
|
|
167
|
-
if (typeof options.track
|
|
168
|
-
this.queue.current.userData = { ...(this.queue.current
|
|
173
|
+
if (typeof options.track?.userData === "object" && this.queue.current)
|
|
174
|
+
this.queue.current.userData = { ...(this.queue.current?.userData || {}), ...(options.track?.userData || {}) };
|
|
169
175
|
}
|
|
170
176
|
catch (error) {
|
|
171
177
|
this.LavalinkManager.emit("trackError", this, this.queue.current, error);
|
|
@@ -242,8 +248,8 @@ export class Player {
|
|
|
242
248
|
this.ping.lavalink = Math.round((performance.now() - now) / 10) / 100;
|
|
243
249
|
return this;
|
|
244
250
|
}
|
|
245
|
-
async lavaSearch(query, requestUser) {
|
|
246
|
-
return this.node.lavaSearch(query, requestUser);
|
|
251
|
+
async lavaSearch(query, requestUser, throwOnEmpty = false) {
|
|
252
|
+
return this.node.lavaSearch(query, requestUser, throwOnEmpty);
|
|
247
253
|
}
|
|
248
254
|
async setSponsorBlock(segments = ["sponsor", "selfpromo"]) {
|
|
249
255
|
return this.node.setSponsorBlock(this, segments);
|
|
@@ -259,11 +265,11 @@ export class Player {
|
|
|
259
265
|
* @param query Query for your data
|
|
260
266
|
* @param requestUser
|
|
261
267
|
*/
|
|
262
|
-
async search(query, requestUser) {
|
|
268
|
+
async search(query, requestUser, throwOnEmpty = false) {
|
|
263
269
|
const Query = this.LavalinkManager.utils.transformQuery(query);
|
|
264
|
-
if (["bcsearch", "bandcamp"].includes(Query.source))
|
|
270
|
+
if (["bcsearch", "bandcamp"].includes(Query.source) && !this.node.info.sourceManagers.includes("bandcamp"))
|
|
265
271
|
return await bandCampSearch(this, Query.query, requestUser);
|
|
266
|
-
return this.node.search(Query, requestUser);
|
|
272
|
+
return this.node.search(Query, requestUser, throwOnEmpty);
|
|
267
273
|
}
|
|
268
274
|
/**
|
|
269
275
|
* Pause the player
|
|
@@ -303,7 +309,7 @@ export class Player {
|
|
|
303
309
|
throw new RangeError("Current Track is not seekable / a stream");
|
|
304
310
|
if (position < 0 || position > this.queue.current.info.duration)
|
|
305
311
|
position = Math.max(Math.min(position, this.queue.current.info.duration), 0);
|
|
306
|
-
this.
|
|
312
|
+
this.lastPositionChange = Date.now();
|
|
307
313
|
this.lastPosition = position;
|
|
308
314
|
const now = performance.now();
|
|
309
315
|
await this.node.updatePlayer({ guildId: this.guildId, playerOptions: { position } });
|
|
@@ -485,6 +491,7 @@ export class Player {
|
|
|
485
491
|
textChannelId: this.textChannelId,
|
|
486
492
|
position: this.position,
|
|
487
493
|
lastPosition: this.lastPosition,
|
|
494
|
+
lastPositionChange: this.lastPositionChange,
|
|
488
495
|
volume: this.volume,
|
|
489
496
|
lavalinkVolume: this.lavalinkVolume,
|
|
490
497
|
repeatMode: this.repeatMode,
|
|
@@ -495,6 +502,7 @@ export class Player {
|
|
|
495
502
|
equalizer: this.filterManager?.equalizerBands || [],
|
|
496
503
|
nodeId: this.node?.id,
|
|
497
504
|
ping: this.ping,
|
|
505
|
+
queue: this.queue.utils.toJSON(),
|
|
498
506
|
};
|
|
499
507
|
}
|
|
500
508
|
}
|
|
@@ -76,7 +76,7 @@ export class Queue {
|
|
|
76
76
|
sync: async (override = true, dontSyncCurrent = true) => {
|
|
77
77
|
const data = await this.QueueSaver.get(this.guildId);
|
|
78
78
|
if (!data)
|
|
79
|
-
|
|
79
|
+
throw new Error(`No data found to sync for guildId: ${this.guildId}`);
|
|
80
80
|
if (!dontSyncCurrent && !this.current && (this.managerUtils.isTrack(data.current)))
|
|
81
81
|
this.current = data.current;
|
|
82
82
|
if (Array.isArray(data.tracks) && data?.tracks.length && data.tracks.some(track => this.managerUtils.isTrack(track) || this.managerUtils.isUnresolvedTrack(track)))
|
|
@@ -14,10 +14,10 @@ export type IntegerNumber = Opaque<number, 'Int'>;
|
|
|
14
14
|
export type FloatNumber = Opaque<number, 'Float'>;
|
|
15
15
|
export type LavaSrcSearchPlatformBase = "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ymsearch";
|
|
16
16
|
export type LavaSrcSearchPlatform = LavaSrcSearchPlatformBase | "ftts";
|
|
17
|
-
export type DuncteSearchPlatform = "speak" | "tts";
|
|
17
|
+
export type DuncteSearchPlatform = "speak" | "phsearch" | "pornhub" | "porn" | "tts";
|
|
18
18
|
export type LavalinkClientSearchPlatform = "bcsearch";
|
|
19
19
|
export type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
|
|
20
|
-
export type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | LavalinkClientSearchPlatform;
|
|
20
|
+
export type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | "bcsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | LavalinkClientSearchPlatform;
|
|
21
21
|
export type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
|
|
22
22
|
export type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
|
|
23
23
|
"youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
|
|
@@ -105,6 +105,7 @@ export declare class ManagerUtils {
|
|
|
105
105
|
validateQueryString(node: LavalinkNode, queryString: string, sourceString?: LavalinkSearchPlatform): void;
|
|
106
106
|
transformQuery(query: SearchQuery): {
|
|
107
107
|
query: string;
|
|
108
|
+
extraQueryUrlParams: URLSearchParams;
|
|
108
109
|
source: any;
|
|
109
110
|
};
|
|
110
111
|
transformLavaSearchQuery(query: LavaSearchQuery): {
|
|
@@ -453,6 +454,8 @@ export interface LavaSearchResponse {
|
|
|
453
454
|
export type SearchQuery = {
|
|
454
455
|
/** lavalink search Query / identifier string */
|
|
455
456
|
query: string;
|
|
457
|
+
/** Extra url query params to use, e.g. for flowertts */
|
|
458
|
+
extraQueryUrlParams?: URLSearchParams;
|
|
456
459
|
/** Source to append to the search query string */
|
|
457
460
|
source?: SearchPlatform;
|
|
458
461
|
} | /** Our just the search query / identifier string */ string;
|
|
@@ -46,7 +46,7 @@ export class ManagerUtils {
|
|
|
46
46
|
identifier: data.info.identifier,
|
|
47
47
|
title: data.info.title,
|
|
48
48
|
author: data.info.author,
|
|
49
|
-
duration: data.info.
|
|
49
|
+
duration: data.info.duration || data.info.length,
|
|
50
50
|
artworkUrl: data.info.artworkUrl || data.pluginInfo?.artworkUrl || data.plugin?.artworkUrl,
|
|
51
51
|
uri: data.info.uri,
|
|
52
52
|
sourceName: data.info.sourceName,
|
|
@@ -202,7 +202,7 @@ export class ManagerUtils {
|
|
|
202
202
|
throw new Error("Lavalink Node has not 'soundcloud' enabled");
|
|
203
203
|
}
|
|
204
204
|
if (SourceLinksRegexes.bandcamp.test(queryString) && !node.info?.sourceManagers?.includes("bandcamp")) {
|
|
205
|
-
throw new Error("Lavalink Node has not 'bandcamp' enabled");
|
|
205
|
+
throw new Error("Lavalink Node has not 'bandcamp' enabled (introduced with lavaplayer 2.2.0 or lavalink 4.0.6)");
|
|
206
206
|
}
|
|
207
207
|
if (SourceLinksRegexes.TwitchTv.test(queryString) && !node.info?.sourceManagers?.includes("twitch")) {
|
|
208
208
|
throw new Error("Lavalink Node has not 'twitch' enabled");
|
|
@@ -234,9 +234,11 @@ export class ManagerUtils {
|
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
236
236
|
transformQuery(query) {
|
|
237
|
+
const sourceOfQuery = typeof query === "string" ? undefined : (DefaultSources[(query.source?.trim?.()?.toLowerCase?.()) ?? this.LavalinkManager?.options?.playerOptions?.defaultSearchPlatform?.toLowerCase?.()] ?? (query.source?.trim?.()?.toLowerCase?.()));
|
|
237
238
|
const Query = {
|
|
238
239
|
query: typeof query === "string" ? query : query.query,
|
|
239
|
-
|
|
240
|
+
extraQueryUrlParams: typeof query !== "string" ? query.extraQueryUrlParams : undefined,
|
|
241
|
+
source: sourceOfQuery ?? this.LavalinkManager?.options?.playerOptions?.defaultSearchPlatform?.toLowerCase?.()
|
|
240
242
|
};
|
|
241
243
|
const foundSource = Object.keys(DefaultSources).find(source => Query.query?.toLowerCase?.()?.startsWith(`${source}:`.toLowerCase()))?.trim?.()?.toLowerCase?.();
|
|
242
244
|
// ignore links...
|
|
@@ -248,10 +250,11 @@ export class ManagerUtils {
|
|
|
248
250
|
}
|
|
249
251
|
transformLavaSearchQuery(query) {
|
|
250
252
|
// transform the query object
|
|
253
|
+
const sourceOfQuery = typeof query === "string" ? undefined : (DefaultSources[(query.source?.trim?.()?.toLowerCase?.()) ?? this.LavalinkManager?.options?.playerOptions?.defaultSearchPlatform?.toLowerCase?.()] ?? (query.source?.trim?.()?.toLowerCase?.()));
|
|
251
254
|
const Query = {
|
|
252
255
|
query: typeof query === "string" ? query : query.query,
|
|
253
256
|
types: query.types ? ["track", "playlist", "artist", "album", "text"].filter(v => query.types?.find(x => x.toLowerCase().startsWith(v))) : ["track", "playlist", "artist", "album", /*"text"*/],
|
|
254
|
-
source:
|
|
257
|
+
source: sourceOfQuery ?? this.LavalinkManager?.options?.playerOptions?.defaultSearchPlatform?.toLowerCase?.()
|
|
255
258
|
};
|
|
256
259
|
const foundSource = Object.keys(DefaultSources).find(source => Query.query.toLowerCase().startsWith(`${source}:`.toLowerCase()))?.trim?.()?.toLowerCase?.();
|
|
257
260
|
if (foundSource && DefaultSources[foundSource]) {
|
|
@@ -7,7 +7,7 @@ export declare class FilterManager {
|
|
|
7
7
|
/** The Equalizer bands currently applied to the Lavalink Server */
|
|
8
8
|
equalizerBands: EQBand[];
|
|
9
9
|
/** Private Util for the instaFix Filters option */
|
|
10
|
-
filterUpdatedState:
|
|
10
|
+
filterUpdatedState: boolean;
|
|
11
11
|
/** All "Active" / "disabled" Player Filters */
|
|
12
12
|
filters: PlayerFilters;
|
|
13
13
|
/** The Filter Data sent to Lavalink, only if the filter is enabled (ofc.) */
|
|
@@ -6,6 +6,7 @@ import { DestroyReasonsType, Player, PlayerJson, PlayerOptions } from "./Player"
|
|
|
6
6
|
import { ManagerQueueOptions } from "./Queue";
|
|
7
7
|
import { Track, UnresolvedTrack } from "./Track";
|
|
8
8
|
import { ChannelDeletePacket, GuildShardPayload, ManagerUtils, MiniMap, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, VoicePacket, VoiceServer, VoiceState, WebSocketClosedEvent } from "./Utils";
|
|
9
|
+
/** How the botclient is allowed to be structured */
|
|
9
10
|
export interface BotClientOptions {
|
|
10
11
|
/** Bot Client Id */
|
|
11
12
|
id: string;
|
|
@@ -14,6 +15,7 @@ export interface BotClientOptions {
|
|
|
14
15
|
/** So users can pass entire objects / classes */
|
|
15
16
|
[x: string | number | symbol]: unknown;
|
|
16
17
|
}
|
|
18
|
+
/** Sub Manager Options, for player specific things */
|
|
17
19
|
export interface ManagerPlayerOptions {
|
|
18
20
|
/** If the Lavalink Volume should be decremented by x number */
|
|
19
21
|
volumeDecrementer?: number;
|
|
@@ -39,6 +41,7 @@ export interface ManagerPlayerOptions {
|
|
|
39
41
|
};
|
|
40
42
|
useUnresolvedData?: boolean;
|
|
41
43
|
}
|
|
44
|
+
/** Manager Options used to create the manager */
|
|
42
45
|
export interface ManagerOptions {
|
|
43
46
|
/** The Node Options, for all Nodes! (on init) */
|
|
44
47
|
nodes: LavalinkNodeOptions[];
|
|
@@ -64,8 +67,12 @@ export interface ManagerOptions {
|
|
|
64
67
|
linksAllowed?: boolean;
|
|
65
68
|
/** Advanced Options for the Library, which may or may not be "library breaking" */
|
|
66
69
|
advancedOptions?: {
|
|
70
|
+
/** Max duration for that the filter fix duration works (in ms) - default is 8mins */
|
|
71
|
+
maxFilterFixDuration?: number;
|
|
67
72
|
/** optional */
|
|
68
73
|
debugOptions?: {
|
|
74
|
+
/** For logging custom searches */
|
|
75
|
+
logCustomSearches?: boolean;
|
|
69
76
|
/** logs for debugging the "no-Audio" playing error */
|
|
70
77
|
noAudio?: boolean;
|
|
71
78
|
/** For Logging the Destroy function */
|
|
@@ -78,7 +85,7 @@ export interface ManagerOptions {
|
|
|
78
85
|
};
|
|
79
86
|
};
|
|
80
87
|
}
|
|
81
|
-
interface LavalinkManagerEvents {
|
|
88
|
+
export interface LavalinkManagerEvents {
|
|
82
89
|
/**
|
|
83
90
|
* Emitted when a Track started playing.
|
|
84
91
|
* @event Manager#trackStart
|
|
@@ -93,12 +100,12 @@ interface LavalinkManagerEvents {
|
|
|
93
100
|
* Emitted when a Track got stuck while playing.
|
|
94
101
|
* @event Manager#trackStuck
|
|
95
102
|
*/
|
|
96
|
-
"trackStuck": (player: Player, track: Track, payload: TrackStuckEvent) => void;
|
|
103
|
+
"trackStuck": (player: Player, track: Track | null, payload: TrackStuckEvent) => void;
|
|
97
104
|
/**
|
|
98
105
|
* Emitted when a Track errored.
|
|
99
106
|
* @event Manager#trackError
|
|
100
107
|
*/
|
|
101
|
-
"trackError": (player: Player, track: Track | UnresolvedTrack, payload: TrackExceptionEvent) => void;
|
|
108
|
+
"trackError": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackExceptionEvent) => void;
|
|
102
109
|
/**
|
|
103
110
|
* Emitted when the Playing finished and no more tracks in the queue.
|
|
104
111
|
* @event Manager#queueEnd
|
|
@@ -237,6 +244,7 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
237
244
|
* linksBlacklist: [],
|
|
238
245
|
* linksWhitelist: [],
|
|
239
246
|
* advancedOptions: {
|
|
247
|
+
* maxFilterFixDuration: 600_000,
|
|
240
248
|
* debugOptions: {
|
|
241
249
|
* noAudio: false,
|
|
242
250
|
* playerDestroy: {
|
|
@@ -307,10 +315,22 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
307
315
|
* Delete's a player from the cache without destroying it on lavalink (only works when it's disconnected)
|
|
308
316
|
* @param guildId
|
|
309
317
|
* @returns
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```ts
|
|
321
|
+
* client.lavalink.deletePlayer(interaction.guildId);
|
|
322
|
+
* // shouldn't be used except you know what you are doing.
|
|
323
|
+
* ```
|
|
310
324
|
*/
|
|
311
325
|
deletePlayer(guildId: string): boolean;
|
|
312
326
|
/**
|
|
313
327
|
* Checks wether the the lib is useable based on if any node is connected
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* if(!client.lavalink.useable) return console.error("can'T search yet, because there is no useable lavalink node.")
|
|
332
|
+
* // continue with code e.g. createing a player and searching
|
|
333
|
+
* ```
|
|
314
334
|
*/
|
|
315
335
|
get useable(): boolean;
|
|
316
336
|
/**
|
|
@@ -318,7 +338,6 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
318
338
|
* @param clientData
|
|
319
339
|
*
|
|
320
340
|
* @example
|
|
321
|
-
*
|
|
322
341
|
* ```ts
|
|
323
342
|
* // on the bot ready event
|
|
324
343
|
* client.on("ready", () => {
|
|
@@ -347,4 +366,3 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
347
366
|
*/
|
|
348
367
|
sendRawData(data: VoicePacket | VoiceServer | VoiceState | ChannelDeletePacket): Promise<void>;
|
|
349
368
|
}
|
|
350
|
-
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ClientCustomSearchPlatformUtils, LavalinkSearchPlatform, SearchPlatform, SourcesRegex } from "./Utils";
|
|
2
|
+
/** Default Sources Record, to allow source parsing with multiple inputs. */
|
|
2
3
|
export declare const DefaultSources: Record<SearchPlatform, LavalinkSearchPlatform | ClientCustomSearchPlatformUtils>;
|
|
4
|
+
/** Lavalink Plugins definiton */
|
|
3
5
|
export declare const LavalinkPlugins: {
|
|
4
6
|
DuncteBot_Plugin: string;
|
|
5
7
|
LavaSrc: string;
|
|
@@ -7,4 +9,5 @@ export declare const LavalinkPlugins: {
|
|
|
7
9
|
LavaSearch: string;
|
|
8
10
|
LavalinkFilterPlugin: string;
|
|
9
11
|
};
|
|
12
|
+
/** Lavalink Sources regexes for url validations */
|
|
10
13
|
export declare const SourceLinksRegexes: Record<SourcesRegex, RegExp>;
|