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 +15 -4
- package/dist/index.js +119 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +25 -25
package/dist/index.mjs
CHANGED
|
@@ -44,7 +44,7 @@ var require_package = __commonJS({
|
|
|
44
44
|
"package.json"(exports, module) {
|
|
45
45
|
module.exports = {
|
|
46
46
|
name: "distube",
|
|
47
|
-
version: "4.0.0-dev.
|
|
47
|
+
version: "4.0.0-dev.4",
|
|
48
48
|
description: "A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key.",
|
|
49
49
|
main: "./dist/index.js",
|
|
50
50
|
module: "./dist/index.mjs",
|
|
@@ -65,7 +65,7 @@ var require_package = __commonJS({
|
|
|
65
65
|
docs: "docgen -s src/*.ts src/**/*.ts -o docs.json -c pages/index.yml -g -j jsdoc.config.json",
|
|
66
66
|
lint: "prettier --check . && eslint .",
|
|
67
67
|
"lint:fix": "eslint . --fix",
|
|
68
|
-
prettier:
|
|
68
|
+
prettier: 'prettier --write "**/*.{ts,json,yml,yaml,md}"',
|
|
69
69
|
build: "tsup",
|
|
70
70
|
"build:check": "tsc --noEmit",
|
|
71
71
|
update: "ncu -u --dep dev,prod && yarn up '**' -R",
|
|
@@ -108,43 +108,43 @@ var require_package = __commonJS({
|
|
|
108
108
|
],
|
|
109
109
|
homepage: "https://distube.js.org/",
|
|
110
110
|
dependencies: {
|
|
111
|
-
"@distube/ytdl-core": "^4.11.
|
|
111
|
+
"@distube/ytdl-core": "^4.11.3",
|
|
112
112
|
"@distube/ytpl": "^1.1.1",
|
|
113
113
|
"@distube/ytsr": "^1.1.5",
|
|
114
114
|
"prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main#workaround.tar.gz",
|
|
115
115
|
"tiny-typed-emitter": "^2.1.0",
|
|
116
|
-
tslib: "^2.
|
|
116
|
+
tslib: "^2.4.0"
|
|
117
117
|
},
|
|
118
118
|
devDependencies: {
|
|
119
|
-
"@babel/core": "^7.
|
|
120
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
121
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
122
|
-
"@babel/preset-env": "^7.
|
|
123
|
-
"@babel/preset-typescript": "^7.
|
|
124
|
-
"@commitlint/cli": "^
|
|
125
|
-
"@commitlint/config-conventional": "^
|
|
119
|
+
"@babel/core": "^7.18.0",
|
|
120
|
+
"@babel/plugin-proposal-class-properties": "^7.17.12",
|
|
121
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.0",
|
|
122
|
+
"@babel/preset-env": "^7.18.0",
|
|
123
|
+
"@babel/preset-typescript": "^7.17.12",
|
|
124
|
+
"@commitlint/cli": "^17.0.0",
|
|
125
|
+
"@commitlint/config-conventional": "^17.0.0",
|
|
126
126
|
"@discordjs/voice": "dev",
|
|
127
127
|
"@distube/docgen": "distubejs/docgen",
|
|
128
|
-
"@types/jest": "^27.
|
|
129
|
-
"@types/node": "^17.0.
|
|
130
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
131
|
-
"@typescript-eslint/parser": "^5.
|
|
132
|
-
"babel-jest": "^
|
|
128
|
+
"@types/jest": "^27.5.1",
|
|
129
|
+
"@types/node": "^17.0.35",
|
|
130
|
+
"@typescript-eslint/eslint-plugin": "^5.25.0",
|
|
131
|
+
"@typescript-eslint/parser": "^5.25.0",
|
|
132
|
+
"babel-jest": "^28.1.0",
|
|
133
133
|
"discord.js": "dev",
|
|
134
|
-
eslint: "^8.
|
|
134
|
+
eslint: "^8.15.0",
|
|
135
135
|
"eslint-config-distube": "^1.6.4",
|
|
136
136
|
"eslint-config-prettier": "^8.5.0",
|
|
137
137
|
"eslint-plugin-deprecation": "^1.3.2",
|
|
138
|
-
"eslint-plugin-jsdoc": "^
|
|
139
|
-
husky: "^
|
|
140
|
-
jest: "^
|
|
138
|
+
"eslint-plugin-jsdoc": "^39.3.0",
|
|
139
|
+
husky: "^8.0.1",
|
|
140
|
+
jest: "^28.1.0",
|
|
141
141
|
"jsdoc-babel": "^0.5.0",
|
|
142
|
-
"nano-staged": "^0.
|
|
143
|
-
"npm-check-updates": "^
|
|
142
|
+
"nano-staged": "^0.8.0",
|
|
143
|
+
"npm-check-updates": "^13.0.1",
|
|
144
144
|
pinst: "^3.0.0",
|
|
145
|
-
prettier: "^2.6.
|
|
146
|
-
tsup: "^5.12.
|
|
147
|
-
typescript: "^4.6.
|
|
145
|
+
prettier: "^2.6.2",
|
|
146
|
+
tsup: "^5.12.8",
|
|
147
|
+
typescript: "^4.6.4"
|
|
148
148
|
},
|
|
149
149
|
peerDependencies: {
|
|
150
150
|
"@discordjs/opus": "*",
|
|
@@ -191,6 +191,11 @@ var SearchResultType = /* @__PURE__ */ ((SearchResultType2) => {
|
|
|
191
191
|
SearchResultType2["PLAYLIST"] = "playlist";
|
|
192
192
|
return SearchResultType2;
|
|
193
193
|
})(SearchResultType || {});
|
|
194
|
+
var StreamType = /* @__PURE__ */ ((StreamType2) => {
|
|
195
|
+
StreamType2[StreamType2["OPUS"] = 0] = "OPUS";
|
|
196
|
+
StreamType2[StreamType2["RAW"] = 1] = "RAW";
|
|
197
|
+
return StreamType2;
|
|
198
|
+
})(StreamType || {});
|
|
194
199
|
|
|
195
200
|
// src/constant.ts
|
|
196
201
|
var defaultFilters = {
|
|
@@ -224,7 +229,8 @@ var defaultOptions = {
|
|
|
224
229
|
nsfw: false,
|
|
225
230
|
emitAddSongWhenCreatingQueue: true,
|
|
226
231
|
emitAddListWhenCreatingQueue: true,
|
|
227
|
-
joinNewVoiceChannel: true
|
|
232
|
+
joinNewVoiceChannel: true,
|
|
233
|
+
streamType: 0 /* OPUS */
|
|
228
234
|
};
|
|
229
235
|
|
|
230
236
|
// src/struct/DisTubeError.ts
|
|
@@ -246,7 +252,8 @@ var ERROR_MESSAGES = {
|
|
|
246
252
|
VOICE_CONNECT_FAILED: (s) => `Cannot connect to the voice channel after ${s} seconds`,
|
|
247
253
|
VOICE_MISSING_PERMS: "I do not have permission to join this voice channel",
|
|
248
254
|
VOICE_RECONNECT_FAILED: "Cannot reconnect to the voice channel",
|
|
249
|
-
VOICE_DIFFERENT_GUILD: "Cannot join a channel in a different guild",
|
|
255
|
+
VOICE_DIFFERENT_GUILD: "Cannot join a voice channel in a different guild",
|
|
256
|
+
VOICE_DIFFERENT_CLIENT: "Cannot join a voice channel created by a different client",
|
|
250
257
|
NO_QUEUE: "There is no playing queue in this guild",
|
|
251
258
|
QUEUE_EXIST: "This guild has a Queue already",
|
|
252
259
|
PAUSED: "The queue has been paused already",
|
|
@@ -285,6 +292,7 @@ var DisTubeError = class extends Error {
|
|
|
285
292
|
return this.errorCode;
|
|
286
293
|
}
|
|
287
294
|
};
|
|
295
|
+
__name(DisTubeError, "DisTubeError");
|
|
288
296
|
|
|
289
297
|
// src/struct/TaskQueue.ts
|
|
290
298
|
var Task = class {
|
|
@@ -298,6 +306,7 @@ var Task = class {
|
|
|
298
306
|
});
|
|
299
307
|
}
|
|
300
308
|
};
|
|
309
|
+
__name(Task, "Task");
|
|
301
310
|
var _tasks;
|
|
302
311
|
var TaskQueue = class {
|
|
303
312
|
constructor() {
|
|
@@ -318,6 +327,7 @@ var TaskQueue = class {
|
|
|
318
327
|
return !!__privateGet(this, _tasks).find((t) => t.resolveInfo);
|
|
319
328
|
}
|
|
320
329
|
};
|
|
330
|
+
__name(TaskQueue, "TaskQueue");
|
|
321
331
|
_tasks = new WeakMap();
|
|
322
332
|
|
|
323
333
|
// src/struct/Playlist.ts
|
|
@@ -380,6 +390,7 @@ var Playlist = class {
|
|
|
380
390
|
this.songs.map((s) => s.constructor.name === "Song" && (s.metadata = metadata));
|
|
381
391
|
}
|
|
382
392
|
};
|
|
393
|
+
__name(Playlist, "Playlist");
|
|
383
394
|
_metadata = new WeakMap();
|
|
384
395
|
_member = new WeakMap();
|
|
385
396
|
|
|
@@ -418,6 +429,7 @@ var SearchResult = class {
|
|
|
418
429
|
};
|
|
419
430
|
}
|
|
420
431
|
};
|
|
432
|
+
__name(SearchResult, "SearchResult");
|
|
421
433
|
|
|
422
434
|
// src/struct/Song.ts
|
|
423
435
|
var _metadata2, _member2, _playlist;
|
|
@@ -552,6 +564,7 @@ var _Song = class {
|
|
|
552
564
|
}
|
|
553
565
|
};
|
|
554
566
|
var Song = _Song;
|
|
567
|
+
__name(Song, "Song");
|
|
555
568
|
_metadata2 = new WeakMap();
|
|
556
569
|
_member2 = new WeakMap();
|
|
557
570
|
_playlist = new WeakMap();
|
|
@@ -578,6 +591,7 @@ var Options = class {
|
|
|
578
591
|
__publicField(this, "emitAddSongWhenCreatingQueue");
|
|
579
592
|
__publicField(this, "emitAddListWhenCreatingQueue");
|
|
580
593
|
__publicField(this, "joinNewVoiceChannel");
|
|
594
|
+
__publicField(this, "streamType");
|
|
581
595
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
582
596
|
throw new DisTubeError("INVALID_TYPE", "object", options, "DisTubeOptions");
|
|
583
597
|
}
|
|
@@ -599,10 +613,12 @@ var Options = class {
|
|
|
599
613
|
this.emitAddSongWhenCreatingQueue = opts.emitAddSongWhenCreatingQueue;
|
|
600
614
|
this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;
|
|
601
615
|
this.joinNewVoiceChannel = opts.joinNewVoiceChannel;
|
|
616
|
+
this.streamType = opts.streamType;
|
|
602
617
|
checkInvalidKey(opts, this, "DisTubeOptions");
|
|
603
618
|
__privateMethod(this, _validateOptions, validateOptions_fn).call(this);
|
|
604
619
|
}
|
|
605
620
|
};
|
|
621
|
+
__name(Options, "Options");
|
|
606
622
|
_validateOptions = new WeakSet();
|
|
607
623
|
validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
|
|
608
624
|
if (typeof options.emitNewSongOnly !== "boolean") {
|
|
@@ -656,6 +672,9 @@ validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
|
|
|
656
672
|
if (typeof options.emitAddListWhenCreatingQueue !== "boolean") {
|
|
657
673
|
throw new DisTubeError("INVALID_TYPE", "boolean", options.emitAddListWhenCreatingQueue, "DisTubeOptions.emitAddListWhenCreatingQueue");
|
|
658
674
|
}
|
|
675
|
+
if (typeof options.streamType !== "number" || isNaN(options.streamType) || !StreamType[options.streamType]) {
|
|
676
|
+
throw new DisTubeError("INVALID_TYPE", "StreamType", options.streamType, "DisTubeOptions.streamType");
|
|
677
|
+
}
|
|
659
678
|
}, "#validateOptions");
|
|
660
679
|
|
|
661
680
|
// src/core/DisTubeBase.ts
|
|
@@ -686,10 +705,11 @@ var DisTubeBase = class {
|
|
|
686
705
|
return this.distube.handler;
|
|
687
706
|
}
|
|
688
707
|
};
|
|
708
|
+
__name(DisTubeBase, "DisTubeBase");
|
|
689
709
|
|
|
690
710
|
// src/core/DisTubeStream.ts
|
|
691
711
|
import { FFmpeg } from "prism-media";
|
|
692
|
-
import { StreamType } from "@discordjs/voice";
|
|
712
|
+
import { StreamType as DiscordVoiceStreamType } from "@discordjs/voice";
|
|
693
713
|
var chooseBestVideoFormat = /* @__PURE__ */ __name((formats, isLive = false) => {
|
|
694
714
|
let filter = /* @__PURE__ */ __name((format) => format.hasAudio, "filter");
|
|
695
715
|
if (isLive)
|
|
@@ -703,7 +723,7 @@ var DisTubeStream = class {
|
|
|
703
723
|
__publicField(this, "stream");
|
|
704
724
|
__publicField(this, "url");
|
|
705
725
|
this.url = url;
|
|
706
|
-
this.type =
|
|
726
|
+
this.type = !options.type ? DiscordVoiceStreamType.Opus : DiscordVoiceStreamType.Raw;
|
|
707
727
|
const args = [
|
|
708
728
|
"-reconnect",
|
|
709
729
|
"1",
|
|
@@ -721,9 +741,13 @@ var DisTubeStream = class {
|
|
|
721
741
|
"48000",
|
|
722
742
|
"-ac",
|
|
723
743
|
"2",
|
|
724
|
-
"-f"
|
|
725
|
-
"s16le"
|
|
744
|
+
"-f"
|
|
726
745
|
];
|
|
746
|
+
if (!options.type) {
|
|
747
|
+
args.push("opus", "-acodec", "libopus");
|
|
748
|
+
} else {
|
|
749
|
+
args.push("s16le");
|
|
750
|
+
}
|
|
727
751
|
if (typeof options.seek === "number" && options.seek > 0) {
|
|
728
752
|
args.unshift("-ss", options.seek.toString());
|
|
729
753
|
}
|
|
@@ -753,6 +777,7 @@ var DisTubeStream = class {
|
|
|
753
777
|
return new DisTubeStream(url, options);
|
|
754
778
|
}
|
|
755
779
|
};
|
|
780
|
+
__name(DisTubeStream, "DisTubeStream");
|
|
756
781
|
|
|
757
782
|
// src/core/manager/BaseManager.ts
|
|
758
783
|
import { Collection } from "discord.js";
|
|
@@ -765,6 +790,7 @@ var BaseManager = class extends DisTubeBase {
|
|
|
765
790
|
return this.collection.size;
|
|
766
791
|
}
|
|
767
792
|
};
|
|
793
|
+
__name(BaseManager, "BaseManager");
|
|
768
794
|
|
|
769
795
|
// src/core/manager/GuildIdManager.ts
|
|
770
796
|
var GuildIdManager = class extends BaseManager {
|
|
@@ -785,6 +811,7 @@ var GuildIdManager = class extends BaseManager {
|
|
|
785
811
|
return this.collection.has(resolveGuildId(idOrInstance));
|
|
786
812
|
}
|
|
787
813
|
};
|
|
814
|
+
__name(GuildIdManager, "GuildIdManager");
|
|
788
815
|
|
|
789
816
|
// src/core/manager/QueueManager.ts
|
|
790
817
|
var _voiceEventHandler, voiceEventHandler_fn, _handleSongFinish, handleSongFinish_fn, _handlePlayingError, handlePlayingError_fn, _emitPlaySong, emitPlaySong_fn;
|
|
@@ -817,7 +844,7 @@ var QueueManager = class extends GuildIdManager {
|
|
|
817
844
|
const { duration, formats, isLive, source, streamURL } = queue.songs[0];
|
|
818
845
|
const ffmpegArgs = queue.filters.size ? ["-af", queue.filters.values.join(",")] : void 0;
|
|
819
846
|
const seek = duration ? queue.beginTime : void 0;
|
|
820
|
-
const streamOptions = { ffmpegArgs, seek, isLive };
|
|
847
|
+
const streamOptions = { ffmpegArgs, seek, isLive, type: this.options.streamType };
|
|
821
848
|
if (source === "youtube")
|
|
822
849
|
return DisTubeStream.YouTube(formats, streamOptions);
|
|
823
850
|
return DisTubeStream.DirectLink(streamURL, streamOptions);
|
|
@@ -831,8 +858,8 @@ var QueueManager = class extends GuildIdManager {
|
|
|
831
858
|
}
|
|
832
859
|
if (queue.stopped)
|
|
833
860
|
return false;
|
|
834
|
-
const song = queue.songs[0];
|
|
835
861
|
try {
|
|
862
|
+
const song = queue.songs[0];
|
|
836
863
|
const { url, source, formats, streamURL } = song;
|
|
837
864
|
if (source === "youtube" && !formats)
|
|
838
865
|
song._patchYouTube(await this.handler.getYouTubeInfo(url));
|
|
@@ -861,6 +888,7 @@ var QueueManager = class extends GuildIdManager {
|
|
|
861
888
|
}
|
|
862
889
|
}
|
|
863
890
|
};
|
|
891
|
+
__name(QueueManager, "QueueManager");
|
|
864
892
|
_voiceEventHandler = new WeakSet();
|
|
865
893
|
voiceEventHandler_fn = /* @__PURE__ */ __name(function(queue) {
|
|
866
894
|
queue._listeners = {
|
|
@@ -1017,6 +1045,7 @@ var FilterManager = class extends BaseManager {
|
|
|
1017
1045
|
return this.names.toString();
|
|
1018
1046
|
}
|
|
1019
1047
|
};
|
|
1048
|
+
__name(FilterManager, "FilterManager");
|
|
1020
1049
|
_validate = new WeakSet();
|
|
1021
1050
|
validate_fn = /* @__PURE__ */ __name(function(filter) {
|
|
1022
1051
|
if (typeof filter === "string" && Object.prototype.hasOwnProperty.call(this.distube.filters, filter) || typeof filter === "object" && typeof filter.name === "string" && typeof filter.value === "string") {
|
|
@@ -1063,9 +1092,9 @@ var DisTubeVoice = class extends TypedEmitter {
|
|
|
1063
1092
|
__publicField(this, "isDisconnected", false);
|
|
1064
1093
|
__privateAdd(this, _channel, void 0);
|
|
1065
1094
|
__privateAdd(this, _volume, 100);
|
|
1095
|
+
this.voices = voiceManager;
|
|
1066
1096
|
this.id = channel.guildId;
|
|
1067
1097
|
this.channel = channel;
|
|
1068
|
-
this.voices = voiceManager;
|
|
1069
1098
|
this.voices.add(this.id, this);
|
|
1070
1099
|
this.audioPlayer = createAudioPlayer().on(AudioPlayerStatus.Idle, (oldState) => {
|
|
1071
1100
|
if (oldState.status !== AudioPlayerStatus.Idle) {
|
|
@@ -1108,6 +1137,8 @@ var DisTubeVoice = class extends TypedEmitter {
|
|
|
1108
1137
|
}
|
|
1109
1138
|
if (channel.guildId !== this.id)
|
|
1110
1139
|
throw new DisTubeError("VOICE_DIFFERENT_GUILD");
|
|
1140
|
+
if (channel.client.user?.id !== this.voices.client.user?.id)
|
|
1141
|
+
throw new DisTubeError("VOICE_DIFFERENT_CLIENT");
|
|
1111
1142
|
if (channel.id === __privateGet(this, _channel)?.id)
|
|
1112
1143
|
return;
|
|
1113
1144
|
if (!channel.joinable) {
|
|
@@ -1211,9 +1242,10 @@ var DisTubeVoice = class extends TypedEmitter {
|
|
|
1211
1242
|
});
|
|
1212
1243
|
}
|
|
1213
1244
|
get voiceState() {
|
|
1214
|
-
return this.channel?.guild?.
|
|
1245
|
+
return getClientMember(this.channel?.guild)?.voice;
|
|
1215
1246
|
}
|
|
1216
1247
|
};
|
|
1248
|
+
__name(DisTubeVoice, "DisTubeVoice");
|
|
1217
1249
|
_channel = new WeakMap();
|
|
1218
1250
|
_volume = new WeakMap();
|
|
1219
1251
|
_br = new WeakSet();
|
|
@@ -1260,6 +1292,7 @@ var DisTubeVoiceManager = class extends GuildIdManager {
|
|
|
1260
1292
|
}
|
|
1261
1293
|
}
|
|
1262
1294
|
};
|
|
1295
|
+
__name(DisTubeVoiceManager, "DisTubeVoiceManager");
|
|
1263
1296
|
|
|
1264
1297
|
// src/core/DisTubeHandler.ts
|
|
1265
1298
|
import ytdl from "@distube/ytdl-core";
|
|
@@ -1495,6 +1528,7 @@ var DisTubeHandler = class extends DisTubeBase {
|
|
|
1495
1528
|
}
|
|
1496
1529
|
}
|
|
1497
1530
|
};
|
|
1531
|
+
__name(DisTubeHandler, "DisTubeHandler");
|
|
1498
1532
|
|
|
1499
1533
|
// src/struct/Queue.ts
|
|
1500
1534
|
var _filters;
|
|
@@ -1516,12 +1550,8 @@ var Queue = class extends DisTubeBase {
|
|
|
1516
1550
|
__publicField(this, "beginTime");
|
|
1517
1551
|
__publicField(this, "textChannel");
|
|
1518
1552
|
__publicField(this, "_emptyTimeout");
|
|
1519
|
-
__publicField(this, "clientMember");
|
|
1520
1553
|
__publicField(this, "_taskQueue");
|
|
1521
1554
|
__publicField(this, "_listeners");
|
|
1522
|
-
this.clientMember = voice.channel.guild?.me ?? (() => {
|
|
1523
|
-
throw new DisTubeError("INVALID_TYPE", "GuildMember", null, "<VoiceChannel>.guild.me");
|
|
1524
|
-
})();
|
|
1525
1555
|
this.voice = voice;
|
|
1526
1556
|
this.id = voice.id;
|
|
1527
1557
|
this.volume = 50;
|
|
@@ -1541,6 +1571,9 @@ var Queue = class extends DisTubeBase {
|
|
|
1541
1571
|
this._taskQueue = new TaskQueue();
|
|
1542
1572
|
this._listeners = void 0;
|
|
1543
1573
|
}
|
|
1574
|
+
get clientMember() {
|
|
1575
|
+
return getClientMember(this.voice.channel.guild);
|
|
1576
|
+
}
|
|
1544
1577
|
get filters() {
|
|
1545
1578
|
return __privateGet(this, _filters);
|
|
1546
1579
|
}
|
|
@@ -1557,7 +1590,7 @@ var Queue = class extends DisTubeBase {
|
|
|
1557
1590
|
return formatDuration(this.currentTime);
|
|
1558
1591
|
}
|
|
1559
1592
|
get voiceChannel() {
|
|
1560
|
-
return this.clientMember
|
|
1593
|
+
return this.clientMember?.voice?.channel ?? null;
|
|
1561
1594
|
}
|
|
1562
1595
|
get volume() {
|
|
1563
1596
|
return this.voice.volume;
|
|
@@ -1755,6 +1788,7 @@ var Queue = class extends DisTubeBase {
|
|
|
1755
1788
|
return this.autoplay;
|
|
1756
1789
|
}
|
|
1757
1790
|
};
|
|
1791
|
+
__name(Queue, "Queue");
|
|
1758
1792
|
_filters = new WeakMap();
|
|
1759
1793
|
|
|
1760
1794
|
// src/struct/Plugin.ts
|
|
@@ -1796,6 +1830,7 @@ var Plugin = class {
|
|
|
1796
1830
|
return [];
|
|
1797
1831
|
}
|
|
1798
1832
|
};
|
|
1833
|
+
__name(Plugin, "Plugin");
|
|
1799
1834
|
|
|
1800
1835
|
// src/struct/CustomPlugin.ts
|
|
1801
1836
|
var CustomPlugin = class extends Plugin {
|
|
@@ -1804,6 +1839,7 @@ var CustomPlugin = class extends Plugin {
|
|
|
1804
1839
|
__publicField(this, "type", "custom" /* CUSTOM */);
|
|
1805
1840
|
}
|
|
1806
1841
|
};
|
|
1842
|
+
__name(CustomPlugin, "CustomPlugin");
|
|
1807
1843
|
|
|
1808
1844
|
// src/struct/ExtractorPlugin.ts
|
|
1809
1845
|
var ExtractorPlugin = class extends Plugin {
|
|
@@ -1812,6 +1848,7 @@ var ExtractorPlugin = class extends Plugin {
|
|
|
1812
1848
|
__publicField(this, "type", "extractor" /* EXTRACTOR */);
|
|
1813
1849
|
}
|
|
1814
1850
|
};
|
|
1851
|
+
__name(ExtractorPlugin, "ExtractorPlugin");
|
|
1815
1852
|
|
|
1816
1853
|
// src/util.ts
|
|
1817
1854
|
import { URL } from "url";
|
|
@@ -1829,6 +1866,7 @@ function formatDuration(sec) {
|
|
|
1829
1866
|
return `${formatInt(minutes)}:${formatInt(seconds)}`;
|
|
1830
1867
|
return `00:${formatInt(seconds)}`;
|
|
1831
1868
|
}
|
|
1869
|
+
__name(formatDuration, "formatDuration");
|
|
1832
1870
|
function toSecond(input) {
|
|
1833
1871
|
if (!input)
|
|
1834
1872
|
return 0;
|
|
@@ -1847,11 +1885,13 @@ function toSecond(input) {
|
|
|
1847
1885
|
return Number(input.replace(/[^\d.]+/g, "")) || 0;
|
|
1848
1886
|
}
|
|
1849
1887
|
}
|
|
1888
|
+
__name(toSecond, "toSecond");
|
|
1850
1889
|
function parseNumber(input) {
|
|
1851
1890
|
if (typeof input === "string")
|
|
1852
1891
|
return Number(input.replace(/[^\d.]+/g, "")) || 0;
|
|
1853
1892
|
return Number(input) || 0;
|
|
1854
1893
|
}
|
|
1894
|
+
__name(parseNumber, "parseNumber");
|
|
1855
1895
|
function isURL(input) {
|
|
1856
1896
|
if (typeof input !== "string" || input.includes(" "))
|
|
1857
1897
|
return false;
|
|
@@ -1864,18 +1904,25 @@ function isURL(input) {
|
|
|
1864
1904
|
}
|
|
1865
1905
|
return true;
|
|
1866
1906
|
}
|
|
1907
|
+
__name(isURL, "isURL");
|
|
1867
1908
|
function checkIntents(options) {
|
|
1868
1909
|
const intents = new IntentsBitField(options.intents);
|
|
1869
1910
|
if (!intents.has(GatewayIntentBits.GuildVoiceStates))
|
|
1870
1911
|
throw new DisTubeError("MISSING_INTENTS", "GuildVoiceStates");
|
|
1871
1912
|
}
|
|
1913
|
+
__name(checkIntents, "checkIntents");
|
|
1872
1914
|
function isVoiceChannelEmpty(voiceState) {
|
|
1873
|
-
const
|
|
1915
|
+
const guild = voiceState.guild;
|
|
1916
|
+
const clientId = voiceState.client.user?.id;
|
|
1917
|
+
if (!guild || !clientId)
|
|
1918
|
+
return false;
|
|
1919
|
+
const voiceChannel = guild.members.resolve(clientId)?.voice?.channel;
|
|
1874
1920
|
if (!voiceChannel)
|
|
1875
1921
|
return false;
|
|
1876
1922
|
const members = voiceChannel.members.filter((m) => !m.user.bot);
|
|
1877
1923
|
return !members.size;
|
|
1878
1924
|
}
|
|
1925
|
+
__name(isVoiceChannelEmpty, "isVoiceChannelEmpty");
|
|
1879
1926
|
function isSnowflake(id) {
|
|
1880
1927
|
try {
|
|
1881
1928
|
return SnowflakeUtil.deconstruct(id).timestamp > SnowflakeUtil.epoch;
|
|
@@ -1883,21 +1930,27 @@ function isSnowflake(id) {
|
|
|
1883
1930
|
return false;
|
|
1884
1931
|
}
|
|
1885
1932
|
}
|
|
1933
|
+
__name(isSnowflake, "isSnowflake");
|
|
1886
1934
|
function isMemberInstance(member) {
|
|
1887
1935
|
return !!member && isSnowflake(member.id) && isSnowflake(member.guild?.id) && isSnowflake(member.user?.id) && member.id === member.user.id;
|
|
1888
1936
|
}
|
|
1937
|
+
__name(isMemberInstance, "isMemberInstance");
|
|
1889
1938
|
function isTextChannelInstance(channel) {
|
|
1890
|
-
return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && Constants.TextBasedChannelTypes.includes(channel.type);
|
|
1939
|
+
return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && Constants.TextBasedChannelTypes.includes(channel.type) && typeof channel.nsfw === "boolean";
|
|
1891
1940
|
}
|
|
1941
|
+
__name(isTextChannelInstance, "isTextChannelInstance");
|
|
1892
1942
|
function isMessageInstance(message) {
|
|
1893
1943
|
return !!message && isSnowflake(message.id) && isSnowflake(message.guildId) && isMemberInstance(message.member) && isTextChannelInstance(message.channel) && Constants.NonSystemMessageTypes.includes(message.type) && message.member.id === message.author?.id;
|
|
1894
1944
|
}
|
|
1945
|
+
__name(isMessageInstance, "isMessageInstance");
|
|
1895
1946
|
function isSupportedVoiceChannel(channel) {
|
|
1896
1947
|
return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && Constants.VoiceBasedChannelTypes.includes(channel.type);
|
|
1897
1948
|
}
|
|
1949
|
+
__name(isSupportedVoiceChannel, "isSupportedVoiceChannel");
|
|
1898
1950
|
function isGuildInstance(guild) {
|
|
1899
1951
|
return !!guild && isSnowflake(guild.id) && isSnowflake(guild.ownerId) && typeof guild.name === "string";
|
|
1900
1952
|
}
|
|
1953
|
+
__name(isGuildInstance, "isGuildInstance");
|
|
1901
1954
|
function resolveGuildId(resolvable) {
|
|
1902
1955
|
let guildId;
|
|
1903
1956
|
if (typeof resolvable === "string") {
|
|
@@ -1915,9 +1968,11 @@ function resolveGuildId(resolvable) {
|
|
|
1915
1968
|
throw new DisTubeError("INVALID_TYPE", "GuildIdResolvable", resolvable);
|
|
1916
1969
|
return guildId;
|
|
1917
1970
|
}
|
|
1971
|
+
__name(resolveGuildId, "resolveGuildId");
|
|
1918
1972
|
function isClientInstance(client) {
|
|
1919
1973
|
return !!client && typeof client.login === "function";
|
|
1920
1974
|
}
|
|
1975
|
+
__name(isClientInstance, "isClientInstance");
|
|
1921
1976
|
function checkInvalidKey(target, source, sourceName) {
|
|
1922
1977
|
if (!isObject(target))
|
|
1923
1978
|
throw new DisTubeError("INVALID_TYPE", "object", target, sourceName);
|
|
@@ -1926,6 +1981,7 @@ function checkInvalidKey(target, source, sourceName) {
|
|
|
1926
1981
|
if (invalidKey)
|
|
1927
1982
|
throw new DisTubeError("INVALID_KEY", sourceName, invalidKey);
|
|
1928
1983
|
}
|
|
1984
|
+
__name(checkInvalidKey, "checkInvalidKey");
|
|
1929
1985
|
async function waitEvent(target, status, maxTime) {
|
|
1930
1986
|
let cleanup = /* @__PURE__ */ __name(() => {
|
|
1931
1987
|
}, "cleanup");
|
|
@@ -1947,17 +2003,31 @@ async function waitEvent(target, status, maxTime) {
|
|
|
1947
2003
|
cleanup();
|
|
1948
2004
|
}
|
|
1949
2005
|
}
|
|
2006
|
+
__name(waitEvent, "waitEvent");
|
|
1950
2007
|
async function entersState(target, status, maxTime) {
|
|
1951
2008
|
if (target.state.status === status)
|
|
1952
2009
|
return target;
|
|
1953
2010
|
return waitEvent(target, status, maxTime);
|
|
1954
2011
|
}
|
|
2012
|
+
__name(entersState, "entersState");
|
|
1955
2013
|
function isObject(obj) {
|
|
1956
2014
|
return typeof obj === "object" && obj !== null && !Array.isArray(obj);
|
|
1957
2015
|
}
|
|
2016
|
+
__name(isObject, "isObject");
|
|
1958
2017
|
function isRecord(obj) {
|
|
1959
2018
|
return isObject(obj);
|
|
1960
2019
|
}
|
|
2020
|
+
__name(isRecord, "isRecord");
|
|
2021
|
+
function getClientMember(guild) {
|
|
2022
|
+
const clientUser = guild.client.user;
|
|
2023
|
+
if (!clientUser)
|
|
2024
|
+
return void 0;
|
|
2025
|
+
const clientMember = guild.members.resolve(clientUser);
|
|
2026
|
+
if (!clientMember)
|
|
2027
|
+
return void 0;
|
|
2028
|
+
return clientMember;
|
|
2029
|
+
}
|
|
2030
|
+
__name(getClientMember, "getClientMember");
|
|
1961
2031
|
|
|
1962
2032
|
// src/plugin/http.ts
|
|
1963
2033
|
import http from "http";
|
|
@@ -1969,6 +2039,7 @@ var HTTPPlugin = class extends ExtractorPlugin {
|
|
|
1969
2039
|
return resolveHttpSong(url, { ...options, source: "http" });
|
|
1970
2040
|
}
|
|
1971
2041
|
};
|
|
2042
|
+
__name(HTTPPlugin, "HTTPPlugin");
|
|
1972
2043
|
|
|
1973
2044
|
// src/plugin/https.ts
|
|
1974
2045
|
import https from "https";
|
|
@@ -2003,6 +2074,7 @@ var HTTPSPlugin = class extends ExtractorPlugin {
|
|
|
2003
2074
|
return resolveHttpSong(url, { ...options, source: "https" });
|
|
2004
2075
|
}
|
|
2005
2076
|
};
|
|
2077
|
+
__name(HTTPSPlugin, "HTTPSPlugin");
|
|
2006
2078
|
|
|
2007
2079
|
// src/DisTube.ts
|
|
2008
2080
|
import ytsr from "@distube/ytsr";
|
|
@@ -2047,7 +2119,7 @@ var DisTube = class extends TypedEmitter2 {
|
|
|
2047
2119
|
if (!isObject(options))
|
|
2048
2120
|
throw new DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
2049
2121
|
const { textChannel, member, skip, message, metadata } = {
|
|
2050
|
-
member: voiceChannel.guild
|
|
2122
|
+
member: getClientMember(voiceChannel.guild),
|
|
2051
2123
|
textChannel: options?.message?.channel,
|
|
2052
2124
|
skip: false,
|
|
2053
2125
|
...options
|
|
@@ -2244,6 +2316,7 @@ ${e.message}`;
|
|
|
2244
2316
|
}
|
|
2245
2317
|
}
|
|
2246
2318
|
};
|
|
2319
|
+
__name(DisTube, "DisTube");
|
|
2247
2320
|
export {
|
|
2248
2321
|
BaseManager,
|
|
2249
2322
|
CustomPlugin,
|
|
@@ -2269,6 +2342,7 @@ export {
|
|
|
2269
2342
|
SearchResult,
|
|
2270
2343
|
SearchResultType,
|
|
2271
2344
|
Song,
|
|
2345
|
+
StreamType,
|
|
2272
2346
|
TaskQueue,
|
|
2273
2347
|
checkIntents,
|
|
2274
2348
|
checkInvalidKey,
|
|
@@ -2278,6 +2352,7 @@ export {
|
|
|
2278
2352
|
defaultOptions,
|
|
2279
2353
|
entersState,
|
|
2280
2354
|
formatDuration,
|
|
2355
|
+
getClientMember,
|
|
2281
2356
|
getResponseHeaders,
|
|
2282
2357
|
isClientInstance,
|
|
2283
2358
|
isGuildInstance,
|