distube 4.0.0-dev.3 → 4.0.0-dev.4

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
@@ -5,7 +5,7 @@ import ytpl from '@distube/ytpl';
5
5
  import { Video, Playlist as Playlist$1 } from '@distube/ytsr';
6
6
  import { TypedEmitter } from 'tiny-typed-emitter';
7
7
  import { FFmpeg } from 'prism-media';
8
- import { StreamType, AudioPlayer, VoiceConnection, AudioResource, VoiceConnectionStatus, AudioPlayerStatus } from '@discordjs/voice';
8
+ import { StreamType as StreamType$1, AudioPlayer, VoiceConnection, AudioResource, VoiceConnectionStatus, AudioPlayerStatus } from '@discordjs/voice';
9
9
  import * as _discordjs_collection from '@discordjs/collection';
10
10
  import { EventEmitter } from 'node:events';
11
11
  import https from 'https';
@@ -58,6 +58,8 @@ interface DisTubeOptions {
58
58
  nsfw?: boolean;
59
59
  emitAddSongWhenCreatingQueue?: boolean;
60
60
  emitAddListWhenCreatingQueue?: boolean;
61
+ joinNewVoiceChannel?: boolean;
62
+ streamType?: StreamType;
61
63
  }
62
64
  declare type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
63
65
  interface OtherSongInfo {
@@ -138,6 +140,10 @@ declare enum SearchResultType {
138
140
  VIDEO = "video",
139
141
  PLAYLIST = "playlist"
140
142
  }
143
+ declare enum StreamType {
144
+ OPUS = 0,
145
+ RAW = 1
146
+ }
141
147
 
142
148
  declare const defaultFilters: Filters;
143
149
  declare const defaultOptions: {
@@ -155,6 +161,7 @@ declare const defaultOptions: {
155
161
  emitAddSongWhenCreatingQueue: boolean;
156
162
  emitAddListWhenCreatingQueue: boolean;
157
163
  joinNewVoiceChannel: boolean;
164
+ streamType: StreamType;
158
165
  };
159
166
 
160
167
  declare const ERROR_MESSAGES: {
@@ -175,6 +182,7 @@ declare const ERROR_MESSAGES: {
175
182
  VOICE_MISSING_PERMS: string;
176
183
  VOICE_RECONNECT_FAILED: string;
177
184
  VOICE_DIFFERENT_GUILD: string;
185
+ VOICE_DIFFERENT_CLIENT: string;
178
186
  NO_QUEUE: string;
179
187
  QUEUE_EXIST: string;
180
188
  PAUSED: string;
@@ -317,6 +325,7 @@ declare class Options {
317
325
  emitAddSongWhenCreatingQueue: boolean;
318
326
  emitAddListWhenCreatingQueue: boolean;
319
327
  joinNewVoiceChannel: boolean;
328
+ streamType: StreamType;
320
329
  constructor(options: DisTubeOptions);
321
330
  }
322
331
 
@@ -336,12 +345,13 @@ interface StreamOptions {
336
345
  seek?: number;
337
346
  ffmpegArgs?: string[];
338
347
  isLive?: boolean;
348
+ type?: StreamType;
339
349
  }
340
350
  declare const chooseBestVideoFormat: (formats: ytdl.videoFormat[], isLive?: boolean) => ytdl.videoFormat;
341
351
  declare class DisTubeStream {
342
352
  static YouTube(formats: ytdl.videoFormat[] | undefined, options?: StreamOptions): DisTubeStream;
343
353
  static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
344
- type: StreamType.Raw;
354
+ type: StreamType$1;
345
355
  stream: FFmpeg;
346
356
  url: string;
347
357
  constructor(url: string, options: StreamOptions);
@@ -449,10 +459,10 @@ declare class Queue extends DisTubeBase {
449
459
  beginTime: number;
450
460
  textChannel?: GuildTextBasedChannel;
451
461
  _emptyTimeout?: NodeJS.Timeout;
452
- clientMember: GuildMember;
453
462
  _taskQueue: TaskQueue;
454
463
  _listeners?: DisTubeVoiceEvents;
455
464
  constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel);
465
+ get clientMember(): discord_js.GuildMember | undefined;
456
466
  get filters(): FilterManager;
457
467
  get formattedDuration(): string;
458
468
  get duration(): number;
@@ -524,6 +534,7 @@ declare function checkInvalidKey(target: Record<string, any>, source: Record<str
524
534
  declare function entersState<T extends VoiceConnection | AudioPlayer>(target: T, status: T extends VoiceConnection ? VoiceConnectionStatus : AudioPlayerStatus, maxTime: number): Promise<EventEmitter | T>;
525
535
  declare function isObject(obj: any): obj is object;
526
536
  declare function isRecord(obj: any): obj is Record<string, unknown>;
537
+ declare function getClientMember(guild: Guild): GuildMember | undefined;
527
538
 
528
539
  declare class HTTPPlugin extends ExtractorPlugin {
529
540
  validate(url: string): Promise<boolean>;
@@ -590,4 +601,4 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
590
601
  emitError(error: Error, channel?: GuildTextBasedChannel): void;
591
602
  }
592
603
 
593
- export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, HTTPPlugin, HTTPSPlugin, Options, OtherSongInfo, PlayHandlerOptions, PlayOptions, Playlist, PlaylistInfo, Plugin, PluginType, Queue, QueueManager, RelatedSong, RepeatMode, ResolveOptions, ResolvePlaylistOptions, SearchResult, SearchResultType, Song, TaskQueue, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions, entersState, formatDuration, getResponseHeaders, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, parseNumber, resolveGuildId, resolveHttpSong, toSecond, validateAudioURL, version };
604
+ export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, HTTPPlugin, HTTPSPlugin, Options, OtherSongInfo, PlayHandlerOptions, PlayOptions, Playlist, PlaylistInfo, Plugin, PluginType, Queue, QueueManager, RelatedSong, RepeatMode, ResolveOptions, ResolvePlaylistOptions, SearchResult, SearchResultType, Song, StreamType, TaskQueue, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions, entersState, formatDuration, getClientMember, getResponseHeaders, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, parseNumber, resolveGuildId, resolveHttpSong, toSecond, validateAudioURL, version };
package/dist/index.js CHANGED
@@ -56,7 +56,7 @@ var require_package = __commonJS({
56
56
  "package.json"(exports, module2) {
57
57
  module2.exports = {
58
58
  name: "distube",
59
- version: "4.0.0-dev.3",
59
+ version: "4.0.0-dev.4",
60
60
  description: "A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key.",
61
61
  main: "./dist/index.js",
62
62
  module: "./dist/index.mjs",
@@ -77,7 +77,7 @@ var require_package = __commonJS({
77
77
  docs: "docgen -s src/*.ts src/**/*.ts -o docs.json -c pages/index.yml -g -j jsdoc.config.json",
78
78
  lint: "prettier --check . && eslint .",
79
79
  "lint:fix": "eslint . --fix",
80
- prettier: "prettier --write **/*.{ts,json,yml,yaml,md}",
80
+ prettier: 'prettier --write "**/*.{ts,json,yml,yaml,md}"',
81
81
  build: "tsup",
82
82
  "build:check": "tsc --noEmit",
83
83
  update: "ncu -u --dep dev,prod && yarn up '**' -R",
@@ -120,43 +120,43 @@ var require_package = __commonJS({
120
120
  ],
121
121
  homepage: "https://distube.js.org/",
122
122
  dependencies: {
123
- "@distube/ytdl-core": "^4.11.1",
123
+ "@distube/ytdl-core": "^4.11.3",
124
124
  "@distube/ytpl": "^1.1.1",
125
125
  "@distube/ytsr": "^1.1.5",
126
126
  "prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main#workaround.tar.gz",
127
127
  "tiny-typed-emitter": "^2.1.0",
128
- tslib: "^2.3.1"
128
+ tslib: "^2.4.0"
129
129
  },
130
130
  devDependencies: {
131
- "@babel/core": "^7.17.8",
132
- "@babel/plugin-proposal-class-properties": "^7.16.7",
133
- "@babel/plugin-proposal-object-rest-spread": "^7.17.3",
134
- "@babel/preset-env": "^7.16.11",
135
- "@babel/preset-typescript": "^7.16.7",
136
- "@commitlint/cli": "^16.2.3",
137
- "@commitlint/config-conventional": "^16.2.1",
131
+ "@babel/core": "^7.18.0",
132
+ "@babel/plugin-proposal-class-properties": "^7.17.12",
133
+ "@babel/plugin-proposal-object-rest-spread": "^7.18.0",
134
+ "@babel/preset-env": "^7.18.0",
135
+ "@babel/preset-typescript": "^7.17.12",
136
+ "@commitlint/cli": "^17.0.0",
137
+ "@commitlint/config-conventional": "^17.0.0",
138
138
  "@discordjs/voice": "dev",
139
139
  "@distube/docgen": "distubejs/docgen",
140
- "@types/jest": "^27.4.1",
141
- "@types/node": "^17.0.23",
142
- "@typescript-eslint/eslint-plugin": "^5.17.0",
143
- "@typescript-eslint/parser": "^5.17.0",
144
- "babel-jest": "^27.5.1",
140
+ "@types/jest": "^27.5.1",
141
+ "@types/node": "^17.0.35",
142
+ "@typescript-eslint/eslint-plugin": "^5.25.0",
143
+ "@typescript-eslint/parser": "^5.25.0",
144
+ "babel-jest": "^28.1.0",
145
145
  "discord.js": "dev",
146
- eslint: "^8.12.0",
146
+ eslint: "^8.15.0",
147
147
  "eslint-config-distube": "^1.6.4",
148
148
  "eslint-config-prettier": "^8.5.0",
149
149
  "eslint-plugin-deprecation": "^1.3.2",
150
- "eslint-plugin-jsdoc": "^38.1.4",
151
- husky: "^7.0.4",
152
- jest: "^27.5.1",
150
+ "eslint-plugin-jsdoc": "^39.3.0",
151
+ husky: "^8.0.1",
152
+ jest: "^28.1.0",
153
153
  "jsdoc-babel": "^0.5.0",
154
- "nano-staged": "^0.6.0",
155
- "npm-check-updates": "^12.5.4",
154
+ "nano-staged": "^0.8.0",
155
+ "npm-check-updates": "^13.0.1",
156
156
  pinst: "^3.0.0",
157
- prettier: "^2.6.1",
158
- tsup: "^5.12.1",
159
- typescript: "^4.6.3"
157
+ prettier: "^2.6.2",
158
+ tsup: "^5.12.8",
159
+ typescript: "^4.6.4"
160
160
  },
161
161
  peerDependencies: {
162
162
  "@discordjs/opus": "*",
@@ -213,6 +213,7 @@ __export(src_exports, {
213
213
  SearchResult: () => SearchResult,
214
214
  SearchResultType: () => SearchResultType,
215
215
  Song: () => Song,
216
+ StreamType: () => StreamType,
216
217
  TaskQueue: () => TaskQueue,
217
218
  checkIntents: () => checkIntents,
218
219
  checkInvalidKey: () => checkInvalidKey,
@@ -222,6 +223,7 @@ __export(src_exports, {
222
223
  defaultOptions: () => defaultOptions,
223
224
  entersState: () => entersState,
224
225
  formatDuration: () => formatDuration,
226
+ getClientMember: () => getClientMember,
225
227
  getResponseHeaders: () => getResponseHeaders,
226
228
  isClientInstance: () => isClientInstance,
227
229
  isGuildInstance: () => isGuildInstance,
@@ -260,6 +262,11 @@ var SearchResultType = /* @__PURE__ */ ((SearchResultType2) => {
260
262
  SearchResultType2["PLAYLIST"] = "playlist";
261
263
  return SearchResultType2;
262
264
  })(SearchResultType || {});
265
+ var StreamType = /* @__PURE__ */ ((StreamType2) => {
266
+ StreamType2[StreamType2["OPUS"] = 0] = "OPUS";
267
+ StreamType2[StreamType2["RAW"] = 1] = "RAW";
268
+ return StreamType2;
269
+ })(StreamType || {});
263
270
 
264
271
  // src/constant.ts
265
272
  var defaultFilters = {
@@ -293,7 +300,8 @@ var defaultOptions = {
293
300
  nsfw: false,
294
301
  emitAddSongWhenCreatingQueue: true,
295
302
  emitAddListWhenCreatingQueue: true,
296
- joinNewVoiceChannel: true
303
+ joinNewVoiceChannel: true,
304
+ streamType: 0 /* OPUS */
297
305
  };
298
306
 
299
307
  // src/struct/DisTubeError.ts
@@ -315,7 +323,8 @@ var ERROR_MESSAGES = {
315
323
  VOICE_CONNECT_FAILED: (s) => `Cannot connect to the voice channel after ${s} seconds`,
316
324
  VOICE_MISSING_PERMS: "I do not have permission to join this voice channel",
317
325
  VOICE_RECONNECT_FAILED: "Cannot reconnect to the voice channel",
318
- VOICE_DIFFERENT_GUILD: "Cannot join a channel in a different guild",
326
+ VOICE_DIFFERENT_GUILD: "Cannot join a voice channel in a different guild",
327
+ VOICE_DIFFERENT_CLIENT: "Cannot join a voice channel created by a different client",
319
328
  NO_QUEUE: "There is no playing queue in this guild",
320
329
  QUEUE_EXIST: "This guild has a Queue already",
321
330
  PAUSED: "The queue has been paused already",
@@ -354,6 +363,7 @@ var DisTubeError = class extends Error {
354
363
  return this.errorCode;
355
364
  }
356
365
  };
366
+ __name(DisTubeError, "DisTubeError");
357
367
 
358
368
  // src/struct/TaskQueue.ts
359
369
  var Task = class {
@@ -367,6 +377,7 @@ var Task = class {
367
377
  });
368
378
  }
369
379
  };
380
+ __name(Task, "Task");
370
381
  var _tasks;
371
382
  var TaskQueue = class {
372
383
  constructor() {
@@ -387,6 +398,7 @@ var TaskQueue = class {
387
398
  return !!__privateGet(this, _tasks).find((t) => t.resolveInfo);
388
399
  }
389
400
  };
401
+ __name(TaskQueue, "TaskQueue");
390
402
  _tasks = new WeakMap();
391
403
 
392
404
  // src/struct/Playlist.ts
@@ -449,6 +461,7 @@ var Playlist = class {
449
461
  this.songs.map((s) => s.constructor.name === "Song" && (s.metadata = metadata));
450
462
  }
451
463
  };
464
+ __name(Playlist, "Playlist");
452
465
  _metadata = new WeakMap();
453
466
  _member = new WeakMap();
454
467
 
@@ -487,6 +500,7 @@ var SearchResult = class {
487
500
  };
488
501
  }
489
502
  };
503
+ __name(SearchResult, "SearchResult");
490
504
 
491
505
  // src/struct/Song.ts
492
506
  var _metadata2, _member2, _playlist;
@@ -621,6 +635,7 @@ var _Song = class {
621
635
  }
622
636
  };
623
637
  var Song = _Song;
638
+ __name(Song, "Song");
624
639
  _metadata2 = new WeakMap();
625
640
  _member2 = new WeakMap();
626
641
  _playlist = new WeakMap();
@@ -647,6 +662,7 @@ var Options = class {
647
662
  __publicField(this, "emitAddSongWhenCreatingQueue");
648
663
  __publicField(this, "emitAddListWhenCreatingQueue");
649
664
  __publicField(this, "joinNewVoiceChannel");
665
+ __publicField(this, "streamType");
650
666
  if (typeof options !== "object" || Array.isArray(options)) {
651
667
  throw new DisTubeError("INVALID_TYPE", "object", options, "DisTubeOptions");
652
668
  }
@@ -668,10 +684,12 @@ var Options = class {
668
684
  this.emitAddSongWhenCreatingQueue = opts.emitAddSongWhenCreatingQueue;
669
685
  this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;
670
686
  this.joinNewVoiceChannel = opts.joinNewVoiceChannel;
687
+ this.streamType = opts.streamType;
671
688
  checkInvalidKey(opts, this, "DisTubeOptions");
672
689
  __privateMethod(this, _validateOptions, validateOptions_fn).call(this);
673
690
  }
674
691
  };
692
+ __name(Options, "Options");
675
693
  _validateOptions = new WeakSet();
676
694
  validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
677
695
  if (typeof options.emitNewSongOnly !== "boolean") {
@@ -725,6 +743,9 @@ validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
725
743
  if (typeof options.emitAddListWhenCreatingQueue !== "boolean") {
726
744
  throw new DisTubeError("INVALID_TYPE", "boolean", options.emitAddListWhenCreatingQueue, "DisTubeOptions.emitAddListWhenCreatingQueue");
727
745
  }
746
+ if (typeof options.streamType !== "number" || isNaN(options.streamType) || !StreamType[options.streamType]) {
747
+ throw new DisTubeError("INVALID_TYPE", "StreamType", options.streamType, "DisTubeOptions.streamType");
748
+ }
728
749
  }, "#validateOptions");
729
750
 
730
751
  // src/core/DisTubeBase.ts
@@ -755,6 +776,7 @@ var DisTubeBase = class {
755
776
  return this.distube.handler;
756
777
  }
757
778
  };
779
+ __name(DisTubeBase, "DisTubeBase");
758
780
 
759
781
  // src/core/DisTubeStream.ts
760
782
  var import_prism_media = require("prism-media");
@@ -772,7 +794,7 @@ var DisTubeStream = class {
772
794
  __publicField(this, "stream");
773
795
  __publicField(this, "url");
774
796
  this.url = url;
775
- this.type = import_voice.StreamType.Raw;
797
+ this.type = !options.type ? import_voice.StreamType.Opus : import_voice.StreamType.Raw;
776
798
  const args = [
777
799
  "-reconnect",
778
800
  "1",
@@ -790,9 +812,13 @@ var DisTubeStream = class {
790
812
  "48000",
791
813
  "-ac",
792
814
  "2",
793
- "-f",
794
- "s16le"
815
+ "-f"
795
816
  ];
817
+ if (!options.type) {
818
+ args.push("opus", "-acodec", "libopus");
819
+ } else {
820
+ args.push("s16le");
821
+ }
796
822
  if (typeof options.seek === "number" && options.seek > 0) {
797
823
  args.unshift("-ss", options.seek.toString());
798
824
  }
@@ -822,6 +848,7 @@ var DisTubeStream = class {
822
848
  return new DisTubeStream(url, options);
823
849
  }
824
850
  };
851
+ __name(DisTubeStream, "DisTubeStream");
825
852
 
826
853
  // src/core/manager/BaseManager.ts
827
854
  var import_discord = require("discord.js");
@@ -834,6 +861,7 @@ var BaseManager = class extends DisTubeBase {
834
861
  return this.collection.size;
835
862
  }
836
863
  };
864
+ __name(BaseManager, "BaseManager");
837
865
 
838
866
  // src/core/manager/GuildIdManager.ts
839
867
  var GuildIdManager = class extends BaseManager {
@@ -854,6 +882,7 @@ var GuildIdManager = class extends BaseManager {
854
882
  return this.collection.has(resolveGuildId(idOrInstance));
855
883
  }
856
884
  };
885
+ __name(GuildIdManager, "GuildIdManager");
857
886
 
858
887
  // src/core/manager/QueueManager.ts
859
888
  var _voiceEventHandler, voiceEventHandler_fn, _handleSongFinish, handleSongFinish_fn, _handlePlayingError, handlePlayingError_fn, _emitPlaySong, emitPlaySong_fn;
@@ -886,7 +915,7 @@ var QueueManager = class extends GuildIdManager {
886
915
  const { duration, formats, isLive, source, streamURL } = queue.songs[0];
887
916
  const ffmpegArgs = queue.filters.size ? ["-af", queue.filters.values.join(",")] : void 0;
888
917
  const seek = duration ? queue.beginTime : void 0;
889
- const streamOptions = { ffmpegArgs, seek, isLive };
918
+ const streamOptions = { ffmpegArgs, seek, isLive, type: this.options.streamType };
890
919
  if (source === "youtube")
891
920
  return DisTubeStream.YouTube(formats, streamOptions);
892
921
  return DisTubeStream.DirectLink(streamURL, streamOptions);
@@ -900,8 +929,8 @@ var QueueManager = class extends GuildIdManager {
900
929
  }
901
930
  if (queue.stopped)
902
931
  return false;
903
- const song = queue.songs[0];
904
932
  try {
933
+ const song = queue.songs[0];
905
934
  const { url, source, formats, streamURL } = song;
906
935
  if (source === "youtube" && !formats)
907
936
  song._patchYouTube(await this.handler.getYouTubeInfo(url));
@@ -930,6 +959,7 @@ var QueueManager = class extends GuildIdManager {
930
959
  }
931
960
  }
932
961
  };
962
+ __name(QueueManager, "QueueManager");
933
963
  _voiceEventHandler = new WeakSet();
934
964
  voiceEventHandler_fn = /* @__PURE__ */ __name(function(queue) {
935
965
  queue._listeners = {
@@ -1086,6 +1116,7 @@ var FilterManager = class extends BaseManager {
1086
1116
  return this.names.toString();
1087
1117
  }
1088
1118
  };
1119
+ __name(FilterManager, "FilterManager");
1089
1120
  _validate = new WeakSet();
1090
1121
  validate_fn = /* @__PURE__ */ __name(function(filter) {
1091
1122
  if (typeof filter === "string" && Object.prototype.hasOwnProperty.call(this.distube.filters, filter) || typeof filter === "object" && typeof filter.name === "string" && typeof filter.value === "string") {
@@ -1125,9 +1156,9 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
1125
1156
  __publicField(this, "isDisconnected", false);
1126
1157
  __privateAdd(this, _channel, void 0);
1127
1158
  __privateAdd(this, _volume, 100);
1159
+ this.voices = voiceManager;
1128
1160
  this.id = channel.guildId;
1129
1161
  this.channel = channel;
1130
- this.voices = voiceManager;
1131
1162
  this.voices.add(this.id, this);
1132
1163
  this.audioPlayer = (0, import_voice2.createAudioPlayer)().on(import_voice2.AudioPlayerStatus.Idle, (oldState) => {
1133
1164
  if (oldState.status !== import_voice2.AudioPlayerStatus.Idle) {
@@ -1170,6 +1201,8 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
1170
1201
  }
1171
1202
  if (channel.guildId !== this.id)
1172
1203
  throw new DisTubeError("VOICE_DIFFERENT_GUILD");
1204
+ if (channel.client.user?.id !== this.voices.client.user?.id)
1205
+ throw new DisTubeError("VOICE_DIFFERENT_CLIENT");
1173
1206
  if (channel.id === __privateGet(this, _channel)?.id)
1174
1207
  return;
1175
1208
  if (!channel.joinable) {
@@ -1273,9 +1306,10 @@ var DisTubeVoice = class extends import_tiny_typed_emitter.TypedEmitter {
1273
1306
  });
1274
1307
  }
1275
1308
  get voiceState() {
1276
- return this.channel?.guild?.me?.voice;
1309
+ return getClientMember(this.channel?.guild)?.voice;
1277
1310
  }
1278
1311
  };
1312
+ __name(DisTubeVoice, "DisTubeVoice");
1279
1313
  _channel = new WeakMap();
1280
1314
  _volume = new WeakMap();
1281
1315
  _br = new WeakSet();
@@ -1322,6 +1356,7 @@ var DisTubeVoiceManager = class extends GuildIdManager {
1322
1356
  }
1323
1357
  }
1324
1358
  };
1359
+ __name(DisTubeVoiceManager, "DisTubeVoiceManager");
1325
1360
 
1326
1361
  // src/core/DisTubeHandler.ts
1327
1362
  var import_ytdl_core = __toESM(require("@distube/ytdl-core"));
@@ -1557,6 +1592,7 @@ var DisTubeHandler = class extends DisTubeBase {
1557
1592
  }
1558
1593
  }
1559
1594
  };
1595
+ __name(DisTubeHandler, "DisTubeHandler");
1560
1596
 
1561
1597
  // src/struct/Queue.ts
1562
1598
  var _filters;
@@ -1578,12 +1614,8 @@ var Queue = class extends DisTubeBase {
1578
1614
  __publicField(this, "beginTime");
1579
1615
  __publicField(this, "textChannel");
1580
1616
  __publicField(this, "_emptyTimeout");
1581
- __publicField(this, "clientMember");
1582
1617
  __publicField(this, "_taskQueue");
1583
1618
  __publicField(this, "_listeners");
1584
- this.clientMember = voice.channel.guild?.me ?? (() => {
1585
- throw new DisTubeError("INVALID_TYPE", "GuildMember", null, "<VoiceChannel>.guild.me");
1586
- })();
1587
1619
  this.voice = voice;
1588
1620
  this.id = voice.id;
1589
1621
  this.volume = 50;
@@ -1603,6 +1635,9 @@ var Queue = class extends DisTubeBase {
1603
1635
  this._taskQueue = new TaskQueue();
1604
1636
  this._listeners = void 0;
1605
1637
  }
1638
+ get clientMember() {
1639
+ return getClientMember(this.voice.channel.guild);
1640
+ }
1606
1641
  get filters() {
1607
1642
  return __privateGet(this, _filters);
1608
1643
  }
@@ -1619,7 +1654,7 @@ var Queue = class extends DisTubeBase {
1619
1654
  return formatDuration(this.currentTime);
1620
1655
  }
1621
1656
  get voiceChannel() {
1622
- return this.clientMember.voice.channel;
1657
+ return this.clientMember?.voice?.channel ?? null;
1623
1658
  }
1624
1659
  get volume() {
1625
1660
  return this.voice.volume;
@@ -1817,6 +1852,7 @@ var Queue = class extends DisTubeBase {
1817
1852
  return this.autoplay;
1818
1853
  }
1819
1854
  };
1855
+ __name(Queue, "Queue");
1820
1856
  _filters = new WeakMap();
1821
1857
 
1822
1858
  // src/struct/Plugin.ts
@@ -1858,6 +1894,7 @@ var Plugin = class {
1858
1894
  return [];
1859
1895
  }
1860
1896
  };
1897
+ __name(Plugin, "Plugin");
1861
1898
 
1862
1899
  // src/struct/CustomPlugin.ts
1863
1900
  var CustomPlugin = class extends Plugin {
@@ -1866,6 +1903,7 @@ var CustomPlugin = class extends Plugin {
1866
1903
  __publicField(this, "type", "custom" /* CUSTOM */);
1867
1904
  }
1868
1905
  };
1906
+ __name(CustomPlugin, "CustomPlugin");
1869
1907
 
1870
1908
  // src/struct/ExtractorPlugin.ts
1871
1909
  var ExtractorPlugin = class extends Plugin {
@@ -1874,6 +1912,7 @@ var ExtractorPlugin = class extends Plugin {
1874
1912
  __publicField(this, "type", "extractor" /* EXTRACTOR */);
1875
1913
  }
1876
1914
  };
1915
+ __name(ExtractorPlugin, "ExtractorPlugin");
1877
1916
 
1878
1917
  // src/util.ts
1879
1918
  var import_url = require("url");
@@ -1891,6 +1930,7 @@ function formatDuration(sec) {
1891
1930
  return `${formatInt(minutes)}:${formatInt(seconds)}`;
1892
1931
  return `00:${formatInt(seconds)}`;
1893
1932
  }
1933
+ __name(formatDuration, "formatDuration");
1894
1934
  function toSecond(input) {
1895
1935
  if (!input)
1896
1936
  return 0;
@@ -1909,11 +1949,13 @@ function toSecond(input) {
1909
1949
  return Number(input.replace(/[^\d.]+/g, "")) || 0;
1910
1950
  }
1911
1951
  }
1952
+ __name(toSecond, "toSecond");
1912
1953
  function parseNumber(input) {
1913
1954
  if (typeof input === "string")
1914
1955
  return Number(input.replace(/[^\d.]+/g, "")) || 0;
1915
1956
  return Number(input) || 0;
1916
1957
  }
1958
+ __name(parseNumber, "parseNumber");
1917
1959
  function isURL(input) {
1918
1960
  if (typeof input !== "string" || input.includes(" "))
1919
1961
  return false;
@@ -1926,18 +1968,25 @@ function isURL(input) {
1926
1968
  }
1927
1969
  return true;
1928
1970
  }
1971
+ __name(isURL, "isURL");
1929
1972
  function checkIntents(options) {
1930
1973
  const intents = new import_discord2.IntentsBitField(options.intents);
1931
1974
  if (!intents.has(import_discord2.GatewayIntentBits.GuildVoiceStates))
1932
1975
  throw new DisTubeError("MISSING_INTENTS", "GuildVoiceStates");
1933
1976
  }
1977
+ __name(checkIntents, "checkIntents");
1934
1978
  function isVoiceChannelEmpty(voiceState) {
1935
- const voiceChannel = voiceState.guild?.me?.voice?.channel;
1979
+ const guild = voiceState.guild;
1980
+ const clientId = voiceState.client.user?.id;
1981
+ if (!guild || !clientId)
1982
+ return false;
1983
+ const voiceChannel = guild.members.resolve(clientId)?.voice?.channel;
1936
1984
  if (!voiceChannel)
1937
1985
  return false;
1938
1986
  const members = voiceChannel.members.filter((m) => !m.user.bot);
1939
1987
  return !members.size;
1940
1988
  }
1989
+ __name(isVoiceChannelEmpty, "isVoiceChannelEmpty");
1941
1990
  function isSnowflake(id) {
1942
1991
  try {
1943
1992
  return import_discord2.SnowflakeUtil.deconstruct(id).timestamp > import_discord2.SnowflakeUtil.epoch;
@@ -1945,21 +1994,27 @@ function isSnowflake(id) {
1945
1994
  return false;
1946
1995
  }
1947
1996
  }
1997
+ __name(isSnowflake, "isSnowflake");
1948
1998
  function isMemberInstance(member) {
1949
1999
  return !!member && isSnowflake(member.id) && isSnowflake(member.guild?.id) && isSnowflake(member.user?.id) && member.id === member.user.id;
1950
2000
  }
2001
+ __name(isMemberInstance, "isMemberInstance");
1951
2002
  function isTextChannelInstance(channel) {
1952
- return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && import_discord2.Constants.TextBasedChannelTypes.includes(channel.type);
2003
+ return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && import_discord2.Constants.TextBasedChannelTypes.includes(channel.type) && typeof channel.nsfw === "boolean";
1953
2004
  }
2005
+ __name(isTextChannelInstance, "isTextChannelInstance");
1954
2006
  function isMessageInstance(message) {
1955
2007
  return !!message && isSnowflake(message.id) && isSnowflake(message.guildId) && isMemberInstance(message.member) && isTextChannelInstance(message.channel) && import_discord2.Constants.NonSystemMessageTypes.includes(message.type) && message.member.id === message.author?.id;
1956
2008
  }
2009
+ __name(isMessageInstance, "isMessageInstance");
1957
2010
  function isSupportedVoiceChannel(channel) {
1958
2011
  return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && import_discord2.Constants.VoiceBasedChannelTypes.includes(channel.type);
1959
2012
  }
2013
+ __name(isSupportedVoiceChannel, "isSupportedVoiceChannel");
1960
2014
  function isGuildInstance(guild) {
1961
2015
  return !!guild && isSnowflake(guild.id) && isSnowflake(guild.ownerId) && typeof guild.name === "string";
1962
2016
  }
2017
+ __name(isGuildInstance, "isGuildInstance");
1963
2018
  function resolveGuildId(resolvable) {
1964
2019
  let guildId;
1965
2020
  if (typeof resolvable === "string") {
@@ -1977,9 +2032,11 @@ function resolveGuildId(resolvable) {
1977
2032
  throw new DisTubeError("INVALID_TYPE", "GuildIdResolvable", resolvable);
1978
2033
  return guildId;
1979
2034
  }
2035
+ __name(resolveGuildId, "resolveGuildId");
1980
2036
  function isClientInstance(client) {
1981
2037
  return !!client && typeof client.login === "function";
1982
2038
  }
2039
+ __name(isClientInstance, "isClientInstance");
1983
2040
  function checkInvalidKey(target, source, sourceName) {
1984
2041
  if (!isObject(target))
1985
2042
  throw new DisTubeError("INVALID_TYPE", "object", target, sourceName);
@@ -1988,6 +2045,7 @@ function checkInvalidKey(target, source, sourceName) {
1988
2045
  if (invalidKey)
1989
2046
  throw new DisTubeError("INVALID_KEY", sourceName, invalidKey);
1990
2047
  }
2048
+ __name(checkInvalidKey, "checkInvalidKey");
1991
2049
  async function waitEvent(target, status, maxTime) {
1992
2050
  let cleanup = /* @__PURE__ */ __name(() => {
1993
2051
  }, "cleanup");
@@ -2009,17 +2067,31 @@ async function waitEvent(target, status, maxTime) {
2009
2067
  cleanup();
2010
2068
  }
2011
2069
  }
2070
+ __name(waitEvent, "waitEvent");
2012
2071
  async function entersState(target, status, maxTime) {
2013
2072
  if (target.state.status === status)
2014
2073
  return target;
2015
2074
  return waitEvent(target, status, maxTime);
2016
2075
  }
2076
+ __name(entersState, "entersState");
2017
2077
  function isObject(obj) {
2018
2078
  return typeof obj === "object" && obj !== null && !Array.isArray(obj);
2019
2079
  }
2080
+ __name(isObject, "isObject");
2020
2081
  function isRecord(obj) {
2021
2082
  return isObject(obj);
2022
2083
  }
2084
+ __name(isRecord, "isRecord");
2085
+ function getClientMember(guild) {
2086
+ const clientUser = guild.client.user;
2087
+ if (!clientUser)
2088
+ return void 0;
2089
+ const clientMember = guild.members.resolve(clientUser);
2090
+ if (!clientMember)
2091
+ return void 0;
2092
+ return clientMember;
2093
+ }
2094
+ __name(getClientMember, "getClientMember");
2023
2095
 
2024
2096
  // src/plugin/http.ts
2025
2097
  var import_http = __toESM(require("http"));
@@ -2031,6 +2103,7 @@ var HTTPPlugin = class extends ExtractorPlugin {
2031
2103
  return resolveHttpSong(url, { ...options, source: "http" });
2032
2104
  }
2033
2105
  };
2106
+ __name(HTTPPlugin, "HTTPPlugin");
2034
2107
 
2035
2108
  // src/plugin/https.ts
2036
2109
  var import_https = __toESM(require("https"));
@@ -2065,6 +2138,7 @@ var HTTPSPlugin = class extends ExtractorPlugin {
2065
2138
  return resolveHttpSong(url, { ...options, source: "https" });
2066
2139
  }
2067
2140
  };
2141
+ __name(HTTPSPlugin, "HTTPSPlugin");
2068
2142
 
2069
2143
  // src/DisTube.ts
2070
2144
  var import_ytsr = __toESM(require("@distube/ytsr"));
@@ -2109,7 +2183,7 @@ var DisTube = class extends import_tiny_typed_emitter2.TypedEmitter {
2109
2183
  if (!isObject(options))
2110
2184
  throw new DisTubeError("INVALID_TYPE", "object", options, "options");
2111
2185
  const { textChannel, member, skip, message, metadata } = {
2112
- member: voiceChannel.guild.me ?? void 0,
2186
+ member: getClientMember(voiceChannel.guild),
2113
2187
  textChannel: options?.message?.channel,
2114
2188
  skip: false,
2115
2189
  ...options
@@ -2306,6 +2380,7 @@ ${e.message}`;
2306
2380
  }
2307
2381
  }
2308
2382
  };
2383
+ __name(DisTube, "DisTube");
2309
2384
  // Annotate the CommonJS export names for ESM import in node:
2310
2385
  0 && (module.exports = {
2311
2386
  BaseManager,
@@ -2332,6 +2407,7 @@ ${e.message}`;
2332
2407
  SearchResult,
2333
2408
  SearchResultType,
2334
2409
  Song,
2410
+ StreamType,
2335
2411
  TaskQueue,
2336
2412
  checkIntents,
2337
2413
  checkInvalidKey,
@@ -2340,6 +2416,7 @@ ${e.message}`;
2340
2416
  defaultOptions,
2341
2417
  entersState,
2342
2418
  formatDuration,
2419
+ getClientMember,
2343
2420
  getResponseHeaders,
2344
2421
  isClientInstance,
2345
2422
  isGuildInstance,