magmastream 2.9.2-dev.5 → 2.9.2-dev.6

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.
@@ -693,16 +693,25 @@ class Player {
693
693
  async stop(amount) {
694
694
  const oldPlayer = { ...this };
695
695
  let removedTracks = [];
696
+ const current = await this.queue.getCurrent(); // may be null
696
697
  if (typeof amount === "number" && amount > 1) {
697
- if (amount > (await this.queue.size())) {
698
+ const queueSize = await this.queue.size();
699
+ if (amount > queueSize) {
698
700
  throw new MagmastreamError_1.MagmaStreamError({
699
701
  code: Enums_1.MagmaStreamErrorCode.PLAYER_QUEUE_EMPTY,
700
- message: "The queue size must be greater than 1.",
702
+ message: "The amount of tracks to remove is greater than the queue size.",
701
703
  });
702
704
  }
703
705
  removedTracks = await this.queue.getSlice(0, amount - 1);
704
706
  await this.queue.modifyAt(0, amount - 1);
707
+ const toAdd = [];
708
+ if (current)
709
+ toAdd.push(current);
710
+ toAdd.push(...removedTracks);
711
+ await this.queue.addPrevious(toAdd);
705
712
  }
713
+ // This will trigger trackEnd for the current track; since we already added current,
714
+ // addPrevious will ignore duplicates.
706
715
  this.node.rest.updatePlayer({
707
716
  guildId: this.guildId,
708
717
  data: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magmastream",
3
- "version": "2.9.2-dev.5",
3
+ "version": "2.9.2-dev.6",
4
4
  "description": "A user-friendly Lavalink client designed for NodeJS.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",