distube 3.0.0-beta.35 → 3.0.0-beta.39

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 (88) hide show
  1. package/README.md +4 -3
  2. package/dist/DisTube.d.ts +78 -57
  3. package/dist/DisTube.d.ts.map +1 -1
  4. package/dist/DisTube.js +87 -87
  5. package/dist/DisTube.js.map +1 -1
  6. package/dist/constant.d.ts +43 -10
  7. package/dist/constant.d.ts.map +1 -1
  8. package/dist/constant.js +45 -11
  9. package/dist/constant.js.map +1 -1
  10. package/dist/core/DisTubeBase.d.ts +7 -13
  11. package/dist/core/DisTubeBase.d.ts.map +1 -1
  12. package/dist/core/DisTubeBase.js +4 -9
  13. package/dist/core/DisTubeBase.js.map +1 -1
  14. package/dist/core/DisTubeHandler.d.ts +9 -4
  15. package/dist/core/DisTubeHandler.d.ts.map +1 -1
  16. package/dist/core/DisTubeHandler.js +56 -10
  17. package/dist/core/DisTubeHandler.js.map +1 -1
  18. package/dist/core/DisTubeOptions.d.ts +0 -18
  19. package/dist/core/DisTubeOptions.d.ts.map +1 -1
  20. package/dist/core/DisTubeOptions.js +4 -1
  21. package/dist/core/DisTubeOptions.js.map +1 -1
  22. package/dist/core/DisTubeStream.d.ts +5 -2
  23. package/dist/core/DisTubeStream.d.ts.map +1 -1
  24. package/dist/core/DisTubeStream.js +23 -21
  25. package/dist/core/DisTubeStream.js.map +1 -1
  26. package/dist/core/manager/BaseManager.d.ts +2 -3
  27. package/dist/core/manager/BaseManager.d.ts.map +1 -1
  28. package/dist/core/manager/BaseManager.js +3 -3
  29. package/dist/core/manager/BaseManager.js.map +1 -1
  30. package/dist/core/manager/QueueManager.d.ts +2 -2
  31. package/dist/core/manager/QueueManager.d.ts.map +1 -1
  32. package/dist/core/manager/QueueManager.js +25 -22
  33. package/dist/core/manager/QueueManager.js.map +1 -1
  34. package/dist/core/voice/DisTubeVoice.d.ts +15 -15
  35. package/dist/core/voice/DisTubeVoice.d.ts.map +1 -1
  36. package/dist/core/voice/DisTubeVoice.js +27 -16
  37. package/dist/core/voice/DisTubeVoice.js.map +1 -1
  38. package/dist/core/voice/DisTubeVoiceManager.js +1 -1
  39. package/dist/core/voice/DisTubeVoiceManager.js.map +1 -1
  40. package/dist/plugin/http.js +2 -2
  41. package/dist/plugin/http.js.map +1 -1
  42. package/dist/plugin/https.js +3 -3
  43. package/dist/plugin/https.js.map +1 -1
  44. package/dist/plugin/youtube-dl.js +3 -3
  45. package/dist/plugin/youtube-dl.js.map +1 -1
  46. package/dist/struct/CustomPlugin.d.ts +17 -14
  47. package/dist/struct/CustomPlugin.d.ts.map +1 -1
  48. package/dist/struct/CustomPlugin.js +16 -16
  49. package/dist/struct/CustomPlugin.js.map +1 -1
  50. package/dist/struct/DisTubeError.d.ts +12 -3
  51. package/dist/struct/DisTubeError.d.ts.map +1 -1
  52. package/dist/struct/DisTubeError.js +11 -12
  53. package/dist/struct/DisTubeError.js.map +1 -1
  54. package/dist/struct/ExtractorPlugin.d.ts +16 -8
  55. package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
  56. package/dist/struct/ExtractorPlugin.js +13 -12
  57. package/dist/struct/ExtractorPlugin.js.map +1 -1
  58. package/dist/struct/Playlist.d.ts +2 -3
  59. package/dist/struct/Playlist.d.ts.map +1 -1
  60. package/dist/struct/Playlist.js +9 -6
  61. package/dist/struct/Playlist.js.map +1 -1
  62. package/dist/struct/Plugin.d.ts +62 -9
  63. package/dist/struct/Plugin.d.ts.map +1 -1
  64. package/dist/struct/Plugin.js +73 -14
  65. package/dist/struct/Plugin.js.map +1 -1
  66. package/dist/struct/Queue.d.ts +17 -15
  67. package/dist/struct/Queue.d.ts.map +1 -1
  68. package/dist/struct/Queue.js +31 -16
  69. package/dist/struct/Queue.js.map +1 -1
  70. package/dist/struct/SearchResult.js +2 -2
  71. package/dist/struct/SearchResult.js.map +1 -1
  72. package/dist/struct/Song.d.ts +6 -8
  73. package/dist/struct/Song.d.ts.map +1 -1
  74. package/dist/struct/Song.js +17 -15
  75. package/dist/struct/Song.js.map +1 -1
  76. package/dist/struct/__mocks__/Queue.d.ts +12 -0
  77. package/dist/struct/__mocks__/Queue.d.ts.map +1 -0
  78. package/dist/struct/__mocks__/Queue.js +22 -0
  79. package/dist/struct/__mocks__/Queue.js.map +1 -0
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/dist/type.d.ts +76 -20
  82. package/dist/type.d.ts.map +1 -1
  83. package/dist/type.js.map +1 -1
  84. package/dist/util.d.ts +1 -1
  85. package/dist/util.d.ts.map +1 -1
  86. package/dist/util.js +16 -7
  87. package/dist/util.js.map +1 -1
  88. package/package.json +30 -28
@@ -1 +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,qBAAQ,EAAE;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,CAAC;YAC9F,8BAA8B;SAC/B;IACH,CAAC;IACD,4DAA4D;IAC5D,KAAK,CAAC,QAAQ;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,MAAmB;QAC5C,MAAM,IAAI,GAAQ,MAAM,oBAAa,CAAC,GAAG,EAAE;YACzC,cAAc,EAAE,IAAI;YACpB,UAAU,EAAE,IAAI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\"@distube/youtube-dl\";\nimport ExtractorPlugin from \"../struct/ExtractorPlugin\";\nimport { Playlist, Song } from \"../struct\";\nimport type { OtherSongInfo } from \"../type\";\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"]}
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;Y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AI,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,GAAW;QAC5B,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAa,EAAC,GAAG,EAAE;YACpC,cAAc,EAAE,IAAI;YACpB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,iBAAiB,EAAE,IAAI;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"]}
@@ -3,21 +3,24 @@ import type { GuildMember, StageChannel, TextChannel, VoiceChannel } from "disco
3
3
  /**
4
4
  * Custom Plugin
5
5
  * @extends Plugin
6
+ * @abstract
6
7
  */
7
- export declare class CustomPlugin extends Plugin {
8
- /** Create a custom plugin */
9
- constructor();
10
- /**
11
- * Execute if the url is validated
12
- * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
13
- * @param {string} url Validated url
14
- * @param {Discord.GuildMember} member Requested user
15
- * @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
16
- * @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
17
- * @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
18
- * @returns {Promise<void>}
19
- */
20
- play(voiceChannel: VoiceChannel | StageChannel, url: string, member: GuildMember, textChannel: TextChannel | undefined, skip: boolean, unshift: boolean): Promise<void>;
8
+ export declare abstract class CustomPlugin extends Plugin {
9
+ type: "custom";
10
+ abstract play(voiceChannel: VoiceChannel | StageChannel, url: string, member: GuildMember, textChannel: TextChannel | undefined, skip: boolean, unshift: boolean): Promise<void>;
21
11
  }
12
+ /**
13
+ * This method will be executed if the url is validated.
14
+ * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
15
+ * @param {string} url Validated url
16
+ * @param {Discord.GuildMember} member Requested user
17
+ * @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
18
+ * @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
19
+ * @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
20
+ * @returns {Promise<void>}
21
+ * @method play
22
+ * @memberof CustomPlugin#
23
+ * @abstract
24
+ */
22
25
  export default CustomPlugin;
23
26
  //# sourceMappingURL=CustomPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEvF;;;GAGG;AACH,qBAAa,YAAa,SAAQ,MAAM;IACtC,6BAA6B;;IAI7B;;;;;;;;;OASG;IACG,IAAI,CACR,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;CAGjB;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEvF;;;;GAIG;AACH,8BAAsB,YAAa,SAAQ,MAAM;IAC/C,IAAI,WAAqB;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"}
@@ -4,31 +4,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CustomPlugin = void 0;
7
- /* eslint-disable @typescript-eslint/no-unused-vars */
8
7
  const Plugin_1 = __importDefault(require("./Plugin"));
9
8
  /**
10
9
  * Custom Plugin
11
10
  * @extends Plugin
11
+ * @abstract
12
12
  */
13
13
  class CustomPlugin extends Plugin_1.default {
14
- /** Create a custom plugin */
15
14
  constructor() {
16
- super("custom");
17
- }
18
- /**
19
- * Execute if the url is validated
20
- * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
21
- * @param {string} url Validated url
22
- * @param {Discord.GuildMember} member Requested user
23
- * @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
24
- * @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
25
- * @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
26
- * @returns {Promise<void>}
27
- */
28
- async play(voiceChannel, url, member, textChannel, skip, unshift) {
29
- // Template
15
+ super(...arguments);
16
+ this.type = "custom";
30
17
  }
31
18
  }
32
19
  exports.CustomPlugin = CustomPlugin;
20
+ /**
21
+ * This method will be executed if the url is validated.
22
+ * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
23
+ * @param {string} url Validated url
24
+ * @param {Discord.GuildMember} member Requested user
25
+ * @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
26
+ * @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
27
+ * @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
28
+ * @returns {Promise<void>}
29
+ * @method play
30
+ * @memberof CustomPlugin#
31
+ * @abstract
32
+ */
33
33
  exports.default = CustomPlugin;
34
34
  //# sourceMappingURL=CustomPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAsD;AACtD,sDAA8B;AAG9B;;;GAGG;AACH,MAAa,YAAa,SAAQ,gBAAM;IACtC,6BAA6B;IAC7B;QACE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IACD;;;;;;;;;OASG;IACH,KAAK,CAAC,IAAI,CACR,YAAyC,EACzC,GAAW,EACX,MAAmB,EACnB,WAAoC,EACpC,IAAa,EACb,OAAgB;QAEhB,WAAW;IACb,CAAC;CACF;AAzBD,oCAyBC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport Plugin from \"./Plugin\";\nimport type { GuildMember, StageChannel, TextChannel, VoiceChannel } from \"discord.js\";\n\n/**\n * Custom Plugin\n * @extends Plugin\n */\nexport class CustomPlugin extends Plugin {\n /** Create a custom plugin */\n constructor() {\n super(\"custom\");\n }\n /**\n * Execute 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 */\n async 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 // Template\n }\n}\n\nexport default CustomPlugin;\n"]}
1
+ {"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAG9B;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,gBAAM;IAAjD;;QACE,SAAI,GAAG,QAAiB,CAAC;IAS3B,CAAC;CAAA;AAVD,oCAUC;AAED;;;;;;;;;;;;GAYG;AAEH,kBAAe,YAAY,CAAC","sourcesContent":["import Plugin from \"./Plugin\";\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 = \"custom\" as const;\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"]}
@@ -1,5 +1,5 @@
1
1
  declare const ERROR_MESSAGES: {
2
- INVALID_TYPE: (expected: string | string[], got: any, name?: string | undefined) => string;
2
+ INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string | undefined) => string;
3
3
  NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
4
4
  EMPTY_ARRAY: (name: string) => string;
5
5
  EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
@@ -35,9 +35,18 @@ declare const ERROR_MESSAGES: {
35
35
  EMPTY_FILTERED_PLAYLIST: string;
36
36
  EMPTY_PLAYLIST: string;
37
37
  };
38
- export declare class DisTubeError extends Error {
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 {
39
45
  errorCode: string;
40
- constructor(code: keyof typeof ERROR_MESSAGES, ...args: any);
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);
41
50
  get name(): string;
42
51
  get code(): string;
43
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,cAAc;6BACO,MAAM,GAAG,MAAM,EAAE,OAAO,GAAG;2BAY7B,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;;;;CAKhC,CAAC;AAOF,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAE,MAAM,OAAO,cAAc,EAAE,GAAG,IAAI,EAAE,GAAG;IAQ3D,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,WAEP;CACF;AAED,eAAe,YAAY,CAAC"}
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"}
@@ -10,12 +10,12 @@ const ERROR_MESSAGES = {
10
10
  ? got
11
11
  : Array.isArray(got)
12
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}`;
13
+ : ((_a = got === null || got === void 0 ? void 0 : got.constructor) === null || _a === void 0 ? void 0 : _a.name) || typeof got} (${typeof got})`;
14
14
  },
15
15
  NUMBER_COMPARE: (name, expected, value) => `'${name}' must be ${expected} ${value}`,
16
16
  EMPTY_ARRAY: (name) => `'${name}' is an empty array`,
17
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}`,
18
+ INVALID_KEY: (obj, key) => `'${key}' does not need to be provided in ${obj}`,
19
19
  MISSING_INTENTS: (i) => `${i} intent must be provided for the Client`,
20
20
  DISABLED_OPTION: (o) => `DisTubeOptions.${o} is disabled`,
21
21
  ENABLED_OPTION: (o) => `DisTubeOptions.${o} is enabled`,
@@ -44,25 +44,24 @@ const ERROR_MESSAGES = {
44
44
  NOT_SUPPORTED_URL: "This url is not supported",
45
45
  CANNOT_RESOLVE_SONG: (t) => `Cannot resolve ${t} to a Song`,
46
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\nMaybe age-restricted contents is filtered because you are in non-NSFW channel",
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",
48
49
  EMPTY_PLAYLIST: "There is no valid video in the playlist",
49
50
  };
50
- const createMessage = (msg, ...args) => {
51
- if (typeof msg === "string")
52
- return msg;
53
- return msg(...args);
54
- };
51
+ const errMsg = (msg, ...args) => (typeof msg === "string" ? msg : msg(...args));
52
+ const haveCode = (code) => Object.keys(ERROR_MESSAGES).includes(code);
55
53
  class DisTubeError extends Error {
56
54
  constructor(code, ...args) {
57
- if (!Object.keys(ERROR_MESSAGES).includes(code))
58
- throw new TypeError(`Error code '${code}' does not exist`);
59
- super(createMessage(ERROR_MESSAGES[code], ...args));
55
+ if (haveCode(code))
56
+ super(errMsg(ERROR_MESSAGES[code], ...args));
57
+ else
58
+ super(...args);
60
59
  this.errorCode = code;
61
60
  if (Error.captureStackTrace)
62
61
  Error.captureStackTrace(this, DisTubeError);
63
62
  }
64
63
  get name() {
65
- return `${super.name} [${this.errorCode}]`;
64
+ return `DisTubeError [${this.errorCode}]`;
66
65
  }
67
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C5E,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,MAAa,YAAa,SAAQ,KAAK;IAErC,YAAY,IAAiC,EAAE,GAAG,IAAS;QACzD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,eAAe,IAAI,kBAAkB,CAAC,CAAC;QAE5G,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;QACpD,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,GAAG,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,SAAS,GAAG,CAAC;IAC7C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAjBD,oCAiBC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["const ERROR_MESSAGES = {\n INVALID_TYPE: (expected: string | 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 }`,\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\\nMaybe 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\nconst createMessage = (msg: string | ((...x: any) => string), ...args: any) => {\n if (typeof msg === \"string\") return msg;\n return msg(...args);\n};\n\nexport class DisTubeError extends Error {\n errorCode: string;\n constructor(code: keyof typeof ERROR_MESSAGES, ...args: any) {\n if (!Object.keys(ERROR_MESSAGES).includes(code)) throw new TypeError(`Error code '${code}' does not exist`);\n\n super(createMessage(ERROR_MESSAGES[code], ...args));\n this.errorCode = code;\n if (Error.captureStackTrace) Error.captureStackTrace(this, DisTubeError);\n }\n\n get name() {\n return `${super.name} [${this.errorCode}]`;\n }\n\n get code() {\n return this.errorCode;\n }\n}\n\nexport default DisTubeError;\n"]}
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,GACjH,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,aAC7B,OAAO,GAAG,KAAK,QAAQ;YACrB,CAAC,CAAC,IAAI,GAAG,GAAG;YACZ,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ;gBACzB,CAAC,CAAC,GAAG;gBACL,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;oBACpB,CAAC,CAAC,SAAS,GAAG,CAAC,MAAM,GAAG;oBACxB,CAAC,CAAC,CAAA,MAAA,GAAG,aAAH,GAAG,uBAAH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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"]}
@@ -4,17 +4,25 @@ import type { GuildMember } from "discord.js";
4
4
  /**
5
5
  * Extractor Plugin
6
6
  * @extends Plugin
7
+ * @abstract
7
8
  */
8
- export declare class ExtractorPlugin extends Plugin {
9
- /** Create a extractor plugin */
10
- constructor();
9
+ export declare abstract class ExtractorPlugin extends Plugin {
10
+ type: "extractor";
11
11
  /**
12
- * Execute if the url is validated (Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs})
13
- * @param {string} url URL
14
- * @param {Discord.GuildMember} member Requested user
15
- * @returns {Promise<Song|Song[]|Playlist>}
12
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.\
13
+ * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
16
14
  */
17
- resolve(url: string, member: GuildMember): Promise<Song | Playlist>;
15
+ abstract resolve(url: string, member: GuildMember): Promise<Song | Playlist>;
18
16
  }
17
+ /**
18
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.\
19
+ * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
20
+ * @param {string} url URL
21
+ * @param {Discord.GuildMember} member Requested user
22
+ * @returns {Promise<Song|Song[]|Playlist>}
23
+ * @method resolve
24
+ * @memberof ExtractorPlugin#
25
+ * @abstract
26
+ */
19
27
  export default ExtractorPlugin;
20
28
  //# sourceMappingURL=ExtractorPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;GAGG;AACH,qBAAa,eAAgB,SAAQ,MAAM;IACzC,gCAAgC;;IAIhC;;;;;OAKG;IAEG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG,QAAQ,CAAC;CAG1E;AAED,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,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,cAAwB;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"}
@@ -8,23 +8,24 @@ const Plugin_1 = __importDefault(require("./Plugin"));
8
8
  /**
9
9
  * Extractor Plugin
10
10
  * @extends Plugin
11
+ * @abstract
11
12
  */
12
13
  class ExtractorPlugin extends Plugin_1.default {
13
- /** Create a extractor plugin */
14
14
  constructor() {
15
- super("extractor");
16
- }
17
- /**
18
- * Execute if the url is validated (Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs})
19
- * @param {string} url URL
20
- * @param {Discord.GuildMember} member Requested user
21
- * @returns {Promise<Song|Song[]|Playlist>}
22
- */
23
- // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/require-await
24
- async resolve(url, member) {
25
- return undefined;
15
+ super(...arguments);
16
+ this.type = "extractor";
26
17
  }
27
18
  }
28
19
  exports.ExtractorPlugin = ExtractorPlugin;
20
+ /**
21
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.\
22
+ * Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
23
+ * @param {string} url URL
24
+ * @param {Discord.GuildMember} member Requested user
25
+ * @returns {Promise<Song|Song[]|Playlist>}
26
+ * @method resolve
27
+ * @memberof ExtractorPlugin#
28
+ * @abstract
29
+ */
29
30
  exports.default = ExtractorPlugin;
30
31
  //# sourceMappingURL=ExtractorPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtractorPlugin.js","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAI9B;;;GAGG;AACH,MAAa,eAAgB,SAAQ,gBAAM;IACzC,gCAAgC;IAChC;QACE,KAAK,CAAC,WAAW,CAAC,CAAC;IACrB,CAAC;IACD;;;;;OAKG;IACH,+FAA+F;IAC/F,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,MAAmB;QAC5C,OAAO,SAA4B,CAAC;IACtC,CAAC;CACF;AAfD,0CAeC;AAED,kBAAe,eAAe,CAAC","sourcesContent":["import Plugin from \"./Plugin\";\nimport type { Playlist, Song } from \".\";\nimport type { GuildMember } from \"discord.js\";\n\n/**\n * Extractor Plugin\n * @extends Plugin\n */\nexport class ExtractorPlugin extends Plugin {\n /** Create a extractor plugin */\n constructor() {\n super(\"extractor\");\n }\n /**\n * Execute if the url is validated (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 */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/require-await\n async resolve(url: string, member: GuildMember): Promise<Song | Playlist> {\n return undefined as unknown as Song;\n }\n}\n\nexport default ExtractorPlugin;\n"]}
1
+ {"version":3,"file":"ExtractorPlugin.js","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAI9B;;;;GAIG;AACH,MAAsB,eAAgB,SAAQ,gBAAM;IAApD;;QACE,SAAI,GAAG,WAAoB,CAAC;IAM9B,CAAC;CAAA;AAPD,0CAOC;AAED;;;;;;;;;GASG;AAEH,kBAAe,eAAe,CAAC","sourcesContent":["import Plugin from \"./Plugin\";\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 = \"extractor\" as const;\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"]}
@@ -1,6 +1,5 @@
1
- import type Song from "./Song";
2
1
  import type ytpl from "@distube/ytpl";
3
- import type { PlaylistInfo } from "..";
2
+ import type { PlaylistInfo, Song } from "..";
4
3
  import type { GuildMember, User } from "discord.js";
5
4
  /**
6
5
  * Class representing a playlist.
@@ -33,7 +32,7 @@ export declare class Playlist implements PlaylistInfo {
33
32
  */
34
33
  get formattedDuration(): string;
35
34
  /**
36
- * @param {Discord.GuildMember} [member] Requested user
35
+ * @param {?Discord.GuildMember} [member] Requested user
37
36
  * @private
38
37
  * @returns {Playlist}
39
38
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Playlist.d.ts","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD;;;GA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;;;OAKG;gBACS,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,GAAE,GAAQ;IA8CrG;;;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"}
@@ -41,7 +41,10 @@ class Playlist {
41
41
  * Playlist name.
42
42
  * @type {string}
43
43
  */
44
- this.name = info.name || info.title || `${this.songs[0].name} and ${this.songs.length - 1} more songs.`;
44
+ this.name =
45
+ info.name || info.title || this.songs[0].name
46
+ ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.`
47
+ : `${this.songs.length} songs playlist`;
45
48
  /**
46
49
  * Playlist URL.
47
50
  * @type {string}
@@ -49,7 +52,7 @@ class Playlist {
49
52
  this.url = info.url || info.webpage_url;
50
53
  /**
51
54
  * Playlist thumbnail.
52
- * @type {string}
55
+ * @type {?string}
53
56
  */
54
57
  this.thumbnail = ((_a = info.thumbnail) === null || _a === void 0 ? void 0 : _a.url) || info.thumbnail || this.songs[0].thumbnail;
55
58
  for (const [key, value] of Object.entries(properties)) {
@@ -69,10 +72,10 @@ class Playlist {
69
72
  * @type {string}
70
73
  */
71
74
  get formattedDuration() {
72
- return __1.formatDuration(this.duration);
75
+ return (0, __1.formatDuration)(this.duration);
73
76
  }
74
77
  /**
75
- * @param {Discord.GuildMember} [member] Requested user
78
+ * @param {?Discord.GuildMember} [member] Requested user
76
79
  * @private
77
80
  * @returns {Playlist}
78
81
  */
@@ -81,12 +84,12 @@ class Playlist {
81
84
  if (member) {
82
85
  /**
83
86
  * User requested.
84
- * @type {Discord.GuildMember}
87
+ * @type {?Discord.GuildMember}
85
88
  */
86
89
  this.member = member;
87
90
  /**
88
91
  * User requested.
89
- * @type {Discord.User}
92
+ * @type {?Discord.User}
90
93
  */
91
94
  this.user = (_a = this.member) === null || _a === void 0 ? void 0 : _a.user;
92
95
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Playlist.js","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":";;;AAAA,0BAAkD;AAMlD;;;GAGG;AACH,MAAa,QAAQ;IASnB;;;;;OAKG;IACH,YAAY,QAA6C,EAAE,MAAoB,EAAE,aAAkB,EAAE;;QACnG,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;SACzF;QACD,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;YAClC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;SAC5E;QACD,QAAQ;QACR,MAAM,IAAI,GAAG,QAAe,CAAC;QAC7B;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5E;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC;QACnE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACpD,MAAM,IAAI,gBAAY,CAAC,gBAAgB,CAAC,CAAC;SAC1C;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC;QACzC;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAA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AAK,MAAM,IAAI,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/FD,4BA+FC;AAED,kBAAe,QAAQ,CAAC","sourcesContent":["import { DisTubeError, formatDuration } from \"..\";\nimport type Song from \"./Song\";\nimport type ytpl from \"@distube/ytpl\";\nimport type { PlaylistInfo } from \"..\";\nimport type { GuildMember, User } from \"discord.js\";\n\n/**\n * Class representing a playlist.\n * @prop {string} source Playlist source\n */\nexport class Playlist implements PlaylistInfo {\n source: string;\n member?: GuildMember;\n user?: User;\n songs: Song[];\n name: string;\n url?: string;\n thumbnail?: string;\n [x: string]: any;\n /**\n * Create a playlist\n * @param {Song[]|PlaylistInfo} playlist Playlist\n * @param {Discord.GuildMember} member Requested user\n * @param {Object} properties Custom properties\n */\n constructor(playlist: Song[] | ytpl.result | PlaylistInfo, member?: GuildMember, properties: any = {}) {\n if (typeof playlist !== \"object\") {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Array<Song>\", \"object\"], playlist, \"playlist\");\n }\n if (typeof properties !== \"object\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", properties, \"properties\");\n }\n // FIXME\n const info = playlist as any;\n /**\n * The source of the playlist\n * @type {string}\n */\n this.source = (info.source || properties.source || \"youtube\").toLowerCase();\n /**\n * Playlist songs.\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(info) ? info : info.items || info.songs;\n if (!Array.isArray(this.songs) || !this.songs.length) {\n throw new DisTubeError(\"EMPTY_PLAYLIST\");\n }\n this._patchMember(member || info.member);\n /**\n * Playlist name.\n * @type {string}\n */\n this.name = info.name || info.title || `${this.songs[0].name} and ${this.songs.length - 1} more songs.`;\n /**\n * Playlist URL.\n * @type {string}\n */\n this.url = info.url || info.webpage_url;\n /**\n * Playlist thumbnail.\n * @type {string}\n */\n this.thumbnail = info.thumbnail?.url || info.thumbnail || this.songs[0].thumbnail;\n for (const [key, value] of Object.entries(properties)) {\n this[key] = value;\n }\n }\n\n /**\n * Playlist duration in second.\n * @type {number}\n */\n get duration() {\n return this.songs?.reduce((prev, next) => prev + (next.duration || 0), 0) || 0;\n }\n\n /**\n * Formatted duration string `hh:mm:ss`.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n\n /**\n * @param {Discord.GuildMember} [member] Requested user\n * @private\n * @returns {Playlist}\n */\n _patchMember(member?: GuildMember): Playlist {\n if (member) {\n /**\n * User requested.\n * @type {Discord.GuildMember}\n */\n this.member = member;\n /**\n * User requested.\n * @type {Discord.User}\n */\n this.user = this.member?.user;\n }\n this.songs.map(s => s.constructor.name === \"Song\" && s._patchPlaylist(this, this.member));\n return this;\n }\n}\n\nexport default Playlist;\n"]}
1
+ {"version":3,"file":"Playlist.js","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":";;;AAAA,0BAAkD;AAKlD;;;GAGG;AACH,MAAa,QAAQ;IASnB;;;;;OAKG;IACH,YAAY,QAA6C,EAAE,MAAoB,EAAE,aAAkB,EAAE;;QACnG,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,CAAC,aAAa,EAAE,QAAQ,CAAC,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;SACzF;QACD,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE;YAClC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;SAC5E;QACD,QAAQ;QACR,MAAM,IAAI,GAAG,QAAe,CAAC;QAC7B;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,IAAI,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5E;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC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,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAI,CAAC,CAAC;IACjF,CAAC;IAED;;;OAGG;IACH,IAAI,iBAAiB;QACnB,OAAO,IAAA,kBAAc,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,MAAoB;;QAC/B,IAAI,MAAM,EAAE;YACV;;;eAGG;YACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB;;;eAGG;YACH,IAAI,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,CAAC;SAC/B;QACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1F,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAlGD,4BAkGC;AAED,kBAAe,QAAQ,CAAC","sourcesContent":["import { DisTubeError, formatDuration } from \"..\";\nimport type ytpl from \"@distube/ytpl\";\nimport type { PlaylistInfo, Song } from \"..\";\nimport type { GuildMember, User } from \"discord.js\";\n\n/**\n * Class representing a playlist.\n * @prop {string} source Playlist source\n */\nexport class Playlist implements PlaylistInfo {\n source: string;\n member?: GuildMember;\n user?: User;\n songs: Song[];\n name: string;\n url?: string;\n thumbnail?: string;\n [x: string]: any;\n /**\n * Create a playlist\n * @param {Song[]|PlaylistInfo} playlist Playlist\n * @param {Discord.GuildMember} member Requested user\n * @param {Object} properties Custom properties\n */\n constructor(playlist: Song[] | ytpl.result | PlaylistInfo, member?: GuildMember, properties: any = {}) {\n if (typeof playlist !== \"object\") {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Array<Song>\", \"object\"], playlist, \"playlist\");\n }\n if (typeof properties !== \"object\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", properties, \"properties\");\n }\n // FIXME\n const info = playlist as any;\n /**\n * The source of the playlist\n * @type {string}\n */\n this.source = (info.source || properties.source || \"youtube\").toLowerCase();\n /**\n * Playlist songs.\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(info) ? info : info.items || info.songs;\n if (!Array.isArray(this.songs) || !this.songs.length) {\n throw new DisTubeError(\"EMPTY_PLAYLIST\");\n }\n this._patchMember(member || info.member);\n /**\n * Playlist name.\n * @type {string}\n */\n this.name =\n info.name || info.title || this.songs[0].name\n ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.`\n : `${this.songs.length} songs playlist`;\n /**\n * Playlist URL.\n * @type {string}\n */\n this.url = info.url || info.webpage_url;\n /**\n * Playlist thumbnail.\n * @type {?string}\n */\n this.thumbnail = info.thumbnail?.url || info.thumbnail || this.songs[0].thumbnail;\n for (const [key, value] of Object.entries(properties)) {\n this[key] = value;\n }\n }\n\n /**\n * Playlist duration in second.\n * @type {number}\n */\n get duration() {\n return this.songs?.reduce((prev, next) => prev + (next.duration || 0), 0) || 0;\n }\n\n /**\n * Formatted duration string `hh:mm:ss`.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n\n /**\n * @param {?Discord.GuildMember} [member] Requested user\n * @private\n * @returns {Playlist}\n */\n _patchMember(member?: GuildMember): Playlist {\n if (member) {\n /**\n * User requested.\n * @type {?Discord.GuildMember}\n */\n this.member = member;\n /**\n * User requested.\n * @type {?Discord.User}\n */\n this.user = this.member?.user;\n }\n this.songs.map(s => s.constructor.name === \"Song\" && s._patchPlaylist(this, this.member));\n return this;\n }\n}\n\nexport default Playlist;\n"]}
@@ -1,17 +1,68 @@
1
- import type DisTube from "../DisTube";
2
- import type { Song } from ".";
3
- import type { DisTubeHandler } from "../core";
1
+ import type { Client, TextChannel } from "discord.js";
2
+ import type { DisTube, DisTubeEvents, DisTubeHandler, DisTubeVoiceManager, Options, QueueManager, Song } from "..";
3
+ /**
4
+ * All available plugin types:
5
+ * * `custom`: {@link CustomPlugin}
6
+ * * `extractor`: {@link ExtractorPlugin}
7
+ * @typedef {"custom"|"extractor"} PluginType
8
+ */
4
9
  /**
5
10
  * DisTube Plugin
11
+ * @abstract
6
12
  * @private
7
13
  */
8
- export declare class Plugin {
9
- /** Type of the plugin */
14
+ export declare abstract class Plugin {
10
15
  type: "custom" | "extractor";
11
16
  distube: DisTube;
12
- handler: DisTubeHandler;
13
- constructor(type: "custom" | "extractor");
14
17
  init(distube: DisTube): void;
18
+ /**
19
+ * Type of the plugin
20
+ * @name Plugin#type
21
+ * @type {PluginType}
22
+ */
23
+ /**
24
+ * Emit the {@link DisTube} of this base
25
+ * @param {string} eventName Event name
26
+ * @param {...any} args arguments
27
+ * @returns {boolean}
28
+ */
29
+ emit(eventName: keyof DisTubeEvents, ...args: any): boolean;
30
+ /**
31
+ * Emit error event
32
+ * @param {Error} error error
33
+ * @param {Discord.TextChannel?} channel Text channel where the error is encountered.
34
+ */
35
+ emitError(error: Error, channel?: TextChannel): void;
36
+ /**
37
+ * The queue manager
38
+ * @type {QueueManager}
39
+ * @readonly
40
+ */
41
+ get queues(): QueueManager;
42
+ /**
43
+ * The voice manager
44
+ * @type {DisTubeVoiceManager}
45
+ * @readonly
46
+ */
47
+ get voices(): DisTubeVoiceManager;
48
+ /**
49
+ * Discord.js client
50
+ * @type {Discord.Client}
51
+ * @readonly
52
+ */
53
+ get client(): Client;
54
+ /**
55
+ * DisTube options
56
+ * @type {DisTubeOptions}
57
+ * @readonly
58
+ */
59
+ get options(): Options;
60
+ /**
61
+ * DisTube handler
62
+ * @type {DisTubeHandler}
63
+ * @readonly
64
+ */
65
+ get handler(): DisTubeHandler;
15
66
  /**
16
67
  * Check if the url is working with this plugin
17
68
  * @param {string} url Input url
@@ -19,13 +70,15 @@ export declare class Plugin {
19
70
  */
20
71
  validate(url: string): Promise<boolean>;
21
72
  /**
22
- * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default. Not needed if the plugin plays song from YouTube.
73
+ * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
74
+ * Not needed if the plugin plays song from YouTube.
23
75
  * @param {string} url Input url
24
76
  * @returns {Promise<string>}
25
77
  */
26
78
  getStreamURL(url: string): Promise<string>;
27
79
  /**
28
- * (Optional) Get related songs from a supported url (Not needed to add {@link Song#related} and member is `null` because it will be added with this function later)
80
+ * (Optional) Get related songs from a supported url. {@link Song#member} should be `undefined`.
81
+ * Not needed to add {@link Song#related} because it will be added with this function later.
29
82
  * @param {string} url Input url
30
83
  * @returns {Promise<Song[]>}
31
84
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,qBAAa,MAAM;IACjB,yBAAyB;IACzB,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAC7B,OAAO,EAAG,OAAO,CAAC;IAClB,OAAO,EAAG,cAAc,CAAC;gBACb,IAAI,EAAE,QAAQ,GAAG,WAAW;IAOxC,IAAI,CAAC,OAAO,EAAE,OAAO;IAYrB;;;;OAIG;IACG,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAG7C;;;;OAIG;IACG,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAGhD;;;;OAIG;IACG,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;CAGpD;AAED,eAAe,MAAM,CAAC"}
1
+ {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":"AACA,OAAO,KA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