distube 2.8.18 → 3.0.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.
Files changed (139) hide show
  1. package/README.md +32 -98
  2. package/dist/DisTube.d.ts +522 -0
  3. package/dist/DisTube.d.ts.map +1 -0
  4. package/dist/DisTube.js +794 -0
  5. package/dist/DisTube.js.map +1 -0
  6. package/dist/constant.d.ts +130 -0
  7. package/dist/constant.d.ts.map +1 -0
  8. package/dist/constant.js +150 -0
  9. package/dist/constant.js.map +1 -0
  10. package/dist/core/DisTubeBase.d.ts +55 -0
  11. package/dist/core/DisTubeBase.d.ts.map +1 -0
  12. package/dist/core/DisTubeBase.js +76 -0
  13. package/dist/core/DisTubeBase.js.map +1 -0
  14. package/dist/core/DisTubeHandler.d.ts +84 -0
  15. package/dist/core/DisTubeHandler.d.ts.map +1 -0
  16. package/dist/core/DisTubeHandler.js +311 -0
  17. package/dist/core/DisTubeHandler.js.map +1 -0
  18. package/dist/core/DisTubeOptions.d.ts +26 -0
  19. package/dist/core/DisTubeOptions.d.ts.map +1 -0
  20. package/dist/core/DisTubeOptions.js +93 -0
  21. package/dist/core/DisTubeOptions.js.map +1 -0
  22. package/dist/core/DisTubeStream.d.ts +52 -0
  23. package/dist/core/DisTubeStream.d.ts.map +1 -0
  24. package/dist/core/DisTubeStream.js +109 -0
  25. package/dist/core/DisTubeStream.js.map +1 -0
  26. package/dist/core/index.d.ts +7 -0
  27. package/dist/core/index.d.ts.map +1 -0
  28. package/dist/core/index.js +19 -0
  29. package/dist/core/index.js.map +1 -0
  30. package/dist/core/manager/BaseManager.d.ts +18 -0
  31. package/dist/core/manager/BaseManager.d.ts.map +1 -0
  32. package/dist/core/manager/BaseManager.js +44 -0
  33. package/dist/core/manager/BaseManager.js.map +1 -0
  34. package/dist/core/manager/QueueManager.d.ts +60 -0
  35. package/dist/core/manager/QueueManager.d.ts.map +1 -0
  36. package/dist/core/manager/QueueManager.js +202 -0
  37. package/dist/core/manager/QueueManager.js.map +1 -0
  38. package/dist/core/manager/index.d.ts +3 -0
  39. package/dist/core/manager/index.d.ts.map +1 -0
  40. package/dist/core/manager/index.js +15 -0
  41. package/dist/core/manager/index.js.map +1 -0
  42. package/dist/core/voice/DJSAdapter.d.ts +4 -0
  43. package/dist/core/voice/DJSAdapter.d.ts.map +1 -0
  44. package/dist/core/voice/DJSAdapter.js +61 -0
  45. package/dist/core/voice/DJSAdapter.js.map +1 -0
  46. package/dist/core/voice/DisTubeVoice.d.ts +83 -0
  47. package/dist/core/voice/DisTubeVoice.d.ts.map +1 -0
  48. package/dist/core/voice/DisTubeVoice.js +236 -0
  49. package/dist/core/voice/DisTubeVoice.js.map +1 -0
  50. package/dist/core/voice/DisTubeVoiceManager.d.ts +41 -0
  51. package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -0
  52. package/dist/core/voice/DisTubeVoiceManager.js +67 -0
  53. package/dist/core/voice/DisTubeVoiceManager.js.map +1 -0
  54. package/dist/core/voice/index.d.ts +4 -0
  55. package/dist/core/voice/index.d.ts.map +1 -0
  56. package/dist/core/voice/index.js +16 -0
  57. package/dist/core/voice/index.js.map +1 -0
  58. package/dist/index.d.ts +8 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +23 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/plugin/http.d.ts +8 -0
  63. package/dist/plugin/http.d.ts.map +1 -0
  64. package/dist/plugin/http.js +20 -0
  65. package/dist/plugin/http.js.map +1 -0
  66. package/dist/plugin/https.d.ts +14 -0
  67. package/dist/plugin/https.d.ts.map +1 -0
  68. package/dist/plugin/https.js +50 -0
  69. package/dist/plugin/https.js.map +1 -0
  70. package/dist/plugin/index.d.ts +4 -0
  71. package/dist/plugin/index.d.ts.map +1 -0
  72. package/dist/plugin/index.js +16 -0
  73. package/dist/plugin/index.js.map +1 -0
  74. package/dist/plugin/youtube-dl.d.ts +11 -0
  75. package/dist/plugin/youtube-dl.d.ts.map +1 -0
  76. package/dist/plugin/youtube-dl.js +75 -0
  77. package/dist/plugin/youtube-dl.js.map +1 -0
  78. package/dist/struct/CustomPlugin.d.ts +27 -0
  79. package/dist/struct/CustomPlugin.d.ts.map +1 -0
  80. package/dist/struct/CustomPlugin.js +35 -0
  81. package/dist/struct/CustomPlugin.js.map +1 -0
  82. package/dist/struct/DisTubeError.d.ts +54 -0
  83. package/dist/struct/DisTubeError.d.ts.map +1 -0
  84. package/dist/struct/DisTubeError.js +72 -0
  85. package/dist/struct/DisTubeError.js.map +1 -0
  86. package/dist/struct/ExtractorPlugin.d.ts +29 -0
  87. package/dist/struct/ExtractorPlugin.d.ts.map +1 -0
  88. package/dist/struct/ExtractorPlugin.js +32 -0
  89. package/dist/struct/ExtractorPlugin.js.map +1 -0
  90. package/dist/struct/Playlist.d.ts +42 -0
  91. package/dist/struct/Playlist.d.ts.map +1 -0
  92. package/dist/struct/Playlist.js +104 -0
  93. package/dist/struct/Playlist.js.map +1 -0
  94. package/dist/struct/Plugin.d.ts +82 -0
  95. package/dist/struct/Plugin.d.ts.map +1 -0
  96. package/dist/struct/Plugin.js +108 -0
  97. package/dist/struct/Plugin.js.map +1 -0
  98. package/dist/struct/Queue.d.ts +217 -0
  99. package/dist/struct/Queue.d.ts.map +1 -0
  100. package/dist/struct/Queue.js +480 -0
  101. package/dist/struct/Queue.js.map +1 -0
  102. package/dist/struct/SearchResult.d.ts +28 -0
  103. package/dist/struct/SearchResult.d.ts.map +1 -0
  104. package/dist/struct/SearchResult.js +79 -0
  105. package/dist/struct/SearchResult.js.map +1 -0
  106. package/dist/struct/Song.d.ts +68 -0
  107. package/dist/struct/Song.d.ts.map +1 -0
  108. package/dist/struct/Song.js +229 -0
  109. package/dist/struct/Song.js.map +1 -0
  110. package/dist/struct/TaskQueue.d.ts +33 -0
  111. package/dist/struct/TaskQueue.d.ts.map +1 -0
  112. package/dist/struct/TaskQueue.js +58 -0
  113. package/dist/struct/TaskQueue.js.map +1 -0
  114. package/dist/struct/index.d.ts +10 -0
  115. package/dist/struct/index.d.ts.map +1 -0
  116. package/dist/struct/index.js +22 -0
  117. package/dist/struct/index.js.map +1 -0
  118. package/dist/tsconfig.tsbuildinfo +1 -0
  119. package/dist/type.d.ts +159 -0
  120. package/dist/type.d.ts.map +1 -0
  121. package/dist/type.js +3 -0
  122. package/dist/type.js.map +1 -0
  123. package/dist/util.d.ts +47 -0
  124. package/dist/util.d.ts.map +1 -0
  125. package/dist/util.js +205 -0
  126. package/dist/util.js.map +1 -0
  127. package/package.json +50 -24
  128. package/src/DisTube.js +0 -1121
  129. package/src/Playlist.js +0 -107
  130. package/src/Queue.js +0 -120
  131. package/src/SearchResult.js +0 -81
  132. package/src/Song.js +0 -135
  133. package/src/duration.js +0 -39
  134. package/typings/DisTube.d.ts +0 -635
  135. package/typings/Playlist.d.ts +0 -73
  136. package/typings/Queue.d.ts +0 -106
  137. package/typings/SearchResult.d.ts +0 -59
  138. package/typings/Song.d.ts +0 -104
  139. package/typings/duration.d.ts +0 -2
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.HTTPSPlugin = exports.resolveHttpSong = exports.validateAudioURL = exports.getResponseHeaders = void 0;
7
+ const https_1 = __importDefault(require("https"));
8
+ const ExtractorPlugin_1 = __importDefault(require("../struct/ExtractorPlugin"));
9
+ const url_1 = require("url");
10
+ const __1 = require("..");
11
+ const getResponseHeaders = async (httpModule, url) => new Promise((resolve, reject) => {
12
+ httpModule
13
+ .get(url)
14
+ .on("response", res => {
15
+ resolve(res.headers);
16
+ })
17
+ .on("error", reject);
18
+ });
19
+ exports.getResponseHeaders = getResponseHeaders;
20
+ const validateAudioURL = async (httpModule, protocol, url) => {
21
+ if (new url_1.URL(url).protocol.toLowerCase() !== protocol) {
22
+ return false;
23
+ }
24
+ const headers = await (0, exports.getResponseHeaders)(httpModule, url), type = headers["content-type"];
25
+ if (type === null || type === void 0 ? void 0 : type.startsWith("audio")) {
26
+ return true;
27
+ }
28
+ return false;
29
+ };
30
+ exports.validateAudioURL = validateAudioURL;
31
+ // eslint-disable-next-line @typescript-eslint/require-await
32
+ const resolveHttpSong = async (source, url, member) => {
33
+ url = url.replace(/\/+$/, "");
34
+ return new __1.Song({
35
+ name: url.substring(url.lastIndexOf("/") + 1).replace(/((\?|#).*)?$/, "") || url,
36
+ url,
37
+ }, member, source);
38
+ };
39
+ exports.resolveHttpSong = resolveHttpSong;
40
+ class HTTPSPlugin extends ExtractorPlugin_1.default {
41
+ async validate(url) {
42
+ return (0, exports.validateAudioURL)(https_1.default, "https:", url);
43
+ }
44
+ async resolve(url, member) {
45
+ return (0, exports.resolveHttpSong)("https", url, member);
46
+ }
47
+ }
48
+ exports.HTTPSPlugin = HTTPSPlugin;
49
+ exports.default = HTTPSPlugin;
50
+ //# sourceMappingURL=https.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"https.js","sourceRoot":"","sources":["../../src/plugin/https.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,gFAAwD;AACxD,6BAA0B;AAC1B,0BAA0B;AAInB,MAAM,kBAAkB,GAAG,KAAK,EACrC,UAAsC,EACtC,GAAW,EACwB,EAAE,CACrC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;IAC9B,UAAU;SACP,GAAG,CAAC,GAAG,CAAC;SACR,EAAE,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE;QACpB,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC,CAAC;SACD,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC;AAXQ,QAAA,kBAAkB,sBAW1B;AAEE,MAAM,gBAAgB,GAAG,KAAK,EAAE,UAAsC,EAAE,QAAgB,EAAE,GAAW,EAAE,EAAE;IAC9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\"../struct/ExtractorPlugin\";\nimport { URL } from \"url\";\nimport { Song } from \"..\";\nimport type http from \"http\";\nimport type { GuildMember } from \"discord.js\";\n\nexport const getResponseHeaders = async (\n httpModule: typeof http | typeof https,\n url: string,\n): Promise<http.IncomingHttpHeaders> =>\n new Promise((resolve, reject) => {\n httpModule\n .get(url)\n .on(\"response\", res => {\n resolve(res.headers);\n })\n .on(\"error\", reject);\n });\n\nexport const validateAudioURL = async (httpModule: typeof http | typeof https, protocol: string, url: string) => {\n if (new URL(url).protocol.toLowerCase() !== protocol) {\n return false;\n }\n const headers = await getResponseHeaders(httpModule, url),\n type = headers[\"content-type\"];\n if (type?.startsWith(\"audio\")) {\n return true;\n }\n return false;\n};\n\n// eslint-disable-next-line @typescript-eslint/require-await\nexport const resolveHttpSong = async (source: string, url: string, member: GuildMember) => {\n url = url.replace(/\\/+$/, \"\");\n return new Song(\n {\n name: url.substring(url.lastIndexOf(\"/\") + 1).replace(/((\\?|#).*)?$/, \"\") || url,\n url,\n },\n member,\n source,\n );\n};\n\nexport class HTTPSPlugin extends ExtractorPlugin {\n async validate(url: string) {\n return validateAudioURL(https, \"https:\", url);\n }\n\n async resolve(url: string, member: GuildMember) {\n return resolveHttpSong(\"https\", url, member);\n }\n}\n\nexport default HTTPSPlugin;\n"]}
@@ -0,0 +1,4 @@
1
+ export * from "./http";
2
+ export * from "./https";
3
+ export * from "./youtube-dl";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./http"), exports);
14
+ __exportStar(require("./https"), exports);
15
+ __exportStar(require("./youtube-dl"), exports);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,0CAAwB;AACxB,+CAA6B","sourcesContent":["export * from \"./http\";\nexport * from \"./https\";\nexport * from \"./youtube-dl\";\n"]}
@@ -0,0 +1,11 @@
1
+ import ExtractorPlugin from "../struct/ExtractorPlugin";
2
+ import { Playlist, Song } from "../struct";
3
+ import type { GuildMember } from "discord.js";
4
+ export declare class YouTubeDLPlugin extends ExtractorPlugin {
5
+ constructor(updateYouTubeDL?: boolean);
6
+ validate(): Promise<boolean>;
7
+ resolve(url: string, member: GuildMember): Promise<Song | Playlist>;
8
+ getStreamURL(url: string): Promise<string>;
9
+ }
10
+ export default YouTubeDLPlugin;
11
+ //# sourceMappingURL=youtube-dl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"youtube-dl.d.ts","sourceRoot":"","sources":["../../src/plugin/youtube-dl.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,qBAAa,eAAgB,SAAQ,eAAe;gBACtC,eAAe,UAAO;IAY5B,QAAQ;IAGR,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW;IAgBxC,YAAY,CAAC,GAAG,EAAE,MAAM;CAW/B;AAED,eAAe,eAAe,CAAC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.YouTubeDLPlugin = void 0;
26
+ const youtube_dl_1 = __importStar(require("@distube/youtube-dl"));
27
+ const ExtractorPlugin_1 = __importDefault(require("../struct/ExtractorPlugin"));
28
+ const struct_1 = require("../struct");
29
+ class YouTubeDLPlugin extends ExtractorPlugin_1.default {
30
+ constructor(updateYouTubeDL = true) {
31
+ super();
32
+ if (updateYouTubeDL) {
33
+ /* eslint-disable no-console */
34
+ (0, youtube_dl_1.download)()
35
+ .then((version) => console.log(`[DisTube] Updated youtube-dl to ${version}!`))
36
+ .catch(console.error)
37
+ .catch(() => console.warn("[DisTube] Unable to update youtube-dl, using default version."));
38
+ /* eslint-enable no-console */
39
+ }
40
+ }
41
+ // eslint-disable-next-line @typescript-eslint/require-await
42
+ async validate() {
43
+ return true;
44
+ }
45
+ async resolve(url, member) {
46
+ const info = await (0, youtube_dl_1.default)(url, {
47
+ dumpSingleJson: true,
48
+ noWarnings: true,
49
+ noCallHome: true,
50
+ preferFreeFormats: true,
51
+ }).catch(e => {
52
+ throw new Error(`[youtube-dl] ${e.stderr || e}`);
53
+ });
54
+ if (Array.isArray(info.entries) && info.entries.length > 0) {
55
+ info.source = info.extractor.match(/\w+/)[0];
56
+ info.songs = info.entries.map((i) => new struct_1.Song(i, member, i.extractor));
57
+ return new struct_1.Playlist(info, member);
58
+ }
59
+ return new struct_1.Song(info, member, info.extractor);
60
+ }
61
+ async getStreamURL(url) {
62
+ const info = await (0, youtube_dl_1.default)(url, {
63
+ dumpSingleJson: true,
64
+ noWarnings: true,
65
+ noCallHome: true,
66
+ preferFreeFormats: true,
67
+ }).catch(e => {
68
+ throw new Error(`[youtube-dl] ${e.stderr || e}`);
69
+ });
70
+ return info.url;
71
+ }
72
+ }
73
+ exports.YouTubeDLPlugin = YouTubeDLPlugin;
74
+ exports.default = YouTubeDLPlugin;
75
+ //# sourceMappingURL=youtube-dl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"youtube-dl.js","sourceRoot":"","sources":["../../src/plugin/youtube-dl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA8D;AAC9D,gFAAwD;AACxD,sCAA2C;AAK3C,MAAa,eAAgB,SAAQ,yBAAe;IAClD,YAAY,eAAe,GAAG,IAAI;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,eAAe,EAAE;YACnB,+BAA+B;YAC/B,IAAA,qBAAQ,GAAE;iBACP,IAAI,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,mCAAmC,OAAO,GAAG,CAAC,CAAC;iBAClF,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;iBACpB,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC,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AI;SACxB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AA3CD,0CA2CC;AAED,kBAAe,eAAe,CAAC","sourcesContent":["import youtubeDlExec, { download } from \"@distube/youtube-dl\";\nimport ExtractorPlugin from \"../struct/ExtractorPlugin\";\nimport { Playlist, Song } from \"../struct\";\nimport type { OtherSongInfo } from \"..\";\nimport type { GuildMember } from \"discord.js\";\nimport type { YtResponse } from \"@distube/youtube-dl\";\n\nexport class YouTubeDLPlugin extends ExtractorPlugin {\n constructor(updateYouTubeDL = true) {\n super();\n if (updateYouTubeDL) {\n /* eslint-disable no-console */\n download()\n .then((version: any) => console.log(`[DisTube] Updated youtube-dl to ${version}!`))\n .catch(console.error)\n .catch(() => console.warn(\"[DisTube] Unable to update youtube-dl, using default version.\"));\n /* eslint-enable no-console */\n }\n }\n // eslint-disable-next-line @typescript-eslint/require-await\n async validate() {\n return true;\n }\n async resolve(url: string, member: GuildMember) {\n const info: any = await youtubeDlExec(url, {\n dumpSingleJson: true,\n noWarnings: true,\n noCallHome: true,\n preferFreeFormats: true,\n }).catch(e => {\n throw new Error(`[youtube-dl] ${e.stderr || e}`);\n });\n if (Array.isArray(info.entries) && info.entries.length > 0) {\n info.source = info.extractor.match(/\\w+/)[0];\n info.songs = info.entries.map((i: OtherSongInfo & YtResponse) => new Song(i, member, i.extractor));\n return new Playlist(info, member);\n }\n return new Song(info, member, info.extractor);\n }\n async getStreamURL(url: string) {\n const info = await youtubeDlExec(url, {\n dumpSingleJson: true,\n noWarnings: true,\n noCallHome: true,\n preferFreeFormats: true,\n }).catch(e => {\n throw new Error(`[youtube-dl] ${e.stderr || e}`);\n });\n return info.url;\n }\n}\n\nexport default YouTubeDLPlugin;\n"]}
@@ -0,0 +1,27 @@
1
+ import Plugin from "./Plugin";
2
+ import { PluginType } from "..";
3
+ import type { GuildMember, StageChannel, TextChannel, VoiceChannel } from "discord.js";
4
+ /**
5
+ * Custom Plugin
6
+ * @extends Plugin
7
+ * @abstract
8
+ */
9
+ export declare abstract class CustomPlugin extends Plugin {
10
+ type: PluginType;
11
+ abstract play(voiceChannel: VoiceChannel | StageChannel, url: string, member: GuildMember, textChannel: TextChannel | undefined, skip: boolean, unshift: boolean): Promise<void>;
12
+ }
13
+ /**
14
+ * This method will be executed if the url is validated.
15
+ * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
16
+ * @param {string} url Validated url
17
+ * @param {Discord.GuildMember} member Requested user
18
+ * @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
19
+ * @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
20
+ * @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
21
+ * @returns {Promise<void>}
22
+ * @method play
23
+ * @memberof CustomPlugin#
24
+ * @abstract
25
+ */
26
+ export default CustomPlugin;
27
+ //# sourceMappingURL=CustomPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEvF;;;;GAIG;AACH,8BAAsB,YAAa,SAAQ,MAAM;IAC/C,IAAI,aAAqB;IACzB,QAAQ,CAAC,IAAI,CACX,YAAY,EAAE,YAAY,GAAG,YAAY,EACzC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC;CACjB;AAED;;;;;;;;;;;;GAYG;AAEH,eAAe,YAAY,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CustomPlugin = void 0;
7
+ const Plugin_1 = __importDefault(require("./Plugin"));
8
+ const __1 = require("..");
9
+ /**
10
+ * Custom Plugin
11
+ * @extends Plugin
12
+ * @abstract
13
+ */
14
+ class CustomPlugin extends Plugin_1.default {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.type = __1.PluginType.CUSTOM;
18
+ }
19
+ }
20
+ exports.CustomPlugin = CustomPlugin;
21
+ /**
22
+ * This method will be executed if the url is validated.
23
+ * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
24
+ * @param {string} url Validated url
25
+ * @param {Discord.GuildMember} member Requested user
26
+ * @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
27
+ * @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
28
+ * @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
29
+ * @returns {Promise<void>}
30
+ * @method play
31
+ * @memberof CustomPlugin#
32
+ * @abstract
33
+ */
34
+ exports.default = CustomPlugin;
35
+ //# sourceMappingURL=CustomPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,0BAAgC;AAGhC;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,gBAAM;IAAjD;;QACE,SAAI,GAAG,cAAU,CAAC,MAAM,CAAC;IAS3B,CAAC;CAAA;AAVD,oCAUC;AAED;;;;;;;;;;;;GAYG;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["import Plugin from \"./Plugin\";\nimport { PluginType } from \"..\";\nimport type { GuildMember, StageChannel, TextChannel, VoiceChannel } from \"discord.js\";\n\n/**\n * Custom Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class CustomPlugin extends Plugin {\n type = PluginType.CUSTOM;\n abstract play(\n voiceChannel: VoiceChannel | StageChannel,\n url: string,\n member: GuildMember,\n textChannel: TextChannel | undefined,\n skip: boolean,\n unshift: boolean,\n ): Promise<void>;\n}\n\n/**\n * This method will be executed if the url is validated.\n * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined\n * @param {string} url Validated url\n * @param {Discord.GuildMember} member Requested user\n * @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}\n * @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)\n * @returns {Promise<void>}\n * @method play\n * @memberof CustomPlugin#\n * @abstract\n */\n\nexport default CustomPlugin;\n"]}
@@ -0,0 +1,54 @@
1
+ declare const ERROR_MESSAGES: {
2
+ INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string | undefined) => string;
3
+ NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
4
+ EMPTY_ARRAY: (name: string) => string;
5
+ EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
6
+ INVALID_KEY: (obj: string, key: string) => string;
7
+ MISSING_INTENTS: (i: string) => string;
8
+ DISABLED_OPTION: (o: string) => string;
9
+ ENABLED_OPTION: (o: string) => string;
10
+ NOT_IN_VOICE: string;
11
+ NOT_SUPPORTED_VOICE: string;
12
+ VOICE_FULL: string;
13
+ VOICE_CONNECT_FAILED: (s: number) => string;
14
+ VOICE_MISSING_PERMS: string;
15
+ VOICE_RECONNECT_FAILED: string;
16
+ VOICE_CHANGE_GUILD: string;
17
+ NO_QUEUE: string;
18
+ QUEUE_EXIST: string;
19
+ ADD_BEFORE_PLAYING: string;
20
+ PAUSED: string;
21
+ RESUMED: string;
22
+ NO_PREVIOUS: string;
23
+ NO_UP_NEXT: string;
24
+ NO_SONG_POSITION: string;
25
+ NO_PLAYING: string;
26
+ NO_RESULT: string;
27
+ NO_RELATED: string;
28
+ CANNOT_PLAY_RELATED: string;
29
+ UNAVAILABLE_VIDEO: string;
30
+ UNPLAYABLE_FORMATS: string;
31
+ NON_NSFW: string;
32
+ NOT_SUPPORTED_URL: string;
33
+ CANNOT_RESOLVE_SONG: (t: string) => string;
34
+ NO_VALID_SONG: string;
35
+ EMPTY_FILTERED_PLAYLIST: string;
36
+ EMPTY_PLAYLIST: string;
37
+ };
38
+ declare type ErrorMessages = typeof ERROR_MESSAGES;
39
+ declare type ErrorCodes = keyof ErrorMessages;
40
+ declare type ErrorCode = {
41
+ [K in ErrorCodes]-?: ErrorMessages[K] extends string ? K : never;
42
+ }[ErrorCodes];
43
+ declare type ErrorCodeTemplate = Exclude<keyof typeof ERROR_MESSAGES, ErrorCode>;
44
+ export declare class DisTubeError<T extends string> extends Error {
45
+ errorCode: string;
46
+ constructor(code: ErrorCode);
47
+ constructor(code: T extends ErrorCodeTemplate ? T : never, ...args: Parameters<ErrorMessages[typeof code]>);
48
+ constructor(code: ErrorCodeTemplate, _: never);
49
+ constructor(code: T extends ErrorCodes ? "This is built-in error code" : T, message: string);
50
+ get name(): string;
51
+ get code(): string;
52
+ }
53
+ export default DisTubeError;
54
+ //# sourceMappingURL=DisTubeError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,cAAc;6BACO,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,GAAG;2BAY5D,MAAM,YAAY,MAAM,SAAS,MAAM;wBAC1C,MAAM;iCACG,MAAM,QAAQ,MAAM;uBAC9B,MAAM,OAAO,MAAM;yBAEjB,MAAM;yBACN,MAAM;wBACP,MAAM;;;;8BAKA,MAAM;;;;;;;;;;;;;;;;;;;;6BAsBP,MAAM;;;;CAMhC,CAAC;AAEF,aAAK,aAAa,GAAG,OAAO,cAAc,CAAC;AAC3C,aAAK,UAAU,GAAG,MAAM,aAAa,CAAC;AACtC,aAAK,SAAS,GAAG;KAAG,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,UAAU,CAAC,CAAC;AAClG,aAAK,iBAAiB,GAAG,OAAO,CAAC,MAAM,OAAO,cAAc,EAAE,SAAS,CAAC,CAAC;AAMzE,qBAAa,YAAY,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,KAAK;IACvD,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,CAAC,SAAS,iBAAiB,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,CAAC;gBAC9F,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE,KAAK;gBACjC,IAAI,EAAE,CAAC,SAAS,UAAU,GAAG,6BAA6B,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM;IAS3F,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,WAEP;CACF;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DisTubeError = void 0;
4
+ const ERROR_MESSAGES = {
5
+ INVALID_TYPE: (expected, got, name) => {
6
+ var _a;
7
+ return `Expected ${Array.isArray(expected) ? expected.map(e => (typeof e === "number" ? e : `'${e}'`)).join(" or ") : `'${expected}'`}${name ? ` for '${name}'` : ""}, but got ${typeof got === "string"
8
+ ? `'${got}'`
9
+ : typeof got === "number"
10
+ ? got
11
+ : Array.isArray(got)
12
+ ? `Array<${got.length}>`
13
+ : ((_a = got === null || got === void 0 ? void 0 : got.constructor) === null || _a === void 0 ? void 0 : _a.name) || typeof got} (${typeof got})`;
14
+ },
15
+ NUMBER_COMPARE: (name, expected, value) => `'${name}' must be ${expected} ${value}`,
16
+ EMPTY_ARRAY: (name) => `'${name}' is an empty array`,
17
+ EMPTY_FILTERED_ARRAY: (name, type) => `There is no valid '${type}' in the '${name}' array`,
18
+ INVALID_KEY: (obj, key) => `'${key}' does not need to be provided in ${obj}`,
19
+ MISSING_INTENTS: (i) => `${i} intent must be provided for the Client`,
20
+ DISABLED_OPTION: (o) => `DisTubeOptions.${o} is disabled`,
21
+ ENABLED_OPTION: (o) => `DisTubeOptions.${o} is enabled`,
22
+ NOT_IN_VOICE: "User is not in any voice channel",
23
+ NOT_SUPPORTED_VOICE: "DisTubeVoice only supports VoiceChannel or a StageChannel",
24
+ VOICE_FULL: "The voice channel is full",
25
+ VOICE_CONNECT_FAILED: (s) => `Cannot connect to the voice channel after ${s} seconds`,
26
+ VOICE_MISSING_PERMS: "You do not have permission to join this voice channel",
27
+ VOICE_RECONNECT_FAILED: "Cannot reconnect to the voice channel",
28
+ VOICE_CHANGE_GUILD: "Cannot join a channel in a different guild",
29
+ NO_QUEUE: "There is no playing queue in this guild",
30
+ QUEUE_EXIST: "This guild has a Queue already",
31
+ ADD_BEFORE_PLAYING: "Cannot add Song before the playing Song",
32
+ PAUSED: "The queue has been paused already",
33
+ RESUMED: "The queue has been playing already",
34
+ NO_PREVIOUS: "There is no previous song in this queue",
35
+ NO_UP_NEXT: "There is no up next song",
36
+ NO_SONG_POSITION: "Does not have any song at this position",
37
+ NO_PLAYING: "There is no playing song in the queue",
38
+ NO_RESULT: "No result found",
39
+ NO_RELATED: "Cannot find any related songs",
40
+ CANNOT_PLAY_RELATED: "Cannot play the related song",
41
+ UNAVAILABLE_VIDEO: "This video is unavailable",
42
+ UNPLAYABLE_FORMATS: "No playable format found",
43
+ NON_NSFW: "Cannot play age-restricted content in non-NSFW channel",
44
+ NOT_SUPPORTED_URL: "This url is not supported",
45
+ CANNOT_RESOLVE_SONG: (t) => `Cannot resolve ${t} to a Song`,
46
+ NO_VALID_SONG: "'songs' array does not have any valid Song, SearchResult or url",
47
+ EMPTY_FILTERED_PLAYLIST: "There is no valid video in the playlist\n" +
48
+ "Maybe age-restricted contents is filtered because you are in non-NSFW channel",
49
+ EMPTY_PLAYLIST: "There is no valid video in the playlist",
50
+ };
51
+ const errMsg = (msg, ...args) => (typeof msg === "string" ? msg : msg(...args));
52
+ const haveCode = (code) => Object.keys(ERROR_MESSAGES).includes(code);
53
+ class DisTubeError extends Error {
54
+ constructor(code, ...args) {
55
+ if (haveCode(code))
56
+ super(errMsg(ERROR_MESSAGES[code], ...args));
57
+ else
58
+ super(...args);
59
+ this.errorCode = code;
60
+ if (Error.captureStackTrace)
61
+ Error.captureStackTrace(this, DisTubeError);
62
+ }
63
+ get name() {
64
+ return `DisTubeError [${this.errorCode}]`;
65
+ }
66
+ get code() {
67
+ return this.errorCode;
68
+ }
69
+ }
70
+ exports.DisTubeError = DisTubeError;
71
+ exports.default = DisTubeError;
72
+ //# sourceMappingURL=DisTubeError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DisTubeError.js","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":";;;AAAA,MAAM,cAAc,GAAG;IACrB,YAAY,EAAE,CAAC,QAA0D,EAAE,GAAQ,EAAE,IAAa,EAAE,EAAE;;QACpG,OAAA,YACE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,GAC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AG,IAAI,CAAC,CAAC;QAEpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,KAAK,CAAC,iBAAiB;YAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,IAAI;QACN,OAAO,iBAAiB,IAAI,CAAC,SAAS,GAAG,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AArBD,oCAqBC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["const ERROR_MESSAGES = {\n INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) =>\n `Expected ${\n Array.isArray(expected) ? expected.map(e => (typeof e === \"number\" ? e : `'${e}'`)).join(\" or \") : `'${expected}'`\n }${name ? ` for '${name}'` : \"\"}, but got ${\n typeof got === \"string\"\n ? `'${got}'`\n : typeof got === \"number\"\n ? got\n : Array.isArray(got)\n ? `Array<${got.length}>`\n : got?.constructor?.name || typeof got\n } (${typeof got})`,\n NUMBER_COMPARE: (name: string, expected: string, value: number) => `'${name}' must be ${expected} ${value}`,\n EMPTY_ARRAY: (name: string) => `'${name}' is an empty array`,\n EMPTY_FILTERED_ARRAY: (name: string, type: string) => `There is no valid '${type}' in the '${name}' array`,\n INVALID_KEY: (obj: string, key: string) => `'${key}' does not need to be provided in ${obj}`,\n\n MISSING_INTENTS: (i: string) => `${i} intent must be provided for the Client`,\n DISABLED_OPTION: (o: string) => `DisTubeOptions.${o} is disabled`,\n ENABLED_OPTION: (o: string) => `DisTubeOptions.${o} is enabled`,\n\n NOT_IN_VOICE: \"User is not in any voice channel\",\n NOT_SUPPORTED_VOICE: \"DisTubeVoice only supports VoiceChannel or a StageChannel\",\n VOICE_FULL: \"The voice channel is full\",\n VOICE_CONNECT_FAILED: (s: number) => `Cannot connect to the voice channel after ${s} seconds`,\n VOICE_MISSING_PERMS: \"You do not have permission to join this voice channel\",\n VOICE_RECONNECT_FAILED: \"Cannot reconnect to the voice channel\",\n VOICE_CHANGE_GUILD: \"Cannot join a channel in a different guild\",\n\n NO_QUEUE: \"There is no playing queue in this guild\",\n QUEUE_EXIST: \"This guild has a Queue already\",\n ADD_BEFORE_PLAYING: \"Cannot add Song before the playing Song\",\n PAUSED: \"The queue has been paused already\",\n RESUMED: \"The queue has been playing already\",\n NO_PREVIOUS: \"There is no previous song in this queue\",\n NO_UP_NEXT: \"There is no up next song\",\n NO_SONG_POSITION: \"Does not have any song at this position\",\n NO_PLAYING: \"There is no playing song in the queue\",\n\n NO_RESULT: \"No result found\",\n NO_RELATED: \"Cannot find any related songs\",\n CANNOT_PLAY_RELATED: \"Cannot play the related song\",\n UNAVAILABLE_VIDEO: \"This video is unavailable\",\n UNPLAYABLE_FORMATS: \"No playable format found\",\n NON_NSFW: \"Cannot play age-restricted content in non-NSFW channel\",\n NOT_SUPPORTED_URL: \"This url is not supported\",\n CANNOT_RESOLVE_SONG: (t: string) => `Cannot resolve ${t} to a Song`,\n NO_VALID_SONG: \"'songs' array does not have any valid Song, SearchResult or url\",\n EMPTY_FILTERED_PLAYLIST:\n \"There is no valid video in the playlist\\n\" +\n \"Maybe age-restricted contents is filtered because you are in non-NSFW channel\",\n EMPTY_PLAYLIST: \"There is no valid video in the playlist\",\n};\n\ntype ErrorMessages = typeof ERROR_MESSAGES;\ntype ErrorCodes = keyof ErrorMessages;\ntype ErrorCode = { [K in ErrorCodes]-?: ErrorMessages[K] extends string ? K : never }[ErrorCodes];\ntype ErrorCodeTemplate = Exclude<keyof typeof ERROR_MESSAGES, ErrorCode>;\n\nconst errMsg = (msg: string | ((...x: any) => string), ...args: any) => (typeof msg === \"string\" ? msg : msg(...args));\n\nconst haveCode = (code: string): code is ErrorCodes => Object.keys(ERROR_MESSAGES).includes(code);\n\nexport class DisTubeError<T extends string> extends Error {\n errorCode: string;\n constructor(code: ErrorCode);\n constructor(code: T extends ErrorCodeTemplate ? T : never, ...args: Parameters<ErrorMessages[typeof code]>);\n constructor(code: ErrorCodeTemplate, _: never);\n constructor(code: T extends ErrorCodes ? \"This is built-in error code\" : T, message: string);\n constructor(code: string, ...args: any) {\n if (haveCode(code)) super(errMsg(ERROR_MESSAGES[code], ...args));\n else super(...args);\n\n this.errorCode = code;\n if (Error.captureStackTrace) Error.captureStackTrace(this, DisTubeError);\n }\n\n get name() {\n return `DisTubeError [${this.errorCode}]`;\n }\n\n get code() {\n return this.errorCode;\n }\n}\n\nexport default DisTubeError;\n"]}
@@ -0,0 +1,29 @@
1
+ import Plugin from "./Plugin";
2
+ import { PluginType } from "..";
3
+ import type { Playlist, Song } from ".";
4
+ import type { GuildMember } from "discord.js";
5
+ /**
6
+ * Extractor Plugin
7
+ * @extends Plugin
8
+ * @abstract
9
+ */
10
+ export declare abstract class ExtractorPlugin extends Plugin {
11
+ type: PluginType;
12
+ /**
13
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.\
14
+ * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
15
+ */
16
+ abstract resolve(url: string, member: GuildMember): Promise<Song | Playlist>;
17
+ }
18
+ /**
19
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.\
20
+ * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
21
+ * @param {string} url URL
22
+ * @param {Discord.GuildMember} member Requested user
23
+ * @returns {Promise<Song|Song[]|Playlist>}
24
+ * @method resolve
25
+ * @memberof ExtractorPlugin#
26
+ * @abstract
27
+ */
28
+ export default ExtractorPlugin;
29
+ //# sourceMappingURL=ExtractorPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,8BAAsB,eAAgB,SAAQ,MAAM;IAClD,IAAI,aAAwB;IAC5B;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC;CAC7E;AAED;;;;;;;;;GASG;AAEH,eAAe,eAAe,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ExtractorPlugin = void 0;
7
+ const Plugin_1 = __importDefault(require("./Plugin"));
8
+ const __1 = require("..");
9
+ /**
10
+ * Extractor Plugin
11
+ * @extends Plugin
12
+ * @abstract
13
+ */
14
+ class ExtractorPlugin extends Plugin_1.default {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.type = __1.PluginType.EXTRACTOR;
18
+ }
19
+ }
20
+ exports.ExtractorPlugin = ExtractorPlugin;
21
+ /**
22
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.\
23
+ * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
24
+ * @param {string} url URL
25
+ * @param {Discord.GuildMember} member Requested user
26
+ * @returns {Promise<Song|Song[]|Playlist>}
27
+ * @method resolve
28
+ * @memberof ExtractorPlugin#
29
+ * @abstract
30
+ */
31
+ exports.default = ExtractorPlugin;
32
+ //# sourceMappingURL=ExtractorPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtractorPlugin.js","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,0BAAgC;AAIhC;;;;GAIG;AACH,MAAsB,eAAgB,SAAQ,gBAAM;IAApD;;QACE,SAAI,GAAG,cAAU,CAAC,SAAS,CAAC;IAM9B,CAAC;CAAA;AAPD,0CAOC;AAED;;;;;;;;;GASG;AAEH,kBAAe,eAAe,CAAC","sourcesContent":["import Plugin from \"./Plugin\";\nimport { PluginType } from \"..\";\nimport type { Playlist, Song } from \".\";\nimport type { GuildMember } from \"discord.js\";\n\n/**\n * Extractor Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class ExtractorPlugin extends Plugin {\n type = PluginType.EXTRACTOR;\n /**\n * Resolve the validated url to a {@link Song} or a {@link Playlist}.\\\n * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.\n */\n abstract resolve(url: string, member: GuildMember): Promise<Song | Playlist>;\n}\n\n/**\n * Resolve the validated url to a {@link Song} or a {@link Playlist}.\\\n * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.\n * @param {string} url URL\n * @param {Discord.GuildMember} member Requested user\n * @returns {Promise<Song|Song[]|Playlist>}\n * @method resolve\n * @memberof ExtractorPlugin#\n * @abstract\n */\n\nexport default ExtractorPlugin;\n"]}
@@ -0,0 +1,42 @@
1
+ import type ytpl from "@distube/ytpl";
2
+ import type { PlaylistInfo, Song } from "..";
3
+ import type { GuildMember, User } from "discord.js";
4
+ /**
5
+ * Class representing a playlist.
6
+ * @prop {string} source Playlist source
7
+ */
8
+ export declare class Playlist implements PlaylistInfo {
9
+ source: string;
10
+ member?: GuildMember;
11
+ user?: User;
12
+ songs: Song[];
13
+ name: string;
14
+ url?: string;
15
+ thumbnail?: string;
16
+ [x: string]: any;
17
+ /**
18
+ * Create a playlist
19
+ * @param {Song[]|PlaylistInfo} playlist Playlist
20
+ * @param {Discord.GuildMember} member Requested user
21
+ * @param {Object} properties Custom properties
22
+ */
23
+ constructor(playlist: Song[] | ytpl.result | PlaylistInfo, member?: GuildMember, properties?: any);
24
+ /**
25
+ * Playlist duration in second.
26
+ * @type {number}
27
+ */
28
+ get duration(): number;
29
+ /**
30
+ * Formatted duration string `hh:mm:ss`.
31
+ * @type {string}
32
+ */
33
+ get formattedDuration(): string;
34
+ /**
35
+ * @param {?Discord.GuildMember} [member] Requested user
36
+ * @private
37
+ * @returns {Playlist}
38
+ */
39
+ _patchMember(member?: GuildMember): Playlist;
40
+ }
41
+ export default Playlist;
42
+ //# sourceMappingURL=Playlist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Playlist.d.ts","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GAGG;AACH,qBAAa,QAAS,YAAW,YAAY;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACjB;;;;;OAKG;gBACS,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,GAAE,GAAQ;IAgDrG;;;OAGG;IACH,IAAI,QAAQ,WAEX;IAED;;;OAGG;IACH,IAAI,iBAAiB,WAEpB;IAED;;;;OAIG;IACH,YAAY,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,QAAQ;CAgB7C;AAED,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Playlist = void 0;
4
+ const __1 = require("..");
5
+ /**
6
+ * Class representing a playlist.
7
+ * @prop {string} source Playlist source
8
+ */
9
+ class Playlist {
10
+ /**
11
+ * Create a playlist
12
+ * @param {Song[]|PlaylistInfo} playlist Playlist
13
+ * @param {Discord.GuildMember} member Requested user
14
+ * @param {Object} properties Custom properties
15
+ */
16
+ constructor(playlist, member, properties = {}) {
17
+ var _a;
18
+ if (typeof playlist !== "object") {
19
+ throw new __1.DisTubeError("INVALID_TYPE", ["Array<Song>", "object"], playlist, "playlist");
20
+ }
21
+ if (typeof properties !== "object") {
22
+ throw new __1.DisTubeError("INVALID_TYPE", "object", properties, "properties");
23
+ }
24
+ // FIXME
25
+ const info = playlist;
26
+ /**
27
+ * The source of the playlist
28
+ * @type {string}
29
+ */
30
+ this.source = (info.source || properties.source || "youtube").toLowerCase();
31
+ /**
32
+ * Playlist songs.
33
+ * @type {Array<Song>}
34
+ */
35
+ this.songs = Array.isArray(info) ? info : info.items || info.songs;
36
+ if (!Array.isArray(this.songs) || !this.songs.length) {
37
+ throw new __1.DisTubeError("EMPTY_PLAYLIST");
38
+ }
39
+ this._patchMember(member || info.member);
40
+ /**
41
+ * Playlist name.
42
+ * @type {string}
43
+ */
44
+ this.name =
45
+ info.name ||
46
+ info.title ||
47
+ (this.songs[0].name
48
+ ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.`
49
+ : `${this.songs.length} songs playlist`);
50
+ /**
51
+ * Playlist URL.
52
+ * @type {string}
53
+ */
54
+ this.url = info.url || info.webpage_url;
55
+ /**
56
+ * Playlist thumbnail.
57
+ * @type {?string}
58
+ */
59
+ this.thumbnail = ((_a = info.thumbnail) === null || _a === void 0 ? void 0 : _a.url) || info.thumbnail || this.songs[0].thumbnail;
60
+ for (const [key, value] of Object.entries(properties)) {
61
+ this[key] = value;
62
+ }
63
+ }
64
+ /**
65
+ * Playlist duration in second.
66
+ * @type {number}
67
+ */
68
+ get duration() {
69
+ var _a;
70
+ return ((_a = this.songs) === null || _a === void 0 ? void 0 : _a.reduce((prev, next) => prev + (next.duration || 0), 0)) || 0;
71
+ }
72
+ /**
73
+ * Formatted duration string `hh:mm:ss`.
74
+ * @type {string}
75
+ */
76
+ get formattedDuration() {
77
+ return (0, __1.formatDuration)(this.duration);
78
+ }
79
+ /**
80
+ * @param {?Discord.GuildMember} [member] Requested user
81
+ * @private
82
+ * @returns {Playlist}
83
+ */
84
+ _patchMember(member) {
85
+ var _a;
86
+ if (member) {
87
+ /**
88
+ * User requested.
89
+ * @type {?Discord.GuildMember}
90
+ */
91
+ this.member = member;
92
+ /**
93
+ * User requested.
94
+ * @type {?Discord.User}
95
+ */
96
+ this.user = (_a = this.member) === null || _a === void 0 ? void 0 : _a.user;
97
+ }
98
+ this.songs.map(s => s.constructor.name === "Song" && s._patchPlaylist(this, this.member));
99
+ return this;
100
+ }
101
+ }
102
+ exports.Playlist = Playlist;
103
+ exports.default = Playlist;
104
+ //# sourceMappingURL=Playlist.js.map