magmastream 2.9.0-dev.17 → 2.9.0-dev.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -593,6 +593,7 @@ declare class Queue extends Array<Track> implements IQueue {
|
|
|
593
593
|
setCurrent(track: Track | null): Promise<void>;
|
|
594
594
|
getPrevious(): Promise<Track[]>;
|
|
595
595
|
addPrevious(track: Track | Track[]): Promise<void>;
|
|
596
|
+
setPrevious(tracks: Track[]): Promise<void>;
|
|
596
597
|
clearPrevious(): Promise<void>;
|
|
597
598
|
/**
|
|
598
599
|
* The total duration of the queue in milliseconds.
|
|
@@ -919,6 +920,7 @@ interface IQueue {
|
|
|
919
920
|
setCurrent(track: Track | null): Promise<void>;
|
|
920
921
|
getPrevious(): Promise<Track[]>;
|
|
921
922
|
addPrevious(track: Track | Track[]): Promise<void>;
|
|
923
|
+
setPrevious(track: Track | Track[]): Promise<void>;
|
|
922
924
|
clearPrevious(): Promise<void>;
|
|
923
925
|
size(): Promise<number>;
|
|
924
926
|
totalSize(): Promise<number>;
|
package/dist/structures/Node.js
CHANGED
|
@@ -539,14 +539,11 @@ class Node {
|
|
|
539
539
|
const previous = await player.queue.getPrevious();
|
|
540
540
|
const current = await player.queue.getCurrent();
|
|
541
541
|
if (!skipFlag && (previous.length === 0 || (previous[0] && previous[0].track !== current?.track))) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
// Limit the previous tracks queue to maxPreviousTracks
|
|
545
|
-
const previous = await player.queue.getPrevious();
|
|
542
|
+
await player.queue.addPrevious(current);
|
|
543
|
+
let previous = await player.queue.getPrevious();
|
|
546
544
|
if (previous.length > this.manager.options.maxPreviousTracks) {
|
|
547
|
-
previous.
|
|
548
|
-
await player.queue.
|
|
549
|
-
await player.queue.addPrevious(previous);
|
|
545
|
+
previous = previous.slice(0, this.manager.options.maxPreviousTracks); // drop oldest
|
|
546
|
+
await player.queue.setPrevious(previous);
|
|
550
547
|
}
|
|
551
548
|
}
|
|
552
549
|
const oldPlayer = player;
|
|
@@ -672,7 +672,10 @@ class Player {
|
|
|
672
672
|
// Store the current track before changing it.
|
|
673
673
|
// let currentTrackBeforeChange: Track | null = this.queue.current ? (this.queue.current as Track) : null;
|
|
674
674
|
// Get the last played track and remove it from the history
|
|
675
|
-
const
|
|
675
|
+
const previousTracks = await this.queue.getPrevious();
|
|
676
|
+
const lastTrack = previousTracks.pop();
|
|
677
|
+
await this.queue.clearPrevious();
|
|
678
|
+
await this.queue.addPrevious(previousTracks);
|
|
676
679
|
// Set the skip flag to true to prevent the onTrackEnd event from playing the next track.
|
|
677
680
|
this.set("skipFlag", true);
|
|
678
681
|
await this.play(lastTrack);
|
package/dist/structures/Queue.js
CHANGED
|
@@ -53,9 +53,16 @@ class RedisQueue {
|
|
|
53
53
|
return;
|
|
54
54
|
const serialized = tracks.map(this.serialize);
|
|
55
55
|
if (!serialized.length)
|
|
56
|
-
return;
|
|
56
|
+
return;
|
|
57
57
|
await this.redis.lpush(this.previousKey, ...serialized.reverse());
|
|
58
58
|
}
|
|
59
|
+
async setPrevious(track) {
|
|
60
|
+
const tracks = Array.isArray(track) ? track : [track];
|
|
61
|
+
if (!tracks.length)
|
|
62
|
+
return;
|
|
63
|
+
await this.redis.del(this.previousKey);
|
|
64
|
+
await this.redis.rpush(this.previousKey, ...tracks.map(this.serialize));
|
|
65
|
+
}
|
|
59
66
|
async clearPrevious() {
|
|
60
67
|
await this.redis.del(this.previousKey);
|
|
61
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magmastream",
|
|
3
|
-
"version": "2.9.0-dev.
|
|
3
|
+
"version": "2.9.0-dev.19",
|
|
4
4
|
"description": "A user-friendly Lavalink client designed for NodeJS.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -90,4 +90,4 @@
|
|
|
90
90
|
"homepage": "https://docs.magmastream.com",
|
|
91
91
|
"author": "Abel Purnwasy",
|
|
92
92
|
"license": "Apache-2.0"
|
|
93
|
-
}
|
|
93
|
+
}
|