distube 3.2.1 → 3.3.1-1

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 (59) hide show
  1. package/dist/DisTube.d.ts +31 -23
  2. package/dist/DisTube.d.ts.map +1 -1
  3. package/dist/DisTube.js +56 -28
  4. package/dist/DisTube.js.map +1 -1
  5. package/dist/constant.d.ts +2 -3
  6. package/dist/constant.d.ts.map +1 -1
  7. package/dist/constant.js +2 -3
  8. package/dist/constant.js.map +1 -1
  9. package/dist/core/DisTubeHandler.d.ts +10 -3
  10. package/dist/core/DisTubeHandler.d.ts.map +1 -1
  11. package/dist/core/DisTubeHandler.js +22 -23
  12. package/dist/core/DisTubeHandler.js.map +1 -1
  13. package/dist/core/DisTubeOptions.d.ts +1 -1
  14. package/dist/core/DisTubeOptions.d.ts.map +1 -1
  15. package/dist/core/DisTubeOptions.js +8 -4
  16. package/dist/core/DisTubeOptions.js.map +1 -1
  17. package/dist/core/DisTubeStream.d.ts +1 -1
  18. package/dist/core/DisTubeStream.d.ts.map +1 -1
  19. package/dist/core/DisTubeStream.js.map +1 -1
  20. package/dist/core/manager/QueueManager.d.ts.map +1 -1
  21. package/dist/core/manager/QueueManager.js +4 -1
  22. package/dist/core/manager/QueueManager.js.map +1 -1
  23. package/dist/struct/CustomPlugin.d.ts +34 -30
  24. package/dist/struct/CustomPlugin.d.ts.map +1 -1
  25. package/dist/struct/CustomPlugin.js +32 -16
  26. package/dist/struct/CustomPlugin.js.map +1 -1
  27. package/dist/struct/DisTubeError.d.ts +1 -2
  28. package/dist/struct/DisTubeError.d.ts.map +1 -1
  29. package/dist/struct/DisTubeError.js +1 -2
  30. package/dist/struct/DisTubeError.js.map +1 -1
  31. package/dist/struct/ExtractorPlugin.d.ts +21 -15
  32. package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
  33. package/dist/struct/ExtractorPlugin.js +21 -12
  34. package/dist/struct/ExtractorPlugin.js.map +1 -1
  35. package/dist/struct/Playlist.d.ts +15 -12
  36. package/dist/struct/Playlist.d.ts.map +1 -1
  37. package/dist/struct/Playlist.js +50 -39
  38. package/dist/struct/Playlist.js.map +1 -1
  39. package/dist/struct/Plugin.d.ts +9 -8
  40. package/dist/struct/Plugin.d.ts.map +1 -1
  41. package/dist/struct/Plugin.js +10 -9
  42. package/dist/struct/Plugin.js.map +1 -1
  43. package/dist/struct/Queue.d.ts +6 -6
  44. package/dist/struct/Queue.d.ts.map +1 -1
  45. package/dist/struct/Queue.js +23 -21
  46. package/dist/struct/Queue.js.map +1 -1
  47. package/dist/struct/Song.d.ts +18 -21
  48. package/dist/struct/Song.d.ts.map +1 -1
  49. package/dist/struct/Song.js +74 -58
  50. package/dist/struct/Song.js.map +1 -1
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/dist/type.d.ts +18 -4
  53. package/dist/type.d.ts.map +1 -1
  54. package/dist/type.js.map +1 -1
  55. package/dist/util.d.ts +2 -0
  56. package/dist/util.d.ts.map +1 -1
  57. package/dist/util.js +11 -4
  58. package/dist/util.js.map +1 -1
  59. package/package.json +12 -12
@@ -1,47 +1,51 @@
1
1
  import { Plugin } from ".";
2
2
  import { PluginType } from "..";
3
- import type { GuildMember, GuildTextBasedChannel, VoiceBasedChannel } from "discord.js";
3
+ import type { VoiceBasedChannel } from "discord.js";
4
+ import type { Awaitable, CustomPluginPlayOptions } from "..";
4
5
  /**
5
6
  * Custom Plugin
6
7
  * @extends Plugin
7
8
  * @abstract
8
9
  */
9
10
  export declare abstract class CustomPlugin extends Plugin {
11
+ type: PluginType;
10
12
  /**
11
- * This method will be executed if the url is validated.
13
+ * This method will be executed if the `song` string is validated.
12
14
  * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
13
- * @param {string} song Validated url
14
- * @param {Object} [options] Optional options
15
- * @param {Discord.GuildMember} [options.member] Requested user
16
- * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
17
- * @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly
18
- * @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists
19
- * @param {*} [options.metadata] Metadata
15
+ * @param {string} song Validated `song`
16
+ * @param {CustomPluginPlayOptions} [options] Optional options
20
17
  * @returns {Promise<void>}
21
18
  * @abstract
22
- * @method play
23
- * @memberof CustomPlugin#
24
19
  */
25
- type: PluginType;
20
+ abstract play(voiceChannel: VoiceBasedChannel, song: string, options: CustomPluginPlayOptions): Awaitable<void>;
26
21
  /**
27
- * This method will be executed if the url is validated.
28
- * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
29
- * @param {string} song Validated url
30
- * @param {Object} [options] Optional options
31
- * @param {Discord.GuildMember} [options.member] Requested user
32
- * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
33
- * @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly
34
- * @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists
35
- * @param {*} [options.metadata] Metadata
36
- * @returns {Promise<void>}
37
- * @abstract
22
+ * Check if the {@link DisTube#play} `song` parameter is working with this plugin
23
+ * @param {string} song String need to validate
24
+ * @returns {boolean|Promise<boolean>}
38
25
  */
39
- abstract play(voiceChannel: VoiceBasedChannel, song: string, options: {
40
- skip?: boolean;
41
- unshift?: boolean;
42
- member?: GuildMember;
43
- textChannel?: GuildTextBasedChannel;
44
- metadata?: any;
45
- }): Promise<void>;
26
+ validate(song: string): Awaitable<boolean>;
46
27
  }
28
+ /**
29
+ * @typedef {Object} CustomPluginPlayOptions
30
+ * @param {Discord.GuildMember} [member] Requested user
31
+ * @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
32
+ * @param {boolean} [skip=false]
33
+ * Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
34
+ * If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
35
+ * @param {number} [position=0] Position of the song/playlist to add to the queue,
36
+ * <= 0 to add to the end of the queue.
37
+ * @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
38
+ * (after the playing song if exists)
39
+ * @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.
40
+ */
41
+ /**
42
+ * This method will be executed if the url is validated.
43
+ * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
44
+ * @param {string} song Validated `song`
45
+ * @param {CustomPluginPlayOptions} [options] Optional options
46
+ * @returns {Promise<void>}
47
+ * @abstract
48
+ * @method play
49
+ * @memberof CustomPlugin#
50
+ */
47
51
  //# sourceMappingURL=CustomPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIxF;;;;GAIG;AACH,8BAAsB,YAAa,SAAQ,MAAM;IAC/C;;;;;;;;;;;;;;OAcG;IACH,IAAI,aAAqB;IACzB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,IAAI,CACX,YAAY,EAAE,iBAAiB,EAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,WAAW,CAAC,EAAE,qBAAqB,CAAC;QACpC,QAAQ,CAAC,EAAE,GAAG,CAAC;KAChB,GACA,OAAO,CAAC,IAAI,CAAC;CACjB"}
1
+ {"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAgC,MAAM,IAAI,CAAC;AAE3F;;;;GAIG;AACH,8BAAsB,YAAa,SAAQ,MAAM;IAC/C,IAAI,aAAqB;IACzB;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,SAAS,CAAC,IAAI,CAAC;IAC/G;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;CAG3C;AAED;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;GASG"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CustomPlugin = void 0;
4
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4
5
  const _1 = require(".");
5
6
  const __1 = require("..");
6
- // TODO: Clean parameters on the next major version.
7
7
  /**
8
8
  * Custom Plugin
9
9
  * @extends Plugin
@@ -12,23 +12,39 @@ const __1 = require("..");
12
12
  class CustomPlugin extends _1.Plugin {
13
13
  constructor() {
14
14
  super(...arguments);
15
- /**
16
- * This method will be executed if the url is validated.
17
- * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
18
- * @param {string} song Validated url
19
- * @param {Object} [options] Optional options
20
- * @param {Discord.GuildMember} [options.member] Requested user
21
- * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
22
- * @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly
23
- * @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists
24
- * @param {*} [options.metadata] Metadata
25
- * @returns {Promise<void>}
26
- * @abstract
27
- * @method play
28
- * @memberof CustomPlugin#
29
- */
30
15
  this.type = __1.PluginType.CUSTOM;
31
16
  }
17
+ /**
18
+ * Check if the {@link DisTube#play} `song` parameter is working with this plugin
19
+ * @param {string} song String need to validate
20
+ * @returns {boolean|Promise<boolean>}
21
+ */
22
+ validate(song) {
23
+ return false;
24
+ }
32
25
  }
33
26
  exports.CustomPlugin = CustomPlugin;
27
+ /**
28
+ * @typedef {Object} CustomPluginPlayOptions
29
+ * @param {Discord.GuildMember} [member] Requested user
30
+ * @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
31
+ * @param {boolean} [skip=false]
32
+ * Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
33
+ * If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
34
+ * @param {number} [position=0] Position of the song/playlist to add to the queue,
35
+ * <= 0 to add to the end of the queue.
36
+ * @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
37
+ * (after the playing song if exists)
38
+ * @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.
39
+ */
40
+ /**
41
+ * This method will be executed if the url is validated.
42
+ * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
43
+ * @param {string} song Validated `song`
44
+ * @param {CustomPluginPlayOptions} [options] Optional options
45
+ * @returns {Promise<void>}
46
+ * @abstract
47
+ * @method play
48
+ * @memberof CustomPlugin#
49
+ */
34
50
  //# sourceMappingURL=CustomPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;AAAA,wBAA2B;AAC3B,0BAAgC;AAGhC,oDAAoD;AAEpD;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,SAAM;IAAjD;;QACE;;;;;;;;;;;;;;WAcG;QACH,SAAI,GAAG,cAAU,CAAC,MAAM,CAAC;IAyB3B,CAAC;CAAA;AAzCD,oCAyCC","sourcesContent":["import { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, VoiceBasedChannel } from \"discord.js\";\n\n// TODO: Clean parameters on the next major version.\n\n/**\n * Custom Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class CustomPlugin extends Plugin {\n /**\n * This method will be executed if the url is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated url\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<void>}\n * @abstract\n * @method play\n * @memberof CustomPlugin#\n */\n type = PluginType.CUSTOM;\n /**\n * This method will be executed if the url is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated url\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<void>}\n * @abstract\n */\n abstract play(\n voiceChannel: VoiceBasedChannel,\n song: string,\n options: {\n skip?: boolean;\n unshift?: boolean;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n metadata?: any;\n },\n ): Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,wBAA2B;AAC3B,0BAAgC;AAIhC;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,SAAM;IAAjD;;QACE,SAAI,GAAG,cAAU,CAAC,MAAM,CAAC;IAkB3B,CAAC;IARC;;;;OAIG;IACH,QAAQ,CAAC,IAAY;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnBD,oCAmBC;AAED;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;GASG","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { VoiceBasedChannel } from \"discord.js\";\nimport type { Awaitable, CustomPluginPlayOptions, Playlist, SearchResult, Song } from \"..\";\n\n/**\n * Custom Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class CustomPlugin extends Plugin {\n type = PluginType.CUSTOM;\n /**\n * This method will be executed if the `song` string is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated `song`\n * @param {CustomPluginPlayOptions} [options] Optional options\n * @returns {Promise<void>}\n * @abstract\n */\n abstract play(voiceChannel: VoiceBasedChannel, song: string, options: CustomPluginPlayOptions): Awaitable<void>;\n /**\n * Check if the {@link DisTube#play} `song` parameter is working with this plugin\n * @param {string} song String need to validate\n * @returns {boolean|Promise<boolean>}\n */\n validate(song: string): Awaitable<boolean> {\n return false;\n }\n}\n\n/**\n * @typedef {Object} CustomPluginPlayOptions\n * @param {Discord.GuildMember} [member] Requested user\n * @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}\n * @param {boolean} [skip=false]\n * Skip the playing song (if exists) and play the added song/playlist if `position` is 1.\n * If `position` is defined and not equal to 1, it will skip to the next song instead of the added song\n * @param {number} [position=0] Position of the song/playlist to add to the queue,\n * <= 0 to add to the end of the queue.\n * @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.\n */\n\n/**\n * This method will be executed if the url is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated `song`\n * @param {CustomPluginPlayOptions} [options] Optional options\n * @returns {Promise<void>}\n * @abstract\n * @method play\n * @memberof CustomPlugin#\n */\n"]}
@@ -19,7 +19,6 @@ declare const ERROR_MESSAGES: {
19
19
  VOICE_DEPRECATED_CONNECTION: string;
20
20
  NO_QUEUE: string;
21
21
  QUEUE_EXIST: string;
22
- ADD_BEFORE_PLAYING: string;
23
22
  PAUSED: string;
24
23
  RESUMED: string;
25
24
  NO_PREVIOUS: string;
@@ -33,7 +32,7 @@ declare const ERROR_MESSAGES: {
33
32
  UNPLAYABLE_FORMATS: string;
34
33
  NON_NSFW: string;
35
34
  NOT_SUPPORTED_URL: string;
36
- CANNOT_RESOLVE_SONG: (t: string) => string;
35
+ CANNOT_RESOLVE_SONG: (t: any) => string;
37
36
  NO_VALID_SONG: string;
38
37
  EMPTY_FILTERED_PLAYLIST: string;
39
38
  EMPTY_PLAYLIST: string;
@@ -1 +1 @@
1
- {"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc;6BACO,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,GAAG;2BAI5D,MAAM,YAAY,MAAM,SAAS,MAAM;wBAC1C,MAAM;iCACG,MAAM,QAAQ,MAAM;yBAC5B,MAAM;uBACR,MAAM,OAAO,MAAM;uBACnB,MAAM,OAAO,MAAM;wBAClB,MAAM,OAAO,MAAM,EAAE,OAAO,OAAO;yBAGlC,MAAM;yBACN,MAAM;wBACP,MAAM;;;8BAIA,MAAM;;;;;;;;;;;;;;;;;;;;;6BAyBP,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,G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Aa,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"}
@@ -24,7 +24,6 @@ const ERROR_MESSAGES = {
24
24
  "Read more: https://distube.js.org/guide/additional-info/update.html#voice",
25
25
  NO_QUEUE: "There is no playing queue in this guild",
26
26
  QUEUE_EXIST: "This guild has a Queue already",
27
- ADD_BEFORE_PLAYING: "Cannot add Song before the playing Song",
28
27
  PAUSED: "The queue has been paused already",
29
28
  RESUMED: "The queue has been playing already",
30
29
  NO_PREVIOUS: "There is no previous song in this queue",
@@ -38,7 +37,7 @@ const ERROR_MESSAGES = {
38
37
  UNPLAYABLE_FORMATS: "No playable format found",
39
38
  NON_NSFW: "Cannot play age-restricted content in non-NSFW channel",
40
39
  NOT_SUPPORTED_URL: "This url is not supported",
41
- CANNOT_RESOLVE_SONG: (t) => `Cannot resolve ${t} to a Song`,
40
+ CANNOT_RESOLVE_SONG: (t) => `Cannot resolve ${(0, node_util_1.inspect)(t)} to a Song`,
42
41
  NO_VALID_SONG: "'songs' array does not have any valid Song, SearchResult or url",
43
42
  EMPTY_FILTERED_PLAYLIST: "There is no valid video in the playlist\n" +
44
43
  "Maybe age-restricted contents is filtered because you are in non-NSFW channel",
@@ -1 +1 @@
1
- {"version":3,"file":"DisTubeError.js","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAEpC,MAAM,cAAc,GAAG;IACrB,YAAY,EAAE,CAAC,QAA0D,EAAE,GAAQ,EAAE,IAAa,EAAE,EAAE,CACpG,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,aAAa,IAAA,mBAAO,EAAC,GAAG,CAAC,EAAE;IAC5D,cAAc,EAAE,CAAC,IAAY,EAAE,QAAgB,EAAE,KAAa,EAAE,EAAE,CAAC,IAAI,IAAI,aAAa,QAAQ,IAAI,KAAK,EAAE;IAC3G,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,qBAAqB;IAC5D,oBAAoB,EAAE,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,sBAAsB,IAAI,aAAa,IAAI,SAAS;IAC1G,YAAY,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,IAAI,4BAA4B;IACpE,WAAW,EAAE,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,GAAG,qCAAqC,GAAG,EAAE;IAC5F,WAAW,EAAE,CAAC,GAAW,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,GAAG,6BAA6B,GAAG,EAAE;IACpF,YAAY,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E,aAAa,EAAE,iEAAiE;IAChF,uBAAuB,EACrB,2CAA2C;QAC3C,+EAA+E;IACjF,cAAc,EAAE,yCAAyC;CAC1D,CAAC;AAOF,MAAM,MAAM,GAAG,CAAC,GAAqC,EAAE,GAAG,IAAS,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAEvH,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAsB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAElG,MAAa,YAA+B,SAAQ,KAAK;IAMvD,YAAY,IAAY,EAAE,GAAG,IAAS;QACpC,IAAI,QAAQ,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;;YAC5D,KAAK,CAAC,GAAG,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","sourcesContent":["import { inspect } from \"node:util\";\n\nconst 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 ${inspect(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 EMPTY_STRING: (name: string) => `'${name}' string must not be empty`,\n INVALID_KEY: (obj: string, key: string) => `'${key}' does not need to be provided in ${obj}`,\n MISSING_KEY: (obj: string, key: string) => `'${key}' needs to be provided in ${obj}`,\n MISSING_KEYS: (obj: string, key: string[], all: boolean) =>\n `${key.map(k => `'${k}'`).join(all ? \" and \" : \" or \")} 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 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 VOICE_DEPRECATED_CONNECTION:\n \"Cannot connect to the voice channel due to a deprecated connection is created.\\n\" +\n \"Read more: https://distube.js.org/guide/additional-info/update.html#voice\",\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"]}
1
+ {"version":3,"file":"DisTubeError.js","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAEpC,MAAM,cAAc,GAAG;IACrB,YAAY,EAAE,CAAC,QAA0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AAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAEvH,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAsB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAElG,MAAa,YAA+B,SAAQ,KAAK;IAMvD,YAAY,IAAY,EAAE,GAAG,IAAS;QACpC,IAAI,QAAQ,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;;YAC5D,KAAK,CAAC,GAAG,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","sourcesContent":["import { inspect } from \"node:util\";\n\nconst 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 ${inspect(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 EMPTY_STRING: (name: string) => `'${name}' string must not be empty`,\n INVALID_KEY: (obj: string, key: string) => `'${key}' does not need to be provided in ${obj}`,\n MISSING_KEY: (obj: string, key: string) => `'${key}' needs to be provided in ${obj}`,\n MISSING_KEYS: (obj: string, key: string[], all: boolean) =>\n `${key.map(k => `'${k}'`).join(all ? \" and \" : \" or \")} 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 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 VOICE_DEPRECATED_CONNECTION:\n \"Cannot connect to the voice channel due to a deprecated connection is created.\\n\" +\n \"Read more: https://distube.js.org/guide/additional-info/update.html#voice\",\n\n NO_QUEUE: \"There is no playing queue in this guild\",\n QUEUE_EXIST: \"This guild has a Queue already\",\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: any) => `Cannot resolve ${inspect(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"]}
@@ -1,25 +1,13 @@
1
1
  import { Plugin } from ".";
2
2
  import { PluginType } from "..";
3
- import type { Playlist, Song } from ".";
4
3
  import type { GuildMember } from "discord.js";
4
+ import type { Awaitable, Playlist, Song } from "..";
5
5
  /**
6
6
  * Extractor Plugin
7
7
  * @extends Plugin
8
8
  * @abstract
9
9
  */
10
10
  export declare abstract class ExtractorPlugin extends Plugin {
11
- /**
12
- * Resolve the validated url to a {@link Song} or a {@link Playlist}.
13
- *
14
- * @param {string} url URL
15
- * @param {Object} [options] Optional options
16
- * @param {Discord.GuildMember} [options.member] Requested user
17
- * @param {*} [options.metadata] Metadata
18
- * @returns {Promise<Song|Playlist>}
19
- * @method resolve
20
- * @memberof ExtractorPlugin#
21
- * @abstract
22
- */
23
11
  type: PluginType;
24
12
  /**
25
13
  * Resolve the validated url to a {@link Song} or a {@link Playlist}.
@@ -28,12 +16,30 @@ export declare abstract class ExtractorPlugin extends Plugin {
28
16
  * @param {Object} [options] Optional options
29
17
  * @param {Discord.GuildMember} [options.member] Requested user
30
18
  * @param {*} [options.metadata] Metadata
31
- * @returns {Promise<Song|Playlist>}
19
+ * @returns {Song|Playlist|Promise<Song|Playlist>}
32
20
  * @abstract
33
21
  */
34
22
  abstract resolve<T = unknown>(url: string, options: {
35
23
  member?: GuildMember;
36
24
  metadata?: T;
37
- }): Promise<Song<T> | Playlist<T>>;
25
+ }): Awaitable<Song<T> | Playlist<T>>;
26
+ /**
27
+ * Check if the url is working with this plugin
28
+ * @param {string} url Input url
29
+ * @returns {boolean|Promise<boolean>}
30
+ */
31
+ validate(url: string): Awaitable<boolean>;
38
32
  }
33
+ /**
34
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.
35
+ *
36
+ * @param {string} url URL
37
+ * @param {Object} [options] Optional options
38
+ * @param {Discord.GuildMember} [options.member] Requested user
39
+ * @param {*} [options.metadata] Metadata
40
+ * @returns {Song|Playlist|Promise<Song|Playlist>}
41
+ * @method resolve
42
+ * @memberof ExtractorPlugin#
43
+ * @abstract
44
+ */
39
45
  //# sourceMappingURL=ExtractorPlugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,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;;;;;;;;;;;OAWG;IACH,IAAI,aAAwB;IAC5B;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;KAAE,GAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;CAClC"}
1
+ {"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAEpD;;;;GAIG;AACH,8BAAsB,eAAgB,SAAQ,MAAM;IAClD,IAAI,aAAwB;IAC5B;;;;;;;;;OASG;IACH,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;KAAE,GAC9C,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;CAG1C;AAED;;;;;;;;;;;GAWG"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExtractorPlugin = void 0;
4
+ /* eslint-disable @typescript-eslint/no-unused-vars */
4
5
  const _1 = require(".");
5
6
  const __1 = require("..");
6
7
  /**
@@ -11,20 +12,28 @@ const __1 = require("..");
11
12
  class ExtractorPlugin extends _1.Plugin {
12
13
  constructor() {
13
14
  super(...arguments);
14
- /**
15
- * Resolve the validated url to a {@link Song} or a {@link Playlist}.
16
- *
17
- * @param {string} url URL
18
- * @param {Object} [options] Optional options
19
- * @param {Discord.GuildMember} [options.member] Requested user
20
- * @param {*} [options.metadata] Metadata
21
- * @returns {Promise<Song|Playlist>}
22
- * @method resolve
23
- * @memberof ExtractorPlugin#
24
- * @abstract
25
- */
26
15
  this.type = __1.PluginType.EXTRACTOR;
27
16
  }
17
+ /**
18
+ * Check if the url is working with this plugin
19
+ * @param {string} url Input url
20
+ * @returns {boolean|Promise<boolean>}
21
+ */
22
+ validate(url) {
23
+ return false;
24
+ }
28
25
  }
29
26
  exports.ExtractorPlugin = ExtractorPlugin;
27
+ /**
28
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.
29
+ *
30
+ * @param {string} url URL
31
+ * @param {Object} [options] Optional options
32
+ * @param {Discord.GuildMember} [options.member] Requested user
33
+ * @param {*} [options.metadata] Metadata
34
+ * @returns {Song|Playlist|Promise<Song|Playlist>}
35
+ * @method resolve
36
+ * @memberof ExtractorPlugin#
37
+ * @abstract
38
+ */
30
39
  //# sourceMappingURL=ExtractorPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtractorPlugin.js","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":";;;AAAA,wBAA2B;AAC3B,0BAAgC;AAIhC;;;;GAIG;AACH,MAAsB,eAAgB,SAAQ,SAAM;IAApD;;QACE;;;;;;;;;;;WAWG;QACH,SAAI,GAAG,cAAU,CAAC,SAAS,CAAC;IAe9B,CAAC;CAAA;AA5BD,0CA4BC","sourcesContent":["import { Plugin } from \".\";\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 /**\n * Resolve the validated url to a {@link Song} or a {@link Playlist}.\n *\n * @param {string} url URL\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<Song|Playlist>}\n * @method resolve\n * @memberof ExtractorPlugin#\n * @abstract\n */\n type = PluginType.EXTRACTOR;\n /**\n * Resolve the validated url to a {@link Song} or a {@link Playlist}.\n *\n * @param {string} url URL\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<Song|Playlist>}\n * @abstract\n */\n abstract resolve<T = unknown>(\n url: string,\n options: { member?: GuildMember; metadata?: T },\n ): Promise<Song<T> | Playlist<T>>;\n}\n"]}
1
+ {"version":3,"file":"ExtractorPlugin.js","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AACtD,wBAA2B;AAC3B,0BAAgC;AAIhC;;;;GAIG;AACH,MAAsB,eAAgB,SAAQ,SAAM;IAApD;;QACE,SAAI,GAAG,cAAU,CAAC,SAAS,CAAC;IAuB9B,CAAC;IARC;;;;OAIG;IACH,QAAQ,CAAC,GAAW;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxBD,0CAwBC;AAED;;;;;;;;;;;GAWG","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { GuildMember } from \"discord.js\";\nimport type { Awaitable, Playlist, Song } from \"..\";\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 *\n * @param {string} url URL\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Song|Playlist|Promise<Song|Playlist>}\n * @abstract\n */\n abstract resolve<T = unknown>(\n url: string,\n options: { member?: GuildMember; metadata?: T },\n ): Awaitable<Song<T> | Playlist<T>>;\n /**\n * Check if the url is working with this plugin\n * @param {string} url Input url\n * @returns {boolean|Promise<boolean>}\n */\n validate(url: string): Awaitable<boolean> {\n return false;\n }\n}\n\n/**\n * Resolve the validated url to a {@link Song} or a {@link Playlist}.\n *\n * @param {string} url URL\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Song|Playlist|Promise<Song|Playlist>}\n * @method resolve\n * @memberof ExtractorPlugin#\n * @abstract\n */\n"]}
@@ -1,18 +1,16 @@
1
1
  import type ytpl from "@distube/ytpl";
2
2
  import type { PlaylistInfo, Song } from "..";
3
- import type { GuildMember, User } from "discord.js";
3
+ import type { GuildMember } from "discord.js";
4
4
  /**
5
5
  * Class representing a playlist.
6
6
  * @prop {string} source Playlist source
7
7
  * @template T - The type for the metadata (if any) of the playlist
8
8
  */
9
9
  export declare class Playlist<T = unknown> implements PlaylistInfo {
10
+ #private;
10
11
  source: string;
11
12
  songs: Song[];
12
13
  name: string;
13
- metadata: T;
14
- member?: GuildMember;
15
- user?: User;
16
14
  url?: string;
17
15
  thumbnail?: string;
18
16
  [x: string]: any;
@@ -43,16 +41,21 @@ export declare class Playlist<T = unknown> implements PlaylistInfo {
43
41
  */
44
42
  get formattedDuration(): string;
45
43
  /**
46
- * @param {?Discord.GuildMember} [member] Requested user
47
- * @private
48
- * @returns {Playlist}
44
+ * User requested.
45
+ * @type {Discord.GuildMember?}
49
46
  */
50
- _patchMember(member?: GuildMember): this;
47
+ get member(): GuildMember | undefined;
48
+ set member(member: GuildMember | undefined);
51
49
  /**
52
- * @param {*} metadata Metadata
53
- * @private
54
- * @returns {Playlist}
50
+ * User requested.
51
+ * @type {Discord.User?}
55
52
  */
56
- _patchMetadata<S = unknown>(metadata: S): Playlist<S>;
53
+ get user(): import("discord.js").User | undefined;
54
+ /**
55
+ * Optional metadata that can be used to identify the playlist.
56
+ * @type {T}
57
+ */
58
+ get metadata(): T;
59
+ set metadata(metadata: T);
57
60
  }
58
61
  //# sourceMappingURL=Playlist.d.ts.map
@@ -1 +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;AAIpD;;;;GAIG;AACH,qBAAa,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAE,YAAW,YAAY;IACxD,MAAM,EAAG,MAAM,CAAC;IAChB,KAAK,EAAG,IAAI,EAAE,CAAC;IACf,IAAI,EAAG,MAAM,CAAC;IACd,QAAQ,EAAG,CAAC,CAAC;IACb,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;gBACL,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY;IACzD,4EAA4E;gBAE1E,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,EAC7C,MAAM,CAAC,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAChC,QAAQ,CAAC,EAAE,CAAC;IAEd;;;;;;;OAOG;gBAED,QAAQ,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,MAAM,GAAG,YAAY,EAC7C,OAAO,CAAC,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AG,IAAI,CAAC,MAAM,GAAG,YAAY,EAC7C,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACjC,QAAQ,CAAC,EAAE,CAAC,CAAC;KACd;IAwEH;;;OAGG;IACH,IAAI,QAAQ,WAEX;IAED;;;OAGG;IACH,IAAI,iBAAiB,WAEpB;IAED;;;OAGG;IACH,IAAI,MAAM,IAIS,WAAW,GAAG,SAAS,CAFzC;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAIzC;IAED;;;OAGG;IACH,IAAI,IAAI,0CAEP;IAED;;;OAGG;IACH,IAAI,QAAQ,IAIW,CAAC,CAFvB;IAED,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAGvB;CACF"}
@@ -1,4 +1,16 @@
1
1
  "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var _Playlist_metadata, _Playlist_member;
2
14
  Object.defineProperty(exports, "__esModule", { value: true });
3
15
  exports.Playlist = void 0;
4
16
  const __1 = require("..");
@@ -9,16 +21,18 @@ const __1 = require("..");
9
21
  * @template T - The type for the metadata (if any) of the playlist
10
22
  */
11
23
  class Playlist {
12
- constructor(playlist, options = {}, props = {}, meta) {
24
+ constructor(playlist, options = {}, props, meta) {
25
+ _Playlist_metadata.set(this, void 0);
26
+ _Playlist_member.set(this, void 0);
13
27
  if ((0, __1.isMemberInstance)(options)) {
14
28
  process.emitWarning("Passing GuildMember for DisTube#Playlist() is deprecated, read the docs for more.", "DeprecationWarning");
15
29
  return new Playlist(playlist, { member: options, properties: props, metadata: meta });
16
30
  }
17
- const { member, properties, metadata } = Object.assign({ properties: {} }, options);
31
+ const { member, properties, metadata } = options;
18
32
  if (typeof playlist !== "object") {
19
33
  throw new __1.DisTubeError("INVALID_TYPE", ["Array<Song>", "object"], playlist, "playlist");
20
34
  }
21
- if (typeof properties !== "object") {
35
+ if (typeof properties !== "undefined" && !(0, __1.isRecord)(properties)) {
22
36
  throw new __1.DisTubeError("INVALID_TYPE", "object", properties, "properties");
23
37
  }
24
38
  // FIXME
@@ -27,7 +41,7 @@ class Playlist {
27
41
  * The source of the playlist
28
42
  * @type {string}
29
43
  */
30
- this.source = (info.source || properties.source || "youtube").toLowerCase();
44
+ this.source = (info.source || properties?.source || "youtube").toLowerCase();
31
45
  /**
32
46
  * Playlist songs.
33
47
  * @type {Array<Song>}
@@ -36,7 +50,8 @@ class Playlist {
36
50
  if (!Array.isArray(this.songs) || !this.songs.length) {
37
51
  throw new __1.DisTubeError("EMPTY_PLAYLIST");
38
52
  }
39
- this._patchMember(member || info.member);
53
+ this.songs.map(s => s.constructor.name === "Song" && (s.playlist = this));
54
+ this.member = member || info.member || undefined;
40
55
  /**
41
56
  * Playlist name.
42
57
  * @type {string}
@@ -54,18 +69,13 @@ class Playlist {
54
69
  this.url = info.url || info.webpage_url;
55
70
  /**
56
71
  * Playlist thumbnail.
57
- * @type {?string}
72
+ * @type {string?}
58
73
  */
59
74
  this.thumbnail = info.thumbnail?.url || info.thumbnail || this.songs[0].thumbnail;
60
- for (const [key, value] of Object.entries(properties)) {
61
- this[key] = value;
62
- }
63
- /**
64
- * Optional metadata that can be used to identify the playlist.
65
- * @type {T}
66
- */
75
+ if (properties)
76
+ for (const [key, value] of Object.entries(properties))
77
+ this[key] = value;
67
78
  this.metadata = metadata;
68
- this._patchMetadata(metadata);
69
79
  }
70
80
  /**
71
81
  * Playlist duration in second.
@@ -82,36 +92,37 @@ class Playlist {
82
92
  return (0, __1.formatDuration)(this.duration);
83
93
  }
84
94
  /**
85
- * @param {?Discord.GuildMember} [member] Requested user
86
- * @private
87
- * @returns {Playlist}
95
+ * User requested.
96
+ * @type {Discord.GuildMember?}
88
97
  */
89
- _patchMember(member) {
90
- if (member) {
91
- /**
92
- * User requested.
93
- * @type {?Discord.GuildMember}
94
- */
95
- this.member = member;
96
- /**
97
- * User requested.
98
- * @type {?Discord.User}
99
- */
100
- this.user = this.member?.user;
101
- }
102
- this.songs.map(s => s.constructor.name === "Song" && s._patchPlaylist(this, this.member));
103
- return this;
98
+ get member() {
99
+ return __classPrivateFieldGet(this, _Playlist_member, "f");
100
+ }
101
+ set member(member) {
102
+ if (!member)
103
+ return;
104
+ __classPrivateFieldSet(this, _Playlist_member, member, "f");
105
+ this.songs.map(s => s.constructor.name === "Song" && (s.member = this.member));
104
106
  }
105
107
  /**
106
- * @param {*} metadata Metadata
107
- * @private
108
- * @returns {Playlist}
108
+ * User requested.
109
+ * @type {Discord.User?}
109
110
  */
110
- _patchMetadata(metadata) {
111
- this.metadata = metadata;
112
- this.songs.map(s => s.constructor.name === "Song" && s._patchMetadata(metadata));
113
- return this;
111
+ get user() {
112
+ return this.member?.user;
113
+ }
114
+ /**
115
+ * Optional metadata that can be used to identify the playlist.
116
+ * @type {T}
117
+ */
118
+ get metadata() {
119
+ return __classPrivateFieldGet(this, _Playlist_metadata, "f");
120
+ }
121
+ set metadata(metadata) {
122
+ __classPrivateFieldSet(this, _Playlist_metadata, metadata, "f");
123
+ this.songs.map(s => s.constructor.name === "Song" && (s.metadata = metadata));
114
124
  }
115
125
  }
116
126
  exports.Playlist = Playlist;
127
+ _Playlist_metadata = new WeakMap(), _Playlist_member = new WeakMap();
117
128
  //# sourceMappingURL=Playlist.js.map