magmastream 2.9.0-dev.18 → 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 +11 -1
- package/dist/storage/CollectionPlayerStore.js +1 -4
- package/dist/storage/RedisPlayerStore.js +4 -7
- package/dist/structures/Manager.js +366 -164
- package/dist/structures/Node.js +5 -8
- package/dist/structures/Player.js +16 -6
- package/dist/structures/Queue.js +213 -259
- package/dist/structures/RedisQueue.js +208 -250
- package/dist/structures/Utils.js +56 -0
- package/package.json +1 -1
- package/dist/utils/logExecutionTime.js +0 -11
|
@@ -224,20 +224,27 @@ class Player {
|
|
|
224
224
|
*/
|
|
225
225
|
async destroy(disconnect = true) {
|
|
226
226
|
const oldPlayer = this ? { ...this } : null;
|
|
227
|
+
if (this.state === Utils_1.StateTypes.Destroying || this.state === Utils_1.StateTypes.Disconnected) {
|
|
228
|
+
console.debug(`[Player#destroy] Already destroying/destroyed for ${this.guildId}`);
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
227
231
|
this.state = Utils_1.StateTypes.Destroying;
|
|
228
232
|
if (disconnect) {
|
|
229
|
-
await this.disconnect()
|
|
233
|
+
await this.disconnect().catch((err) => {
|
|
234
|
+
console.warn(`[Player#destroy] Failed to disconnect player ${this.guildId}:`, err);
|
|
235
|
+
});
|
|
230
236
|
}
|
|
231
|
-
await this.node.rest.destroyPlayer(this.guildId)
|
|
237
|
+
await this.node.rest.destroyPlayer(this.guildId).catch((err) => {
|
|
238
|
+
console.warn(`[Player#destroy] REST failed to destroy player ${this.guildId}:`, err);
|
|
239
|
+
});
|
|
232
240
|
await this.queue.clear();
|
|
241
|
+
await this.queue.clearPrevious();
|
|
242
|
+
await this.queue.setCurrent(null);
|
|
233
243
|
this.manager.emit(Manager_1.ManagerEventTypes.PlayerStateUpdate, oldPlayer, null, {
|
|
234
244
|
changeType: Manager_1.PlayerStateEventTypes.PlayerDestroy,
|
|
235
245
|
});
|
|
236
246
|
this.manager.emit(Manager_1.ManagerEventTypes.PlayerDestroy, this);
|
|
237
247
|
const deleted = this.manager.players.delete(this.guildId);
|
|
238
|
-
if (!deleted) {
|
|
239
|
-
console.warn(`Failed to delete player with guildId: ${this.guildId}`);
|
|
240
|
-
}
|
|
241
248
|
return deleted;
|
|
242
249
|
}
|
|
243
250
|
/**
|
|
@@ -665,7 +672,10 @@ class Player {
|
|
|
665
672
|
// Store the current track before changing it.
|
|
666
673
|
// let currentTrackBeforeChange: Track | null = this.queue.current ? (this.queue.current as Track) : null;
|
|
667
674
|
// Get the last played track and remove it from the history
|
|
668
|
-
const
|
|
675
|
+
const previousTracks = await this.queue.getPrevious();
|
|
676
|
+
const lastTrack = previousTracks.pop();
|
|
677
|
+
await this.queue.clearPrevious();
|
|
678
|
+
await this.queue.addPrevious(previousTracks);
|
|
669
679
|
// Set the skip flag to true to prevent the onTrackEnd event from playing the next track.
|
|
670
680
|
this.set("skipFlag", true);
|
|
671
681
|
await this.play(lastTrack);
|