distube 4.0.1 → 4.0.2
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 +3 -0
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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.
|
|
47
|
+
version: "4.0.2",
|
|
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",
|
|
@@ -68,7 +68,7 @@ var require_package = __commonJS({
|
|
|
68
68
|
prettier: 'prettier --write "**/*.{ts,json,yml,yaml,md}"',
|
|
69
69
|
build: "tsup",
|
|
70
70
|
"build:check": "tsc --noEmit",
|
|
71
|
-
update: "ncu -u
|
|
71
|
+
update: "ncu -u && yarn up '**' -R",
|
|
72
72
|
postinstall: "husky install",
|
|
73
73
|
prepublishOnly: "yarn lint && yarn test",
|
|
74
74
|
prepack: "yarn build && pinst --disable",
|
|
@@ -230,7 +230,8 @@ var defaultOptions = {
|
|
|
230
230
|
emitAddSongWhenCreatingQueue: true,
|
|
231
231
|
emitAddListWhenCreatingQueue: true,
|
|
232
232
|
joinNewVoiceChannel: true,
|
|
233
|
-
streamType: 0 /* OPUS
|
|
233
|
+
streamType: 0 /* OPUS */,
|
|
234
|
+
directLink: true
|
|
234
235
|
};
|
|
235
236
|
|
|
236
237
|
// src/struct/DisTubeError.ts
|
|
@@ -1414,6 +1415,7 @@ var Options = class {
|
|
|
1414
1415
|
__publicField(this, "emitAddListWhenCreatingQueue");
|
|
1415
1416
|
__publicField(this, "joinNewVoiceChannel");
|
|
1416
1417
|
__publicField(this, "streamType");
|
|
1418
|
+
__publicField(this, "directLink");
|
|
1417
1419
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
1418
1420
|
throw new DisTubeError("INVALID_TYPE", "object", options, "DisTubeOptions");
|
|
1419
1421
|
}
|
|
@@ -1436,6 +1438,7 @@ var Options = class {
|
|
|
1436
1438
|
this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;
|
|
1437
1439
|
this.joinNewVoiceChannel = opts.joinNewVoiceChannel;
|
|
1438
1440
|
this.streamType = opts.streamType;
|
|
1441
|
+
this.directLink = opts.directLink;
|
|
1439
1442
|
checkInvalidKey(opts, this, "DisTubeOptions");
|
|
1440
1443
|
__privateMethod(this, _validateOptions, validateOptions_fn).call(this);
|
|
1441
1444
|
}
|
|
@@ -1497,6 +1500,9 @@ validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
|
|
|
1497
1500
|
if (typeof options.streamType !== "number" || isNaN(options.streamType) || !StreamType[options.streamType]) {
|
|
1498
1501
|
throw new DisTubeError("INVALID_TYPE", "StreamType", options.streamType, "DisTubeOptions.streamType");
|
|
1499
1502
|
}
|
|
1503
|
+
if (typeof options.directLink !== "boolean") {
|
|
1504
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.directLink, "DisTubeOptions.directLink");
|
|
1505
|
+
}
|
|
1500
1506
|
}, "#validateOptions");
|
|
1501
1507
|
|
|
1502
1508
|
// src/core/DisTubeStream.ts
|
|
@@ -2036,10 +2042,13 @@ __name(isRecord, "isRecord");
|
|
|
2036
2042
|
import { request } from "undici";
|
|
2037
2043
|
var DirectLinkPlugin = class extends ExtractorPlugin {
|
|
2038
2044
|
async validate(url) {
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2045
|
+
try {
|
|
2046
|
+
const headers = await request(url, { method: "HEAD" }).then((res) => res.headers);
|
|
2047
|
+
const type = headers["content-type"];
|
|
2048
|
+
if (type?.startsWith("audio"))
|
|
2049
|
+
return true;
|
|
2050
|
+
} catch {
|
|
2051
|
+
}
|
|
2043
2052
|
return false;
|
|
2044
2053
|
}
|
|
2045
2054
|
async resolve(url, options = {}) {
|
|
@@ -2077,7 +2086,8 @@ var DisTube = class extends TypedEmitter2 {
|
|
|
2077
2086
|
this.handler = new DisTubeHandler(this);
|
|
2078
2087
|
this.queues = new QueueManager(this);
|
|
2079
2088
|
this.filters = { ...defaultFilters, ...this.options.customFilters };
|
|
2080
|
-
this.options.
|
|
2089
|
+
if (this.options.directLink)
|
|
2090
|
+
this.options.plugins.push(new DirectLinkPlugin());
|
|
2081
2091
|
this.options.plugins.map((p) => p.init(this));
|
|
2082
2092
|
this.extractorPlugins = this.options.plugins.filter((p) => p.type === "extractor");
|
|
2083
2093
|
this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
|