distube 5.1.0 → 5.1.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/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
3
 
4
4
  // src/constant.ts
5
- var version = "5.1.0";
5
+ var version = "5.1.1";
6
6
  var defaultFilters = {
7
7
  "3d": "apulsator=hz=0.125",
8
8
  bassboost: "bass=g=10",
@@ -1001,10 +1001,11 @@ var Queue = class extends DisTubeBase {
1001
1001
  }
1002
1002
  /**
1003
1003
  * Add a related song of the playing song to the queue
1004
+ * @param song - The song to get related songs from. Defaults to the current playing song.
1004
1005
  * @returns The added song
1005
1006
  */
1006
- async addRelatedSong() {
1007
- const current = this.songs?.[0];
1007
+ async addRelatedSong(song) {
1008
+ const current = song ?? this.songs?.[0];
1008
1009
  if (!current) throw new DisTubeError("NO_PLAYING_SONG");
1009
1010
  const prevIds = this.previousSongs.map((p) => p.id);
1010
1011
  const relatedSongs = (await this.#getRelatedSong(current)).filter((s) => !prevIds.includes(s.id));
@@ -1014,12 +1015,12 @@ var Queue = class extends DisTubeBase {
1014
1015
  if (altSong) relatedSongs.push(...(await this.#getRelatedSong(altSong)).filter((s) => !prevIds.includes(s.id)));
1015
1016
  this.debug(`[${this.id}] Getting related songs from streamed song: ${altSong}`);
1016
1017
  }
1017
- const song = relatedSongs[0];
1018
- if (!song) throw new DisTubeError("NO_RELATED");
1019
- song.metadata = current.metadata;
1020
- song.member = this.clientMember;
1021
- this.addToQueue(song);
1022
- return song;
1018
+ const nextSong = relatedSongs[0];
1019
+ if (!nextSong) throw new DisTubeError("NO_RELATED");
1020
+ nextSong.metadata = current.metadata;
1021
+ nextSong.member = this.clientMember;
1022
+ this.addToQueue(nextSong);
1023
+ return nextSong;
1023
1024
  }
1024
1025
  /**
1025
1026
  * Stop the guild stream and delete the queue
@@ -1926,7 +1927,7 @@ var QueueManager = class extends GuildIdManager {
1926
1927
  if (queue.songs.length === 0 && queue.autoplay) {
1927
1928
  try {
1928
1929
  this.debug(`[QueueManager] Adding related song: ${queue.id}`);
1929
- await queue.addRelatedSong();
1930
+ await queue.addRelatedSong(song);
1930
1931
  } catch (e) {
1931
1932
  this.debug(`[${queue.id}] Add related song error: ${e.message}`);
1932
1933
  this.emit("noRelated" /* NO_RELATED */, queue, e);