lavalink-client 2.2.2 → 2.3.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 +95 -1
- package/dist/cjs/index.d.ts +8 -1
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/structures/Constants.d.ts +40 -0
- package/dist/cjs/structures/Constants.js +244 -0
- package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/cjs/structures/Filters.d.ts +2 -217
- package/dist/cjs/structures/Filters.js +8 -232
- package/dist/cjs/structures/LavalinkManager.d.ts +31 -166
- package/dist/cjs/structures/LavalinkManager.js +59 -7
- package/dist/cjs/structures/LavalinkManagerStatics.d.ts +1 -1
- package/dist/cjs/structures/Node.d.ts +15 -156
- package/dist/cjs/structures/Node.js +131 -49
- package/dist/cjs/structures/NodeManager.d.ts +54 -52
- package/dist/cjs/structures/NodeManager.js +74 -4
- package/dist/cjs/structures/Player.d.ts +31 -124
- package/dist/cjs/structures/Player.js +77 -43
- package/dist/cjs/structures/Queue.d.ts +66 -42
- package/dist/cjs/structures/Queue.js +69 -11
- package/dist/cjs/structures/Types/Filters.d.ts +190 -0
- package/dist/cjs/structures/Types/Manager.d.ts +184 -0
- package/dist/cjs/structures/Types/Manager.js +2 -0
- package/dist/cjs/structures/Types/Node.d.ts +216 -0
- package/dist/cjs/structures/Types/Node.js +2 -0
- package/dist/cjs/structures/Types/Player.d.ts +108 -0
- package/dist/cjs/structures/Types/Player.js +2 -0
- package/dist/cjs/structures/Types/Queue.d.ts +34 -0
- package/dist/cjs/structures/Types/Queue.js +2 -0
- package/dist/cjs/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
- package/dist/{structures → cjs/structures/Types}/Track.js +2 -2
- package/dist/cjs/structures/Types/Utils.d.ts +367 -0
- package/dist/cjs/structures/Types/Utils.js +2 -0
- package/dist/cjs/structures/Utils.d.ts +13 -369
- package/dist/cjs/structures/Utils.js +35 -14
- package/dist/esm/index.d.ts +8 -1
- package/dist/esm/index.js +8 -1
- package/dist/esm/structures/Constants.d.ts +40 -0
- package/dist/esm/structures/Constants.js +241 -0
- package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/esm/structures/Filters.d.ts +2 -217
- package/dist/esm/structures/Filters.js +3 -227
- package/dist/esm/structures/LavalinkManager.d.ts +31 -166
- package/dist/esm/structures/LavalinkManager.js +57 -5
- package/dist/esm/structures/LavalinkManagerStatics.d.ts +1 -1
- package/dist/esm/structures/Node.d.ts +15 -156
- package/dist/esm/structures/Node.js +122 -40
- package/dist/esm/structures/NodeManager.d.ts +54 -52
- package/dist/esm/structures/NodeManager.js +71 -1
- package/dist/esm/structures/Player.d.ts +31 -124
- package/dist/esm/structures/Player.js +76 -42
- package/dist/esm/structures/Queue.d.ts +66 -42
- package/dist/esm/structures/Queue.js +69 -11
- package/dist/esm/structures/Types/Filters.d.ts +190 -0
- package/dist/esm/structures/Types/Manager.d.ts +184 -0
- package/dist/esm/structures/Types/Manager.js +1 -0
- package/dist/esm/structures/Types/Node.d.ts +216 -0
- package/dist/esm/structures/Types/Node.js +1 -0
- package/dist/esm/structures/Types/Player.d.ts +108 -0
- package/dist/esm/structures/Types/Player.js +1 -0
- package/dist/esm/structures/Types/Queue.d.ts +34 -0
- package/dist/esm/structures/Types/Queue.js +1 -0
- package/dist/esm/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
- package/dist/esm/structures/Types/Track.js +1 -0
- package/dist/esm/structures/Types/Utils.d.ts +367 -0
- package/dist/esm/structures/Types/Utils.js +1 -0
- package/dist/esm/structures/Utils.d.ts +13 -369
- package/dist/esm/structures/Utils.js +35 -14
- package/dist/types/index.d.ts +8 -1
- package/dist/types/structures/Constants.d.ts +40 -0
- package/dist/types/structures/CustomSearches/BandCampSearch.d.ts +2 -2
- package/dist/types/structures/Filters.d.ts +2 -217
- package/dist/types/structures/LavalinkManager.d.ts +31 -166
- package/dist/types/structures/LavalinkManagerStatics.d.ts +1 -1
- package/dist/types/structures/Node.d.ts +15 -156
- package/dist/types/structures/NodeManager.d.ts +54 -52
- package/dist/types/structures/Player.d.ts +31 -124
- package/dist/types/structures/Queue.d.ts +66 -42
- package/dist/types/structures/Types/Filters.d.ts +190 -0
- package/dist/types/structures/Types/Manager.d.ts +184 -0
- package/dist/types/structures/Types/Node.d.ts +216 -0
- package/dist/types/structures/Types/Player.d.ts +108 -0
- package/dist/types/structures/Types/Queue.d.ts +34 -0
- package/dist/types/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
- package/dist/types/structures/Types/Utils.d.ts +367 -0
- package/dist/types/structures/Utils.d.ts +13 -369
- package/package.json +1 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -13
- package/dist/structures/Filters.d.ts +0 -230
- package/dist/structures/Filters.js +0 -472
- package/dist/structures/LavalinkManager.d.ts +0 -47
- package/dist/structures/LavalinkManager.js +0 -36
- package/dist/structures/LavalinkManagerStatics.d.ts +0 -3
- package/dist/structures/LavalinkManagerStatics.js +0 -76
- package/dist/structures/Node.d.ts +0 -171
- package/dist/structures/Node.js +0 -462
- package/dist/structures/NodeManager.d.ts +0 -58
- package/dist/structures/NodeManager.js +0 -25
- package/dist/structures/Player.d.ts +0 -101
- package/dist/structures/Player.js +0 -232
- package/dist/structures/PlayerManager.d.ts +0 -62
- package/dist/structures/PlayerManager.js +0 -26
- package/dist/structures/Queue.d.ts +0 -93
- package/dist/structures/Queue.js +0 -160
- package/dist/structures/QueueManager.d.ts +0 -77
- package/dist/structures/QueueManager.js +0 -74
- package/dist/structures/Track.d.ts +0 -27
- package/dist/structures/Utils.d.ts +0 -183
- package/dist/structures/Utils.js +0 -43
- /package/dist/cjs/structures/{Track.js → Types/Filters.js} +0 -0
- /package/dist/esm/structures/{Track.js → Types/Filters.js} +0 -0
|
@@ -1,62 +1,79 @@
|
|
|
1
|
-
import { Track, UnresolvedTrack } from "./Track";
|
|
2
1
|
import { MiniMap } from "./Utils";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** @async Delete a Database Value based of it's guildId */
|
|
14
|
-
delete: (guildId: unknown) => Promise<unknown>;
|
|
15
|
-
/** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
|
|
16
|
-
stringify: (value: unknown) => Promise<unknown>;
|
|
17
|
-
/** @async Parse the saved value back to the Queue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
|
|
18
|
-
parse: (value: unknown) => Promise<Partial<StoredQueue>>;
|
|
19
|
-
}
|
|
20
|
-
export interface ManagerQueueOptions {
|
|
21
|
-
/** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
|
|
22
|
-
maxPreviousTracks?: number;
|
|
23
|
-
/** Custom Queue Store option */
|
|
24
|
-
queueStore?: QueueStoreManager;
|
|
25
|
-
/** Custom Queue Watcher class */
|
|
26
|
-
queueChangesWatcher?: QueueChangesWatcher;
|
|
27
|
-
}
|
|
28
|
-
export interface QueueSaver {
|
|
29
|
-
/** @private */
|
|
30
|
-
_: QueueStoreManager;
|
|
31
|
-
/** @private */
|
|
2
|
+
import type { Track, UnresolvedTrack } from "./Types/Track";
|
|
3
|
+
import type { ManagerQueueOptions, QueueStoreManager, StoredQueue } from "./Types/Queue";
|
|
4
|
+
export declare class QueueSaver {
|
|
5
|
+
/**
|
|
6
|
+
* The queue store manager
|
|
7
|
+
*/
|
|
8
|
+
private _;
|
|
9
|
+
/**
|
|
10
|
+
* The options for the queue saver
|
|
11
|
+
*/
|
|
32
12
|
options: {
|
|
33
13
|
maxPreviousTracks: number;
|
|
34
14
|
};
|
|
35
|
-
}
|
|
36
|
-
export declare class QueueSaver {
|
|
37
15
|
constructor(options: ManagerQueueOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Get the queue for a guild
|
|
18
|
+
* @param guildId The guild ID
|
|
19
|
+
* @returns The queue for the guild
|
|
20
|
+
*/
|
|
38
21
|
get(guildId: string): Promise<Partial<StoredQueue>>;
|
|
22
|
+
/**
|
|
23
|
+
* Delete the queue for a guild
|
|
24
|
+
* @param guildId The guild ID
|
|
25
|
+
* @returns The queue for the guild
|
|
26
|
+
*/
|
|
39
27
|
delete(guildId: string): Promise<unknown>;
|
|
40
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Set the queue for a guild
|
|
30
|
+
* @param guildId The guild ID
|
|
31
|
+
* @param valueToStringify The queue to set
|
|
32
|
+
* @returns The queue for the guild
|
|
33
|
+
*/
|
|
34
|
+
set(guildId: string, valueToStringify: StoredQueue): Promise<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Sync the queue for a guild
|
|
37
|
+
* @param guildId The guild ID
|
|
38
|
+
* @returns The queue for the guild
|
|
39
|
+
*/
|
|
41
40
|
sync(guildId: string): Promise<Partial<StoredQueue>>;
|
|
42
41
|
}
|
|
43
42
|
export declare class DefaultQueueStore implements QueueStoreManager {
|
|
44
43
|
private data;
|
|
45
44
|
constructor();
|
|
45
|
+
/**
|
|
46
|
+
* Get the queue for a guild
|
|
47
|
+
* @param guildId The guild ID
|
|
48
|
+
* @returns The queue for the guild
|
|
49
|
+
*/
|
|
46
50
|
get(guildId: any): Promise<unknown>;
|
|
47
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Set the queue for a guild
|
|
53
|
+
* @param guildId The guild ID
|
|
54
|
+
* @param valueToStringify The queue to set
|
|
55
|
+
* @returns The queue for the guild
|
|
56
|
+
*/
|
|
57
|
+
set(guildId: any, valueToStringify: any): Promise<MiniMap<unknown, unknown>>;
|
|
58
|
+
/**
|
|
59
|
+
* Delete the queue for a guild
|
|
60
|
+
* @param guildId The guild ID
|
|
61
|
+
* @returns The queue for the guild
|
|
62
|
+
*/
|
|
48
63
|
delete(guildId: any): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Stringify the queue for a guild
|
|
66
|
+
* @param value The queue to stringify
|
|
67
|
+
* @returns The stringified queue
|
|
68
|
+
*/
|
|
49
69
|
stringify(value: any): Promise<any>;
|
|
70
|
+
/**
|
|
71
|
+
* Parse the queue for a guild
|
|
72
|
+
* @param value The queue to parse
|
|
73
|
+
* @returns The parsed queue
|
|
74
|
+
*/
|
|
50
75
|
parse(value: any): Promise<Partial<StoredQueue>>;
|
|
51
76
|
}
|
|
52
|
-
export interface QueueChangesWatcher {
|
|
53
|
-
/** get a Value (MUST RETURN UNPARSED!) */
|
|
54
|
-
tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => any;
|
|
55
|
-
/** Set a value inside a guildId (MUST BE UNPARSED) */
|
|
56
|
-
tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => any;
|
|
57
|
-
/** Set a value inside a guildId (MUST BE UNPARSED) */
|
|
58
|
-
shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => any;
|
|
59
|
-
}
|
|
60
77
|
export declare class Queue {
|
|
61
78
|
readonly tracks: (Track | UnresolvedTrack)[];
|
|
62
79
|
readonly previous: Track[];
|
|
@@ -68,6 +85,13 @@ export declare class Queue {
|
|
|
68
85
|
private readonly QueueSaver;
|
|
69
86
|
private managerUtils;
|
|
70
87
|
private queueChanges;
|
|
88
|
+
/**
|
|
89
|
+
* Create a new Queue
|
|
90
|
+
* @param guildId The guild ID
|
|
91
|
+
* @param data The data to initialize the queue with
|
|
92
|
+
* @param QueueSaver The queue saver to use
|
|
93
|
+
* @param queueOptions
|
|
94
|
+
*/
|
|
71
95
|
constructor(guildId: string, data?: Partial<StoredQueue>, QueueSaver?: QueueSaver, queueOptions?: ManagerQueueOptions);
|
|
72
96
|
/**
|
|
73
97
|
* Utils for a Queue
|
|
@@ -1,39 +1,94 @@
|
|
|
1
1
|
import { ManagerUtils, MiniMap, QueueSymbol } from "./Utils";
|
|
2
2
|
export class QueueSaver {
|
|
3
|
+
/**
|
|
4
|
+
* The queue store manager
|
|
5
|
+
*/
|
|
6
|
+
_;
|
|
7
|
+
/**
|
|
8
|
+
* The options for the queue saver
|
|
9
|
+
*/
|
|
10
|
+
options;
|
|
3
11
|
constructor(options) {
|
|
4
12
|
this._ = options?.queueStore || new DefaultQueueStore();
|
|
5
13
|
this.options = {
|
|
6
14
|
maxPreviousTracks: options?.maxPreviousTracks || 25,
|
|
7
15
|
};
|
|
8
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the queue for a guild
|
|
19
|
+
* @param guildId The guild ID
|
|
20
|
+
* @returns The queue for the guild
|
|
21
|
+
*/
|
|
9
22
|
async get(guildId) {
|
|
10
|
-
return
|
|
23
|
+
return this._.parse(await this._.get(guildId));
|
|
11
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Delete the queue for a guild
|
|
27
|
+
* @param guildId The guild ID
|
|
28
|
+
* @returns The queue for the guild
|
|
29
|
+
*/
|
|
12
30
|
async delete(guildId) {
|
|
13
|
-
return
|
|
31
|
+
return this._.delete(guildId);
|
|
14
32
|
}
|
|
15
|
-
|
|
16
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Set the queue for a guild
|
|
35
|
+
* @param guildId The guild ID
|
|
36
|
+
* @param valueToStringify The queue to set
|
|
37
|
+
* @returns The queue for the guild
|
|
38
|
+
*/
|
|
39
|
+
async set(guildId, valueToStringify) {
|
|
40
|
+
return this._.set(guildId, await this._.stringify(valueToStringify));
|
|
17
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Sync the queue for a guild
|
|
44
|
+
* @param guildId The guild ID
|
|
45
|
+
* @returns The queue for the guild
|
|
46
|
+
*/
|
|
18
47
|
async sync(guildId) {
|
|
19
|
-
return
|
|
48
|
+
return this.get(guildId);
|
|
20
49
|
}
|
|
21
50
|
}
|
|
22
51
|
export class DefaultQueueStore {
|
|
23
52
|
data = new MiniMap();
|
|
24
53
|
constructor() { }
|
|
54
|
+
/**
|
|
55
|
+
* Get the queue for a guild
|
|
56
|
+
* @param guildId The guild ID
|
|
57
|
+
* @returns The queue for the guild
|
|
58
|
+
*/
|
|
25
59
|
async get(guildId) {
|
|
26
60
|
return await this.data.get(guildId);
|
|
27
61
|
}
|
|
28
|
-
|
|
29
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Set the queue for a guild
|
|
64
|
+
* @param guildId The guild ID
|
|
65
|
+
* @param valueToStringify The queue to set
|
|
66
|
+
* @returns The queue for the guild
|
|
67
|
+
*/
|
|
68
|
+
async set(guildId, valueToStringify) {
|
|
69
|
+
return await this.data.set(guildId, valueToStringify);
|
|
30
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Delete the queue for a guild
|
|
73
|
+
* @param guildId The guild ID
|
|
74
|
+
* @returns The queue for the guild
|
|
75
|
+
*/
|
|
31
76
|
async delete(guildId) {
|
|
32
77
|
return await this.data.delete(guildId);
|
|
33
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Stringify the queue for a guild
|
|
81
|
+
* @param value The queue to stringify
|
|
82
|
+
* @returns The stringified queue
|
|
83
|
+
*/
|
|
34
84
|
async stringify(value) {
|
|
35
85
|
return value; // JSON.stringify(value);
|
|
36
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Parse the queue for a guild
|
|
89
|
+
* @param value The queue to parse
|
|
90
|
+
* @returns The parsed queue
|
|
91
|
+
*/
|
|
37
92
|
async parse(value) {
|
|
38
93
|
return value; // JSON.parse(value)
|
|
39
94
|
}
|
|
@@ -47,6 +102,13 @@ export class Queue {
|
|
|
47
102
|
QueueSaver = null;
|
|
48
103
|
managerUtils = new ManagerUtils();
|
|
49
104
|
queueChanges;
|
|
105
|
+
/**
|
|
106
|
+
* Create a new Queue
|
|
107
|
+
* @param guildId The guild ID
|
|
108
|
+
* @param data The data to initialize the queue with
|
|
109
|
+
* @param QueueSaver The queue saver to use
|
|
110
|
+
* @param queueOptions
|
|
111
|
+
*/
|
|
50
112
|
constructor(guildId, data = {}, QueueSaver, queueOptions) {
|
|
51
113
|
this.queueChanges = queueOptions.queueChangesWatcher || null;
|
|
52
114
|
this.guildId = guildId;
|
|
@@ -230,7 +292,6 @@ export class Queue {
|
|
|
230
292
|
return null;
|
|
231
293
|
const removed = this.tracks.splice(removeQueryTrack, 1);
|
|
232
294
|
await this.utils.save();
|
|
233
|
-
console.log("0st", removed, toRemove);
|
|
234
295
|
return { removed };
|
|
235
296
|
}
|
|
236
297
|
if (Array.isArray(removeQueryTrack)) {
|
|
@@ -240,7 +301,6 @@ export class Queue {
|
|
|
240
301
|
if (this.tracks[i])
|
|
241
302
|
removed.push(...this.tracks.splice(i, 1));
|
|
242
303
|
}
|
|
243
|
-
console.log("1st", removed, removeQueryTrack);
|
|
244
304
|
if (!removed.length)
|
|
245
305
|
return null;
|
|
246
306
|
await this.utils.save();
|
|
@@ -261,7 +321,6 @@ export class Queue {
|
|
|
261
321
|
removed.push(...this.tracks.splice(i, 1));
|
|
262
322
|
}
|
|
263
323
|
await this.utils.save();
|
|
264
|
-
console.log("2nd", removed, tracksToRemove);
|
|
265
324
|
return { removed };
|
|
266
325
|
}
|
|
267
326
|
const toRemove = this.tracks.findIndex((v) => removeQueryTrack.encoded && removeQueryTrack.encoded === v.encoded ||
|
|
@@ -274,7 +333,6 @@ export class Queue {
|
|
|
274
333
|
return null;
|
|
275
334
|
const removed = this.tracks.splice(toRemove, 1);
|
|
276
335
|
await this.utils.save();
|
|
277
|
-
console.log("3rd", removed, toRemove);
|
|
278
336
|
return { removed };
|
|
279
337
|
}
|
|
280
338
|
/**
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { FloatNumber, IntegerNumber } from "./Utils";
|
|
2
|
+
/** The Audio Outputs type */
|
|
3
|
+
export type AudioOutputs = "mono" | "stereo" | "left" | "right";
|
|
4
|
+
/** The "active" / "disabled" Player Filters */
|
|
5
|
+
export interface PlayerFilters {
|
|
6
|
+
/** Sets nightcore to false, and vaporwave to false */
|
|
7
|
+
custom: boolean;
|
|
8
|
+
/** Sets custom to false, and vaporwave to false */
|
|
9
|
+
nightcore: boolean;
|
|
10
|
+
/** Sets custom to false, and nightcore to false */
|
|
11
|
+
vaporwave: boolean;
|
|
12
|
+
/** If rotation filter is enabled / not */
|
|
13
|
+
rotation: boolean;
|
|
14
|
+
/** if karaoke filter is enabled / not */
|
|
15
|
+
karaoke: boolean;
|
|
16
|
+
/** if tremolo filter is enabled / not */
|
|
17
|
+
tremolo: boolean;
|
|
18
|
+
/** if vibrato filter is enabled / not */
|
|
19
|
+
vibrato: boolean;
|
|
20
|
+
lowPass: boolean;
|
|
21
|
+
/** audio Output (default stereo, mono sounds the fullest and best for not-stereo tracks) */
|
|
22
|
+
audioOutput: AudioOutputs;
|
|
23
|
+
/** Lavalink Volume FILTER (not player Volume, think of it as a gain booster) */
|
|
24
|
+
volume: boolean;
|
|
25
|
+
/** Filters for the Lavalink Filter Plugin */
|
|
26
|
+
lavalinkFilterPlugin: {
|
|
27
|
+
/** if echo filter is enabled / not */
|
|
28
|
+
echo: boolean;
|
|
29
|
+
/** if reverb filter is enabled / not */
|
|
30
|
+
reverb: boolean;
|
|
31
|
+
};
|
|
32
|
+
lavalinkLavaDspxPlugin: {
|
|
33
|
+
/** if lowPass filter is enabled / not */
|
|
34
|
+
lowPass: boolean;
|
|
35
|
+
/** if highPass filter is enabled / not */
|
|
36
|
+
highPass: boolean;
|
|
37
|
+
/** if normalization filter is enabled / not */
|
|
38
|
+
normalization: boolean;
|
|
39
|
+
/** if echo filter is enabled / not */
|
|
40
|
+
echo: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* There are 15 bands (0-14) that can be changed.
|
|
45
|
+
* "gain" is the multiplier for the given band.
|
|
46
|
+
* The default value is 0.
|
|
47
|
+
* Valid values range from -0.25 to 1.0, where -0.25 means the given band is completely muted, and 0.25 means it is doubled.
|
|
48
|
+
* Modifying the gain could also change the volume of the output.
|
|
49
|
+
*/
|
|
50
|
+
export interface EQBand {
|
|
51
|
+
/** On what band position (0-14) it should work */
|
|
52
|
+
band: IntegerNumber | number;
|
|
53
|
+
/** The gain (-0.25 to 1.0) */
|
|
54
|
+
gain: FloatNumber | number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Uses equalization to eliminate part of a band, usually targeting vocals.
|
|
58
|
+
*/
|
|
59
|
+
export interface KaraokeFilter {
|
|
60
|
+
/** The level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
|
|
61
|
+
level?: number;
|
|
62
|
+
/** The mono level (0 to 1.0 where 0.0 is no effect and 1.0 is full effect) */
|
|
63
|
+
monoLevel?: number;
|
|
64
|
+
/** The filter band (in Hz) */
|
|
65
|
+
filterBand?: number;
|
|
66
|
+
/** The filter width */
|
|
67
|
+
filterWidth?: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Changes the speed, pitch, and rate
|
|
71
|
+
*/
|
|
72
|
+
export interface TimescaleFilter {
|
|
73
|
+
/** The playback speed 0.0 ≤ x */
|
|
74
|
+
speed?: number;
|
|
75
|
+
/** The pitch 0.0 ≤ x */
|
|
76
|
+
pitch?: number;
|
|
77
|
+
/** The rate 0.0 ≤ x */
|
|
78
|
+
rate?: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Uses amplification to create a shuddering effect, where the volume quickly oscillates.
|
|
82
|
+
* Demo: https://en.wikipedia.org/wiki/File:Fuse_Electronics_Tremolo_MK-III_Quick_Demo.ogv
|
|
83
|
+
*/
|
|
84
|
+
export interface TremoloFilter {
|
|
85
|
+
/** The frequency 0.0 < x */
|
|
86
|
+
frequency?: number;
|
|
87
|
+
/** The tremolo depth 0.0 < x ≤ 1.0 */
|
|
88
|
+
depth?: number;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Similar to tremolo. While tremolo oscillates the volume, vibrato oscillates the pitch.
|
|
92
|
+
*/
|
|
93
|
+
export interface VibratoFilter {
|
|
94
|
+
/** The frequency 0.0 < x ≤ 14.0 */
|
|
95
|
+
frequency?: number;
|
|
96
|
+
/** The vibrato depth 0.0 < x ≤ 1.0 */
|
|
97
|
+
depth?: number;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Rotates the sound around the stereo channels/user headphones (aka Audio Panning).
|
|
101
|
+
* It can produce an effect similar to https://youtu.be/QB9EB8mTKcc (without the reverb).
|
|
102
|
+
*/
|
|
103
|
+
export interface RotationFilter {
|
|
104
|
+
/** The frequency of the audio rotating around the listener in Hz. 0.2 is similar to the example video above */
|
|
105
|
+
rotationHz?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Distortion effect. It can generate some pretty unique audio effects.
|
|
109
|
+
*/
|
|
110
|
+
export interface DistortionFilter {
|
|
111
|
+
sinOffset?: number;
|
|
112
|
+
sinScale?: number;
|
|
113
|
+
cosOffset?: number;
|
|
114
|
+
cosScale?: number;
|
|
115
|
+
tanOffset?: number;
|
|
116
|
+
tanScale?: number;
|
|
117
|
+
offset?: number;
|
|
118
|
+
scale?: number;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Mixes both channels (left and right), with a configurable factor on how much each channel affects the other.
|
|
122
|
+
* With the defaults, both channels are kept independent of each other.
|
|
123
|
+
* Setting all factors to 0.5 means both channels get the same audio.
|
|
124
|
+
*/
|
|
125
|
+
export interface ChannelMixFilter {
|
|
126
|
+
/** The left to left channel mix factor (0.0 ≤ x ≤ 1.0) */
|
|
127
|
+
leftToLeft?: number;
|
|
128
|
+
/** The left to right channel mix factor (0.0 ≤ x ≤ 1.0) */
|
|
129
|
+
leftToRight?: number;
|
|
130
|
+
/** The right to left channel mix factor (0.0 ≤ x ≤ 1.0) */
|
|
131
|
+
rightToLeft?: number;
|
|
132
|
+
/** The right to right channel mix factor (0.0 ≤ x ≤ 1.0) */
|
|
133
|
+
rightToRight?: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Higher frequencies get suppressed, while lower frequencies pass through this filter, thus the name low pass.
|
|
137
|
+
* Any smoothing values equal to or less than 1.0 will disable the filter.
|
|
138
|
+
*/
|
|
139
|
+
export interface LowPassFilter {
|
|
140
|
+
/** The smoothing factor (1.0 < x) */
|
|
141
|
+
smoothing?: number;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Filter Data stored in the Client and partially sent to Lavalink
|
|
145
|
+
*/
|
|
146
|
+
export interface FilterData {
|
|
147
|
+
volume?: number;
|
|
148
|
+
karaoke?: KaraokeFilter;
|
|
149
|
+
timescale?: TimescaleFilter;
|
|
150
|
+
tremolo?: TremoloFilter;
|
|
151
|
+
vibrato?: VibratoFilter;
|
|
152
|
+
rotation?: RotationFilter;
|
|
153
|
+
distortion?: DistortionFilter;
|
|
154
|
+
channelMix?: ChannelMixFilter;
|
|
155
|
+
lowPass?: LowPassFilter;
|
|
156
|
+
pluginFilters?: {
|
|
157
|
+
"lavalink-filter-plugin"?: {
|
|
158
|
+
"echo"?: {
|
|
159
|
+
delay?: number;
|
|
160
|
+
decay?: number;
|
|
161
|
+
};
|
|
162
|
+
"reverb"?: {
|
|
163
|
+
delays?: number[];
|
|
164
|
+
gains?: number[];
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
"high-pass"?: {
|
|
168
|
+
cutoffFrequency?: number;
|
|
169
|
+
boostFactor?: number;
|
|
170
|
+
};
|
|
171
|
+
"low-pass"?: {
|
|
172
|
+
cutoffFrequency?: number;
|
|
173
|
+
boostFactor?: number;
|
|
174
|
+
};
|
|
175
|
+
normalization?: {
|
|
176
|
+
maxAmplitude?: number;
|
|
177
|
+
adaptive?: boolean;
|
|
178
|
+
};
|
|
179
|
+
echo?: {
|
|
180
|
+
echoLength?: number;
|
|
181
|
+
decay?: number;
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Actual Filter Data sent to Lavalink
|
|
187
|
+
*/
|
|
188
|
+
export interface LavalinkFilterData extends FilterData {
|
|
189
|
+
equalizer?: EQBand[];
|
|
190
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import type { Player } from "../Player";
|
|
2
|
+
import type { LavalinkNodeOptions } from "./Node";
|
|
3
|
+
import type { DestroyReasonsType, PlayerJson } from "./Player";
|
|
4
|
+
import type { ManagerQueueOptions } from "./Queue";
|
|
5
|
+
import type { Track, UnresolvedTrack } from "./Track";
|
|
6
|
+
import type { GuildShardPayload, SearchPlatform, SponsorBlockChaptersLoaded, SponsorBlockChapterStarted, SponsorBlockSegmentSkipped, SponsorBlockSegmentsLoaded, TrackExceptionEvent, TrackEndEvent, TrackStuckEvent, WebSocketClosedEvent, TrackStartEvent } from "./Utils";
|
|
7
|
+
/**
|
|
8
|
+
* The events from the lavalink Manager
|
|
9
|
+
*/
|
|
10
|
+
export interface LavalinkManagerEvents {
|
|
11
|
+
/**
|
|
12
|
+
* Emitted when a Track started playing.
|
|
13
|
+
* @event Manager#trackStart
|
|
14
|
+
*/
|
|
15
|
+
"trackStart": (player: Player, track: Track | null, payload: TrackStartEvent) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Emitted when a Track finished.
|
|
18
|
+
* @event Manager#trackEnd
|
|
19
|
+
*/
|
|
20
|
+
"trackEnd": (player: Player, track: Track | null, payload: TrackEndEvent) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Emitted when a Track got stuck while playing.
|
|
23
|
+
* @event Manager#trackStuck
|
|
24
|
+
*/
|
|
25
|
+
"trackStuck": (player: Player, track: Track | null, payload: TrackStuckEvent) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Emitted when a Track errored.
|
|
28
|
+
* @event Manager#trackError
|
|
29
|
+
*/
|
|
30
|
+
"trackError": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackExceptionEvent) => void;
|
|
31
|
+
/**
|
|
32
|
+
* Emitted when the Playing finished and no more tracks in the queue.
|
|
33
|
+
* @event Manager#queueEnd
|
|
34
|
+
*/
|
|
35
|
+
"queueEnd": (player: Player, track: Track | UnresolvedTrack | null, payload: TrackEndEvent | TrackStuckEvent | TrackExceptionEvent) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Emitted when a Player is created.
|
|
38
|
+
* @event Manager#playerCreate
|
|
39
|
+
*/
|
|
40
|
+
"playerCreate": (player: Player) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Emitted when a Player is moved within the channel.
|
|
43
|
+
* @event Manager#playerMove
|
|
44
|
+
*/
|
|
45
|
+
"playerMove": (player: Player, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Emitted when a Player is disconnected from a channel.
|
|
48
|
+
* @event Manager#playerDisconnect
|
|
49
|
+
*/
|
|
50
|
+
"playerDisconnect": (player: Player, voiceChannelId: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Emitted when a Node-Socket got closed for a specific Player.
|
|
53
|
+
* Usually emits when the audio websocket to discord is closed, This can happen for various reasons (normal and abnormal), e.g. when using an expired voice server update. 4xxx codes are usually bad.
|
|
54
|
+
*
|
|
55
|
+
* So this is just information, normally lavalink should handle disconnections
|
|
56
|
+
*
|
|
57
|
+
* Discord Docs:
|
|
58
|
+
* @link https://discord.com/developers/docs/topics/opcodes-and-status-codes#voice-voice-close-event-codes
|
|
59
|
+
*
|
|
60
|
+
* Lavalink Docs:
|
|
61
|
+
* @link https://lavalink.dev/api/websocket.html#websocketclosedevent
|
|
62
|
+
* @event Manager#playerSocketClosed
|
|
63
|
+
*/
|
|
64
|
+
"playerSocketClosed": (player: Player, payload: WebSocketClosedEvent) => void;
|
|
65
|
+
/**
|
|
66
|
+
* Emitted when a Player get's destroyed
|
|
67
|
+
* @event Manager#playerDestroy
|
|
68
|
+
*/
|
|
69
|
+
"playerDestroy": (player: Player, destroyReason?: DestroyReasonsType) => void;
|
|
70
|
+
/**
|
|
71
|
+
* Always emits when the player (on lavalink side) got updated
|
|
72
|
+
* @event Manager#playerUpdate
|
|
73
|
+
*/
|
|
74
|
+
"playerUpdate": (oldPlayerJson: PlayerJson, newPlayer: Player) => void;
|
|
75
|
+
/**
|
|
76
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
77
|
+
* Emitted when Segments are loaded
|
|
78
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
|
|
79
|
+
* @event Manager#trackError
|
|
80
|
+
*/
|
|
81
|
+
"SegmentsLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentsLoaded) => void;
|
|
82
|
+
/**
|
|
83
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
84
|
+
* Emitted when a specific Segment was skipped
|
|
85
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#segmentskipped
|
|
86
|
+
* @event Manager#trackError
|
|
87
|
+
*/
|
|
88
|
+
"SegmentSkipped": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockSegmentSkipped) => void;
|
|
89
|
+
/**
|
|
90
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
91
|
+
* Emitted when a specific Chapter starts playing
|
|
92
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#chapterstarted
|
|
93
|
+
* @event Manager#trackError
|
|
94
|
+
*/
|
|
95
|
+
"ChapterStarted": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChapterStarted) => void;
|
|
96
|
+
/**
|
|
97
|
+
* SPONSORBLOCK-PLUGIN EVENT
|
|
98
|
+
* Emitted when Chapters are loaded
|
|
99
|
+
* @link https://github.com/topi314/Sponsorblock-Plugin#chaptersloaded
|
|
100
|
+
* @event Manager#trackError
|
|
101
|
+
*/
|
|
102
|
+
"ChaptersLoaded": (player: Player, track: Track | UnresolvedTrack | null, payload: SponsorBlockChaptersLoaded) => void;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The Bot client Options needed for the manager
|
|
106
|
+
*/
|
|
107
|
+
export interface BotClientOptions {
|
|
108
|
+
/** Bot Client Id */
|
|
109
|
+
id: string;
|
|
110
|
+
/** Bot Client Username */
|
|
111
|
+
username?: string;
|
|
112
|
+
/** So users can pass entire objects / classes */
|
|
113
|
+
[x: string | number | symbol]: unknown;
|
|
114
|
+
}
|
|
115
|
+
/** Sub Manager Options, for player specific things */
|
|
116
|
+
export interface ManagerPlayerOptions {
|
|
117
|
+
/** If the Lavalink Volume should be decremented by x number */
|
|
118
|
+
volumeDecrementer?: number;
|
|
119
|
+
/** How often it should update the the player Position */
|
|
120
|
+
clientBasedPositionUpdateInterval?: number;
|
|
121
|
+
/** What should be used as a searchPlatform, if no source was provided during the query */
|
|
122
|
+
defaultSearchPlatform?: SearchPlatform;
|
|
123
|
+
/** Applies the volume via a filter, not via the lavalink volume transformer */
|
|
124
|
+
applyVolumeAsFilter?: boolean;
|
|
125
|
+
/** Transforms the saved data of a requested user */
|
|
126
|
+
requesterTransformer?: (requester: unknown) => unknown;
|
|
127
|
+
/** What lavalink-client should do when the player reconnects */
|
|
128
|
+
onDisconnect?: {
|
|
129
|
+
/** Try to reconnect? -> If fails -> Destroy */
|
|
130
|
+
autoReconnect?: boolean;
|
|
131
|
+
/** Instantly destroy player (overrides autoReconnect) | Don't provide == disable feature*/
|
|
132
|
+
destroyPlayer?: boolean;
|
|
133
|
+
};
|
|
134
|
+
onEmptyQueue?: {
|
|
135
|
+
/** Get's executed onEmptyQueue -> You can do any track queue previous transformations, if you add a track to the queue -> it will play it, if not queueEnd will execute! */
|
|
136
|
+
autoPlayFunction?: (player: Player, lastPlayedTrack: Track) => Promise<void>;
|
|
137
|
+
destroyAfterMs?: number;
|
|
138
|
+
};
|
|
139
|
+
useUnresolvedData?: boolean;
|
|
140
|
+
}
|
|
141
|
+
/** Manager Options used to create the manager */
|
|
142
|
+
export interface ManagerOptions {
|
|
143
|
+
/** The Node Options, for all Nodes! (on init) */
|
|
144
|
+
nodes: LavalinkNodeOptions[];
|
|
145
|
+
/** @async The Function to send the voice connection changes from Lavalink to Discord */
|
|
146
|
+
sendToShard: (guildId: string, payload: GuildShardPayload) => void;
|
|
147
|
+
/** The Bot Client's Data for Authorization */
|
|
148
|
+
client?: BotClientOptions;
|
|
149
|
+
/** QueueOptions for all Queues */
|
|
150
|
+
queueOptions?: ManagerQueueOptions;
|
|
151
|
+
/** PlayerOptions for all Players */
|
|
152
|
+
playerOptions?: ManagerPlayerOptions;
|
|
153
|
+
/** If it should skip to the next Track on TrackEnd / TrackError etc. events */
|
|
154
|
+
autoSkip?: boolean;
|
|
155
|
+
/** If it should skip to the next Track if track.resolve errors while trying to play a track. */
|
|
156
|
+
autoSkipOnResolveError?: boolean;
|
|
157
|
+
/** If it should emit only new (unique) songs and not when a looping track (or similar) is plaid, default false */
|
|
158
|
+
emitNewSongsOnly?: boolean;
|
|
159
|
+
/** Only allow link requests with links either matching some of that regExp or including some of that string */
|
|
160
|
+
linksWhitelist?: (RegExp | string)[];
|
|
161
|
+
/** Never allow link requests with links either matching some of that regExp or including some of that string (doesn't even allow if it's whitelisted) */
|
|
162
|
+
linksBlacklist?: (RegExp | string)[];
|
|
163
|
+
/** If links should be allowed or not. If set to false, it will throw an error if a link was provided. */
|
|
164
|
+
linksAllowed?: boolean;
|
|
165
|
+
/** Advanced Options for the Library, which may or may not be "library breaking" */
|
|
166
|
+
advancedOptions?: {
|
|
167
|
+
/** Max duration for that the filter fix duration works (in ms) - default is 8mins */
|
|
168
|
+
maxFilterFixDuration?: number;
|
|
169
|
+
/** optional */
|
|
170
|
+
debugOptions?: {
|
|
171
|
+
/** For logging custom searches */
|
|
172
|
+
logCustomSearches?: boolean;
|
|
173
|
+
/** logs for debugging the "no-Audio" playing error */
|
|
174
|
+
noAudio?: boolean;
|
|
175
|
+
/** For Logging the Destroy function */
|
|
176
|
+
playerDestroy?: {
|
|
177
|
+
/** To show the debug reason at all times. */
|
|
178
|
+
debugLog?: boolean;
|
|
179
|
+
/** If you get 'Error: Use Player#destroy("reason") not LavalinkManager#deletePlayer() to stop the Player' put it on true */
|
|
180
|
+
dontThrowError?: boolean;
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|