distube 4.0.5 → 4.1.0

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.js CHANGED
@@ -63,7 +63,7 @@ var require_package = __commonJS({
63
63
  "package.json"(exports, module2) {
64
64
  module2.exports = {
65
65
  name: "distube",
66
- version: "4.0.5",
66
+ version: "4.1.0",
67
67
  description: "A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key.",
68
68
  main: "./dist/index.js",
69
69
  types: "./dist/index.d.ts",
@@ -124,45 +124,47 @@ var require_package = __commonJS({
124
124
  ],
125
125
  homepage: "https://distube.js.org/",
126
126
  dependencies: {
127
- "@distube/ytdl-core": "^4.11.12",
128
- "@distube/ytpl": "^1.1.1",
129
- "@distube/ytsr": "^1.1.9",
130
- "prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main#workaround.tar.gz",
127
+ "@distube/ytdl-core": "^4.12.1",
128
+ "@distube/ytpl": "^1.1.4",
129
+ "@distube/ytsr": "^1.1.10",
130
+ "prism-media": "npm:@distube/prism-media@latest",
131
131
  "tiny-typed-emitter": "^2.1.0",
132
- tslib: "^2.6.0",
133
- undici: "^5.22.1"
132
+ "tough-cookie": "^4.1.3",
133
+ tslib: "^2.6.2",
134
+ undici: "^5.23.0"
134
135
  },
135
136
  devDependencies: {
136
- "@babel/core": "^7.22.9",
137
+ "@babel/core": "^7.22.11",
137
138
  "@babel/plugin-proposal-class-properties": "^7.18.6",
138
139
  "@babel/plugin-proposal-object-rest-spread": "^7.20.7",
139
140
  "@babel/plugin-transform-private-methods": "^7.22.5",
140
- "@babel/preset-env": "^7.22.9",
141
- "@babel/preset-typescript": "^7.22.5",
142
- "@commitlint/cli": "^17.6.7",
143
- "@commitlint/config-conventional": "^17.6.7",
141
+ "@babel/preset-env": "^7.22.10",
142
+ "@babel/preset-typescript": "^7.22.11",
143
+ "@commitlint/cli": "^17.7.1",
144
+ "@commitlint/config-conventional": "^17.7.0",
144
145
  "@discordjs/voice": "^0.16.0",
145
146
  "@distubejs/docgen": "distubejs/docgen",
146
- "@types/jest": "^29.5.3",
147
- "@types/node": "^20.4.2",
148
- "@typescript-eslint/eslint-plugin": "^6.1.0",
149
- "@typescript-eslint/parser": "^6.1.0",
150
- "babel-jest": "^29.6.1",
151
- "discord.js": "^14.11.0",
152
- eslint: "^8.45.0",
147
+ "@types/jest": "^29.5.4",
148
+ "@types/node": "^20.5.7",
149
+ "@types/tough-cookie": "^4.0.2",
150
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
151
+ "@typescript-eslint/parser": "^6.5.0",
152
+ "babel-jest": "^29.6.4",
153
+ "discord.js": "^14.13.0",
154
+ eslint: "^8.48.0",
153
155
  "eslint-config-distube": "^1.6.4",
154
- "eslint-config-prettier": "^8.8.0",
155
- "eslint-plugin-deprecation": "^1.4.1",
156
- "eslint-plugin-jsdoc": "^46.4.4",
156
+ "eslint-config-prettier": "^9.0.0",
157
+ "eslint-plugin-deprecation": "^1.5.0",
158
+ "eslint-plugin-jsdoc": "^46.5.1",
157
159
  husky: "^8.0.3",
158
- jest: "^29.6.1",
160
+ jest: "^29.6.4",
159
161
  "jsdoc-babel": "^0.5.0",
160
162
  "nano-staged": "^0.8.0",
161
- "npm-check-updates": "^16.10.16",
163
+ "npm-check-updates": "^16.13.2",
162
164
  pinst: "^3.0.0",
163
- prettier: "^3.0.0",
164
- tsup: "^7.1.0",
165
- typescript: "^5.1.6"
165
+ prettier: "^3.0.3",
166
+ tsup: "^7.2.0",
167
+ typescript: "^5.2.2"
166
168
  },
167
169
  peerDependencies: {
168
170
  "@discordjs/opus": "*",
@@ -238,6 +240,7 @@ __export(src_exports, {
238
240
  isSnowflake: () => isSnowflake,
239
241
  isSupportedVoiceChannel: () => isSupportedVoiceChannel,
240
242
  isTextChannelInstance: () => isTextChannelInstance,
243
+ isTruthy: () => isTruthy,
241
244
  isURL: () => isURL,
242
245
  isVoiceChannelEmpty: () => isVoiceChannelEmpty,
243
246
  objectKeys: () => objectKeys,
@@ -441,7 +444,7 @@ var _TaskQueue = class _TaskQueue {
441
444
  * @type {boolean}
442
445
  */
443
446
  get hasResolveTask() {
444
- return !!__privateGet(this, _tasks).find((t) => t.resolveInfo);
447
+ return __privateGet(this, _tasks).some((t) => t.resolveInfo);
445
448
  }
446
449
  };
447
450
  _tasks = new WeakMap();
@@ -481,9 +484,9 @@ var _Playlist = class _Playlist {
481
484
  this.songs = playlist;
482
485
  this.name = this.songs[0].name ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.` : `${this.songs.length} songs playlist`;
483
486
  this.thumbnail = this.songs[0].thumbnail;
484
- this.member = member || void 0;
487
+ this.member = member;
485
488
  } else {
486
- this.source = (playlist.source || "youtube").toLowerCase();
489
+ this.source = playlist.source.toLowerCase();
487
490
  if (!Array.isArray(playlist.songs) || !playlist.songs.length)
488
491
  throw new DisTubeError("EMPTY_PLAYLIST");
489
492
  this.songs = playlist.songs;
@@ -491,9 +494,9 @@ var _Playlist = class _Playlist {
491
494
  playlist.title || (this.songs[0].name ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.` : `${this.songs.length} songs playlist`);
492
495
  this.url = playlist.url || playlist.webpage_url;
493
496
  this.thumbnail = playlist.thumbnail || this.songs[0].thumbnail;
494
- this.member = member || playlist.member || void 0;
497
+ this.member = member || playlist.member;
495
498
  }
496
- this.songs.map((s) => s.constructor.name === "Song" && (s.playlist = this));
499
+ this.songs.forEach((s) => s.constructor.name === "Song" && (s.playlist = this));
497
500
  if (properties)
498
501
  for (const [key, value] of Object.entries(properties))
499
502
  this[key] = value;
@@ -504,7 +507,7 @@ var _Playlist = class _Playlist {
504
507
  * @type {number}
505
508
  */
506
509
  get duration() {
507
- return this.songs?.reduce((prev, next) => prev + (next.duration || 0), 0) || 0;
510
+ return this.songs.reduce((prev, next) => prev + next.duration, 0);
508
511
  }
509
512
  /**
510
513
  * Formatted duration string `hh:mm:ss`.
@@ -524,7 +527,7 @@ var _Playlist = class _Playlist {
524
527
  if (!isMemberInstance(member))
525
528
  return;
526
529
  __privateSet(this, _member, member);
527
- this.songs.map((s) => s.constructor.name === "Song" && (s.member = this.member));
530
+ this.songs.forEach((s) => s.constructor.name === "Song" && (s.member = this.member));
528
531
  }
529
532
  /**
530
533
  * User requested.
@@ -538,7 +541,7 @@ var _Playlist = class _Playlist {
538
541
  }
539
542
  set metadata(metadata) {
540
543
  __privateSet(this, _metadata, metadata);
541
- this.songs.map((s) => s.constructor.name === "Song" && (s.metadata = metadata));
544
+ this.songs.forEach((s) => s.constructor.name === "Song" && (s.metadata = metadata));
542
545
  }
543
546
  };
544
547
  _metadata = new WeakMap();
@@ -676,7 +679,7 @@ var _Song = class _Song {
676
679
  const details = info.videoDetails || info;
677
680
  this.id = details.videoId || details.id;
678
681
  this.name = details.title || details.name;
679
- this.isLive = !!details.isLive;
682
+ this.isLive = Boolean(details.isLive);
680
683
  this.duration = this.isLive ? 0 : toSecond(details.lengthSeconds || details.length_seconds || details.duration);
681
684
  this.formattedDuration = this.isLive ? "Live" : formatDuration(this.duration);
682
685
  this.url = `https://www.youtube.com/watch?v=${this.id}`;
@@ -693,7 +696,7 @@ var _Song = class _Song {
693
696
  name: info.uploader?.name || details.author?.name,
694
697
  url: info.uploader?.url || details.author?.channel_url || details.author?.url
695
698
  };
696
- this.age_restricted = !!details.age_restricted;
699
+ this.age_restricted = Boolean(details.age_restricted);
697
700
  this.chapters = details.chapters || [];
698
701
  this.reposts = 0;
699
702
  }
@@ -729,7 +732,7 @@ var _Song = class _Song {
729
732
  url: info.uploader?.url
730
733
  };
731
734
  }
732
- this.age_restricted = info.age_restricted || !!info.age_limit && parseNumber(info.age_limit) >= 18;
735
+ this.age_restricted = info.age_restricted || Boolean(info.age_limit) && parseNumber(info.age_limit) >= 18;
733
736
  this.chapters = info.chapters || [];
734
737
  }
735
738
  /**
@@ -878,27 +881,23 @@ var _DisTubeVoice = class _DisTubeVoice extends import_tiny_typed_emitter.TypedE
878
881
  this.emit("error", error);
879
882
  });
880
883
  this.connection.on(import_voice.VoiceConnectionStatus.Disconnected, (_, newState) => {
881
- if (newState.reason === import_voice.VoiceConnectionDisconnectReason.Manual)
882
- return this.leave();
883
- if (newState.reason === import_voice.VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) {
884
+ if (newState.reason === import_voice.VoiceConnectionDisconnectReason.Manual) {
885
+ this.leave();
886
+ } else if (newState.reason === import_voice.VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) {
884
887
  (0, import_voice.entersState)(this.connection, import_voice.VoiceConnectionStatus.Connecting, 5e3).catch(() => {
885
888
  if (![import_voice.VoiceConnectionStatus.Ready, import_voice.VoiceConnectionStatus.Connecting].includes(this.connection.state.status)) {
886
889
  this.leave();
887
890
  }
888
891
  });
889
- return;
890
- }
891
- if (this.connection.rejoinAttempts < 5) {
892
+ } else if (this.connection.rejoinAttempts < 5) {
892
893
  setTimeout(
893
894
  () => {
894
895
  this.connection.rejoin();
895
896
  },
896
897
  (this.connection.rejoinAttempts + 1) * 5e3
897
898
  ).unref();
898
- return;
899
- }
900
- if (this.connection.state.status !== import_voice.VoiceConnectionStatus.Destroyed) {
901
- return this.leave(new DisTubeError("VOICE_RECONNECT_FAILED"));
899
+ } else if (this.connection.state.status !== import_voice.VoiceConnectionStatus.Destroyed) {
900
+ this.leave(new DisTubeError("VOICE_RECONNECT_FAILED"));
902
901
  }
903
902
  }).on(import_voice.VoiceConnectionStatus.Destroyed, () => {
904
903
  this.leave();
@@ -1041,8 +1040,9 @@ var _DisTubeVoice = class _DisTubeVoice extends import_tiny_typed_emitter.TypedE
1041
1040
  if (state.status !== import_voice.AudioPlayerStatus.Paused)
1042
1041
  return;
1043
1042
  if (this.audioResource && state.resource !== this.audioResource)
1044
- return this.audioPlayer.play(this.audioResource);
1045
- this.audioPlayer.unpause();
1043
+ this.audioPlayer.play(this.audioResource);
1044
+ else
1045
+ this.audioPlayer.unpause();
1046
1046
  }
1047
1047
  /**
1048
1048
  * Whether the bot is self-deafened
@@ -1155,17 +1155,14 @@ var _DisTubeStream = class _DisTubeStream {
1155
1155
  "2",
1156
1156
  "-f"
1157
1157
  ];
1158
- if (!options.type) {
1158
+ if (!options.type)
1159
1159
  args.push("opus", "-acodec", "libopus");
1160
- } else {
1160
+ else
1161
1161
  args.push("s16le");
1162
- }
1163
- if (typeof options.seek === "number" && options.seek > 0) {
1162
+ if (typeof options.seek === "number" && options.seek > 0)
1164
1163
  args.unshift("-ss", options.seek.toString());
1165
- }
1166
- if (Array.isArray(options.ffmpegArgs)) {
1164
+ if (Array.isArray(options.ffmpegArgs) && options.ffmpegArgs.length)
1167
1165
  args.push(...options.ffmpegArgs);
1168
- }
1169
1166
  this.stream = new import_prism_media.FFmpeg({ args, shell: false });
1170
1167
  this.stream._readableState && (this.stream._readableState.highWaterMark = 1 << 25);
1171
1168
  }
@@ -1210,9 +1207,12 @@ var DisTubeStream = _DisTubeStream;
1210
1207
  // src/core/DisTubeHandler.ts
1211
1208
  var import_ytpl = __toESM(require("@distube/ytpl"));
1212
1209
  var import_ytdl_core = __toESM(require("@distube/ytdl-core"));
1210
+ var import_tough_cookie = require("tough-cookie");
1211
+ var _cookie;
1213
1212
  var _DisTubeHandler = class _DisTubeHandler extends DisTubeBase {
1214
1213
  constructor(distube) {
1215
1214
  super(distube);
1215
+ __privateAdd(this, _cookie, "");
1216
1216
  const client = this.client;
1217
1217
  if (this.options.leaveOnEmpty) {
1218
1218
  client.on("voiceStateUpdate", (oldState) => {
@@ -1248,18 +1248,28 @@ var _DisTubeHandler = class _DisTubeHandler extends DisTubeBase {
1248
1248
  }
1249
1249
  get ytdlOptions() {
1250
1250
  const options = this.options.ytdlOptions;
1251
- if (this.options.youtubeCookie) {
1252
- if (!options.requestOptions)
1253
- options.requestOptions = {};
1254
- if (!options.requestOptions.headers)
1255
- options.requestOptions.headers = {};
1256
- options.requestOptions.headers.cookie = this.options.youtubeCookie;
1257
- if (this.options.youtubeIdentityToken) {
1258
- options.requestOptions.headers["x-youtube-identity-token"] = this.options.youtubeIdentityToken;
1251
+ if (this.options.youtubeCookie && this.options.youtubeCookie !== __privateGet(this, _cookie)) {
1252
+ const cookies = __privateSet(this, _cookie, this.options.youtubeCookie);
1253
+ if (typeof cookies === "string") {
1254
+ console.warn(
1255
+ "\x1B[33mWARNING:\x1B[0m You are using the old YouTube cookie format, please use the new one instead. (https://distube.js.org/#/docs/DisTube/main/general/cookie)"
1256
+ );
1257
+ options.agent = import_ytdl_core.default.createAgent(
1258
+ cookies.split(";").map((c) => import_tough_cookie.Cookie.parse(c)).filter(isTruthy)
1259
+ );
1260
+ } else {
1261
+ options.agent = import_ytdl_core.default.createAgent(cookies);
1259
1262
  }
1260
1263
  }
1261
1264
  return options;
1262
1265
  }
1266
+ get ytCookie() {
1267
+ const agent = this.ytdlOptions.agent;
1268
+ if (!agent)
1269
+ return "";
1270
+ const { jar } = agent;
1271
+ return jar.getCookieStringSync("https://www.youtube.com");
1272
+ }
1263
1273
  /**
1264
1274
  * @param {string} url url
1265
1275
  * @param {boolean} [basic=false] getBasicInfo?
@@ -1323,7 +1333,7 @@ var _DisTubeHandler = class _DisTubeHandler extends DisTubeBase {
1323
1333
  return playlist;
1324
1334
  }
1325
1335
  if (typeof playlist === "string") {
1326
- const info = await (0, import_ytpl.default)(playlist, { limit: Infinity });
1336
+ const info = await (0, import_ytpl.default)(playlist, { limit: Infinity, requestOptions: { headers: { cookie: this.ytCookie } } });
1327
1337
  const songs = info.items.filter((v) => !v.thumbnail.includes("no_thumbnail")).map((v) => new Song(v, { member, metadata }));
1328
1338
  return new Playlist(
1329
1339
  {
@@ -1381,7 +1391,7 @@ var _DisTubeHandler = class _DisTubeHandler extends DisTubeBase {
1381
1391
  async createSearchMessageCollector(message, results, query) {
1382
1392
  if (!isMessageInstance(message))
1383
1393
  throw new DisTubeError("INVALID_TYPE", "Discord.Message", message, "message");
1384
- if (!Array.isArray(results) || results.length == 0) {
1394
+ if (!Array.isArray(results) || results.length === 0) {
1385
1395
  throw new DisTubeError("INVALID_TYPE", "Array<SearchResult|Song|Playlist>", results, "results");
1386
1396
  }
1387
1397
  if (this.options.searchSongs > 1) {
@@ -1408,8 +1418,7 @@ var _DisTubeHandler = class _DisTubeHandler extends DisTubeBase {
1408
1418
  if (limit > 1) {
1409
1419
  results.splice(limit);
1410
1420
  this.emit("searchResult", message, results, query);
1411
- const c = message.channel;
1412
- const answers = await c.awaitMessages({
1421
+ const answers = await message.channel.awaitMessages({
1413
1422
  filter: (m) => m.author.id === message.author.id,
1414
1423
  max: 1,
1415
1424
  time: this.options.searchCooldown * 1e3,
@@ -1526,6 +1535,7 @@ var _DisTubeHandler = class _DisTubeHandler extends DisTubeBase {
1526
1535
  }
1527
1536
  }
1528
1537
  };
1538
+ _cookie = new WeakMap();
1529
1539
  __name(_DisTubeHandler, "DisTubeHandler");
1530
1540
  var DisTubeHandler = _DisTubeHandler;
1531
1541
 
@@ -1544,7 +1554,6 @@ var _Options = class _Options {
1544
1554
  __publicField(this, "searchSongs");
1545
1555
  __publicField(this, "searchCooldown");
1546
1556
  __publicField(this, "youtubeCookie");
1547
- __publicField(this, "youtubeIdentityToken");
1548
1557
  __publicField(this, "customFilters");
1549
1558
  __publicField(this, "ytdlOptions");
1550
1559
  __publicField(this, "nsfw");
@@ -1565,7 +1574,6 @@ var _Options = class _Options {
1565
1574
  this.savePreviousSongs = opts.savePreviousSongs;
1566
1575
  this.searchSongs = opts.searchSongs;
1567
1576
  this.youtubeCookie = opts.youtubeCookie;
1568
- this.youtubeIdentityToken = opts.youtubeIdentityToken;
1569
1577
  this.customFilters = opts.customFilters;
1570
1578
  this.ytdlOptions = opts.ytdlOptions;
1571
1579
  this.searchCooldown = opts.searchCooldown;
@@ -1582,82 +1590,48 @@ var _Options = class _Options {
1582
1590
  };
1583
1591
  _validateOptions = new WeakSet();
1584
1592
  validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
1585
- if (typeof options.emitNewSongOnly !== "boolean") {
1586
- throw new DisTubeError("INVALID_TYPE", "boolean", options.emitNewSongOnly, "DisTubeOptions.emitNewSongOnly");
1587
- }
1588
- if (typeof options.leaveOnEmpty !== "boolean") {
1589
- throw new DisTubeError("INVALID_TYPE", "boolean", options.leaveOnEmpty, "DisTubeOptions.leaveOnEmpty");
1590
- }
1591
- if (typeof options.leaveOnFinish !== "boolean") {
1592
- throw new DisTubeError("INVALID_TYPE", "boolean", options.leaveOnFinish, "DisTubeOptions.leaveOnFinish");
1593
- }
1594
- if (typeof options.leaveOnStop !== "boolean") {
1595
- throw new DisTubeError("INVALID_TYPE", "boolean", options.leaveOnStop, "DisTubeOptions.leaveOnStop");
1596
- }
1597
- if (typeof options.savePreviousSongs !== "boolean") {
1598
- throw new DisTubeError("INVALID_TYPE", "boolean", options.savePreviousSongs, "DisTubeOptions.savePreviousSongs");
1599
- }
1600
- if (typeof options.joinNewVoiceChannel !== "boolean") {
1601
- throw new DisTubeError(
1602
- "INVALID_TYPE",
1603
- "boolean",
1604
- options.joinNewVoiceChannel,
1605
- "DisTubeOptions.joinNewVoiceChannel"
1606
- );
1607
- }
1608
- if (typeof options.youtubeCookie !== "undefined" && typeof options.youtubeCookie !== "string") {
1609
- throw new DisTubeError("INVALID_TYPE", "string", options.youtubeCookie, "DisTubeOptions.youtubeCookie");
1610
- }
1611
- if (typeof options.youtubeIdentityToken !== "undefined" && typeof options.youtubeIdentityToken !== "string") {
1612
- throw new DisTubeError(
1613
- "INVALID_TYPE",
1614
- "string",
1615
- options.youtubeIdentityToken,
1616
- "DisTubeOptions.youtubeIdentityToken"
1617
- );
1618
- }
1619
- if (typeof options.customFilters !== "undefined" && typeof options.customFilters !== "object" || Array.isArray(options.customFilters)) {
1620
- throw new DisTubeError("INVALID_TYPE", "object", options.customFilters, "DisTubeOptions.customFilters");
1621
- }
1622
- if (typeof options.ytdlOptions !== "object" || Array.isArray(options.ytdlOptions)) {
1623
- throw new DisTubeError("INVALID_TYPE", "object", options.ytdlOptions, "DisTubeOptions.ytdlOptions");
1624
- }
1625
- if (typeof options.searchCooldown !== "number" || isNaN(options.searchCooldown)) {
1626
- throw new DisTubeError("INVALID_TYPE", "number", options.searchCooldown, "DisTubeOptions.searchCooldown");
1627
- }
1628
- if (typeof options.emptyCooldown !== "number" || isNaN(options.emptyCooldown)) {
1629
- throw new DisTubeError("INVALID_TYPE", "number", options.emptyCooldown, "DisTubeOptions.emptyCooldown");
1630
- }
1631
- if (typeof options.searchSongs !== "number" || isNaN(options.searchSongs)) {
1632
- throw new DisTubeError("INVALID_TYPE", "number", options.searchSongs, "DisTubeOptions.searchSongs");
1633
- }
1634
- if (!Array.isArray(options.plugins)) {
1635
- throw new DisTubeError("INVALID_TYPE", "Array<Plugin>", options.plugins, "DisTubeOptions.plugins");
1636
- }
1637
- if (typeof options.nsfw !== "boolean") {
1638
- throw new DisTubeError("INVALID_TYPE", "boolean", options.nsfw, "DisTubeOptions.nsfw");
1639
- }
1640
- if (typeof options.emitAddSongWhenCreatingQueue !== "boolean") {
1641
- throw new DisTubeError(
1642
- "INVALID_TYPE",
1643
- "boolean",
1644
- options.emitAddSongWhenCreatingQueue,
1645
- "DisTubeOptions.emitAddSongWhenCreatingQueue"
1646
- );
1647
- }
1648
- if (typeof options.emitAddListWhenCreatingQueue !== "boolean") {
1649
- throw new DisTubeError(
1650
- "INVALID_TYPE",
1651
- "boolean",
1652
- options.emitAddListWhenCreatingQueue,
1653
- "DisTubeOptions.emitAddListWhenCreatingQueue"
1654
- );
1655
- }
1656
- if (typeof options.streamType !== "number" || isNaN(options.streamType) || !StreamType[options.streamType]) {
1657
- throw new DisTubeError("INVALID_TYPE", "StreamType", options.streamType, "DisTubeOptions.streamType");
1658
- }
1659
- if (typeof options.directLink !== "boolean") {
1660
- throw new DisTubeError("INVALID_TYPE", "boolean", options.directLink, "DisTubeOptions.directLink");
1593
+ const booleanOptions = /* @__PURE__ */ new Set([
1594
+ "emitNewSongOnly",
1595
+ "leaveOnEmpty",
1596
+ "leaveOnFinish",
1597
+ "leaveOnStop",
1598
+ "savePreviousSongs",
1599
+ "joinNewVoiceChannel",
1600
+ "nsfw",
1601
+ "emitAddSongWhenCreatingQueue",
1602
+ "emitAddListWhenCreatingQueue",
1603
+ "directLink"
1604
+ ]);
1605
+ const numberOptions = /* @__PURE__ */ new Set(["searchCooldown", "emptyCooldown", "searchSongs"]);
1606
+ const stringOptions = /* @__PURE__ */ new Set();
1607
+ const objectOptions = /* @__PURE__ */ new Set(["customFilters", "ytdlOptions"]);
1608
+ const optionalOptions = /* @__PURE__ */ new Set(["youtubeCookie", "customFilters"]);
1609
+ for (const [key, value] of Object.entries(options)) {
1610
+ if (value === void 0 && optionalOptions.has(key))
1611
+ continue;
1612
+ if (key === "youtubeCookie" && !Array.isArray(value) && typeof value !== "string") {
1613
+ throw new DisTubeError("INVALID_TYPE", ["Array<Cookie>", "string"], value, `DisTubeOptions.${key}`);
1614
+ } else if (key === "streamType" && (typeof value !== "number" || isNaN(value) || !StreamType[value])) {
1615
+ throw new DisTubeError("INVALID_TYPE", "StreamType", value, `DisTubeOptions.${key}`);
1616
+ } else if (key === "plugins" && !Array.isArray(value)) {
1617
+ throw new DisTubeError("INVALID_TYPE", "Array<Plugin>", value, `DisTubeOptions.${key}`);
1618
+ } else if (booleanOptions.has(key)) {
1619
+ if (typeof value !== "boolean") {
1620
+ throw new DisTubeError("INVALID_TYPE", "boolean", value, `DisTubeOptions.${key}`);
1621
+ }
1622
+ } else if (numberOptions.has(key)) {
1623
+ if (typeof value !== "number" || isNaN(value)) {
1624
+ throw new DisTubeError("INVALID_TYPE", "number", value, `DisTubeOptions.${key}`);
1625
+ }
1626
+ } else if (stringOptions.has(key)) {
1627
+ if (typeof value !== "string") {
1628
+ throw new DisTubeError("INVALID_TYPE", "string", value, `DisTubeOptions.${key}`);
1629
+ }
1630
+ } else if (objectOptions.has(key)) {
1631
+ if (typeof value !== "object" || Array.isArray(value)) {
1632
+ throw new DisTubeError("INVALID_TYPE", "object", value, `DisTubeOptions.${key}`);
1633
+ }
1634
+ }
1661
1635
  }
1662
1636
  }, "#validateOptions");
1663
1637
  __name(_Options, "Options");
@@ -1768,17 +1742,15 @@ __name(_DisTubeVoiceManager, "DisTubeVoiceManager");
1768
1742
  var DisTubeVoiceManager = _DisTubeVoiceManager;
1769
1743
 
1770
1744
  // src/core/manager/FilterManager.ts
1771
- var _validate, validate_fn, _resolveName, resolveName_fn, _resolveValue, resolveValue_fn, _apply, apply_fn, _removeFn, removeFn_get;
1745
+ var _resolve, resolve_fn, _apply, apply_fn, _removeFn, removeFn_fn;
1772
1746
  var _FilterManager = class _FilterManager extends BaseManager {
1773
1747
  constructor(queue) {
1774
1748
  super(queue.distube);
1775
- __privateAdd(this, _validate);
1776
- __privateAdd(this, _resolveName);
1777
- __privateAdd(this, _resolveValue);
1749
+ __privateAdd(this, _resolve);
1778
1750
  __privateAdd(this, _apply);
1779
1751
  __privateAdd(this, _removeFn);
1780
1752
  /**
1781
- * Collection of {@link FilterResolvable}.
1753
+ * Collection of {@link Filter}.
1782
1754
  * @name FilterManager#collection
1783
1755
  * @type {Discord.Collection<string, DisTubeVoice>}
1784
1756
  */
@@ -1793,28 +1765,18 @@ var _FilterManager = class _FilterManager extends BaseManager {
1793
1765
  */
1794
1766
  add(filterOrFilters, override = false) {
1795
1767
  if (Array.isArray(filterOrFilters)) {
1796
- const resolvedFilters = filterOrFilters.map((f) => __privateMethod(this, _validate, validate_fn).call(this, f));
1797
- const newFilters = resolvedFilters.reduceRight((unique, o) => {
1798
- if (!unique.some((obj) => obj === o && obj.name === o) && !unique.some((obj) => obj !== o.name && obj.name !== o.name)) {
1799
- if (!this.has(o))
1800
- unique.push(o);
1801
- if (this.has(o) && override) {
1802
- this.remove(o);
1803
- unique.push(o);
1804
- }
1805
- }
1806
- return unique;
1807
- }, []).reverse();
1808
- return this.set([...this.collection.values(), ...newFilters]);
1809
- } else if (typeof filterOrFilters === "string") {
1810
- return this.set([...this.collection.values(), filterOrFilters]);
1811
- }
1812
- throw new DisTubeError(
1813
- "INVALID_TYPE",
1814
- ["FilterResolvable", "Array<FilterResolvable>"],
1815
- filterOrFilters,
1816
- "filterOrFilters"
1817
- );
1768
+ for (const filter of filterOrFilters) {
1769
+ const ft = __privateMethod(this, _resolve, resolve_fn).call(this, filter);
1770
+ if (override || !this.has(ft))
1771
+ this.collection.set(ft.name, ft);
1772
+ }
1773
+ } else {
1774
+ const ft = __privateMethod(this, _resolve, resolve_fn).call(this, filterOrFilters);
1775
+ if (override || !this.has(ft))
1776
+ this.collection.set(ft.name, ft);
1777
+ }
1778
+ __privateMethod(this, _apply, apply_fn).call(this);
1779
+ return this;
1818
1780
  }
1819
1781
  /**
1820
1782
  * Clear enabled filters of the manager
@@ -1832,9 +1794,9 @@ var _FilterManager = class _FilterManager extends BaseManager {
1832
1794
  if (!Array.isArray(filters))
1833
1795
  throw new DisTubeError("INVALID_TYPE", "Array<FilterResolvable>", filters, "filters");
1834
1796
  this.collection.clear();
1835
- for (const filter of filters) {
1836
- const resolved = __privateMethod(this, _validate, validate_fn).call(this, filter);
1837
- this.collection.set(__privateMethod(this, _resolveName, resolveName_fn).call(this, resolved), resolved);
1797
+ for (const f of filters) {
1798
+ const filter = __privateMethod(this, _resolve, resolve_fn).call(this, f);
1799
+ this.collection.set(filter.name, filter);
1838
1800
  }
1839
1801
  __privateMethod(this, _apply, apply_fn).call(this);
1840
1802
  return this;
@@ -1845,18 +1807,10 @@ var _FilterManager = class _FilterManager extends BaseManager {
1845
1807
  * @returns {FilterManager}
1846
1808
  */
1847
1809
  remove(filterOrFilters) {
1848
- if (Array.isArray(filterOrFilters)) {
1849
- filterOrFilters.map(__privateGet(this, _removeFn, removeFn_get));
1850
- } else if (typeof filterOrFilters === "string") {
1851
- __privateGet(this, _removeFn, removeFn_get).call(this, filterOrFilters);
1852
- } else {
1853
- throw new DisTubeError(
1854
- "INVALID_TYPE",
1855
- ["FilterResolvable", "Array<FilterResolvable>"],
1856
- filterOrFilters,
1857
- "filterOrFilters"
1858
- );
1859
- }
1810
+ if (Array.isArray(filterOrFilters))
1811
+ filterOrFilters.forEach((f) => __privateMethod(this, _removeFn, removeFn_fn).call(this, f));
1812
+ else
1813
+ __privateMethod(this, _removeFn, removeFn_fn).call(this, filterOrFilters);
1860
1814
  __privateMethod(this, _apply, apply_fn).call(this);
1861
1815
  return this;
1862
1816
  }
@@ -1866,46 +1820,52 @@ var _FilterManager = class _FilterManager extends BaseManager {
1866
1820
  * @returns {boolean}
1867
1821
  */
1868
1822
  has(filter) {
1869
- return this.collection.has(__privateMethod(this, _resolveName, resolveName_fn).call(this, filter));
1823
+ return this.collection.has(typeof filter === "string" ? filter : __privateMethod(this, _resolve, resolve_fn).call(this, filter).name);
1870
1824
  }
1871
1825
  /**
1872
- * Array of enabled filter name
1826
+ * Array of enabled filter names
1873
1827
  * @type {Array<string>}
1874
1828
  * @readonly
1875
1829
  */
1876
1830
  get names() {
1877
- return this.collection.map((f) => __privateMethod(this, _resolveName, resolveName_fn).call(this, f));
1831
+ return [...this.collection.keys()];
1878
1832
  }
1833
+ /**
1834
+ * Array of enabled filters
1835
+ * @type {Array<Filter>}
1836
+ * @readonly
1837
+ */
1879
1838
  get values() {
1880
- return this.collection.map((f) => __privateMethod(this, _resolveValue, resolveValue_fn).call(this, f));
1839
+ return [...this.collection.values()];
1840
+ }
1841
+ get ffmpegArgs() {
1842
+ return this.size ? ["-af", this.values.map((f) => f.value).join(",")] : [];
1881
1843
  }
1882
1844
  toString() {
1883
1845
  return this.names.toString();
1884
1846
  }
1885
1847
  };
1886
- _validate = new WeakSet();
1887
- validate_fn = /* @__PURE__ */ __name(function(filter) {
1888
- if (typeof filter === "string" && Object.prototype.hasOwnProperty.call(this.distube.filters, filter) || typeof filter === "object" && typeof filter.name === "string" && typeof filter.value === "string") {
1848
+ _resolve = new WeakSet();
1849
+ resolve_fn = /* @__PURE__ */ __name(function(filter) {
1850
+ if (typeof filter === "object" && typeof filter.name === "string" && typeof filter.value === "string") {
1889
1851
  return filter;
1890
1852
  }
1853
+ if (typeof filter === "string" && Object.prototype.hasOwnProperty.call(this.distube.filters, filter)) {
1854
+ return {
1855
+ name: filter,
1856
+ value: this.distube.filters[filter]
1857
+ };
1858
+ }
1891
1859
  throw new DisTubeError("INVALID_TYPE", "FilterResolvable", filter, "filter");
1892
- }, "#validate");
1893
- _resolveName = new WeakSet();
1894
- resolveName_fn = /* @__PURE__ */ __name(function(filter) {
1895
- return typeof filter === "string" ? filter : filter.name;
1896
- }, "#resolveName");
1897
- _resolveValue = new WeakSet();
1898
- resolveValue_fn = /* @__PURE__ */ __name(function(filter) {
1899
- return typeof filter === "string" ? this.distube.filters[filter] : filter.value;
1900
- }, "#resolveValue");
1860
+ }, "#resolve");
1901
1861
  _apply = new WeakSet();
1902
1862
  apply_fn = /* @__PURE__ */ __name(function() {
1903
1863
  this.queue.beginTime = this.queue.currentTime;
1904
1864
  this.queues.playSong(this.queue);
1905
1865
  }, "#apply");
1906
1866
  _removeFn = new WeakSet();
1907
- removeFn_get = /* @__PURE__ */ __name(function() {
1908
- return (f) => this.collection.delete(__privateMethod(this, _resolveName, resolveName_fn).call(this, __privateMethod(this, _validate, validate_fn).call(this, f)));
1867
+ removeFn_fn = /* @__PURE__ */ __name(function(f) {
1868
+ return this.collection.delete(__privateMethod(this, _resolve, resolve_fn).call(this, f).name);
1909
1869
  }, "#removeFn");
1910
1870
  __name(_FilterManager, "FilterManager");
1911
1871
  var FilterManager = _FilterManager;
@@ -1987,9 +1947,12 @@ var _QueueManager = class _QueueManager extends GuildIdManager {
1987
1947
  */
1988
1948
  createStream(queue) {
1989
1949
  const { duration, formats, isLive, source, streamURL } = queue.songs[0];
1990
- const ffmpegArgs = queue.filters.size ? ["-af", queue.filters.values.join(",")] : void 0;
1991
- const seek = duration ? queue.beginTime : void 0;
1992
- const streamOptions = { ffmpegArgs, seek, isLive, type: this.options.streamType };
1950
+ const streamOptions = {
1951
+ ffmpegArgs: queue.filters.ffmpegArgs,
1952
+ seek: duration ? queue.beginTime : void 0,
1953
+ isLive,
1954
+ type: this.options.streamType
1955
+ };
1993
1956
  if (source === "youtube")
1994
1957
  return DisTubeStream.YouTube(formats, streamOptions);
1995
1958
  return DisTubeStream.DirectLink(streamURL, streamOptions);
@@ -2255,7 +2218,7 @@ var _Queue = class _Queue extends DisTubeBase {
2255
2218
  this.songs.splice(position, 0, song);
2256
2219
  }
2257
2220
  if (Array.isArray(song))
2258
- song.map((s) => delete s.formats);
2221
+ song.forEach((s) => delete s.formats);
2259
2222
  else
2260
2223
  delete song.formats;
2261
2224
  return this;
@@ -2638,15 +2601,15 @@ function toSecond(input) {
2638
2601
  return 0;
2639
2602
  if (typeof input !== "string")
2640
2603
  return Number(input) || 0;
2641
- if (input.match(/:/g)) {
2604
+ if (input.includes(":")) {
2642
2605
  const time = input.split(":").reverse();
2643
- let s = 0;
2606
+ let seconds = 0;
2644
2607
  for (let i = 0; i < 3; i++)
2645
2608
  if (time[i])
2646
- s += Number(time[i].replace(/[^\d.]+/g, "")) * Math.pow(60, i);
2609
+ seconds += Number(time[i].replace(/[^\d.]+/g, "")) * Math.pow(60, i);
2647
2610
  if (time.length > 3)
2648
- s += Number(time[3].replace(/[^\d.]+/g, "")) * 24 * 60 * 60;
2649
- return s;
2611
+ seconds += Number(time[3].replace(/[^\d.]+/g, "")) * 24 * 60 * 60;
2612
+ return seconds;
2650
2613
  } else {
2651
2614
  return Number(input.replace(/[^\d.]+/g, "")) || 0;
2652
2615
  }
@@ -2699,23 +2662,23 @@ function isSnowflake(id) {
2699
2662
  }
2700
2663
  __name(isSnowflake, "isSnowflake");
2701
2664
  function isMemberInstance(member) {
2702
- return !!member && isSnowflake(member.id) && isSnowflake(member.guild?.id) && isSnowflake(member.user?.id) && member.id === member.user.id;
2665
+ return Boolean(member) && isSnowflake(member.id) && isSnowflake(member.guild?.id) && isSnowflake(member.user?.id) && member.id === member.user.id;
2703
2666
  }
2704
2667
  __name(isMemberInstance, "isMemberInstance");
2705
2668
  function isTextChannelInstance(channel) {
2706
- return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && import_discord3.Constants.TextBasedChannelTypes.includes(channel.type) && "messages" in channel && typeof channel.send === "function";
2669
+ return Boolean(channel) && isSnowflake(channel.id) && isSnowflake(channel.guildId || channel.guild?.id) && import_discord3.Constants.TextBasedChannelTypes.includes(channel.type) && typeof channel.send === "function" && (typeof channel.nsfw === "boolean" || typeof channel.parent?.nsfw === "boolean");
2707
2670
  }
2708
2671
  __name(isTextChannelInstance, "isTextChannelInstance");
2709
2672
  function isMessageInstance(message) {
2710
- return !!message && isSnowflake(message.id) && isSnowflake(message.guildId) && isMemberInstance(message.member) && isTextChannelInstance(message.channel) && import_discord3.Constants.NonSystemMessageTypes.includes(message.type) && message.member.id === message.author?.id;
2673
+ return Boolean(message) && isSnowflake(message.id) && isSnowflake(message.guildId || message.guild?.id) && isMemberInstance(message.member) && isTextChannelInstance(message.channel) && import_discord3.Constants.NonSystemMessageTypes.includes(message.type) && message.member.id === message.author?.id;
2711
2674
  }
2712
2675
  __name(isMessageInstance, "isMessageInstance");
2713
2676
  function isSupportedVoiceChannel(channel) {
2714
- return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && import_discord3.Constants.VoiceBasedChannelTypes.includes(channel.type);
2677
+ return Boolean(channel) && isSnowflake(channel.id) && isSnowflake(channel.guildId || channel.guild?.id) && import_discord3.Constants.VoiceBasedChannelTypes.includes(channel.type);
2715
2678
  }
2716
2679
  __name(isSupportedVoiceChannel, "isSupportedVoiceChannel");
2717
2680
  function isGuildInstance(guild) {
2718
- return !!guild && isSnowflake(guild.id) && isSnowflake(guild.ownerId) && typeof guild.name === "string";
2681
+ return Boolean(guild) && isSnowflake(guild.id) && isSnowflake(guild.ownerId) && typeof guild.name === "string";
2719
2682
  }
2720
2683
  __name(isGuildInstance, "isGuildInstance");
2721
2684
  function resolveGuildId(resolvable) {
@@ -2737,7 +2700,7 @@ function resolveGuildId(resolvable) {
2737
2700
  }
2738
2701
  __name(resolveGuildId, "resolveGuildId");
2739
2702
  function isClientInstance(client) {
2740
- return !!client && typeof client.login === "function";
2703
+ return Boolean(client) && typeof client.login === "function";
2741
2704
  }
2742
2705
  __name(isClientInstance, "isClientInstance");
2743
2706
  function checkInvalidKey(target, source, sourceName) {
@@ -2771,6 +2734,7 @@ function isNsfwChannel(channel) {
2771
2734
  return channel.nsfw;
2772
2735
  }
2773
2736
  __name(isNsfwChannel, "isNsfwChannel");
2737
+ var isTruthy = /* @__PURE__ */ __name((x) => Boolean(x), "isTruthy");
2774
2738
 
2775
2739
  // src/plugin/DirectLink.ts
2776
2740
  var import_undici = require("undici");
@@ -2786,8 +2750,7 @@ var _DirectLinkPlugin = class _DirectLinkPlugin extends ExtractorPlugin {
2786
2750
  }
2787
2751
  return false;
2788
2752
  }
2789
- // eslint-disable-next-line @typescript-eslint/require-await
2790
- async resolve(url, options = {}) {
2753
+ resolve(url, options = {}) {
2791
2754
  url = url.replace(/\/+$/, "");
2792
2755
  return new Song(
2793
2756
  {
@@ -2806,23 +2769,11 @@ var DirectLinkPlugin = _DirectLinkPlugin;
2806
2769
  var import_ytsr = __toESM(require("@distube/ytsr"));
2807
2770
  var import_tiny_typed_emitter2 = require("tiny-typed-emitter");
2808
2771
  var { version } = require_package();
2772
+ var _getQueue, getQueue_fn;
2809
2773
  var _DisTube = class _DisTube extends import_tiny_typed_emitter2.TypedEmitter {
2810
- /**
2811
- * Create a new DisTube class.
2812
- * @param {Discord.Client} client Discord.JS client
2813
- * @param {DisTubeOptions} [otp] Custom DisTube options
2814
- * @throws {DisTubeError}
2815
- * @example
2816
- * const Discord = require('discord.js'),
2817
- * DisTube = require('distube'),
2818
- * client = new Discord.Client();
2819
- * // Create a new DisTube
2820
- * const distube = new DisTube.default(client, { searchSongs: 10 });
2821
- * // client.DisTube = distube // make it access easily
2822
- * client.login("Your Discord Bot Token")
2823
- */
2824
2774
  constructor(client, otp = {}) {
2825
2775
  super();
2776
+ __privateAdd(this, _getQueue);
2826
2777
  __publicField(this, "handler");
2827
2778
  __publicField(this, "options");
2828
2779
  __publicField(this, "client");
@@ -2843,7 +2794,7 @@ var _DisTube = class _DisTube extends import_tiny_typed_emitter2.TypedEmitter {
2843
2794
  this.filters = { ...defaultFilters, ...this.options.customFilters };
2844
2795
  if (this.options.directLink)
2845
2796
  this.options.plugins.push(new DirectLinkPlugin());
2846
- this.options.plugins.map((p) => p.init(this));
2797
+ this.options.plugins.forEach((p) => p.init(this));
2847
2798
  this.extractorPlugins = this.options.plugins.filter((p) => p.type === "extractor");
2848
2799
  this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
2849
2800
  }
@@ -2903,7 +2854,7 @@ var _DisTube = class _DisTube extends import_tiny_typed_emitter2.TypedEmitter {
2903
2854
  throw new DisTubeError("INVALID_TYPE", "Discord.GuildMember", member, "options.member");
2904
2855
  }
2905
2856
  const queue = this.getQueue(voiceChannel);
2906
- const queuing = !!queue && !queue._taskQueue.hasResolveTask;
2857
+ const queuing = queue && !queue._taskQueue.hasResolveTask;
2907
2858
  if (queuing)
2908
2859
  await queue?._taskQueue.queuing(true);
2909
2860
  try {
@@ -2979,13 +2930,13 @@ ${e.message}`;
2979
2930
  const promises = filteredSongs.map(
2980
2931
  (song) => this.handler.resolve(song, { member, metadata }).catch(() => void 0)
2981
2932
  );
2982
- resolvedSongs = (await Promise.all(promises)).filter((s) => !!s);
2933
+ resolvedSongs = (await Promise.all(promises)).filter((s) => Boolean(s));
2983
2934
  } else {
2984
2935
  const resolved = [];
2985
2936
  for (const song of filteredSongs) {
2986
2937
  resolved.push(await this.handler.resolve(song, { member, metadata }).catch(() => void 0));
2987
2938
  }
2988
- resolvedSongs = resolved.filter((s) => !!s);
2939
+ resolvedSongs = resolved.filter((s) => Boolean(s));
2989
2940
  }
2990
2941
  return new Playlist(resolvedSongs, { member, properties, metadata });
2991
2942
  }
@@ -3014,7 +2965,7 @@ ${e.message}`;
3014
2965
  throw new DisTubeError("INVALID_TYPE", "boolean", opts.safeSearch, "options.safeSearch");
3015
2966
  }
3016
2967
  try {
3017
- const search = await (0, import_ytsr.default)(string, opts);
2968
+ const search = await (0, import_ytsr.default)(string, { ...opts, requestOptions: { headers: { cookie: this.handler.ytCookie } } });
3018
2969
  const results = search.items.map((i) => {
3019
2970
  if (i.type === "video")
3020
2971
  return new SearchResultVideo(i);
@@ -3058,10 +3009,7 @@ ${e.message}`;
3058
3009
  * @throws {Error}
3059
3010
  */
3060
3011
  pause(guild) {
3061
- const q = this.getQueue(guild);
3062
- if (!q)
3063
- throw new DisTubeError("NO_QUEUE");
3064
- return q.pause();
3012
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).pause();
3065
3013
  }
3066
3014
  /**
3067
3015
  * Resume the guild stream
@@ -3070,10 +3018,7 @@ ${e.message}`;
3070
3018
  * @throws {Error}
3071
3019
  */
3072
3020
  resume(guild) {
3073
- const q = this.getQueue(guild);
3074
- if (!q)
3075
- throw new DisTubeError("NO_QUEUE");
3076
- return q.resume();
3021
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).resume();
3077
3022
  }
3078
3023
  /**
3079
3024
  * Stop the guild stream
@@ -3092,10 +3037,7 @@ ${e.message}`;
3092
3037
  * });
3093
3038
  */
3094
3039
  stop(guild) {
3095
- const q = this.getQueue(guild);
3096
- if (!q)
3097
- throw new DisTubeError("NO_QUEUE");
3098
- return q.stop();
3040
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).stop();
3099
3041
  }
3100
3042
  /**
3101
3043
  * Set the guild stream's volume
@@ -3113,10 +3055,7 @@ ${e.message}`;
3113
3055
  * });
3114
3056
  */
3115
3057
  setVolume(guild, percent) {
3116
- const q = this.getQueue(guild);
3117
- if (!q)
3118
- throw new DisTubeError("NO_QUEUE");
3119
- return q.setVolume(percent);
3058
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).setVolume(percent);
3120
3059
  }
3121
3060
  /**
3122
3061
  * Skip the playing song if there is a next song in the queue.
@@ -3135,10 +3074,7 @@ ${e.message}`;
3135
3074
  * });
3136
3075
  */
3137
3076
  skip(guild) {
3138
- const q = this.getQueue(guild);
3139
- if (!q)
3140
- throw new DisTubeError("NO_QUEUE");
3141
- return q.skip();
3077
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).skip();
3142
3078
  }
3143
3079
  /**
3144
3080
  * Play the previous song
@@ -3155,10 +3091,7 @@ ${e.message}`;
3155
3091
  * });
3156
3092
  */
3157
3093
  previous(guild) {
3158
- const q = this.getQueue(guild);
3159
- if (!q)
3160
- throw new DisTubeError("NO_QUEUE");
3161
- return q.previous();
3094
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).previous();
3162
3095
  }
3163
3096
  /**
3164
3097
  * Shuffle the guild queue songs
@@ -3174,10 +3107,7 @@ ${e.message}`;
3174
3107
  * });
3175
3108
  */
3176
3109
  shuffle(guild) {
3177
- const q = this.getQueue(guild);
3178
- if (!q)
3179
- throw new DisTubeError("NO_QUEUE");
3180
- return q.shuffle();
3110
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).shuffle();
3181
3111
  }
3182
3112
  /**
3183
3113
  * Jump to the song number in the queue.
@@ -3198,10 +3128,7 @@ ${e.message}`;
3198
3128
  * });
3199
3129
  */
3200
3130
  jump(guild, num) {
3201
- const q = this.getQueue(guild);
3202
- if (!q)
3203
- throw new DisTubeError("NO_QUEUE");
3204
- return q.jump(num);
3131
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).jump(num);
3205
3132
  }
3206
3133
  /**
3207
3134
  * Set the repeat mode of the guild queue.\
@@ -3237,10 +3164,7 @@ ${e.message}`;
3237
3164
  * message.channel.send("Set repeat mode to `" + mode + "`");
3238
3165
  */
3239
3166
  setRepeatMode(guild, mode) {
3240
- const q = this.getQueue(guild);
3241
- if (!q)
3242
- throw new DisTubeError("NO_QUEUE");
3243
- return q.setRepeatMode(mode);
3167
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).setRepeatMode(mode);
3244
3168
  }
3245
3169
  /**
3246
3170
  * Toggle autoplay mode
@@ -3259,11 +3183,9 @@ ${e.message}`;
3259
3183
  * });
3260
3184
  */
3261
3185
  toggleAutoplay(guild) {
3262
- const q = this.getQueue(guild);
3263
- if (!q)
3264
- throw new DisTubeError("NO_QUEUE");
3265
- q.autoplay = !q.autoplay;
3266
- return q.autoplay;
3186
+ const queue = __privateMethod(this, _getQueue, getQueue_fn).call(this, guild);
3187
+ queue.autoplay = !queue.autoplay;
3188
+ return queue.autoplay;
3267
3189
  }
3268
3190
  /**
3269
3191
  * Add related song to the queue
@@ -3271,10 +3193,7 @@ ${e.message}`;
3271
3193
  * @returns {Promise<Song>} The guild queue
3272
3194
  */
3273
3195
  addRelatedSong(guild) {
3274
- const q = this.getQueue(guild);
3275
- if (!q)
3276
- throw new DisTubeError("NO_QUEUE");
3277
- return q.addRelatedSong();
3196
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).addRelatedSong();
3278
3197
  }
3279
3198
  /**
3280
3199
  * Set the playing time to another position
@@ -3291,10 +3210,7 @@ ${e.message}`;
3291
3210
  * });
3292
3211
  */
3293
3212
  seek(guild, time) {
3294
- const q = this.getQueue(guild);
3295
- if (!q)
3296
- throw new DisTubeError("NO_QUEUE");
3297
- return q.seek(time);
3213
+ return __privateMethod(this, _getQueue, getQueue_fn).call(this, guild).seek(time);
3298
3214
  }
3299
3215
  /**
3300
3216
  * Emit error event
@@ -3314,6 +3230,13 @@ ${e.message}`;
3314
3230
  }
3315
3231
  }
3316
3232
  };
3233
+ _getQueue = new WeakSet();
3234
+ getQueue_fn = /* @__PURE__ */ __name(function(guild) {
3235
+ const queue = this.getQueue(guild);
3236
+ if (!queue)
3237
+ throw new DisTubeError("NO_QUEUE");
3238
+ return queue;
3239
+ }, "#getQueue");
3317
3240
  __name(_DisTube, "DisTube");
3318
3241
  var DisTube = _DisTube;
3319
3242
  // Annotate the CommonJS export names for ESM import in node:
@@ -3361,6 +3284,7 @@ var DisTube = _DisTube;
3361
3284
  isSnowflake,
3362
3285
  isSupportedVoiceChannel,
3363
3286
  isTextChannelInstance,
3287
+ isTruthy,
3364
3288
  isURL,
3365
3289
  isVoiceChannelEmpty,
3366
3290
  objectKeys,