magmastream 2.9.0-dev.4 → 2.9.0-dev.40
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 +2 -2
- package/dist/index.d.ts +2271 -959
- package/dist/index.js +14 -1
- package/dist/statestorage/JsonQueue.js +436 -0
- package/dist/{structures/Queue.js → statestorage/MemoryQueue.js} +205 -78
- package/dist/statestorage/RedisQueue.js +427 -0
- package/dist/structures/Enums.js +259 -0
- package/dist/structures/Filters.js +54 -82
- package/dist/structures/Manager.js +810 -371
- package/dist/structures/Node.js +335 -202
- package/dist/structures/Player.js +302 -135
- package/dist/structures/Plugin.js +4 -1
- package/dist/structures/Rest.js +11 -7
- package/dist/structures/Types.js +3 -0
- package/dist/structures/Utils.js +312 -263
- package/dist/utils/managerCheck.js +19 -19
- package/dist/wrappers/detritus.js +36 -0
- package/dist/wrappers/discord.js.js +29 -0
- package/dist/wrappers/eris.js +29 -0
- package/dist/wrappers/oceanic.js +29 -0
- package/dist/wrappers/seyfert.js +43 -0
- package/package.json +20 -14
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisQueue = void 0;
|
|
4
|
+
const Enums_1 = require("../structures/Enums");
|
|
5
|
+
/**
|
|
6
|
+
* The player's queue, the `current` property is the currently playing track, think of the rest as the up-coming tracks.
|
|
7
|
+
*/
|
|
8
|
+
class RedisQueue {
|
|
9
|
+
guildId;
|
|
10
|
+
manager;
|
|
11
|
+
/**
|
|
12
|
+
* The Redis instance.
|
|
13
|
+
*/
|
|
14
|
+
redis;
|
|
15
|
+
/**
|
|
16
|
+
* The prefix for the Redis keys.
|
|
17
|
+
*/
|
|
18
|
+
redisPrefix;
|
|
19
|
+
/**
|
|
20
|
+
* Constructs a new RedisQueue.
|
|
21
|
+
* @param guildId The guild ID.
|
|
22
|
+
* @param manager The Manager instance.
|
|
23
|
+
*/
|
|
24
|
+
constructor(guildId, manager) {
|
|
25
|
+
this.guildId = guildId;
|
|
26
|
+
this.manager = manager;
|
|
27
|
+
this.redis = manager.redis;
|
|
28
|
+
this.redisPrefix = manager.options.stateStorage.redisConfig.prefix?.endsWith(":")
|
|
29
|
+
? manager.options.stateStorage.redisConfig.prefix
|
|
30
|
+
: `${manager.options.stateStorage.redisConfig.prefix ?? "magmastream"}:`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @returns The queue key.
|
|
34
|
+
*/
|
|
35
|
+
get queueKey() {
|
|
36
|
+
return `${this.redisPrefix}queue:${this.guildId}:tracks`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @returns The current key.
|
|
40
|
+
*/
|
|
41
|
+
get currentKey() {
|
|
42
|
+
return `${this.redisPrefix}queue:${this.guildId}:current`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* @returns The previous key.
|
|
46
|
+
*/
|
|
47
|
+
get previousKey() {
|
|
48
|
+
return `${this.redisPrefix}queue:${this.guildId}:previous`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Helper to serialize/deserialize Track
|
|
52
|
+
*/
|
|
53
|
+
serialize(track) {
|
|
54
|
+
return JSON.stringify(track);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Helper to serialize/deserialize Track
|
|
58
|
+
*/
|
|
59
|
+
deserialize(data) {
|
|
60
|
+
return JSON.parse(data);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* @returns The current track.
|
|
64
|
+
*/
|
|
65
|
+
async getCurrent() {
|
|
66
|
+
const raw = await this.redis.get(this.currentKey);
|
|
67
|
+
return raw ? this.deserialize(raw) : null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* @param track The track to set.
|
|
71
|
+
*/
|
|
72
|
+
async setCurrent(track) {
|
|
73
|
+
if (track) {
|
|
74
|
+
await this.redis.set(this.currentKey, this.serialize(track));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
await this.redis.del(this.currentKey);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* @returns The previous tracks.
|
|
82
|
+
*/
|
|
83
|
+
async getPrevious() {
|
|
84
|
+
const raw = await this.redis.lrange(this.previousKey, 0, -1);
|
|
85
|
+
return raw.map(this.deserialize);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* @param track The track to add.
|
|
89
|
+
*/
|
|
90
|
+
async addPrevious(track) {
|
|
91
|
+
const tracks = Array.isArray(track) ? track : [track];
|
|
92
|
+
if (!tracks.length)
|
|
93
|
+
return;
|
|
94
|
+
const serialized = tracks.map(this.serialize);
|
|
95
|
+
if (!serialized.length)
|
|
96
|
+
return;
|
|
97
|
+
await this.redis.lpush(this.previousKey, ...serialized.reverse());
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* @param track The track to set.
|
|
101
|
+
*/
|
|
102
|
+
async setPrevious(track) {
|
|
103
|
+
const tracks = Array.isArray(track) ? track : [track];
|
|
104
|
+
if (!tracks.length)
|
|
105
|
+
return;
|
|
106
|
+
await this.redis.del(this.previousKey);
|
|
107
|
+
await this.redis.rpush(this.previousKey, ...tracks.map(this.serialize));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @returns The newest track.
|
|
111
|
+
*/
|
|
112
|
+
async popPrevious() {
|
|
113
|
+
const raw = await this.redis.lpop(this.previousKey); // get newest track (index 0)
|
|
114
|
+
return raw ? this.deserialize(raw) : null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Clears the previous tracks.
|
|
118
|
+
*/
|
|
119
|
+
async clearPrevious() {
|
|
120
|
+
await this.redis.del(this.previousKey);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* @param track The track or tracks to add. Can be a single `Track` or an array of `Track`s.
|
|
124
|
+
* @param [offset=null] The position to add the track(s) at. If not provided, the track(s) will be added at the end of the queue.
|
|
125
|
+
*/
|
|
126
|
+
async add(track, offset) {
|
|
127
|
+
const isArray = Array.isArray(track);
|
|
128
|
+
const tracks = isArray ? track : [track];
|
|
129
|
+
const serialized = tracks.map((t) => this.serialize(t));
|
|
130
|
+
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
131
|
+
// If there's no current track, pop one from the list
|
|
132
|
+
if (!(await this.getCurrent())) {
|
|
133
|
+
const current = serialized.shift();
|
|
134
|
+
if (current) {
|
|
135
|
+
await this.setCurrent(this.deserialize(current));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (typeof offset === "number" && !isNaN(offset)) {
|
|
139
|
+
const queue = await this.redis.lrange(this.queueKey, 0, -1);
|
|
140
|
+
queue.splice(offset, 0, ...serialized);
|
|
141
|
+
await this.redis.del(this.queueKey);
|
|
142
|
+
if (queue.length > 0) {
|
|
143
|
+
await this.redis.rpush(this.queueKey, ...queue);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
else if (serialized.length > 0) {
|
|
147
|
+
await this.redis.rpush(this.queueKey, ...serialized);
|
|
148
|
+
}
|
|
149
|
+
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[QUEUE] Added ${tracks.length} track(s) to queue`);
|
|
150
|
+
if (this.manager.players.has(this.guildId) && this.manager.players.get(this.guildId).isAutoplay) {
|
|
151
|
+
if (!Array.isArray(track)) {
|
|
152
|
+
const botUser = (await this.manager.players.get(this.guildId).get("Internal_BotUser"));
|
|
153
|
+
if (botUser && botUser.id === track.requester.id) {
|
|
154
|
+
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
155
|
+
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
156
|
+
details: {
|
|
157
|
+
type: "queue",
|
|
158
|
+
action: "autoPlayAdd",
|
|
159
|
+
tracks: Array.isArray(track) ? track : [track],
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
167
|
+
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
168
|
+
details: {
|
|
169
|
+
type: "queue",
|
|
170
|
+
action: "add",
|
|
171
|
+
tracks,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async remove(startOrPos = 0, end) {
|
|
176
|
+
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
177
|
+
const queue = await this.redis.lrange(this.queueKey, 0, -1);
|
|
178
|
+
let removed = [];
|
|
179
|
+
if (typeof end === "number") {
|
|
180
|
+
if (startOrPos >= end || startOrPos >= queue.length) {
|
|
181
|
+
throw new RangeError("Invalid range.");
|
|
182
|
+
}
|
|
183
|
+
removed = queue.slice(startOrPos, end);
|
|
184
|
+
queue.splice(startOrPos, end - startOrPos);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
removed = queue.splice(startOrPos, 1);
|
|
188
|
+
}
|
|
189
|
+
await this.redis.del(this.queueKey);
|
|
190
|
+
if (queue.length > 0) {
|
|
191
|
+
await this.redis.rpush(this.queueKey, ...queue);
|
|
192
|
+
}
|
|
193
|
+
const deserialized = removed.map(this.deserialize);
|
|
194
|
+
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[QUEUE] Removed ${removed.length} track(s) from position ${startOrPos}${end ? ` to ${end}` : ""}`);
|
|
195
|
+
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
196
|
+
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
197
|
+
details: {
|
|
198
|
+
type: "queue",
|
|
199
|
+
action: "remove",
|
|
200
|
+
tracks: deserialized,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
return deserialized;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Clears the queue.
|
|
207
|
+
*/
|
|
208
|
+
async clear() {
|
|
209
|
+
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
210
|
+
await this.redis.del(this.queueKey);
|
|
211
|
+
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
212
|
+
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
213
|
+
details: {
|
|
214
|
+
type: "queue",
|
|
215
|
+
action: "clear",
|
|
216
|
+
tracks: [],
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[QUEUE] Cleared the queue for: ${this.guildId}`);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* @returns The size of the queue.
|
|
223
|
+
*/
|
|
224
|
+
async size() {
|
|
225
|
+
return await this.redis.llen(this.queueKey);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* @returns The total size of tracks in the queue including the current track.
|
|
229
|
+
*/
|
|
230
|
+
async totalSize() {
|
|
231
|
+
const size = await this.size();
|
|
232
|
+
return (await this.getCurrent()) ? size + 1 : size;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* @returns The total duration of the queue in milliseconds.
|
|
236
|
+
* This includes the duration of the currently playing track.
|
|
237
|
+
*/
|
|
238
|
+
async duration() {
|
|
239
|
+
const tracks = await this.redis.lrange(this.queueKey, 0, -1);
|
|
240
|
+
const currentDuration = (await this.getCurrent())?.duration || 0;
|
|
241
|
+
const total = tracks.reduce((acc, raw) => {
|
|
242
|
+
try {
|
|
243
|
+
const parsed = this.deserialize(raw);
|
|
244
|
+
return acc + (parsed.duration || 0);
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
return acc;
|
|
248
|
+
}
|
|
249
|
+
}, currentDuration);
|
|
250
|
+
return total;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Shuffles the queue.
|
|
254
|
+
*/
|
|
255
|
+
async shuffle() {
|
|
256
|
+
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
257
|
+
const queue = await this.redis.lrange(this.queueKey, 0, -1);
|
|
258
|
+
for (let i = queue.length - 1; i > 0; i--) {
|
|
259
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
260
|
+
[queue[i], queue[j]] = [queue[j], queue[i]];
|
|
261
|
+
}
|
|
262
|
+
await this.redis.del(this.queueKey);
|
|
263
|
+
if (queue.length > 0) {
|
|
264
|
+
await this.redis.rpush(this.queueKey, ...queue);
|
|
265
|
+
}
|
|
266
|
+
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
267
|
+
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
268
|
+
details: {
|
|
269
|
+
type: "queue",
|
|
270
|
+
action: "shuffle",
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[QUEUE] Shuffled the queue for: ${this.guildId}`);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Shuffles the queue, but keeps the tracks of the same user together.
|
|
277
|
+
*/
|
|
278
|
+
async userBlockShuffle() {
|
|
279
|
+
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
280
|
+
const rawTracks = await this.redis.lrange(this.queueKey, 0, -1);
|
|
281
|
+
const deserialized = rawTracks.map(this.deserialize);
|
|
282
|
+
const userMap = new Map();
|
|
283
|
+
for (const track of deserialized) {
|
|
284
|
+
const userId = track.requester.id;
|
|
285
|
+
if (!userMap.has(userId))
|
|
286
|
+
userMap.set(userId, []);
|
|
287
|
+
userMap.get(userId).push(track);
|
|
288
|
+
}
|
|
289
|
+
const shuffledQueue = [];
|
|
290
|
+
while (shuffledQueue.length < deserialized.length) {
|
|
291
|
+
for (const [, tracks] of userMap) {
|
|
292
|
+
const track = tracks.shift();
|
|
293
|
+
if (track)
|
|
294
|
+
shuffledQueue.push(track);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
await this.redis.del(this.queueKey);
|
|
298
|
+
await this.redis.rpush(this.queueKey, ...shuffledQueue.map(this.serialize));
|
|
299
|
+
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
300
|
+
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
301
|
+
details: {
|
|
302
|
+
type: "queue",
|
|
303
|
+
action: "userBlock",
|
|
304
|
+
},
|
|
305
|
+
});
|
|
306
|
+
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[QUEUE] userBlockShuffled the queue for: ${this.guildId}`);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Shuffles the queue round-robin style.
|
|
310
|
+
*/
|
|
311
|
+
async roundRobinShuffle() {
|
|
312
|
+
const oldPlayer = this.manager.players.get(this.guildId) ? { ...this.manager.players.get(this.guildId) } : null;
|
|
313
|
+
const rawTracks = await this.redis.lrange(this.queueKey, 0, -1);
|
|
314
|
+
const deserialized = rawTracks.map(this.deserialize);
|
|
315
|
+
const userMap = new Map();
|
|
316
|
+
for (const track of deserialized) {
|
|
317
|
+
const userId = track.requester.id;
|
|
318
|
+
if (!userMap.has(userId))
|
|
319
|
+
userMap.set(userId, []);
|
|
320
|
+
userMap.get(userId).push(track);
|
|
321
|
+
}
|
|
322
|
+
// Shuffle each user's tracks
|
|
323
|
+
for (const tracks of userMap.values()) {
|
|
324
|
+
for (let i = tracks.length - 1; i > 0; i--) {
|
|
325
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
326
|
+
[tracks[i], tracks[j]] = [tracks[j], tracks[i]];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const users = [...userMap.keys()];
|
|
330
|
+
const queues = users.map((id) => userMap.get(id));
|
|
331
|
+
const shuffledQueue = [];
|
|
332
|
+
while (queues.some((q) => q.length > 0)) {
|
|
333
|
+
for (const q of queues) {
|
|
334
|
+
const track = q.shift();
|
|
335
|
+
if (track)
|
|
336
|
+
shuffledQueue.push(track);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
await this.redis.del(this.queueKey);
|
|
340
|
+
await this.redis.rpush(this.queueKey, ...shuffledQueue.map(this.serialize));
|
|
341
|
+
this.manager.emit(Enums_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, this.manager.players.get(this.guildId), {
|
|
342
|
+
changeType: Enums_1.PlayerStateEventTypes.QueueChange,
|
|
343
|
+
details: {
|
|
344
|
+
type: "queue",
|
|
345
|
+
action: "roundRobin",
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
this.manager.emit(Enums_1.ManagerEventTypes.Debug, `[QUEUE] roundRobinShuffled the queue for: ${this.guildId}`);
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Removes the first track from the queue.
|
|
352
|
+
*/
|
|
353
|
+
async dequeue() {
|
|
354
|
+
const raw = await this.redis.lpop(this.queueKey);
|
|
355
|
+
return raw ? this.deserialize(raw) : undefined;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Adds a track to the front of the queue.
|
|
359
|
+
*/
|
|
360
|
+
async enqueueFront(track) {
|
|
361
|
+
const serialized = Array.isArray(track) ? track.map(this.serialize) : [this.serialize(track)];
|
|
362
|
+
// Redis: LPUSH adds to front, reverse to maintain order if multiple tracks
|
|
363
|
+
await this.redis.lpush(this.queueKey, ...serialized.reverse());
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* @returns The tracks in the queue.
|
|
367
|
+
*/
|
|
368
|
+
async getTracks() {
|
|
369
|
+
const raw = await this.redis.lrange(this.queueKey, 0, -1);
|
|
370
|
+
return raw.map(this.deserialize);
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* @returns The tracks in the queue from the start to the end.
|
|
374
|
+
*/
|
|
375
|
+
async getSlice(start = 0, end = -1) {
|
|
376
|
+
const raw = await this.redis.lrange(this.queueKey, start, end === -1 ? -1 : end - 1);
|
|
377
|
+
return raw.map(this.deserialize);
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Modifies the queue at the specified index.
|
|
381
|
+
*/
|
|
382
|
+
async modifyAt(start, deleteCount = 0, ...items) {
|
|
383
|
+
const queue = await this.redis.lrange(this.queueKey, 0, -1);
|
|
384
|
+
const removed = queue.splice(start, deleteCount, ...items.map(this.serialize));
|
|
385
|
+
await this.redis.del(this.queueKey);
|
|
386
|
+
if (queue.length > 0) {
|
|
387
|
+
await this.redis.rpush(this.queueKey, ...queue);
|
|
388
|
+
}
|
|
389
|
+
return removed.map(this.deserialize);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* @returns The tracks in the queue after the specified index.
|
|
393
|
+
*/
|
|
394
|
+
async mapAsync(callback) {
|
|
395
|
+
const tracks = await this.getTracks(); // same as lrange + deserialize
|
|
396
|
+
return tracks.map(callback);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* @returns The tracks in the queue that match the specified condition.
|
|
400
|
+
*/
|
|
401
|
+
async filterAsync(callback) {
|
|
402
|
+
const tracks = await this.getTracks();
|
|
403
|
+
return tracks.filter(callback);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* @returns The first track in the queue that matches the specified condition.
|
|
407
|
+
*/
|
|
408
|
+
async findAsync(callback) {
|
|
409
|
+
const tracks = await this.getTracks();
|
|
410
|
+
return tracks.find(callback);
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* @returns Whether any tracks in the queue match the specified condition.
|
|
414
|
+
*/
|
|
415
|
+
async someAsync(callback) {
|
|
416
|
+
const tracks = await this.getTracks();
|
|
417
|
+
return tracks.some(callback);
|
|
418
|
+
}
|
|
419
|
+
/**
|
|
420
|
+
* @returns Whether all tracks in the queue match the specified condition.
|
|
421
|
+
*/
|
|
422
|
+
async everyAsync(callback) {
|
|
423
|
+
const tracks = await this.getTracks();
|
|
424
|
+
return tracks.every(callback);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
exports.RedisQueue = RedisQueue;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AvailableFilters = exports.SponsorBlockSegment = exports.SeverityTypes = exports.TrackEndReasonTypes = exports.ManagerEventTypes = exports.TrackPartial = exports.UseNodeOptions = exports.TrackSourceTypes = exports.PlayerStateEventTypes = exports.SearchPlatform = exports.LoadTypes = exports.StateTypes = exports.AutoPlayPlatform = exports.StateStorageType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* State Storage Enum
|
|
6
|
+
*/
|
|
7
|
+
var StateStorageType;
|
|
8
|
+
(function (StateStorageType) {
|
|
9
|
+
StateStorageType["Memory"] = "memory";
|
|
10
|
+
StateStorageType["Redis"] = "redis";
|
|
11
|
+
StateStorageType["JSON"] = "json";
|
|
12
|
+
})(StateStorageType || (exports.StateStorageType = StateStorageType = {}));
|
|
13
|
+
/**
|
|
14
|
+
* AutoPlay Platform Enum
|
|
15
|
+
*/
|
|
16
|
+
var AutoPlayPlatform;
|
|
17
|
+
(function (AutoPlayPlatform) {
|
|
18
|
+
AutoPlayPlatform["Spotify"] = "spotify";
|
|
19
|
+
AutoPlayPlatform["Deezer"] = "deezer";
|
|
20
|
+
AutoPlayPlatform["SoundCloud"] = "soundcloud";
|
|
21
|
+
AutoPlayPlatform["Tidal"] = "tidal";
|
|
22
|
+
AutoPlayPlatform["VKMusic"] = "vkmusic";
|
|
23
|
+
AutoPlayPlatform["Qobuz"] = "qobuz";
|
|
24
|
+
AutoPlayPlatform["YouTube"] = "youtube";
|
|
25
|
+
})(AutoPlayPlatform || (exports.AutoPlayPlatform = AutoPlayPlatform = {}));
|
|
26
|
+
/**
|
|
27
|
+
* State Types Enum
|
|
28
|
+
*/
|
|
29
|
+
var StateTypes;
|
|
30
|
+
(function (StateTypes) {
|
|
31
|
+
StateTypes["Connected"] = "CONNECTED";
|
|
32
|
+
StateTypes["Connecting"] = "CONNECTING";
|
|
33
|
+
StateTypes["Disconnected"] = "DISCONNECTED";
|
|
34
|
+
StateTypes["Disconnecting"] = "DISCONNECTING";
|
|
35
|
+
StateTypes["Destroying"] = "DESTROYING";
|
|
36
|
+
})(StateTypes || (exports.StateTypes = StateTypes = {}));
|
|
37
|
+
/**
|
|
38
|
+
* Load Types Enum
|
|
39
|
+
*/
|
|
40
|
+
var LoadTypes;
|
|
41
|
+
(function (LoadTypes) {
|
|
42
|
+
LoadTypes["Track"] = "track";
|
|
43
|
+
LoadTypes["Playlist"] = "playlist";
|
|
44
|
+
LoadTypes["Search"] = "search";
|
|
45
|
+
LoadTypes["Empty"] = "empty";
|
|
46
|
+
LoadTypes["Error"] = "error";
|
|
47
|
+
/** Nodelink */
|
|
48
|
+
LoadTypes["Album"] = "album";
|
|
49
|
+
/** Nodelink */
|
|
50
|
+
LoadTypes["Artist"] = "artist";
|
|
51
|
+
/** Nodelink */
|
|
52
|
+
LoadTypes["Station"] = "station";
|
|
53
|
+
/** Nodelink */
|
|
54
|
+
LoadTypes["Podcast"] = "podcast";
|
|
55
|
+
/** Nodelink */
|
|
56
|
+
LoadTypes["Show"] = "show";
|
|
57
|
+
/** Nodelink */
|
|
58
|
+
LoadTypes["Short"] = "short";
|
|
59
|
+
})(LoadTypes || (exports.LoadTypes = LoadTypes = {}));
|
|
60
|
+
/**
|
|
61
|
+
* Search Platform Enum
|
|
62
|
+
*/
|
|
63
|
+
var SearchPlatform;
|
|
64
|
+
(function (SearchPlatform) {
|
|
65
|
+
SearchPlatform["AppleMusic"] = "amsearch";
|
|
66
|
+
SearchPlatform["Bandcamp"] = "bcsearch";
|
|
67
|
+
SearchPlatform["Deezer"] = "dzsearch";
|
|
68
|
+
SearchPlatform["Jiosaavn"] = "jssearch";
|
|
69
|
+
SearchPlatform["Qobuz"] = "qbsearch";
|
|
70
|
+
SearchPlatform["SoundCloud"] = "scsearch";
|
|
71
|
+
SearchPlatform["Spotify"] = "spsearch";
|
|
72
|
+
SearchPlatform["Tidal"] = "tdsearch";
|
|
73
|
+
SearchPlatform["VKMusic"] = "vksearch";
|
|
74
|
+
SearchPlatform["YouTube"] = "ytsearch";
|
|
75
|
+
SearchPlatform["YouTubeMusic"] = "ytmsearch";
|
|
76
|
+
})(SearchPlatform || (exports.SearchPlatform = SearchPlatform = {}));
|
|
77
|
+
/**
|
|
78
|
+
* Player State Event Types Enum
|
|
79
|
+
*/
|
|
80
|
+
var PlayerStateEventTypes;
|
|
81
|
+
(function (PlayerStateEventTypes) {
|
|
82
|
+
PlayerStateEventTypes["AutoPlayChange"] = "playerAutoplay";
|
|
83
|
+
PlayerStateEventTypes["ConnectionChange"] = "playerConnection";
|
|
84
|
+
PlayerStateEventTypes["RepeatChange"] = "playerRepeat";
|
|
85
|
+
PlayerStateEventTypes["PauseChange"] = "playerPause";
|
|
86
|
+
PlayerStateEventTypes["QueueChange"] = "queueChange";
|
|
87
|
+
PlayerStateEventTypes["TrackChange"] = "trackChange";
|
|
88
|
+
PlayerStateEventTypes["VolumeChange"] = "volumeChange";
|
|
89
|
+
PlayerStateEventTypes["ChannelChange"] = "channelChange";
|
|
90
|
+
PlayerStateEventTypes["PlayerCreate"] = "playerCreate";
|
|
91
|
+
PlayerStateEventTypes["PlayerDestroy"] = "playerDestroy";
|
|
92
|
+
})(PlayerStateEventTypes || (exports.PlayerStateEventTypes = PlayerStateEventTypes = {}));
|
|
93
|
+
/**
|
|
94
|
+
* Track Source Types Enum
|
|
95
|
+
*/
|
|
96
|
+
var TrackSourceTypes;
|
|
97
|
+
(function (TrackSourceTypes) {
|
|
98
|
+
TrackSourceTypes["AppleMusic"] = "applemusic";
|
|
99
|
+
TrackSourceTypes["Bandcamp"] = "bandcamp";
|
|
100
|
+
TrackSourceTypes["Deezer"] = "deezer";
|
|
101
|
+
TrackSourceTypes["Jiosaavn"] = "jiosaavn";
|
|
102
|
+
TrackSourceTypes["Qobuz"] = "qobuz";
|
|
103
|
+
TrackSourceTypes["SoundCloud"] = "soundcloud";
|
|
104
|
+
TrackSourceTypes["Spotify"] = "spotify";
|
|
105
|
+
TrackSourceTypes["Tidal"] = "tidal";
|
|
106
|
+
TrackSourceTypes["VKMusic"] = "vkmusic";
|
|
107
|
+
TrackSourceTypes["YouTube"] = "youtube";
|
|
108
|
+
})(TrackSourceTypes || (exports.TrackSourceTypes = TrackSourceTypes = {}));
|
|
109
|
+
/**
|
|
110
|
+
* Use Node Options Enum
|
|
111
|
+
*/
|
|
112
|
+
var UseNodeOptions;
|
|
113
|
+
(function (UseNodeOptions) {
|
|
114
|
+
UseNodeOptions["LeastLoad"] = "leastLoad";
|
|
115
|
+
UseNodeOptions["LeastPlayers"] = "leastPlayers";
|
|
116
|
+
})(UseNodeOptions || (exports.UseNodeOptions = UseNodeOptions = {}));
|
|
117
|
+
/**
|
|
118
|
+
* Track Partial Enum
|
|
119
|
+
*/
|
|
120
|
+
var TrackPartial;
|
|
121
|
+
(function (TrackPartial) {
|
|
122
|
+
/** The base64 encoded string of the track */
|
|
123
|
+
TrackPartial["Track"] = "track";
|
|
124
|
+
/** The title of the track */
|
|
125
|
+
TrackPartial["Title"] = "title";
|
|
126
|
+
/** The track identifier */
|
|
127
|
+
TrackPartial["Identifier"] = "identifier";
|
|
128
|
+
/** The author of the track */
|
|
129
|
+
TrackPartial["Author"] = "author";
|
|
130
|
+
/** The length of the track in milliseconds */
|
|
131
|
+
TrackPartial["Duration"] = "duration";
|
|
132
|
+
/** The ISRC of the track */
|
|
133
|
+
TrackPartial["Isrc"] = "isrc";
|
|
134
|
+
/** Whether the track is seekable */
|
|
135
|
+
TrackPartial["IsSeekable"] = "isSeekable";
|
|
136
|
+
/** Whether the track is a stream */
|
|
137
|
+
TrackPartial["IsStream"] = "isStream";
|
|
138
|
+
/** The URI of the track */
|
|
139
|
+
TrackPartial["Uri"] = "uri";
|
|
140
|
+
/** The artwork URL of the track */
|
|
141
|
+
TrackPartial["ArtworkUrl"] = "artworkUrl";
|
|
142
|
+
/** The source name of the track */
|
|
143
|
+
TrackPartial["SourceName"] = "sourceName";
|
|
144
|
+
/** The thumbnail of the track */
|
|
145
|
+
TrackPartial["ThumbNail"] = "thumbnail";
|
|
146
|
+
/** The requester of the track */
|
|
147
|
+
TrackPartial["Requester"] = "requester";
|
|
148
|
+
/** The plugin info of the track */
|
|
149
|
+
TrackPartial["PluginInfo"] = "pluginInfo";
|
|
150
|
+
/** The custom data of the track */
|
|
151
|
+
TrackPartial["CustomData"] = "customData";
|
|
152
|
+
})(TrackPartial || (exports.TrackPartial = TrackPartial = {}));
|
|
153
|
+
var ManagerEventTypes;
|
|
154
|
+
(function (ManagerEventTypes) {
|
|
155
|
+
ManagerEventTypes["ChapterStarted"] = "chapterStarted";
|
|
156
|
+
ManagerEventTypes["ChaptersLoaded"] = "chaptersLoaded";
|
|
157
|
+
ManagerEventTypes["Debug"] = "debug";
|
|
158
|
+
ManagerEventTypes["LyricsFound"] = "lyricsFound";
|
|
159
|
+
ManagerEventTypes["LyricsLine"] = "lyricsLine";
|
|
160
|
+
ManagerEventTypes["LyricsNotFound"] = "lyricsNotFound";
|
|
161
|
+
ManagerEventTypes["NodeConnect"] = "nodeConnect";
|
|
162
|
+
ManagerEventTypes["NodeCreate"] = "nodeCreate";
|
|
163
|
+
ManagerEventTypes["NodeDestroy"] = "nodeDestroy";
|
|
164
|
+
ManagerEventTypes["NodeDisconnect"] = "nodeDisconnect";
|
|
165
|
+
ManagerEventTypes["NodeError"] = "nodeError";
|
|
166
|
+
ManagerEventTypes["NodeRaw"] = "nodeRaw";
|
|
167
|
+
ManagerEventTypes["NodeReconnect"] = "nodeReconnect";
|
|
168
|
+
ManagerEventTypes["PlayerCreate"] = "playerCreate";
|
|
169
|
+
ManagerEventTypes["PlayerDestroy"] = "playerDestroy";
|
|
170
|
+
ManagerEventTypes["PlayerDisconnect"] = "playerDisconnect";
|
|
171
|
+
ManagerEventTypes["PlayerMove"] = "playerMove";
|
|
172
|
+
ManagerEventTypes["PlayerRestored"] = "playerRestored";
|
|
173
|
+
ManagerEventTypes["PlayerStateUpdate"] = "playerStateUpdate";
|
|
174
|
+
ManagerEventTypes["QueueEnd"] = "queueEnd";
|
|
175
|
+
ManagerEventTypes["RestoreComplete"] = "restoreComplete";
|
|
176
|
+
ManagerEventTypes["SegmentSkipped"] = "segmentSkipped";
|
|
177
|
+
ManagerEventTypes["SegmentsLoaded"] = "segmentsLoaded";
|
|
178
|
+
ManagerEventTypes["SocketClosed"] = "socketClosed";
|
|
179
|
+
ManagerEventTypes["TrackEnd"] = "trackEnd";
|
|
180
|
+
ManagerEventTypes["TrackError"] = "trackError";
|
|
181
|
+
ManagerEventTypes["TrackStart"] = "trackStart";
|
|
182
|
+
ManagerEventTypes["TrackStuck"] = "trackStuck";
|
|
183
|
+
/** Nodelink */
|
|
184
|
+
ManagerEventTypes["VoiceReceiverDisconnect"] = "voiceReceiverDisconnect";
|
|
185
|
+
/** Nodelink */
|
|
186
|
+
ManagerEventTypes["VoiceReceiverConnect"] = "voiceReceiverConnect";
|
|
187
|
+
/** Nodelink */
|
|
188
|
+
ManagerEventTypes["VoiceReceiverError"] = "voiceReceiverError";
|
|
189
|
+
/** Nodelink */
|
|
190
|
+
ManagerEventTypes["VoiceReceiverStartSpeaking"] = "voiceReceiverStartSpeaking";
|
|
191
|
+
/** Nodelink */
|
|
192
|
+
ManagerEventTypes["VoiceReceiverEndSpeaking"] = "voiceReceiverEndSpeaking";
|
|
193
|
+
})(ManagerEventTypes || (exports.ManagerEventTypes = ManagerEventTypes = {}));
|
|
194
|
+
/**
|
|
195
|
+
* Track End Reason Enum
|
|
196
|
+
*/
|
|
197
|
+
var TrackEndReasonTypes;
|
|
198
|
+
(function (TrackEndReasonTypes) {
|
|
199
|
+
TrackEndReasonTypes["Finished"] = "finished";
|
|
200
|
+
TrackEndReasonTypes["LoadFailed"] = "loadFailed";
|
|
201
|
+
TrackEndReasonTypes["Stopped"] = "stopped";
|
|
202
|
+
TrackEndReasonTypes["Replaced"] = "replaced";
|
|
203
|
+
TrackEndReasonTypes["Cleanup"] = "cleanup";
|
|
204
|
+
})(TrackEndReasonTypes || (exports.TrackEndReasonTypes = TrackEndReasonTypes = {}));
|
|
205
|
+
/**
|
|
206
|
+
* Severity Types Enum
|
|
207
|
+
*/
|
|
208
|
+
var SeverityTypes;
|
|
209
|
+
(function (SeverityTypes) {
|
|
210
|
+
SeverityTypes["Common"] = "common";
|
|
211
|
+
SeverityTypes["Suspicious"] = "suspicious";
|
|
212
|
+
SeverityTypes["Fault"] = "fault";
|
|
213
|
+
})(SeverityTypes || (exports.SeverityTypes = SeverityTypes = {}));
|
|
214
|
+
/**
|
|
215
|
+
* SponsorBlock Segment Enum
|
|
216
|
+
*/
|
|
217
|
+
var SponsorBlockSegment;
|
|
218
|
+
(function (SponsorBlockSegment) {
|
|
219
|
+
SponsorBlockSegment["Filler"] = "filler";
|
|
220
|
+
SponsorBlockSegment["Interaction"] = "interaction";
|
|
221
|
+
SponsorBlockSegment["Intro"] = "intro";
|
|
222
|
+
SponsorBlockSegment["MusicOfftopic"] = "music_offtopic";
|
|
223
|
+
SponsorBlockSegment["Outro"] = "outro";
|
|
224
|
+
SponsorBlockSegment["Preview"] = "preview";
|
|
225
|
+
SponsorBlockSegment["SelfPromo"] = "selfpromo";
|
|
226
|
+
SponsorBlockSegment["Sponsor"] = "sponsor";
|
|
227
|
+
})(SponsorBlockSegment || (exports.SponsorBlockSegment = SponsorBlockSegment = {}));
|
|
228
|
+
/**
|
|
229
|
+
* Available Filters Enum
|
|
230
|
+
*/
|
|
231
|
+
var AvailableFilters;
|
|
232
|
+
(function (AvailableFilters) {
|
|
233
|
+
AvailableFilters["BassBoost"] = "bassboost";
|
|
234
|
+
AvailableFilters["China"] = "china";
|
|
235
|
+
AvailableFilters["Chipmunk"] = "chipmunk";
|
|
236
|
+
AvailableFilters["Darthvader"] = "darthvader";
|
|
237
|
+
AvailableFilters["Daycore"] = "daycore";
|
|
238
|
+
AvailableFilters["Demon"] = "demon";
|
|
239
|
+
AvailableFilters["Distort"] = "distort";
|
|
240
|
+
AvailableFilters["Doubletime"] = "doubletime";
|
|
241
|
+
AvailableFilters["Earrape"] = "earrape";
|
|
242
|
+
AvailableFilters["EightD"] = "eightD";
|
|
243
|
+
AvailableFilters["Electronic"] = "electronic";
|
|
244
|
+
AvailableFilters["Nightcore"] = "nightcore";
|
|
245
|
+
AvailableFilters["Party"] = "party";
|
|
246
|
+
AvailableFilters["Pop"] = "pop";
|
|
247
|
+
AvailableFilters["Radio"] = "radio";
|
|
248
|
+
AvailableFilters["SetDistortion"] = "setDistortion";
|
|
249
|
+
AvailableFilters["SetKaraoke"] = "setKaraoke";
|
|
250
|
+
AvailableFilters["SetRotation"] = "setRotation";
|
|
251
|
+
AvailableFilters["SetTimescale"] = "setTimescale";
|
|
252
|
+
AvailableFilters["Slowmo"] = "slowmo";
|
|
253
|
+
AvailableFilters["Soft"] = "soft";
|
|
254
|
+
AvailableFilters["TrebleBass"] = "trebleBass";
|
|
255
|
+
AvailableFilters["Tremolo"] = "tremolo";
|
|
256
|
+
AvailableFilters["TV"] = "tv";
|
|
257
|
+
AvailableFilters["Vaporwave"] = "vaporwave";
|
|
258
|
+
AvailableFilters["Vibrato"] = "vibrato";
|
|
259
|
+
})(AvailableFilters || (exports.AvailableFilters = AvailableFilters = {}));
|