distube 4.0.0-dev.6 → 4.0.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.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.6",
47
+ version: "4.0.0",
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",
@@ -110,10 +110,11 @@ var require_package = __commonJS({
110
110
  dependencies: {
111
111
  "@distube/ytdl-core": "^4.11.3",
112
112
  "@distube/ytpl": "^1.1.1",
113
- "@distube/ytsr": "^1.1.7",
113
+ "@distube/ytsr": "^1.1.8",
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.4.0"
116
+ tslib: "^2.4.0",
117
+ undici: "^5.8.0"
117
118
  },
118
119
  devDependencies: {
119
120
  "@babel/core": "^7.18.6",
@@ -123,15 +124,15 @@ var require_package = __commonJS({
123
124
  "@babel/preset-typescript": "^7.18.6",
124
125
  "@commitlint/cli": "^17.0.3",
125
126
  "@commitlint/config-conventional": "^17.0.3",
126
- "@discordjs/voice": "dev",
127
+ "@discordjs/voice": "latest",
127
128
  "@distube/docgen": "distubejs/docgen",
128
- "@types/jest": "^28.1.5",
129
- "@types/node": "^18.0.4",
129
+ "@types/jest": "^28.1.6",
130
+ "@types/node": "^18.0.6",
130
131
  "@typescript-eslint/eslint-plugin": "^5.30.6",
131
132
  "@typescript-eslint/parser": "^5.30.6",
132
133
  "babel-jest": "^28.1.3",
133
- "discord.js": "dev",
134
- eslint: "^8.19.0",
134
+ "discord.js": "latest",
135
+ eslint: "^8.20.0",
135
136
  "eslint-config-distube": "^1.6.4",
136
137
  "eslint-config-prettier": "^8.5.0",
137
138
  "eslint-plugin-deprecation": "^1.3.2",
@@ -140,7 +141,7 @@ var require_package = __commonJS({
140
141
  jest: "^28.1.3",
141
142
  "jsdoc-babel": "^0.5.0",
142
143
  "nano-staged": "^0.8.0",
143
- "npm-check-updates": "^15.3.0",
144
+ "npm-check-updates": "^15.3.4",
144
145
  pinst: "^3.0.0",
145
146
  prettier: "^2.7.1",
146
147
  tsup: "^6.1.3",
@@ -149,7 +150,7 @@ var require_package = __commonJS({
149
150
  peerDependencies: {
150
151
  "@discordjs/opus": "*",
151
152
  "@discordjs/voice": "*",
152
- "discord.js": "14||^14.0.0-dev"
153
+ "discord.js": "14"
153
154
  },
154
155
  peerDependenciesMeta: {
155
156
  "@discordjs/opus": {
@@ -168,8 +169,7 @@ var require_package = __commonJS({
168
169
  engines: {
169
170
  node: ">=16.9.0"
170
171
  },
171
- packageManager: "yarn@3.2.0",
172
- stableVersion: "4.0.0-dev"
172
+ packageManager: "yarn@3.2.0"
173
173
  };
174
174
  }
175
175
  });
@@ -1132,6 +1132,8 @@ Name: ${song.name}`;
1132
1132
  }
1133
1133
  this.emitError(error, queue.textChannel);
1134
1134
  if (queue.songs.length > 0) {
1135
+ queue._next = queue._prev = false;
1136
+ queue.beginTime = 0;
1135
1137
  this.playSong(queue).then((e) => {
1136
1138
  if (!e)
1137
1139
  this.emit("playSong", queue, queue.songs[0]);
@@ -1215,8 +1217,11 @@ var DisTubeHandler = class extends DisTubeBase {
1215
1217
  return new Song(song, options);
1216
1218
  if (song instanceof SearchResultPlaylist)
1217
1219
  return this.resolvePlaylist(song.url, options);
1218
- if (isObject(song))
1220
+ if (isObject(song)) {
1221
+ if (!("url" in song) && !("id" in song))
1222
+ throw new DisTubeError("CANNOT_RESOLVE_SONG", song);
1219
1223
  return new Song(song, options);
1224
+ }
1220
1225
  if (ytpl.validateID(song))
1221
1226
  return this.resolvePlaylist(song, options);
1222
1227
  if (ytdl.validateURL(song))
@@ -1971,7 +1976,7 @@ function isMemberInstance(member) {
1971
1976
  }
1972
1977
  __name(isMemberInstance, "isMemberInstance");
1973
1978
  function isTextChannelInstance(channel) {
1974
- return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && Constants.TextBasedChannelTypes.includes(channel.type) && typeof channel.nsfw === "boolean" && typeof channel.messages?.cache === "object" && typeof channel.send === "function";
1979
+ return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && Constants.TextBasedChannelTypes.includes(channel.type) && typeof channel.nsfw === "boolean" && "messages" in channel && typeof channel.send === "function";
1975
1980
  }
1976
1981
  __name(isTextChannelInstance, "isTextChannelInstance");
1977
1982
  function isMessageInstance(message) {
@@ -2026,52 +2031,25 @@ function isRecord(obj) {
2026
2031
  }
2027
2032
  __name(isRecord, "isRecord");
2028
2033
 
2029
- // src/plugin/http.ts
2030
- import http from "http";
2031
- var HTTPPlugin = class extends ExtractorPlugin {
2034
+ // src/plugin/DirectLink.ts
2035
+ import { request } from "undici";
2036
+ var DirectLinkPlugin = class extends ExtractorPlugin {
2032
2037
  async validate(url) {
2033
- return validateAudioURL(http, "http:", url);
2034
- }
2035
- async resolve(url, options = {}) {
2036
- return resolveHttpSong(url, { ...options, source: "http" });
2037
- }
2038
- };
2039
- __name(HTTPPlugin, "HTTPPlugin");
2040
-
2041
- // src/plugin/https.ts
2042
- import https from "https";
2043
- import { URL as URL2 } from "url";
2044
- var getResponseHeaders = /* @__PURE__ */ __name(async (httpModule, url) => new Promise((resolve, reject) => {
2045
- httpModule.get(url).on("response", (res) => {
2046
- resolve(res.headers);
2047
- }).on("error", reject);
2048
- }), "getResponseHeaders");
2049
- var validateAudioURL = /* @__PURE__ */ __name(async (httpModule, protocol, url) => {
2050
- if (new URL2(url).protocol.toLowerCase() !== protocol) {
2038
+ const headers = await request(url, { method: "HEAD" }).then((res) => res.headers);
2039
+ const type = headers["content-type"];
2040
+ if (type?.startsWith("audio"))
2041
+ return true;
2051
2042
  return false;
2052
2043
  }
2053
- const headers = await getResponseHeaders(httpModule, url), type = headers["content-type"];
2054
- if (type?.startsWith("audio")) {
2055
- return true;
2056
- }
2057
- return false;
2058
- }, "validateAudioURL");
2059
- var resolveHttpSong = /* @__PURE__ */ __name(async (url, options) => {
2060
- url = url.replace(/\/+$/, "");
2061
- return new Song({
2062
- name: url.substring(url.lastIndexOf("/") + 1).replace(/((\?|#).*)?$/, "") || url,
2063
- url
2064
- }, options);
2065
- }, "resolveHttpSong");
2066
- var HTTPSPlugin = class extends ExtractorPlugin {
2067
- async validate(url) {
2068
- return validateAudioURL(https, "https:", url);
2069
- }
2070
2044
  async resolve(url, options = {}) {
2071
- return resolveHttpSong(url, { ...options, source: "https" });
2045
+ url = url.replace(/\/+$/, "");
2046
+ return new Song({
2047
+ name: url.substring(url.lastIndexOf("/") + 1).replace(/((\?|#).*)?$/, "") || url,
2048
+ url
2049
+ }, options);
2072
2050
  }
2073
2051
  };
2074
- __name(HTTPSPlugin, "HTTPSPlugin");
2052
+ __name(DirectLinkPlugin, "DirectLinkPlugin");
2075
2053
 
2076
2054
  // src/DisTube.ts
2077
2055
  import ytsr from "@distube/ytsr";
@@ -2098,7 +2076,7 @@ var DisTube = class extends TypedEmitter2 {
2098
2076
  this.handler = new DisTubeHandler(this);
2099
2077
  this.queues = new QueueManager(this);
2100
2078
  this.filters = { ...defaultFilters, ...this.options.customFilters };
2101
- this.options.plugins.push(new HTTPPlugin(), new HTTPSPlugin());
2079
+ this.options.plugins.push(new DirectLinkPlugin());
2102
2080
  this.options.plugins.map((p) => p.init(this));
2103
2081
  this.extractorPlugins = this.options.plugins.filter((p) => p.type === "extractor");
2104
2082
  this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
@@ -2321,6 +2299,7 @@ __name(DisTube, "DisTube");
2321
2299
  export {
2322
2300
  BaseManager,
2323
2301
  CustomPlugin,
2302
+ DirectLinkPlugin,
2324
2303
  DisTube,
2325
2304
  DisTubeBase,
2326
2305
  DisTubeError,
@@ -2331,8 +2310,6 @@ export {
2331
2310
  ExtractorPlugin,
2332
2311
  FilterManager,
2333
2312
  GuildIdManager,
2334
- HTTPPlugin,
2335
- HTTPSPlugin,
2336
2313
  Options,
2337
2314
  Playlist,
2338
2315
  Plugin,
@@ -2353,7 +2330,6 @@ export {
2353
2330
  defaultFilters,
2354
2331
  defaultOptions,
2355
2332
  formatDuration,
2356
- getResponseHeaders,
2357
2333
  isClientInstance,
2358
2334
  isGuildInstance,
2359
2335
  isMemberInstance,
@@ -2367,9 +2343,7 @@ export {
2367
2343
  isVoiceChannelEmpty,
2368
2344
  parseNumber,
2369
2345
  resolveGuildId,
2370
- resolveHttpSong,
2371
2346
  toSecond,
2372
- validateAudioURL,
2373
2347
  version
2374
2348
  };
2375
2349
  //# sourceMappingURL=index.mjs.map