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.d.ts
CHANGED
|
@@ -56,6 +56,7 @@ interface DisTubeOptions {
|
|
|
56
56
|
emitAddListWhenCreatingQueue?: boolean;
|
|
57
57
|
joinNewVoiceChannel?: boolean;
|
|
58
58
|
streamType?: StreamType;
|
|
59
|
+
directLink?: boolean;
|
|
59
60
|
}
|
|
60
61
|
declare type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
|
|
61
62
|
interface OtherSongInfo {
|
|
@@ -159,6 +160,7 @@ declare const defaultOptions: {
|
|
|
159
160
|
emitAddListWhenCreatingQueue: boolean;
|
|
160
161
|
joinNewVoiceChannel: boolean;
|
|
161
162
|
streamType: StreamType;
|
|
163
|
+
directLink: boolean;
|
|
162
164
|
};
|
|
163
165
|
|
|
164
166
|
declare const ERROR_MESSAGES: {
|
|
@@ -431,6 +433,7 @@ declare class Options {
|
|
|
431
433
|
emitAddListWhenCreatingQueue: boolean;
|
|
432
434
|
joinNewVoiceChannel: boolean;
|
|
433
435
|
streamType: StreamType;
|
|
436
|
+
directLink: boolean;
|
|
434
437
|
constructor(options: DisTubeOptions);
|
|
435
438
|
}
|
|
436
439
|
|
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.
|
|
59
|
+
version: "4.0.2",
|
|
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",
|
|
@@ -80,7 +80,7 @@ var require_package = __commonJS({
|
|
|
80
80
|
prettier: 'prettier --write "**/*.{ts,json,yml,yaml,md}"',
|
|
81
81
|
build: "tsup",
|
|
82
82
|
"build:check": "tsc --noEmit",
|
|
83
|
-
update: "ncu -u
|
|
83
|
+
update: "ncu -u && yarn up '**' -R",
|
|
84
84
|
postinstall: "husky install",
|
|
85
85
|
prepublishOnly: "yarn lint && yarn test",
|
|
86
86
|
prepack: "yarn build && pinst --disable",
|
|
@@ -296,7 +296,8 @@ var defaultOptions = {
|
|
|
296
296
|
emitAddSongWhenCreatingQueue: true,
|
|
297
297
|
emitAddListWhenCreatingQueue: true,
|
|
298
298
|
joinNewVoiceChannel: true,
|
|
299
|
-
streamType: 0 /* OPUS
|
|
299
|
+
streamType: 0 /* OPUS */,
|
|
300
|
+
directLink: true
|
|
300
301
|
};
|
|
301
302
|
|
|
302
303
|
// src/struct/DisTubeError.ts
|
|
@@ -1472,6 +1473,7 @@ var Options = class {
|
|
|
1472
1473
|
__publicField(this, "emitAddListWhenCreatingQueue");
|
|
1473
1474
|
__publicField(this, "joinNewVoiceChannel");
|
|
1474
1475
|
__publicField(this, "streamType");
|
|
1476
|
+
__publicField(this, "directLink");
|
|
1475
1477
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
1476
1478
|
throw new DisTubeError("INVALID_TYPE", "object", options, "DisTubeOptions");
|
|
1477
1479
|
}
|
|
@@ -1494,6 +1496,7 @@ var Options = class {
|
|
|
1494
1496
|
this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;
|
|
1495
1497
|
this.joinNewVoiceChannel = opts.joinNewVoiceChannel;
|
|
1496
1498
|
this.streamType = opts.streamType;
|
|
1499
|
+
this.directLink = opts.directLink;
|
|
1497
1500
|
checkInvalidKey(opts, this, "DisTubeOptions");
|
|
1498
1501
|
__privateMethod(this, _validateOptions, validateOptions_fn).call(this);
|
|
1499
1502
|
}
|
|
@@ -1555,6 +1558,9 @@ validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
|
|
|
1555
1558
|
if (typeof options.streamType !== "number" || isNaN(options.streamType) || !StreamType[options.streamType]) {
|
|
1556
1559
|
throw new DisTubeError("INVALID_TYPE", "StreamType", options.streamType, "DisTubeOptions.streamType");
|
|
1557
1560
|
}
|
|
1561
|
+
if (typeof options.directLink !== "boolean") {
|
|
1562
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.directLink, "DisTubeOptions.directLink");
|
|
1563
|
+
}
|
|
1558
1564
|
}, "#validateOptions");
|
|
1559
1565
|
|
|
1560
1566
|
// src/core/DisTubeStream.ts
|
|
@@ -2094,10 +2100,13 @@ __name(isRecord, "isRecord");
|
|
|
2094
2100
|
var import_undici = require("undici");
|
|
2095
2101
|
var DirectLinkPlugin = class extends ExtractorPlugin {
|
|
2096
2102
|
async validate(url) {
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2103
|
+
try {
|
|
2104
|
+
const headers = await (0, import_undici.request)(url, { method: "HEAD" }).then((res) => res.headers);
|
|
2105
|
+
const type = headers["content-type"];
|
|
2106
|
+
if (type?.startsWith("audio"))
|
|
2107
|
+
return true;
|
|
2108
|
+
} catch {
|
|
2109
|
+
}
|
|
2101
2110
|
return false;
|
|
2102
2111
|
}
|
|
2103
2112
|
async resolve(url, options = {}) {
|
|
@@ -2135,7 +2144,8 @@ var DisTube = class extends import_tiny_typed_emitter2.TypedEmitter {
|
|
|
2135
2144
|
this.handler = new DisTubeHandler(this);
|
|
2136
2145
|
this.queues = new QueueManager(this);
|
|
2137
2146
|
this.filters = { ...defaultFilters, ...this.options.customFilters };
|
|
2138
|
-
this.options.
|
|
2147
|
+
if (this.options.directLink)
|
|
2148
|
+
this.options.plugins.push(new DirectLinkPlugin());
|
|
2139
2149
|
this.options.plugins.map((p) => p.init(this));
|
|
2140
2150
|
this.extractorPlugins = this.options.plugins.filter((p) => p.type === "extractor");
|
|
2141
2151
|
this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
|