distube 3.0.0-beta.9 → 3.0.3

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 (158) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +64 -51
  3. package/dist/DisTube.d.ts +522 -0
  4. package/dist/DisTube.d.ts.map +1 -0
  5. package/dist/DisTube.js +794 -0
  6. package/dist/DisTube.js.map +1 -0
  7. package/dist/constant.d.ts +130 -0
  8. package/dist/constant.d.ts.map +1 -0
  9. package/dist/constant.js +150 -0
  10. package/dist/constant.js.map +1 -0
  11. package/dist/core/DisTubeBase.d.ts +55 -0
  12. package/dist/core/DisTubeBase.d.ts.map +1 -0
  13. package/dist/core/DisTubeBase.js +76 -0
  14. package/dist/core/DisTubeBase.js.map +1 -0
  15. package/dist/core/DisTubeHandler.d.ts +95 -0
  16. package/dist/core/DisTubeHandler.d.ts.map +1 -0
  17. package/dist/core/DisTubeHandler.js +337 -0
  18. package/dist/core/DisTubeHandler.js.map +1 -0
  19. package/dist/core/DisTubeOptions.d.ts +26 -0
  20. package/dist/core/DisTubeOptions.d.ts.map +1 -0
  21. package/dist/core/DisTubeOptions.js +93 -0
  22. package/dist/core/DisTubeOptions.js.map +1 -0
  23. package/dist/core/DisTubeStream.d.ts +52 -0
  24. package/dist/core/DisTubeStream.d.ts.map +1 -0
  25. package/dist/core/DisTubeStream.js +109 -0
  26. package/dist/core/DisTubeStream.js.map +1 -0
  27. package/dist/core/index.d.ts +7 -0
  28. package/dist/core/index.d.ts.map +1 -0
  29. package/dist/core/index.js +19 -0
  30. package/dist/core/index.js.map +1 -0
  31. package/dist/core/manager/BaseManager.d.ts +18 -0
  32. package/dist/core/manager/BaseManager.d.ts.map +1 -0
  33. package/dist/core/manager/BaseManager.js +44 -0
  34. package/dist/core/manager/BaseManager.js.map +1 -0
  35. package/dist/core/manager/QueueManager.d.ts +60 -0
  36. package/dist/core/manager/QueueManager.d.ts.map +1 -0
  37. package/dist/core/manager/QueueManager.js +202 -0
  38. package/dist/core/manager/QueueManager.js.map +1 -0
  39. package/dist/core/manager/index.d.ts +3 -0
  40. package/dist/core/manager/index.d.ts.map +1 -0
  41. package/dist/core/manager/index.js +15 -0
  42. package/dist/core/manager/index.js.map +1 -0
  43. package/dist/core/voice/DJSAdapter.d.ts +4 -0
  44. package/dist/core/voice/DJSAdapter.d.ts.map +1 -0
  45. package/dist/core/voice/DJSAdapter.js +61 -0
  46. package/dist/core/voice/DJSAdapter.js.map +1 -0
  47. package/dist/core/voice/DisTubeVoice.d.ts +85 -0
  48. package/dist/core/voice/DisTubeVoice.d.ts.map +1 -0
  49. package/dist/core/voice/DisTubeVoice.js +246 -0
  50. package/dist/core/voice/DisTubeVoice.js.map +1 -0
  51. package/dist/core/voice/DisTubeVoiceManager.d.ts +41 -0
  52. package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -0
  53. package/dist/core/voice/DisTubeVoiceManager.js +67 -0
  54. package/dist/core/voice/DisTubeVoiceManager.js.map +1 -0
  55. package/dist/core/voice/index.d.ts +4 -0
  56. package/dist/core/voice/index.d.ts.map +1 -0
  57. package/dist/core/voice/index.js +16 -0
  58. package/dist/core/voice/index.js.map +1 -0
  59. package/dist/index.d.ts +8 -0
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.js +23 -0
  62. package/dist/index.js.map +1 -0
  63. package/dist/plugin/http.d.ts +8 -0
  64. package/dist/plugin/http.d.ts.map +1 -0
  65. package/dist/plugin/http.js +20 -0
  66. package/dist/plugin/http.js.map +1 -0
  67. package/dist/plugin/https.d.ts +14 -0
  68. package/dist/plugin/https.d.ts.map +1 -0
  69. package/dist/plugin/https.js +50 -0
  70. package/dist/plugin/https.js.map +1 -0
  71. package/dist/plugin/index.d.ts +4 -0
  72. package/dist/plugin/index.d.ts.map +1 -0
  73. package/dist/plugin/index.js +16 -0
  74. package/dist/plugin/index.js.map +1 -0
  75. package/dist/plugin/youtube-dl.d.ts +11 -0
  76. package/dist/plugin/youtube-dl.d.ts.map +1 -0
  77. package/dist/plugin/youtube-dl.js +75 -0
  78. package/dist/plugin/youtube-dl.js.map +1 -0
  79. package/dist/struct/CustomPlugin.d.ts +27 -0
  80. package/dist/struct/CustomPlugin.d.ts.map +1 -0
  81. package/dist/struct/CustomPlugin.js +35 -0
  82. package/dist/struct/CustomPlugin.js.map +1 -0
  83. package/dist/struct/DisTubeError.d.ts +56 -0
  84. package/dist/struct/DisTubeError.d.ts.map +1 -0
  85. package/dist/struct/DisTubeError.js +75 -0
  86. package/dist/struct/DisTubeError.js.map +1 -0
  87. package/dist/struct/ExtractorPlugin.d.ts +29 -0
  88. package/dist/struct/ExtractorPlugin.d.ts.map +1 -0
  89. package/dist/struct/ExtractorPlugin.js +32 -0
  90. package/dist/struct/ExtractorPlugin.js.map +1 -0
  91. package/dist/struct/Playlist.d.ts +42 -0
  92. package/dist/struct/Playlist.d.ts.map +1 -0
  93. package/dist/struct/Playlist.js +104 -0
  94. package/dist/struct/Playlist.js.map +1 -0
  95. package/dist/struct/Plugin.d.ts +82 -0
  96. package/dist/struct/Plugin.d.ts.map +1 -0
  97. package/dist/struct/Plugin.js +108 -0
  98. package/dist/struct/Plugin.js.map +1 -0
  99. package/dist/struct/Queue.d.ts +217 -0
  100. package/dist/struct/Queue.d.ts.map +1 -0
  101. package/dist/struct/Queue.js +481 -0
  102. package/dist/struct/Queue.js.map +1 -0
  103. package/dist/struct/SearchResult.d.ts +28 -0
  104. package/dist/struct/SearchResult.d.ts.map +1 -0
  105. package/dist/struct/SearchResult.js +79 -0
  106. package/dist/struct/SearchResult.js.map +1 -0
  107. package/dist/struct/Song.d.ts +68 -0
  108. package/dist/struct/Song.d.ts.map +1 -0
  109. package/dist/struct/Song.js +229 -0
  110. package/dist/struct/Song.js.map +1 -0
  111. package/dist/struct/TaskQueue.d.ts +33 -0
  112. package/dist/struct/TaskQueue.d.ts.map +1 -0
  113. package/dist/struct/TaskQueue.js +58 -0
  114. package/dist/struct/TaskQueue.js.map +1 -0
  115. package/dist/struct/index.d.ts +10 -0
  116. package/dist/struct/index.d.ts.map +1 -0
  117. package/dist/struct/index.js +22 -0
  118. package/dist/struct/index.js.map +1 -0
  119. package/dist/tsconfig.tsbuildinfo +1 -0
  120. package/dist/type.d.ts +159 -0
  121. package/dist/type.d.ts.map +1 -0
  122. package/dist/type.js +3 -0
  123. package/dist/type.js.map +1 -0
  124. package/dist/util.d.ts +47 -0
  125. package/dist/util.d.ts.map +1 -0
  126. package/dist/util.js +205 -0
  127. package/dist/util.js.map +1 -0
  128. package/package.json +88 -62
  129. package/src/DisTube.js +0 -851
  130. package/src/DisTubeBase.js +0 -39
  131. package/src/DisTubeHandler.js +0 -440
  132. package/src/DisTubeOptions.js +0 -82
  133. package/src/Filter.js +0 -36
  134. package/src/Playlist.js +0 -75
  135. package/src/Plugin/CustomPlugin.js +0 -26
  136. package/src/Plugin/ExtractorPlugin.js +0 -25
  137. package/src/Plugin/Plugin.js +0 -36
  138. package/src/Plugin/http.js +0 -27
  139. package/src/Plugin/https.js +0 -27
  140. package/src/Queue.js +0 -340
  141. package/src/SearchResult.js +0 -57
  142. package/src/Song.js +0 -169
  143. package/src/util.js +0 -65
  144. package/typings/DisTube.d.ts +0 -553
  145. package/typings/DisTubeBase.d.ts +0 -31
  146. package/typings/DisTubeHandler.d.ts +0 -130
  147. package/typings/DisTubeOptions.d.ts +0 -5
  148. package/typings/Filter.d.ts +0 -83
  149. package/typings/Playlist.d.ts +0 -58
  150. package/typings/Plugin/CustomPlugin.d.ts +0 -21
  151. package/typings/Plugin/ExtractorPlugin.d.ts +0 -20
  152. package/typings/Plugin/Plugin.d.ts +0 -31
  153. package/typings/Plugin/http.d.ts +0 -4
  154. package/typings/Plugin/https.d.ts +0 -4
  155. package/typings/Queue.d.ts +0 -227
  156. package/typings/SearchResult.d.ts +0 -51
  157. package/typings/Song.d.ts +0 -153
  158. package/typings/util.d.ts +0 -6
@@ -0,0 +1,522 @@
1
+ import { TypedEmitter } from "tiny-typed-emitter";
2
+ import { DisTubeHandler, DisTubeVoiceManager, Options, Playlist, Queue, QueueManager, SearchResult } from ".";
3
+ import type { Client, GuildMember, Message, StageChannel, TextChannel, VoiceChannel } from "discord.js";
4
+ import type { CustomPlugin, DisTubeEvents, DisTubeOptions, ExtractorPlugin, Filters, GuildIDResolvable, Song } from ".";
5
+ /**
6
+ * DisTube class
7
+ * @extends EventEmitter
8
+ */
9
+ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
10
+ handler: DisTubeHandler;
11
+ options: Options;
12
+ client: Client;
13
+ queues: QueueManager;
14
+ voices: DisTubeVoiceManager;
15
+ extractorPlugins: ExtractorPlugin[];
16
+ customPlugins: CustomPlugin[];
17
+ filters: Filters;
18
+ /**
19
+ * Create a new DisTube class.
20
+ * @param {Discord.Client} client Discord.JS client
21
+ * @param {DisTubeOptions} [otp] Custom DisTube options
22
+ * @example
23
+ * const Discord = require('discord.js'),
24
+ * DisTube = require('distube'),
25
+ * client = new Discord.Client();
26
+ * // Create a new DisTube
27
+ * const distube = new DisTube.default(client, { searchSongs: 10 });
28
+ * // client.DisTube = distube // make it access easily
29
+ * client.login("Your Discord Bot Token")
30
+ */
31
+ constructor(client: Client, otp?: DisTubeOptions);
32
+ /**
33
+ * Shorthand method for {@link DisTube#playVoiceChannel}
34
+ * @returns {Promise<void>}
35
+ * @param {Discord.Message} message A message from guild channel
36
+ * @param {string|Song|SearchResult|Playlist} song URL | Search string |
37
+ * {@link Song} | {@link SearchResult} | {@link Playlist}
38
+ * @param {Object} [options] Optional options
39
+ * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
40
+ * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
41
+ * (after the playing song if exists)
42
+ * @example
43
+ * client.on('message', (message) => {
44
+ * if (!message.content.startsWith(config.prefix)) return;
45
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
46
+ * const command = args.shift();
47
+ * if (command == "play")
48
+ * distube.play(message, args.join(" "));
49
+ * });
50
+ */
51
+ play(message: Message, song: string | Song | SearchResult | Playlist, options?: {
52
+ skip?: boolean;
53
+ unshift?: boolean;
54
+ }): Promise<void>;
55
+ /**
56
+ * Play / add a song or playlist from url. Search and play a song if it is not a valid url.
57
+ * Emit {@link DisTube#addList}, {@link DisTube#addSong} or {@link DisTube#playSong} after executing
58
+ * @returns {Promise<void>}
59
+ * @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
60
+ * @param {string|Song|SearchResult|Playlist} song URL | Search string |
61
+ * {@link Song} | {@link SearchResult} | {@link Playlist}
62
+ * @param {Object} [options] Optional options
63
+ * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
64
+ * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
65
+ * (after the playing song if exists)
66
+ * @param {Discord.GuildMember} [options.member] Requested user (default is your bot)
67
+ * @param {Discord.TextChannel} [options.textChannel] Default {@link Queue#textChannel} (if the queue wasn't created)
68
+ * @param {Discord.Message} [options.message] Called message (For built-in search events. If this is a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy value}, it will play the first result instead)
69
+ */
70
+ playVoiceChannel(voiceChannel: VoiceChannel | StageChannel, song: string | Song | SearchResult | Playlist | null, options?: {
71
+ skip?: boolean;
72
+ unshift?: boolean;
73
+ member?: GuildMember;
74
+ textChannel?: TextChannel;
75
+ message?: Message;
76
+ }): Promise<void>;
77
+ /**
78
+ * <info>Shorthand method of {@link DisTubeHandler#createCustomPlaylist} and {@link DisTube#playVoiceChannel}
79
+ *
80
+ * If you doesn't have a user message (interaction,...),
81
+ * see {@link DisTubeHandler#createCustomPlaylist} example</info>
82
+ *
83
+ * Play or add array of video urls.
84
+ * {@link DisTube#event:playSong} or {@link DisTube#event:addList} will be emitted
85
+ * with `playlist`'s properties include `properties` parameter's properties such as
86
+ * `user`, `songs`, `duration`, `formattedDuration`, `thumbnail` like {@link Playlist}
87
+ * @returns {Promise<void>}
88
+ * @param {Discord.Message} message A message from guild channel
89
+ * @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult
90
+ * @param {Object} [properties={}] Additional properties such as `name`
91
+ * @param {Object} [options] Optional options
92
+ * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
93
+ * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
94
+ * (after the playing song if exists)
95
+ * @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel
96
+ * @example
97
+ * const songs = ["https://www.youtube.com/watch?v=xxx", "https://www.youtube.com/watch?v=yyy"];
98
+ * distube.playCustomPlaylist(message, songs, { name: "My playlist name" });
99
+ * // Fetching custom playlist sequentially (reduce lag for low specs)
100
+ * distube.playCustomPlaylist(message, songs, { name: "My playlist name" }, false, false);
101
+ */
102
+ playCustomPlaylist(message: Message, songs: Array<string | Song | SearchResult>, properties?: any, options?: {
103
+ skip?: boolean;
104
+ unshift?: boolean;
105
+ parallel?: boolean;
106
+ }): Promise<void>;
107
+ /**
108
+ * Search for a song.
109
+ * You can customize how user answers instead of send a number.
110
+ * Then use {@link DisTube#play} or {@link DisTube#playVoiceChannel} to play it.
111
+ * @param {string} string The string search for
112
+ * @param {Object} options Search options
113
+ * @param {number} [options.limit=10] Limit the results
114
+ * @param {'video'|'playlist'} [options.type='video'] Type of results (`video` or `playlist`).
115
+ * @param {boolean} [options.safeSearch=false] Whether or not use safe search (YouTube restricted mode)
116
+ * @throws {Error}
117
+ * @returns {Promise<Array<SearchResult>>} Array of results
118
+ */
119
+ search(string: string, options?: {
120
+ type?: "video" | "playlist";
121
+ limit?: number;
122
+ safeSearch?: boolean;
123
+ retried?: boolean;
124
+ }): Promise<Array<SearchResult>>;
125
+ /**
126
+ * Get the guild queue
127
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
128
+ * @returns {Queue?}
129
+ * @throws {Error}
130
+ * @example
131
+ * client.on('message', (message) => {
132
+ * if (!message.content.startsWith(config.prefix)) return;
133
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
134
+ * const command = args.shift();
135
+ * if (command == "queue") {
136
+ * const queue = distube.getQueue(message);
137
+ * message.channel.send('Current queue:\n' + queue.songs.map((song, id) =>
138
+ * `**${id+1}**. [${song.name}](${song.url}) - \`${song.formattedDuration}\``
139
+ * ).join("\n"));
140
+ * }
141
+ * });
142
+ */
143
+ getQueue(queue: GuildIDResolvable): Queue | undefined;
144
+ /**
145
+ * Pause the guild stream
146
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
147
+ * @returns {Queue} The guild queue
148
+ * @throws {Error}
149
+ */
150
+ pause(queue: GuildIDResolvable): Queue;
151
+ /**
152
+ * Resume the guild stream
153
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
154
+ * @returns {Queue} The guild queue
155
+ * @throws {Error}
156
+ */
157
+ resume(queue: GuildIDResolvable): Queue;
158
+ /**
159
+ * Stop the guild stream
160
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
161
+ * @returns {Promise<void>}
162
+ * @throws {Error}
163
+ * @example
164
+ * client.on('message', (message) => {
165
+ * if (!message.content.startsWith(config.prefix)) return;
166
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
167
+ * const command = args.shift();
168
+ * if (command == "stop") {
169
+ * distube.stop(message);
170
+ * message.channel.send("Stopped the queue!");
171
+ * }
172
+ * });
173
+ */
174
+ stop(queue: GuildIDResolvable): Promise<void>;
175
+ /**
176
+ * Set the guild stream's volume
177
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
178
+ * @param {number} percent The percentage of volume you want to set
179
+ * @returns {Queue} The guild queue
180
+ * @throws {Error}
181
+ * @example
182
+ * client.on('message', (message) => {
183
+ * if (!message.content.startsWith(config.prefix)) return;
184
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
185
+ * const command = args.shift();
186
+ * if (command == "volume")
187
+ * distube.setVolume(message, Number(args[0]));
188
+ * });
189
+ */
190
+ setVolume(queue: GuildIDResolvable, percent: number): Queue;
191
+ /**
192
+ * Skip the playing song if there is a next song in the queue.
193
+ * <info>If {@link Queue#autoplay} is `true` and there is no up next song,
194
+ * DisTube will add and play a related song.</info>
195
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
196
+ * @returns {Promise<Song>} The new Song will be played
197
+ * @throws {Error}
198
+ * @example
199
+ * client.on('message', (message) => {
200
+ * if (!message.content.startsWith(config.prefix)) return;
201
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
202
+ * const command = args.shift();
203
+ * if (command == "skip")
204
+ * distube.skip(message);
205
+ * });
206
+ */
207
+ skip(queue: GuildIDResolvable): Promise<Song>;
208
+ /**
209
+ * Play the previous song
210
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
211
+ * @returns {Promise<Song>} The new Song will be played
212
+ * @throws {Error}
213
+ * @example
214
+ * client.on('message', (message) => {
215
+ * if (!message.content.startsWith(config.prefix)) return;
216
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
217
+ * const command = args.shift();
218
+ * if (command == "previous")
219
+ * distube.previous(message);
220
+ * });
221
+ */
222
+ previous(queue: GuildIDResolvable): Promise<Song>;
223
+ /**
224
+ * Shuffle the guild queue songs
225
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
226
+ * @returns {Promise<Queue>} The guild queue
227
+ * @example
228
+ * client.on('message', (message) => {
229
+ * if (!message.content.startsWith(config.prefix)) return;
230
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
231
+ * const command = args.shift();
232
+ * if (command == "shuffle")
233
+ * distube.shuffle(message);
234
+ * });
235
+ */
236
+ shuffle(queue: GuildIDResolvable): Promise<Queue>;
237
+ /**
238
+ * Jump to the song number in the queue.
239
+ * The next one is 1, 2,...
240
+ * The previous one is -1, -2,...
241
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
242
+ * @param {number} num The song number to play
243
+ * @returns {Promise<Queue>} The guild queue
244
+ * @throws {Error} if `num` is invalid number (0 < num < {@link Queue#songs}.length)
245
+ * @example
246
+ * client.on('message', (message) => {
247
+ * if (!message.content.startsWith(config.prefix)) return;
248
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
249
+ * const command = args.shift();
250
+ * if (command == "jump")
251
+ * distube.jump(message, parseInt(args[0]))
252
+ * .catch(err => message.channel.send("Invalid song number."));
253
+ * });
254
+ */
255
+ jump(queue: GuildIDResolvable, num: number): Promise<Queue>;
256
+ /**
257
+ * Set the repeat mode of the guild queue.\
258
+ * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
259
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
260
+ * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
261
+ * @returns {RepeatMode} The new repeat mode
262
+ * @example
263
+ * client.on('message', (message) => {
264
+ * if (!message.content.startsWith(config.prefix)) return;
265
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
266
+ * const command = args.shift();
267
+ * if (command == "repeat") {
268
+ * let mode = distube.setRepeatMode(message, parseInt(args[0]));
269
+ * mode = mode ? mode == 2 ? "Repeat queue" : "Repeat song" : "Off";
270
+ * message.channel.send("Set repeat mode to `" + mode + "`");
271
+ * }
272
+ * });
273
+ * @example
274
+ * const { RepeatMode } = require("distube");
275
+ * let mode;
276
+ * switch(distube.setRepeatMode(message, parseInt(args[0]))) {
277
+ * case RepeatMode.DISABLED:
278
+ * mode = "Off";
279
+ * break;
280
+ * case RepeatMode.SONG:
281
+ * mode = "Repeat a song";
282
+ * break;
283
+ * case RepeatMode.QUEUE:
284
+ * mode = "Repeat all queue";
285
+ * break;
286
+ * }
287
+ * message.channel.send("Set repeat mode to `" + mode + "`");
288
+ */
289
+ setRepeatMode(queue: GuildIDResolvable, mode?: number): number;
290
+ /**
291
+ * Toggle autoplay mode
292
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
293
+ * @returns {boolean} Autoplay mode state
294
+ * @throws {Error}
295
+ * @example
296
+ * client.on('message', (message) => {
297
+ * if (!message.content.startsWith(config.prefix)) return;
298
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
299
+ * const command = args.shift();
300
+ * if (command == "autoplay") {
301
+ * const mode = distube.toggleAutoplay(message);
302
+ * message.channel.send("Set autoplay mode to `" + (mode ? "On" : "Off") + "`");
303
+ * }
304
+ * });
305
+ */
306
+ toggleAutoplay(queue: GuildIDResolvable): boolean;
307
+ /**
308
+ * Add related song to the queue
309
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
310
+ * @returns {Promise<Song>} The guild queue
311
+ */
312
+ addRelatedSong(queue: GuildIDResolvable): Promise<Song>;
313
+ /**
314
+ * Enable or disable filter(s) of the queue.
315
+ * Available filters: {@link Filters}
316
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
317
+ * @param {string|false} filter A filter name, `false` to clear all the filters
318
+ * @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled
319
+ * @returns {Array<string>} Enabled filters.
320
+ * @example
321
+ * client.on('message', (message) => {
322
+ * if (!message.content.startsWith(config.prefix)) return;
323
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
324
+ * const command = args.shift();
325
+ * if ([`3d`, `bassboost`, `echo`, `karaoke`, `nightcore`, `vaporwave`].includes(command)) {
326
+ * const filter = distube.setFilter(message, command);
327
+ * message.channel.send("Current queue filter: " + (filter.join(", ") || "Off"));
328
+ * }
329
+ * });
330
+ */
331
+ setFilter(queue: GuildIDResolvable, filter: string | false, force?: boolean): Array<string>;
332
+ /**
333
+ * Set the playing time to another position
334
+ * @param {GuildIDResolvable} queue The type can be resolved to give a {@link Queue}
335
+ * @param {number} time Time in seconds
336
+ * @returns {Queue} Seeked queue
337
+ * @example
338
+ * client.on('message', message => {
339
+ * if (!message.content.startsWith(config.prefix)) return;
340
+ * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);
341
+ * const command = args.shift();
342
+ * if (command = 'seek')
343
+ * distube.seek(message, Number(args[0]));
344
+ * });
345
+ */
346
+ seek(queue: GuildIDResolvable, time: number): Queue;
347
+ /**
348
+ * Emit error event
349
+ * @param {Error} error error
350
+ * @param {Discord.TextChannel?} channel Text channel where the error is encountered.
351
+ * @private
352
+ */
353
+ emitError(error: Error, channel?: TextChannel): void;
354
+ }
355
+ export default DisTube;
356
+ /**
357
+ * Emitted after DisTube add a new playlist to the playing {@link Queue}.
358
+ *
359
+ * @event DisTube#addList
360
+ * @param {Queue} queue The guild queue
361
+ * @param {Playlist} playlist Playlist info
362
+ * @example
363
+ * distube.on("addList", (queue, playlist) => queue.textChannel.send(
364
+ * `Added \`${playlist.name}\` playlist (${playlist.songs.length} songs) to the queue!`
365
+ * ));
366
+ */
367
+ /**
368
+ * Emitted after DisTube add a new song to the playing {@link Queue}.
369
+ *
370
+ * @event DisTube#addSong
371
+ * @param {Queue} queue The guild queue
372
+ * @param {Song} song Added song
373
+ * @example
374
+ * distube.on("addSong", (queue, song) => queue.textChannel.send(
375
+ * `Added ${song.name} - \`${song.formattedDuration}\` to the queue by ${song.user}.`
376
+ * ));
377
+ */
378
+ /**
379
+ * Emitted when there is no user in the voice channel,
380
+ * {@link DisTubeOptions}.leaveOnEmpty is `true` and there is a playing queue.
381
+ *
382
+ * If there is no playing queue (stopped and {@link DisTubeOptions}.leaveOnStop is `false`),
383
+ * it will leave the channel without emitting this event.
384
+ * @event DisTube#empty
385
+ * @param {Queue} queue The guild queue
386
+ * @example
387
+ * distube.on("empty", queue => queue.textChannel.send("Channel is empty. Leaving the channel"))
388
+ */
389
+ /**
390
+ * Emitted when DisTube encounters an error.
391
+ *
392
+ * @event DisTube#error
393
+ * @param {Discord.TextChannel} channel Text channel where the error is encountered.
394
+ * @param {Error} error The error encountered
395
+ * @example
396
+ * distube.on("error", (channel, error) => channel.send(
397
+ * "An error encountered: " + error
398
+ * ));
399
+ */
400
+ /**
401
+ * Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.
402
+ * DisTube will leave voice channel if {@link DisTubeOptions}.leaveOnFinish is `true`.
403
+ *
404
+ * @event DisTube#finish
405
+ * @param {Queue} queue The guild queue
406
+ * @example
407
+ * distube.on("finish", queue => queue.textChannel.send("No more song in queue"));
408
+ */
409
+ /**
410
+ * Emitted when DisTube initialize a queue to change queue default properties.
411
+ *
412
+ * @event DisTube#initQueue
413
+ * @param {Queue} queue The guild queue
414
+ * @example
415
+ * distube.on("initQueue", queue => {
416
+ * queue.autoplay = false;
417
+ * queue.volume = 100;
418
+ * });
419
+ */
420
+ /**
421
+ * Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty,
422
+ * and DisTube cannot find related songs to play.
423
+ *
424
+ * @event DisTube#noRelated
425
+ * @param {Queue} queue The guild queue
426
+ * @example
427
+ * distube.on("noRelated", queue => queue.textChannel.send("Can't find related video to play."));
428
+ */
429
+ /**
430
+ * Emitted when DisTube play a song.
431
+ *
432
+ * If {@link DisTubeOptions}.emitNewSongOnly is `true`,
433
+ * this event is not emitted when looping a song or next song is the previous one.
434
+ *
435
+ * @event DisTube#playSong
436
+ * @param {Queue} queue The guild queue
437
+ * @param {Song} song Playing song
438
+ * @example
439
+ * distube.on("playSong", (queue, song) => queue.textChannel.send(
440
+ * `Playing \`${song.name}\` - \`${song.formattedDuration}\`\nRequested by: ${song.user}`
441
+ * ));
442
+ */
443
+ /**
444
+ * Emitted when DisTube cannot find any results for the query.
445
+ *
446
+ * @event DisTube#searchNoResult
447
+ * @param {Discord.Message} message The user message called play method
448
+ * @param {string} query The search query
449
+ * @example
450
+ * distube.on("searchNoResult", (message, query) => message.channel.send(`No result found for ${query}!`));
451
+ */
452
+ /**
453
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
454
+ * and song param of {@link DisTube#playVoiceChannel} is invalid url.
455
+ * DisTube will wait for user's next message to choose a song manually.
456
+ * <info>{@link https://support.google.com/youtube/answer/7354993|Safe search} is enabled
457
+ * if {@link DisTubeOptions}.nsfw is disabled and the message's channel is not a nsfw channel.</info>
458
+ *
459
+ * @event DisTube#searchResult
460
+ * @param {Discord.Message} message The user message called play method
461
+ * @param {Array<SearchResult>} results Searched results
462
+ * @param {string} query The search query
463
+ * @example
464
+ * // DisTubeOptions.searchSongs > 0
465
+ * distube.on("searchResult", (message, results) => {
466
+ * message.channel.send(`**Choose an option from below**\n${
467
+ * results.map((song, i) => `**${i + 1}**. ${song.name} - \`${song.formattedDuration}\``).join("\n")
468
+ * }\n*Enter anything else or wait 60 seconds to cancel*`);
469
+ * });
470
+ */
471
+ /**
472
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
473
+ * and the search canceled due to {@link DisTubeOptions|DisTubeOptions.searchTimeout}.
474
+ *
475
+ * @event DisTube#searchCancel
476
+ * @param {Discord.Message} message The user message called play method
477
+ * @param {string} query The search query
478
+ * @example
479
+ * // DisTubeOptions.searchSongs > 0
480
+ * distube.on("searchCancel", (message) => message.channel.send(`Searching canceled`));
481
+ */
482
+ /**
483
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
484
+ * and the search canceled due to user's next message is not a number or out of results range.
485
+ *
486
+ * @event DisTube#searchInvalidAnswer
487
+ * @param {Discord.Message} message The user message called play method
488
+ * @param {Discord.Message} answer The answered message of user
489
+ * @param {string} query The search query
490
+ * @example
491
+ * // DisTubeOptions.searchSongs > 0
492
+ * distube.on("searchInvalidAnswer", (message) => message.channel.send(`You answered an invalid number!`));
493
+ */
494
+ /**
495
+ * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,
496
+ * and after the user chose a search result to play.
497
+ *
498
+ * @event DisTube#searchDone
499
+ * @param {Discord.Message} message The user message called play method
500
+ * @param {Discord.Message} answer The answered message of user
501
+ * @param {string} query The search query
502
+ */
503
+ /**
504
+ * Emitted when the bot is disconnected to a voice channel.
505
+ *
506
+ * @event DisTube#disconnect
507
+ * @param {Queue} queue The guild queue
508
+ */
509
+ /**
510
+ * Emitted when a {@link Queue} is deleted with any reasons.
511
+ *
512
+ * @event DisTube#deleteQueue
513
+ * @param {Queue} queue The guild queue
514
+ */
515
+ /**
516
+ * Emitted when DisTube finished a song.
517
+ *
518
+ * @event DisTube#finishSong
519
+ * @param {Queue} queue The guild queue
520
+ * @param {Song} song Finished song
521
+ */
522
+ //# sourceMappingURL=DisTube.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DisTube.d.ts","sourceRoot":"","sources":["../src/DisTube.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAEL,cAAc,EACd,mBAAmB,EAGnB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,YAAY,EAOb,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxG,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AAExH;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,YAAY,CAAC,aAAa,CAAC;IACtD,OAAO,EAAE,cAAc,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,YAAY,CAAC;IACrB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;;;;;;;OAYG;gBACS,MAAM,EAAE,MAAM,EAAE,GAAG,GAAE,cAAmB;IAuDpD;;;;;;;;;;;;;;;;;;OAkBG;IACG,IA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