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,29 +1,86 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Plugin = void 0;
4
+ /**
5
+ * All available plugin types:
6
+ * * `custom`: {@link CustomPlugin}
7
+ * * `extractor`: {@link ExtractorPlugin}
8
+ * @typedef {"custom"|"extractor"} PluginType
9
+ */
4
10
  /**
5
11
  * DisTube Plugin
12
+ * @abstract
6
13
  * @private
7
14
  */
8
15
  class Plugin {
9
- constructor(type) {
10
- /**
11
- * Type of the plugin
12
- * @type {"custom"|"extractor"}
13
- */
14
- this.type = type;
15
- }
16
16
  init(distube) {
17
17
  /**
18
18
  * DisTube
19
19
  * @type {DisTube}
20
20
  */
21
21
  this.distube = distube;
22
- /**
23
- * Handler
24
- * @type {DisTubeHandler}
25
- */
26
- this.handler = this.distube.handler;
22
+ }
23
+ /**
24
+ * Type of the plugin
25
+ * @name Plugin#type
26
+ * @type {PluginType}
27
+ */
28
+ /**
29
+ * Emit the {@link DisTube} of this base
30
+ * @param {string} eventName Event name
31
+ * @param {...any} args arguments
32
+ * @returns {boolean}
33
+ */
34
+ emit(eventName, ...args) {
35
+ return this.distube.emit(eventName, ...args);
36
+ }
37
+ /**
38
+ * Emit error event
39
+ * @param {Error} error error
40
+ * @param {Discord.TextChannel?} channel Text channel where the error is encountered.
41
+ */
42
+ emitError(error, channel) {
43
+ this.distube.emitError(error, channel);
44
+ }
45
+ /**
46
+ * The queue manager
47
+ * @type {QueueManager}
48
+ * @readonly
49
+ */
50
+ get queues() {
51
+ return this.distube.queues;
52
+ }
53
+ /**
54
+ * The voice manager
55
+ * @type {DisTubeVoiceManager}
56
+ * @readonly
57
+ */
58
+ get voices() {
59
+ return this.distube.voices;
60
+ }
61
+ /**
62
+ * Discord.js client
63
+ * @type {Discord.Client}
64
+ * @readonly
65
+ */
66
+ get client() {
67
+ return this.distube.client;
68
+ }
69
+ /**
70
+ * DisTube options
71
+ * @type {DisTubeOptions}
72
+ * @readonly
73
+ */
74
+ get options() {
75
+ return this.distube.options;
76
+ }
77
+ /**
78
+ * DisTube handler
79
+ * @type {DisTubeHandler}
80
+ * @readonly
81
+ */
82
+ get handler() {
83
+ return this.distube.handler;
27
84
  }
28
85
  /**
29
86
  * Check if the url is working with this plugin
@@ -34,7 +91,8 @@ class Plugin {
34
91
  return false;
35
92
  }
36
93
  /**
37
- * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default. Not needed if the plugin plays song from YouTube.
94
+ * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
95
+ * Not needed if the plugin plays song from YouTube.
38
96
  * @param {string} url Input url
39
97
  * @returns {Promise<string>}
40
98
  */
@@ -42,7 +100,8 @@ class Plugin {
42
100
  return url;
43
101
  }
44
102
  /**
45
- * (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)
103
+ * (Optional) Get related songs from a supported url. {@link Song#member} should be `undefined`.
104
+ * Not needed to add {@link Song#related} because it will be added with this function later.
46
105
  * @param {string} url Input url
47
106
  * @returns {Promise<Song[]>}
48
107
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":";;;AAKA;;;GAGG;AACH,MAAa,MAAM;IAKjB,YAAY,IAA4B;QACtC;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,OAAgB;QACnB;;;WAGG;QACH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB;;;WAGG;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IACtC,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAW;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,GAAW;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,eAAe,CAAC,GAAW;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAhDD,wBAgDC;AAED,kBAAe,MAAM,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/require-await, @typescript-eslint/no-unused-vars */\nimport type DisTube from \"../DisTube\";\nimport type { Song } from \".\";\nimport type { DisTubeHandler } from \"../core\";\n\n/**\n * DisTube Plugin\n * @private\n */\nexport class Plugin {\n /** Type of the plugin */\n type: \"custom\" | \"extractor\";\n distube!: DisTube;\n handler!: DisTubeHandler;\n constructor(type: \"custom\" | \"extractor\") {\n /**\n * Type of the plugin\n * @type {\"custom\"|\"extractor\"}\n */\n this.type = type;\n }\n init(distube: DisTube) {\n /**\n * DisTube\n * @type {DisTube}\n */\n this.distube = distube;\n /**\n * Handler\n * @type {DisTubeHandler}\n */\n this.handler = this.distube.handler;\n }\n /**\n * Check if the url is working with this plugin\n * @param {string} url Input url\n * @returns {Promise<boolean>}\n */\n async validate(url: string): Promise<boolean> {\n return false;\n }\n /**\n * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default. Not needed if the plugin plays song from YouTube.\n * @param {string} url Input url\n * @returns {Promise<string>}\n */\n async getStreamURL(url: string): Promise<string> {\n return url;\n }\n /**\n * (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)\n * @param {string} url Input url\n * @returns {Promise<Song[]>}\n */\n async getRelatedSongs(url: string): Promise<Song[]> {\n return [];\n }\n}\n\nexport default Plugin;\n"]}
1
+ {"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":";;;AAIA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAsB,MAAM;IAG1B,IAAI,CAAC,OAAgB;QACnB;;;WAGG;QACH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;OAIG;IACH;;;;;OAKG;IACH,IAAI,CAAC,SAA8B,EAAE,GAAG,IAAS;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD;;;;OAIG;IACH,SAAS,CAAC,KAAY,EAAE,OAAqB;QAC3C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IACD;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD;;;;OAIG;IACH,KAAK,CAAC,QAAQ,CAAC,GAAW;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;;OAKG;IACH,KAAK,CAAC,YAAY,CAAC,GAAW;QAC5B,OAAO,GAAG,CAAC;IACb,CAAC;IACD;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,GAAW;QAC/B,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAlGD,wBAkGC;AAED,kBAAe,MAAM,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/require-await, @typescript-eslint/no-unused-vars */\nimport type { Client, TextChannel } from \"discord.js\";\nimport type { DisTube, DisTubeEvents, DisTubeHandler, DisTubeVoiceManager, Options, QueueManager, Song } from \"..\";\n\n/**\n * All available plugin types:\n * * `custom`: {@link CustomPlugin}\n * * `extractor`: {@link ExtractorPlugin}\n * @typedef {\"custom\"|\"extractor\"} PluginType\n */\n\n/**\n * DisTube Plugin\n * @abstract\n * @private\n */\nexport abstract class Plugin {\n type!: \"custom\" | \"extractor\";\n distube!: DisTube;\n init(distube: DisTube) {\n /**\n * DisTube\n * @type {DisTube}\n */\n this.distube = distube;\n }\n /**\n * Type of the plugin\n * @name Plugin#type\n * @type {PluginType}\n */\n /**\n * Emit the {@link DisTube} of this base\n * @param {string} eventName Event name\n * @param {...any} args arguments\n * @returns {boolean}\n */\n emit(eventName: keyof DisTubeEvents, ...args: any): boolean {\n return this.distube.emit(eventName, ...args);\n }\n /**\n * Emit error event\n * @param {Error} error error\n * @param {Discord.TextChannel?} channel Text channel where the error is encountered.\n */\n emitError(error: Error, channel?: TextChannel) {\n this.distube.emitError(error, channel);\n }\n /**\n * The queue manager\n * @type {QueueManager}\n * @readonly\n */\n get queues(): QueueManager {\n return this.distube.queues;\n }\n /**\n * The voice manager\n * @type {DisTubeVoiceManager}\n * @readonly\n */\n get voices(): DisTubeVoiceManager {\n return this.distube.voices;\n }\n /**\n * Discord.js client\n * @type {Discord.Client}\n * @readonly\n */\n get client(): Client {\n return this.distube.client;\n }\n /**\n * DisTube options\n * @type {DisTubeOptions}\n * @readonly\n */\n get options(): Options {\n return this.distube.options;\n }\n /**\n * DisTube handler\n * @type {DisTubeHandler}\n * @readonly\n */\n get handler(): DisTubeHandler {\n return this.distube.handler;\n }\n /**\n * Check if the url is working with this plugin\n * @param {string} url Input url\n * @returns {Promise<boolean>}\n */\n async validate(url: string): Promise<boolean> {\n return false;\n }\n /**\n * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.\n * Not needed if the plugin plays song from YouTube.\n * @param {string} url Input url\n * @returns {Promise<string>}\n */\n async getStreamURL(url: string): Promise<string> {\n return url;\n }\n /**\n * (Optional) Get related songs from a supported url. {@link Song#member} should be `undefined`.\n * Not needed to add {@link Song#related} because it will be added with this function later.\n * @param {string} url Input url\n * @returns {Promise<Song[]>}\n */\n async getRelatedSongs(url: string): Promise<Song[]> {\n return [];\n }\n}\n\nexport default Plugin;\n"]}
@@ -1,10 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { DisTubeBase } from "../core";
3
- import { Song, TaskQueue } from "..";
4
- import type DisTube from "../DisTube";
5
- import type { SearchResult } from "..";
6
- import type { DisTubeVoice } from "../core";
3
+ import { RepeatMode, Song, TaskQueue } from "..";
7
4
  import type { GuildMember, Snowflake, TextChannel } from "discord.js";
5
+ import type { DisTube, DisTubeVoice, DisTubeVoiceEvents, SearchResult } from "..";
8
6
  /**
9
7
  * Represents a queue.
10
8
  * @extends DisTubeBase
@@ -50,7 +48,7 @@ export declare class Queue extends DisTubeBase {
50
48
  * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).
51
49
  * Default value: `0` (disabled)
52
50
  */
53
- repeatMode: number;
51
+ repeatMode: RepeatMode;
54
52
  /**
55
53
  * Whether or not the autoplay mode is enabled.
56
54
  * Default value: `false`
@@ -82,6 +80,7 @@ export declare class Queue extends DisTubeBase {
82
80
  * Task queuing system
83
81
  */
84
82
  taskQueue: TaskQueue;
83
+ listeners?: DisTubeVoiceEvents;
85
84
  /**
86
85
  * Create a queue for the guild
87
86
  * @param {DisTube} distube DisTube
@@ -114,7 +113,7 @@ export declare class Queue extends DisTubeBase {
114
113
  * The voice channel playing in.
115
114
  * @type {Discord.VoiceChannel|Discord.StageChannel|null}
116
115
  */
117
- get voiceChannel(): import("discord.js").StageChannel | import("discord.js").VoiceChannel | null;
116
+ get voiceChannel(): import("discord.js").VoiceChannel | import("discord.js").StageChannel | null;
118
117
  get volume(): number;
119
118
  set volume(value: number);
120
119
  /**
@@ -143,13 +142,15 @@ export declare class Queue extends DisTubeBase {
143
142
  */
144
143
  setVolume(percent: number): Queue;
145
144
  /**
146
- * Skip the playing song
145
+ * Skip the playing song if there is a next song in the queue.
146
+ * <info>If {@link Queue#autoplay} is `true` and there is no up next song,
147
+ * DisTube will add and play a related song.</info>
147
148
  * @returns {Promise<Song>} The song will skip to
148
149
  * @throws {Error}
149
150
  */
150
151
  skip(): Promise<Song>;
151
152
  /**
152
- * Play the previous song
153
+ * Play the previous song if exists
153
154
  * @returns {Song} The guild queue
154
155
  * @throws {Error}
155
156
  */
@@ -169,13 +170,12 @@ export declare class Queue extends DisTubeBase {
169
170
  */
170
171
  jump(position: number): Promise<Queue>;
171
172
  /**
172
- * Set the repeat mode of the guild queue.
173
- * Turn off if repeat mode is the same value as new mode.
174
- * Toggle mode `(0 -> 1 -> 2 -> 0...)`: `mode` is `undefined`
175
- * @param {number?} [mode] The repeat modes `(0: disabled, 1: Repeat a song, 2: Repeat all the queue)`
176
- * @returns {number} The new repeat mode
173
+ * Set the repeat mode of the guild queue.\
174
+ * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
175
+ * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
176
+ * @returns {RepeatMode} The new repeat mode
177
177
  */
178
- setRepeatMode(mode?: number): number;
178
+ setRepeatMode(mode?: RepeatMode): RepeatMode;
179
179
  /**
180
180
  * Enable or disable filter(s) of the queue.
181
181
  * Available filters: {@link Filters}
@@ -202,7 +202,9 @@ export declare class Queue extends DisTubeBase {
202
202
  */
203
203
  stop(): Promise<void>;
204
204
  /**
205
- * Delete the queue
205
+ * Delete the queue from the manager
206
+ * (This does not leave the queue even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)
207
+ * @private
206
208
  */
207
209
  delete(): void;
208
210
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAgB,IAAI,EAAE,SAAS,EAAkB,MAAM,IAAI,CAAC;AACnE,OAAO,KAAK,OAAO,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEtE;;;GAGG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC,EAAE,EAAE,SAAS,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,IAAI,EAAE,CAAC;IACd;;OAEG;IACH,aAAa,EAAE,IAAI,EAAE,CAAC;IACtB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;OAGG;IACH,YAAY,CAAC,EAAE,M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G;IACH,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU;IAS5C;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,EAAE,KAAK,UAAQ,GAAG,KAAK,CAAC,MAAM,CAAC;IAwB1E;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAOzB;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IASrC;;OAEG;IACG,IAAI;IAWV;;;;OAIG;IACH,MAAM;IAYN;;;OAGG;IACH,cAAc,IAAI,OAAO;CAI1B;AAED,eAAe,KAAK,CAAC"}
@@ -79,9 +79,9 @@ class Queue extends core_1.DisTubeBase {
79
79
  /**
80
80
  * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).
81
81
  * Default value: `0` (disabled)
82
- * @type {number}
82
+ * @type {RepeatMode}
83
83
  */
84
- this.repeatMode = 0;
84
+ this.repeatMode = __1.RepeatMode.DISABLED;
85
85
  /**
86
86
  * Whether or not the autoplay mode is enabled.
87
87
  * Default value: `false`
@@ -116,13 +116,19 @@ class Queue extends core_1.DisTubeBase {
116
116
  * @private
117
117
  */
118
118
  this.taskQueue = new __1.TaskQueue();
119
+ /**
120
+ * DisTubeVoice listener
121
+ * @type {Object}
122
+ * @private
123
+ */
124
+ this.listeners = undefined;
119
125
  }
120
126
  /**
121
127
  * Formatted duration string.
122
128
  * @type {string}
123
129
  */
124
130
  get formattedDuration() {
125
- return __1.formatDuration(this.duration);
131
+ return (0, __1.formatDuration)(this.duration);
126
132
  }
127
133
  /**
128
134
  * Queue's duration.
@@ -143,7 +149,7 @@ class Queue extends core_1.DisTubeBase {
143
149
  * @type {string}
144
150
  */
145
151
  get formattedCurrentTime() {
146
- return __1.formatDuration(this.currentTime);
152
+ return (0, __1.formatDuration)(this.currentTime);
147
153
  }
148
154
  /**
149
155
  * The voice channel playing in.
@@ -225,7 +231,9 @@ class Queue extends core_1.DisTubeBase {
225
231
  return this;
226
232
  }
227
233
  /**
228
- * Skip the playing song
234
+ * Skip the playing song if there is a next song in the queue.
235
+ * <info>If {@link Queue#autoplay} is `true` and there is no up next song,
236
+ * DisTube will add and play a related song.</info>
229
237
  * @returns {Promise<Song>} The song will skip to
230
238
  * @throws {Error}
231
239
  */
@@ -248,7 +256,7 @@ class Queue extends core_1.DisTubeBase {
248
256
  }
249
257
  }
250
258
  /**
251
- * Play the previous song
259
+ * Play the previous song if exists
252
260
  * @returns {Song} The guild queue
253
261
  * @throws {Error}
254
262
  */
@@ -258,8 +266,9 @@ class Queue extends core_1.DisTubeBase {
258
266
  try {
259
267
  if (!this.options.savePreviousSongs)
260
268
  throw new __1.DisTubeError("DISABLED_OPTION", "savePreviousSongs");
261
- if (((_a = this.previousSongs) === null || _a === void 0 ? void 0 : _a.length) === 0 && this.repeatMode !== 2)
269
+ if (((_a = this.previousSongs) === null || _a === void 0 ? void 0 : _a.length) === 0 && this.repeatMode !== __1.RepeatMode.QUEUE) {
262
270
  throw new __1.DisTubeError("NO_PREVIOUS");
271
+ }
263
272
  const song = this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];
264
273
  this.prev = true;
265
274
  this.voice.stop();
@@ -335,20 +344,19 @@ class Queue extends core_1.DisTubeBase {
335
344
  }
336
345
  }
337
346
  /**
338
- * Set the repeat mode of the guild queue.
339
- * Turn off if repeat mode is the same value as new mode.
340
- * Toggle mode `(0 -> 1 -> 2 -> 0...)`: `mode` is `undefined`
341
- * @param {number?} [mode] The repeat modes `(0: disabled, 1: Repeat a song, 2: Repeat all the queue)`
342
- * @returns {number} The new repeat mode
347
+ * Set the repeat mode of the guild queue.\
348
+ * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
349
+ * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
350
+ * @returns {RepeatMode} The new repeat mode
343
351
  */
344
352
  setRepeatMode(mode) {
345
- if (mode !== undefined && ![0, 1, 2].includes(mode)) {
346
- throw new __1.DisTubeError("INVALID_TYPE", [0, 1, 2, "undefined"], mode, "mode");
353
+ if (mode !== undefined && !Object.values(__1.RepeatMode).includes(mode)) {
354
+ throw new __1.DisTubeError("INVALID_TYPE", ["RepeatMode", "undefined"], mode, "mode");
347
355
  }
348
356
  if (mode === undefined)
349
357
  this.repeatMode = (this.repeatMode + 1) % 3;
350
358
  else if (this.repeatMode === mode)
351
- this.repeatMode = 0;
359
+ this.repeatMode = __1.RepeatMode.DISABLED;
352
360
  else
353
361
  this.repeatMode = mode;
354
362
  return this.repeatMode;
@@ -442,12 +450,19 @@ class Queue extends core_1.DisTubeBase {
442
450
  }
443
451
  }
444
452
  /**
445
- * Delete the queue
453
+ * Delete the queue from the manager
454
+ * (This does not leave the queue even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)
455
+ * @private
446
456
  */
447
457
  delete() {
448
458
  this.stopped = true;
449
459
  this.songs = [];
450
460
  this.previousSongs = [];
461
+ if (this.listeners) {
462
+ for (const event of Object.keys(this.listeners)) {
463
+ this.voice.removeListener(event, this.listeners[event]);
464
+ }
465
+ }
451
466
  this.queues.delete(this.id);
452
467
  this.emit("deleteQueue", this);
453
468
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";;;AAAA,kCAAsC;AACtC,0BAAmE;AAMnE;;;GAGG;AACH,MAAa,KAAM,SAAQ,kBAAW;IAyEpC;;;;;;OAMG;IACH,YAAY,OAAgB,EAAE,KAAmB,EAAE,IAAmB,EAAE,WAAyB;;QAC/F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf;;;WAGG;QACH,IAAI,CAAC,YAAY,GAAG,MAAA,KAAK,CAAC,OAAO,CAAC,KAAK,0CAAE,EAAiB,CAAC;QAC3D;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAA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C1B;IACH,CAAC;IACD;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD;;;OAGG;IACH,cAAc;QACZ,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAreD,sBAqeC;AAED,kBAAe,KAAK,CAAC","sourcesContent":["import { DisTubeBase } from \"../core\";\nimport { DisTubeError, Song, TaskQueue, formatDuration } from \"..\";\nimport type DisTube from \"../DisTube\";\nimport type { SearchResult } from \"..\";\nimport type { DisTubeVoice } from \"../core\";\nimport type { GuildMember, Snowflake, TextChannel } from \"discord.js\";\n\n/**\n * Represents a queue.\n * @extends DisTubeBase\n */\nexport class Queue extends DisTubeBase {\n id: Snowflake;\n /**\n * Voice connection of this queue\n */\n voice: DisTubeVoice;\n /**\n * List of songs in the queue (The first one is the playing song)\n */\n songs: Song[];\n /**\n * List of the previous songs.\n */\n previousSongs: Song[];\n /**\n * Whether stream is currently stopped.\n * @private\n */\n stopped: boolean;\n /**\n * Whether or not the last song was skipped to next song.\n * @private\n */\n next: boolean;\n /**\n * Whether or not the last song was skipped to previous song.\n * @private\n */\n prev: boolean;\n /**\n * Whether or not the stream is currently playing.\n */\n playing: boolean;\n /**\n * Whether or not the stream is currently paused.\n */\n paused: boolean;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n */\n repeatMode: number;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n */\n autoplay: boolean;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n */\n filters: string[];\n /**\n * What time in the song to begin (in seconds).\n */\n beginTime: number;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n */\n textChannel?: TextChannel;\n /**\n * Timeout for checking empty channel\n * @private\n */\n emptyTimeout?: NodeJS.Timeout;\n /**\n * The client user as a `GuildMember` of this queue's guild\n */\n clientMember: GuildMember;\n /**\n * Task queuing system\n */\n taskQueue: TaskQueue;\n /**\n * Create a queue for the guild\n * @param {DisTube} distube DisTube\n * @param {DisTubeVoice} voice Voice connection\n * @param {Song|Song[]} song First song(s)\n * @param {Discord.TextChannel?} textChannel Default text channel\n */\n constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: TextChannel) {\n super(distube);\n /**\n * The client user as a `GuildMember` of this queue's guild\n * @type {Discord.GuildMember}\n */\n this.clientMember = voice.channel.guild?.me as GuildMember;\n /**\n * Voice connection of this queue.\n * @type {DisTubeVoice}\n */\n this.voice = voice;\n /**\n * Queue id (Guild id)\n * @type {Discord.Snowflake}\n */\n this.id = voice.id;\n /**\n * Get or set the stream volume. Default value: `50`.\n * @type {number}\n */\n this.volume = 50;\n /**\n * List of songs in the queue (The first one is the playing song)\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(song) ? [...song] : [song];\n /**\n * List of the previous songs.\n * @type {Array<Song>}\n */\n this.previousSongs = [];\n /**\n * Whether stream is currently stopped.\n * @type {boolean}\n * @private\n */\n this.stopped = false;\n /**\n * Whether or not the last song was skipped to next song.\n * @type {boolean}\n * @private\n */\n this.next = false;\n /**\n * Whether or not the last song was skipped to previous song.\n * @type {boolean}\n * @private\n */\n this.prev = false;\n /**\n * Whether or not the stream is currently playing.\n * @type {boolean}\n */\n this.playing = true;\n /**\n * Whether or not the stream is currently paused.\n * @type {boolean}\n */\n this.paused = false;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n * @type {number}\n */\n this.repeatMode = 0;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n * @type {boolean}\n */\n this.autoplay = false;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n * @type {Array<string>}\n */\n this.filters = [];\n /**\n * What time in the song to begin (in seconds).\n * @type {number}\n */\n this.beginTime = 0;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n * @type {Discord.TextChannel?}\n */\n this.textChannel = textChannel;\n /**\n * Timeout for checking empty channel\n * @type {*}\n * @private\n */\n this.emptyTimeout = undefined;\n /**\n * Task queuing system\n * @type {TaskQueue}\n * @private\n */\n this.taskQueue = new TaskQueue();\n }\n /**\n * Formatted duration string.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n /**\n * Queue's duration.\n * @type {number}\n */\n get duration() {\n return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;\n }\n /**\n * What time in the song is playing (in seconds).\n * @type {number}\n */\n get currentTime() {\n return this.voice.playbackDuration + this.beginTime;\n }\n /**\n * Formatted {@link Queue#currentTime} string.\n * @type {string}\n */\n get formattedCurrentTime() {\n return formatDuration(this.currentTime);\n }\n /**\n * The voice channel playing in.\n * @type {Discord.VoiceChannel|Discord.StageChannel|null}\n */\n get voiceChannel() {\n return this.clientMember.voice.channel;\n }\n get volume() {\n return this.voice.volume;\n }\n set volume(value: number) {\n this.voice.volume = value;\n }\n /**\n * Add a Song or an array of Song to the queue\n * @param {Song|Song[]} song Song to add\n * @param {number} [position=-1] Position to add, < 0 to add to the end of the queue\n * @param {boolean} [queuing=true] Wether or not waiting for unfinished tasks\n * @throws {Error}\n * @returns {Queue} The guild queue\n */\n addToQueue(song: Song | SearchResult | (Song | SearchResult)[], position = -1): Queue {\n const isArray = Array.isArray(song);\n if (!song || (isArray && !(song as Song[]).length)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Song\", \"SearchResult\", \"Array<Song|SearchResult>\"], song, \"song\");\n }\n if (position === 0) throw new DisTubeError(\"ADD_BEFORE_PLAYING\");\n if (position < 0) {\n if (isArray) this.songs.push(...(song as Song[]));\n else this.songs.push(song as Song);\n } else if (isArray) {\n this.songs.splice(position, 0, ...(song as Song[]));\n } else {\n this.songs.splice(position, 0, song as Song);\n }\n if (isArray) (song as Song[]).map(s => delete s.formats);\n else delete (song as Song).formats;\n return this;\n }\n /**\n * Pause the guild stream\n * @returns {Queue} The guild queue\n */\n pause(): Queue {\n if (this.paused) throw new DisTubeError(\"PAUSED\");\n this.playing = false;\n this.paused = true;\n this.voice.pause();\n return this;\n }\n /**\n * Resume the guild stream\n * @returns {Queue} The guild queue\n */\n resume(): Queue {\n if (this.playing) throw new DisTubeError(\"RESUMED\");\n this.playing = true;\n this.paused = false;\n this.voice.unpause();\n return this;\n }\n /**\n * Set the guild stream's volume\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n */\n setVolume(percent: number): Queue {\n this.volume = percent;\n return this;\n }\n\n /**\n * Skip the playing song\n * @returns {Promise<Song>} The song will skip to\n * @throws {Error}\n */\n async skip(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (this.songs.length <= 1) {\n if (this.autoplay) await this.addRelatedSong();\n else throw new DisTubeError(\"NO_UP_NEXT\");\n }\n const song = this.songs[1];\n this.next = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n\n /**\n * Play the previous song\n * @returns {Song} The guild queue\n * @throws {Error}\n */\n async previous(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (!this.options.savePreviousSongs) throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n if (this.previousSongs?.length === 0 && this.repeatMode !== 2) throw new DisTubeError(\"NO_PREVIOUS\");\n const song =\n this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];\n this.prev = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Shuffle the queue's songs\n * @returns {Promise<Queue>} The guild queue\n */\n async shuffle(): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (!this.songs.length) return this;\n const playing = this.songs.shift() as Song;\n for (let i = this.songs.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];\n }\n this.songs.unshift(playing);\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Jump to the song position in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {number} position The song position to play\n * @returns {Promise<Queue>} The guild queue\n * @throws {Error} if `num` is invalid number\n */\n async jump(position: number): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (typeof position !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", position, \"position\");\n if (!position || position > this.songs.length || -position > this.previousSongs.length) {\n throw new DisTubeError(\"NO_SONG_POSITION\");\n }\n if (position > 0) {\n const nextSongs = this.songs.splice(position - 1);\n if (this.options.savePreviousSongs) {\n this.previousSongs.push(...this.songs);\n } else {\n this.previousSongs.push(\n ...this.songs.map(s => {\n return { id: s.id } as Song;\n }),\n );\n }\n this.songs = nextSongs;\n this.next = true;\n } else if (!this.options.savePreviousSongs) {\n throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n } else {\n this.prev = true;\n if (position !== -1) this.songs.unshift(...this.previousSongs.splice(position + 1));\n }\n this.voice.stop();\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Set the repeat mode of the guild queue.\n * Turn off if repeat mode is the same value as new mode.\n * Toggle mode `(0 -> 1 -> 2 -> 0...)`: `mode` is `undefined`\n * @param {number?} [mode] The repeat modes `(0: disabled, 1: Repeat a song, 2: Repeat all the queue)`\n * @returns {number} The new repeat mode\n */\n setRepeatMode(mode?: number): number {\n if (mode !== undefined && ![0, 1, 2].includes(mode)) {\n throw new DisTubeError(\"INVALID_TYPE\", [0, 1, 2, \"undefined\"], mode, \"mode\");\n }\n if (mode === undefined) this.repeatMode = (this.repeatMode + 1) % 3;\n else if (this.repeatMode === mode) this.repeatMode = 0;\n else this.repeatMode = mode;\n return this.repeatMode;\n }\n /**\n * Enable or disable filter(s) of the queue.\n * Available filters: {@link Filters}\n * @param {string|string[]|false} filter A filter name, an array of filter name or `false` to clear all the filters\n * @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled\n * @returns {Array<string>} Enabled filters.\n * @throws {Error}\n */\n setFilter(filter: string | string[] | false, force = false): Array<string> {\n if (Array.isArray(filter)) {\n filter = filter.filter(f => Object.prototype.hasOwnProperty.call(this.distube.filters, f));\n if (!filter.length) throw new DisTubeError(\"EMPTY_FILTERED_ARRAY\", \"filter\", \"filter name\");\n for (const f of filter) {\n if (this.filters.includes(f)) {\n if (!force) this.filters.splice(this.filters.indexOf(f), 1);\n } else {\n this.filters.push(f);\n }\n }\n } else if (filter === false) {\n this.filters = [];\n } else if (!Object.prototype.hasOwnProperty.call(this.distube.filters, filter)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"filter name\", filter, \"filter\");\n } else if (this.filters.includes(filter)) {\n if (!force) this.filters.splice(this.filters.indexOf(filter), 1);\n } else {\n this.filters.push(filter);\n }\n this.beginTime = this.currentTime;\n this.queues.playSong(this);\n return this.filters;\n }\n /**\n * Set the playing time to another position\n * @param {number} time Time in seconds\n * @returns {Queue} The guild queue\n */\n seek(time: number): Queue {\n if (typeof time !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", time, \"time\");\n if (isNaN(time) || time < 0) throw new DisTubeError(\"NUMBER_COMPARE\", \"time\", \"bigger or equal to\", 0);\n this.beginTime = time;\n this.queues.playSong(this);\n return this;\n }\n /**\n * Add a related song of the playing song to the queue\n * @returns {Promise<Song>} The added song\n * @throws {Error}\n */\n async addRelatedSong(): Promise<Song> {\n if (!this.songs?.[0]) throw new DisTubeError(\"NO_PLAYING\");\n const related = this.songs[0].related.find(v => !this.previousSongs.map(s => s.id).includes(v.id));\n if (!related || !(related instanceof Song)) throw new DisTubeError(\"NO_RELATED\");\n const song = await this.handler.resolveSong(this.clientMember, related.url);\n if (!(song instanceof Song)) throw new DisTubeError(\"CANNOT_PLAY_RELATED\");\n this.addToQueue(song);\n return song;\n }\n /**\n * Stop the guild stream\n */\n async stop() {\n await this.taskQueue.queuing();\n try {\n this.stopped = true;\n this.voice.stop();\n if (this.options.leaveOnStop) this.voice.leave();\n this.delete();\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Delete the queue\n */\n delete() {\n this.stopped = true;\n this.songs = [];\n this.previousSongs = [];\n this.queues.delete(this.id);\n this.emit(\"deleteQueue\", this);\n }\n /**\n * Toggle autoplay mode\n * @returns {boolean} Autoplay mode state\n */\n toggleAutoplay(): boolean {\n this.autoplay = !this.autoplay;\n return this.autoplay;\n }\n}\n\nexport default Queue;\n"]}
1
+ {"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";;;AAAA,kCAAsC;AACtC,0BAA+E;AAI/E;;;GAGG;AACH,MAAa,KAAM,SAAQ,kBAAW;IA0EpC;;;;;;OAMG;IACH,YAAY,OAAgB,EAAE,KAAmB,EAAE,IAAmB,EAAE,WAAyB;;QAC/F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf;;;WAGG;QACH,IAAI,CAAC,YAAY,GAAG,MAAA,KAAK,CAAC,OAAO,CAAC,KAAK,0CAAE,EAAiB,CAAC;QAC3D;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CA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AAC,SAAS,EAAE;YAClB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAiC,EAAE;gBAC/E,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;aACzD;SACF;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD;;;OAGG;IACH,cAAc;QACZ,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAtfD,sBAsfC;AAED,kBAAe,KAAK,CAAC","sourcesContent":["import { DisTubeBase } from \"../core\";\nimport { DisTubeError, RepeatMode, Song, TaskQueue, formatDuration } from \"..\";\nimport type { GuildMember, Snowflake, TextChannel } from \"discord.js\";\nimport type { DisTube, DisTubeVoice, DisTubeVoiceEvents, SearchResult } from \"..\";\n\n/**\n * Represents a queue.\n * @extends DisTubeBase\n */\nexport class Queue extends DisTubeBase {\n id: Snowflake;\n /**\n * Voice connection of this queue\n */\n voice: DisTubeVoice;\n /**\n * List of songs in the queue (The first one is the playing song)\n */\n songs: Song[];\n /**\n * List of the previous songs.\n */\n previousSongs: Song[];\n /**\n * Whether stream is currently stopped.\n * @private\n */\n stopped: boolean;\n /**\n * Whether or not the last song was skipped to next song.\n * @private\n */\n next: boolean;\n /**\n * Whether or not the last song was skipped to previous song.\n * @private\n */\n prev: boolean;\n /**\n * Whether or not the stream is currently playing.\n */\n playing: boolean;\n /**\n * Whether or not the stream is currently paused.\n */\n paused: boolean;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n */\n repeatMode: RepeatMode;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n */\n autoplay: boolean;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n */\n filters: string[];\n /**\n * What time in the song to begin (in seconds).\n */\n beginTime: number;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n */\n textChannel?: TextChannel;\n /**\n * Timeout for checking empty channel\n * @private\n */\n emptyTimeout?: NodeJS.Timeout;\n /**\n * The client user as a `GuildMember` of this queue's guild\n */\n clientMember: GuildMember;\n /**\n * Task queuing system\n */\n taskQueue: TaskQueue;\n listeners?: DisTubeVoiceEvents;\n /**\n * Create a queue for the guild\n * @param {DisTube} distube DisTube\n * @param {DisTubeVoice} voice Voice connection\n * @param {Song|Song[]} song First song(s)\n * @param {Discord.TextChannel?} textChannel Default text channel\n */\n constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: TextChannel) {\n super(distube);\n /**\n * The client user as a `GuildMember` of this queue's guild\n * @type {Discord.GuildMember}\n */\n this.clientMember = voice.channel.guild?.me as GuildMember;\n /**\n * Voice connection of this queue.\n * @type {DisTubeVoice}\n */\n this.voice = voice;\n /**\n * Queue id (Guild id)\n * @type {Discord.Snowflake}\n */\n this.id = voice.id;\n /**\n * Get or set the stream volume. Default value: `50`.\n * @type {number}\n */\n this.volume = 50;\n /**\n * List of songs in the queue (The first one is the playing song)\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(song) ? [...song] : [song];\n /**\n * List of the previous songs.\n * @type {Array<Song>}\n */\n this.previousSongs = [];\n /**\n * Whether stream is currently stopped.\n * @type {boolean}\n * @private\n */\n this.stopped = false;\n /**\n * Whether or not the last song was skipped to next song.\n * @type {boolean}\n * @private\n */\n this.next = false;\n /**\n * Whether or not the last song was skipped to previous song.\n * @type {boolean}\n * @private\n */\n this.prev = false;\n /**\n * Whether or not the stream is currently playing.\n * @type {boolean}\n */\n this.playing = true;\n /**\n * Whether or not the stream is currently paused.\n * @type {boolean}\n */\n this.paused = false;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n * @type {RepeatMode}\n */\n this.repeatMode = RepeatMode.DISABLED;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n * @type {boolean}\n */\n this.autoplay = false;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n * @type {Array<string>}\n */\n this.filters = [];\n /**\n * What time in the song to begin (in seconds).\n * @type {number}\n */\n this.beginTime = 0;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n * @type {Discord.TextChannel?}\n */\n this.textChannel = textChannel;\n /**\n * Timeout for checking empty channel\n * @type {*}\n * @private\n */\n this.emptyTimeout = undefined;\n /**\n * Task queuing system\n * @type {TaskQueue}\n * @private\n */\n this.taskQueue = new TaskQueue();\n /**\n * DisTubeVoice listener\n * @type {Object}\n * @private\n */\n this.listeners = undefined;\n }\n /**\n * Formatted duration string.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n /**\n * Queue's duration.\n * @type {number}\n */\n get duration() {\n return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;\n }\n /**\n * What time in the song is playing (in seconds).\n * @type {number}\n */\n get currentTime() {\n return this.voice.playbackDuration + this.beginTime;\n }\n /**\n * Formatted {@link Queue#currentTime} string.\n * @type {string}\n */\n get formattedCurrentTime() {\n return formatDuration(this.currentTime);\n }\n /**\n * The voice channel playing in.\n * @type {Discord.VoiceChannel|Discord.StageChannel|null}\n */\n get voiceChannel() {\n return this.clientMember.voice.channel;\n }\n get volume() {\n return this.voice.volume;\n }\n set volume(value: number) {\n this.voice.volume = value;\n }\n /**\n * Add a Song or an array of Song to the queue\n * @param {Song|Song[]} song Song to add\n * @param {number} [position=-1] Position to add, < 0 to add to the end of the queue\n * @param {boolean} [queuing=true] Wether or not waiting for unfinished tasks\n * @throws {Error}\n * @returns {Queue} The guild queue\n */\n addToQueue(song: Song | SearchResult | (Song | SearchResult)[], position = -1): Queue {\n const isArray = Array.isArray(song);\n if (!song || (isArray && !(song as Song[]).length)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Song\", \"SearchResult\", \"Array<Song|SearchResult>\"], song, \"song\");\n }\n if (position === 0) throw new DisTubeError(\"ADD_BEFORE_PLAYING\");\n if (position < 0) {\n if (isArray) this.songs.push(...(song as Song[]));\n else this.songs.push(song as Song);\n } else if (isArray) {\n this.songs.splice(position, 0, ...(song as Song[]));\n } else {\n this.songs.splice(position, 0, song as Song);\n }\n if (isArray) (song as Song[]).map(s => delete s.formats);\n else delete (song as Song).formats;\n return this;\n }\n /**\n * Pause the guild stream\n * @returns {Queue} The guild queue\n */\n pause(): Queue {\n if (this.paused) throw new DisTubeError(\"PAUSED\");\n this.playing = false;\n this.paused = true;\n this.voice.pause();\n return this;\n }\n /**\n * Resume the guild stream\n * @returns {Queue} The guild queue\n */\n resume(): Queue {\n if (this.playing) throw new DisTubeError(\"RESUMED\");\n this.playing = true;\n this.paused = false;\n this.voice.unpause();\n return this;\n }\n /**\n * Set the guild stream's volume\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n */\n setVolume(percent: number): Queue {\n this.volume = percent;\n return this;\n }\n\n /**\n * Skip the playing song if there is a next song in the queue.\n * <info>If {@link Queue#autoplay} is `true` and there is no up next song,\n * DisTube will add and play a related song.</info>\n * @returns {Promise<Song>} The song will skip to\n * @throws {Error}\n */\n async skip(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (this.songs.length <= 1) {\n if (this.autoplay) await this.addRelatedSong();\n else throw new DisTubeError(\"NO_UP_NEXT\");\n }\n const song = this.songs[1];\n this.next = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n\n /**\n * Play the previous song if exists\n * @returns {Song} The guild queue\n * @throws {Error}\n */\n async previous(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (!this.options.savePreviousSongs) throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n if (this.previousSongs?.length === 0 && this.repeatMode !== RepeatMode.QUEUE) {\n throw new DisTubeError(\"NO_PREVIOUS\");\n }\n const song =\n this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];\n this.prev = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Shuffle the queue's songs\n * @returns {Promise<Queue>} The guild queue\n */\n async shuffle(): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (!this.songs.length) return this;\n const playing = this.songs.shift() as Song;\n for (let i = this.songs.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];\n }\n this.songs.unshift(playing);\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Jump to the song position in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {number} position The song position to play\n * @returns {Promise<Queue>} The guild queue\n * @throws {Error} if `num` is invalid number\n */\n async jump(position: number): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (typeof position !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", position, \"position\");\n if (!position || position > this.songs.length || -position > this.previousSongs.length) {\n throw new DisTubeError(\"NO_SONG_POSITION\");\n }\n if (position > 0) {\n const nextSongs = this.songs.splice(position - 1);\n if (this.options.savePreviousSongs) {\n this.previousSongs.push(...this.songs);\n } else {\n this.previousSongs.push(\n ...this.songs.map(s => {\n return { id: s.id } as Song;\n }),\n );\n }\n this.songs = nextSongs;\n this.next = true;\n } else if (!this.options.savePreviousSongs) {\n throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n } else {\n this.prev = true;\n if (position !== -1) this.songs.unshift(...this.previousSongs.splice(position + 1));\n }\n this.voice.stop();\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Set the repeat mode of the guild queue.\\\n * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`\n * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)\n * @returns {RepeatMode} The new repeat mode\n */\n setRepeatMode(mode?: RepeatMode): RepeatMode {\n if (mode !== undefined && !Object.values(RepeatMode).includes(mode)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"RepeatMode\", \"undefined\"], mode, \"mode\");\n }\n if (mode === undefined) this.repeatMode = (this.repeatMode + 1) % 3;\n else if (this.repeatMode === mode) this.repeatMode = RepeatMode.DISABLED;\n else this.repeatMode = mode;\n return this.repeatMode;\n }\n /**\n * Enable or disable filter(s) of the queue.\n * Available filters: {@link Filters}\n * @param {string|string[]|false} filter A filter name, an array of filter name or `false` to clear all the filters\n * @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled\n * @returns {Array<string>} Enabled filters.\n * @throws {Error}\n */\n setFilter(filter: string | string[] | false, force = false): Array<string> {\n if (Array.isArray(filter)) {\n filter = filter.filter(f => Object.prototype.hasOwnProperty.call(this.distube.filters, f));\n if (!filter.length) throw new DisTubeError(\"EMPTY_FILTERED_ARRAY\", \"filter\", \"filter name\");\n for (const f of filter) {\n if (this.filters.includes(f)) {\n if (!force) this.filters.splice(this.filters.indexOf(f), 1);\n } else {\n this.filters.push(f);\n }\n }\n } else if (filter === false) {\n this.filters = [];\n } else if (!Object.prototype.hasOwnProperty.call(this.distube.filters, filter)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"filter name\", filter, \"filter\");\n } else if (this.filters.includes(filter)) {\n if (!force) this.filters.splice(this.filters.indexOf(filter), 1);\n } else {\n this.filters.push(filter);\n }\n this.beginTime = this.currentTime;\n this.queues.playSong(this);\n return this.filters;\n }\n /**\n * Set the playing time to another position\n * @param {number} time Time in seconds\n * @returns {Queue} The guild queue\n */\n seek(time: number): Queue {\n if (typeof time !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", time, \"time\");\n if (isNaN(time) || time < 0) throw new DisTubeError(\"NUMBER_COMPARE\", \"time\", \"bigger or equal to\", 0);\n this.beginTime = time;\n this.queues.playSong(this);\n return this;\n }\n /**\n * Add a related song of the playing song to the queue\n * @returns {Promise<Song>} The added song\n * @throws {Error}\n */\n async addRelatedSong(): Promise<Song> {\n if (!this.songs?.[0]) throw new DisTubeError(\"NO_PLAYING\");\n const related = this.songs[0].related.find(v => !this.previousSongs.map(s => s.id).includes(v.id));\n if (!related || !(related instanceof Song)) throw new DisTubeError(\"NO_RELATED\");\n const song = await this.handler.resolveSong(this.clientMember, related.url);\n if (!(song instanceof Song)) throw new DisTubeError(\"CANNOT_PLAY_RELATED\");\n this.addToQueue(song);\n return song;\n }\n /**\n * Stop the guild stream\n */\n async stop() {\n await this.taskQueue.queuing();\n try {\n this.stopped = true;\n this.voice.stop();\n if (this.options.leaveOnStop) this.voice.leave();\n this.delete();\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Delete the queue from the manager\n * (This does not leave the queue even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)\n * @private\n */\n delete() {\n this.stopped = true;\n this.songs = [];\n this.previousSongs = [];\n if (this.listeners) {\n for (const event of Object.keys(this.listeners) as (keyof DisTubeVoiceEvents)[]) {\n this.voice.removeListener(event, this.listeners[event]);\n }\n }\n this.queues.delete(this.id);\n this.emit(\"deleteQueue\", this);\n }\n /**\n * Toggle autoplay mode\n * @returns {boolean} Autoplay mode state\n */\n toggleAutoplay(): boolean {\n this.autoplay = !this.autoplay;\n return this.autoplay;\n }\n}\n\nexport default Queue;\n"]}
@@ -47,12 +47,12 @@ class SearchResult {
47
47
  * [Video only] Video duration.
48
48
  * @type {number}
49
49
  */
50
- this.duration = this.isLive ? 0 : __1.toSecond(info.duration);
50
+ this.duration = this.isLive ? 0 : (0, __1.toSecond)(info.duration);
51
51
  /**
52
52
  * [Video only] Formatted duration string `hh:mm:ss` or `mm:ss`.
53
53
  * @type {string}
54
54
  */
55
- this.formattedDuration = this.isLive ? "Live" : __1.formatDuration(this.duration);
55
+ this.formattedDuration = this.isLive ? "Live" : (0, __1.formatDuration)(this.duration);
56
56
  /**
57
57
  * [Video only] Video thumbnail.
58
58
  * @type {string?}
@@ -1 +1 @@
1
- {"version":3,"file":"SearchResult.js","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":";;;AAAA,0BAA4D;AAG5D,0CAA0C;AAC1C,MAAa,YAAY;IAkBvB;;;OAGG;IACH,YAAY,IAAsB;;QAChC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI,GAAG,IAAa,CAAC;YACrB;;;eAGG;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACxB;;;eAGG;YACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC1B;;;eAGG;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1D;;;eAGG;YACH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9E;;;eAGG;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;SACjC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YACnC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;SAC/F;QACD;;;;;WAKG;QACH,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,EAAE,MAAA,CAAE,IAAc,CAAC,MAAM,IAAK,IAAiB,CAAC,KAAK,CAAC,0CAAE,IAAI;YAChE,GAAG,EAAE,MAAA,CAAE,IAAc,CAAC,MAAM,IAAK,IAAiB,CAAC,KAAK,CAAC,0CAAE,GAAG;SAC/D,CAAC;IACJ,CAAC;CACF;AArFD,oCAqFC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["import { DisTubeError, formatDuration, toSecond } from \"..\";\nimport type { Playlist, Video } from \"@distube/ytsr\";\n\n/** Class representing a search result. */\nexport class SearchResult {\n source: \"youtube\";\n type: \"video\" | \"playlist\";\n id: string;\n name: string;\n url: string;\n views?: number;\n isLive?: boolean;\n duration?: number;\n formattedDuration?: string;\n thumbnail?: string;\n /** Video or playlist uploader */\n uploader: {\n /** Uploader name */\n name?: string;\n /** Uploader url */\n url?: string;\n };\n /**\n * Create a search result\n * @param {Object} info ytsr result\n */\n constructor(info: Video | Playlist) {\n this.source = \"youtube\";\n /**\n * Type of SearchResult (`video` or `playlist`)\n * @type {string}\n */\n this.type = info.type;\n /**\n * YouTube video or playlist id\n * @type {string}\n */\n this.id = info.id;\n /**\n * Video or playlist title.\n * @type {string}\n */\n this.name = info.name;\n /**\n * Video or playlist URL.\n * @type {string}\n */\n this.url = info.url;\n if (this.type === \"video\") {\n info = info as Video;\n /**\n * [Video only] Video or playlist views count\n * @type {number}\n */\n this.views = info.views;\n /**\n * [Video only] Indicates if the video is an active live.\n * @type {boolean?}\n */\n this.isLive = info.isLive;\n /**\n * [Video only] Video duration.\n * @type {number}\n */\n this.duration = this.isLive ? 0 : toSecond(info.duration);\n /**\n * [Video only] Formatted duration string `hh:mm:ss` or `mm:ss`.\n * @type {string}\n */\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n /**\n * [Video only] Video thumbnail.\n * @type {string?}\n */\n this.thumbnail = info.thumbnail;\n } else if (this.type !== \"playlist\") {\n throw new DisTubeError(\"INVALID_TYPE\", [\"video\", \"playlist\"], this.type, \"SearchResult.type\");\n }\n /**\n * Song uploader\n * @type {Object}\n * @prop {string?} name Uploader name\n * @prop {string?} url Uploader url\n */\n this.uploader = {\n name: ((info as Video).author || (info as Playlist).owner)?.name,\n url: ((info as Video).author || (info as Playlist).owner)?.url,\n };\n }\n}\n\nexport default SearchResult;\n"]}
1
+ {"version":3,"file":"SearchResult.js","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":";;;AAAA,0BAA4D;AAG5D,0CAA0C;AAC1C,MAAa,YAAY;IAkBvB;;;OAGG;IACH,YAAY,IAAsB;;QAChC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI,GAAG,IAAa,CAAC;YACrB;;;eAGG;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACxB;;;eAGG;YACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC1B;;;eAGG;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,YAAQ,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1D;;;eAGG;YACH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,kBAAc,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9E;;;eAGG;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;SACjC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YACnC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;SAC/F;QACD;;;;;WAKG;QACH,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,EAAE,MAAA,CAAE,IAAc,CAAC,MAAM,IAAK,IAAiB,CAAC,KAAK,CAAC,0CAAE,IAAI;YAChE,GAAG,EAAE,MAAA,CAAE,IAAc,CAAC,MAAM,IAAK,IAAiB,CAAC,KAAK,CAAC,0CAAE,GAAG;SAC/D,CAAC;IACJ,CAAC;CACF;AArFD,oCAqFC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["import { DisTubeError, formatDuration, toSecond } from \"..\";\nimport type { Playlist, Video } from \"@distube/ytsr\";\n\n/** Class representing a search result. */\nexport class SearchResult {\n source: \"youtube\";\n type: \"video\" | \"playlist\";\n id: string;\n name: string;\n url: string;\n views?: number;\n isLive?: boolean;\n duration?: number;\n formattedDuration?: string;\n thumbnail?: string;\n /** Video or playlist uploader */\n uploader: {\n /** Uploader name */\n name?: string;\n /** Uploader url */\n url?: string;\n };\n /**\n * Create a search result\n * @param {Object} info ytsr result\n */\n constructor(info: Video | Playlist) {\n this.source = \"youtube\";\n /**\n * Type of SearchResult (`video` or `playlist`)\n * @type {string}\n */\n this.type = info.type;\n /**\n * YouTube video or playlist id\n * @type {string}\n */\n this.id = info.id;\n /**\n * Video or playlist title.\n * @type {string}\n */\n this.name = info.name;\n /**\n * Video or playlist URL.\n * @type {string}\n */\n this.url = info.url;\n if (this.type === \"video\") {\n info = info as Video;\n /**\n * [Video only] Video or playlist views count\n * @type {number}\n */\n this.views = info.views;\n /**\n * [Video only] Indicates if the video is an active live.\n * @type {boolean?}\n */\n this.isLive = info.isLive;\n /**\n * [Video only] Video duration.\n * @type {number}\n */\n this.duration = this.isLive ? 0 : toSecond(info.duration);\n /**\n * [Video only] Formatted duration string `hh:mm:ss` or `mm:ss`.\n * @type {string}\n */\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n /**\n * [Video only] Video thumbnail.\n * @type {string?}\n */\n this.thumbnail = info.thumbnail;\n } else if (this.type !== \"playlist\") {\n throw new DisTubeError(\"INVALID_TYPE\", [\"video\", \"playlist\"], this.type, \"SearchResult.type\");\n }\n /**\n * Song uploader\n * @type {Object}\n * @prop {string?} name Uploader name\n * @prop {string?} url Uploader url\n */\n this.uploader = {\n name: ((info as Video).author || (info as Playlist).owner)?.name,\n url: ((info as Video).author || (info as Playlist).owner)?.url,\n };\n }\n}\n\nexport default SearchResult;\n"]}
@@ -1,14 +1,15 @@
1
1
  import Playlist from "./Playlist";
2
2
  import type ytdl from "@distube/ytdl-core";
3
- import type { SearchResult } from ".";
4
- import type { Chapter, OtherSongInfo } from "..";
5
3
  import type { GuildMember, User } from "discord.js";
4
+ import type { Chapter, OtherSongInfo, SearchResult } from "..";
6
5
  /**
7
6
  * Class representing a song.
8
- * <info>If {@link Song} is added from a YouTube {@link SearchResult} or {@link Playlist}, some info will be missing to save your resources.
9
- * It will be filled when emitting {@link DisTube#playSong} event.
10
7
  *
11
- * Missing info: {@link Song#likes}, {@link Song#dislikes}, {@link Song#streamURL}, {@link Song#related}, {@link Song#chapters}, {@link Song#age_restricted}</info>
8
+ * <info>If {@link Song} is added from a YouTube {@link SearchResult} or {@link Playlist},
9
+ * some info will be missing to save your resources. It will be filled when emitting {@link DisTube#playSong} event.
10
+ *
11
+ * Missing info: {@link Song#likes}, {@link Song#dislikes}, {@link Song#streamURL},
12
+ * {@link Song#related}, {@link Song#chapters}, {@link Song#age_restricted}</info>
12
13
  */
13
14
  export declare class Song {
14
15
  source: string;
@@ -27,11 +28,8 @@ export declare class Song {
27
28
  views: number;
28
29
  likes: number;
29
30
  dislikes: number;
30
- /** Song uploader */
31
31
  uploader: {
32
- /** Uploader name */
33
32
  name?: string;
34
- /** Uploader url */
35
33
  url?: string;
36
34
  };
37
35
  age_restricted: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Song.d.ts","sourceRoot":"","sources":["../../src/struct/Song.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEpD;;;;;;GAMG;AACH,qBAAa,IAAI;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAG,OAAO,CAAC;IACjB,QAAQ,EAAG,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,GAAG,EAAG,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAG,IAAI,EAAE,CAAC;IACjB,KAAK,EAAG,MAAM,CAAC;IACf,KAAK,EAAG,MAAM,CAAC;IACf,QAAQ,EAAG,MAAM,CAAC;IAClB,oBAAoB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