distube 3.1.0 → 3.2.2
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.
- package/dist/DisTube.d.ts +39 -32
- package/dist/DisTube.d.ts.map +1 -1
- package/dist/DisTube.js +41 -29
- package/dist/DisTube.js.map +1 -1
- package/dist/constant.d.ts +5 -5
- package/dist/constant.js +5 -5
- package/dist/constant.js.map +1 -1
- package/dist/core/DisTubeHandler.js +9 -14
- package/dist/core/DisTubeHandler.js.map +1 -1
- package/dist/core/manager/BaseManager.d.ts +4 -4
- package/dist/core/manager/BaseManager.js +3 -3
- package/dist/core/manager/BaseManager.js.map +1 -1
- package/dist/core/manager/QueueManager.d.ts.map +1 -1
- package/dist/core/manager/QueueManager.js +6 -4
- package/dist/core/manager/QueueManager.js.map +1 -1
- package/dist/core/voice/DJSAdapter.js +4 -7
- package/dist/core/voice/DJSAdapter.js.map +1 -1
- package/dist/core/voice/DisTubeVoice.d.ts.map +1 -1
- package/dist/core/voice/DisTubeVoice.js +10 -12
- package/dist/core/voice/DisTubeVoice.js.map +1 -1
- package/dist/core/voice/DisTubeVoiceManager.d.ts +4 -4
- package/dist/core/voice/DisTubeVoiceManager.js +3 -3
- package/dist/core/voice/DisTubeVoiceManager.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/https.js +1 -1
- package/dist/plugin/https.js.map +1 -1
- package/dist/plugin/youtube-dl.d.ts.map +1 -1
- package/dist/plugin/youtube-dl.js +2 -2
- package/dist/plugin/youtube-dl.js.map +1 -1
- package/dist/struct/DisTubeError.d.ts +0 -1
- package/dist/struct/DisTubeError.d.ts.map +1 -1
- package/dist/struct/DisTubeError.js +2 -5
- package/dist/struct/DisTubeError.js.map +1 -1
- package/dist/struct/Playlist.js +3 -6
- package/dist/struct/Playlist.js.map +1 -1
- package/dist/struct/Plugin.d.ts +8 -1
- package/dist/struct/Plugin.d.ts.map +1 -1
- package/dist/struct/Plugin.js +9 -0
- package/dist/struct/Plugin.js.map +1 -1
- package/dist/struct/Queue.js +4 -7
- package/dist/struct/Queue.js.map +1 -1
- package/dist/struct/SearchResult.js +2 -3
- package/dist/struct/SearchResult.js.map +1 -1
- package/dist/struct/Song.d.ts +2 -2
- package/dist/struct/Song.d.ts.map +1 -1
- package/dist/struct/Song.js +20 -20
- package/dist/struct/Song.js.map +1 -1
- package/dist/struct/TaskQueue.js +1 -2
- package/dist/struct/TaskQueue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +3 -2
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/dist/util.d.ts +3 -2
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +23 -24
- package/dist/util.js.map +1 -1
- package/package.json +3 -3
package/dist/DisTube.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TypedEmitter } from "tiny-typed-emitter";
|
|
2
2
|
import { DisTubeHandler, DisTubeVoiceManager, Options, Playlist, Queue, QueueManager, SearchResult, Song } from ".";
|
|
3
3
|
import type { Client, GuildMember, GuildTextBasedChannel, Message, VoiceBasedChannel } from "discord.js";
|
|
4
|
-
import type { CustomPlugin, DisTubeEvents, DisTubeOptions, ExtractorPlugin, Filters,
|
|
4
|
+
import type { CustomPlugin, DisTubeEvents, DisTubeOptions, ExtractorPlugin, Filters, GuildIdResolvable } from ".";
|
|
5
|
+
export declare const version: string;
|
|
5
6
|
/**
|
|
6
7
|
* DisTube class
|
|
7
8
|
* @extends EventEmitter
|
|
@@ -29,6 +30,12 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
29
30
|
* client.login("Your Discord Bot Token")
|
|
30
31
|
*/
|
|
31
32
|
constructor(client: Client, otp?: DisTubeOptions);
|
|
33
|
+
static get version(): string;
|
|
34
|
+
/**
|
|
35
|
+
* DisTube version
|
|
36
|
+
* @type {string}
|
|
37
|
+
*/
|
|
38
|
+
get version(): string;
|
|
32
39
|
/**
|
|
33
40
|
* Play / add a song or playlist from url. Search and play a song if it is not a valid url.
|
|
34
41
|
*
|
|
@@ -59,7 +66,7 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
59
66
|
* });
|
|
60
67
|
* @returns {Promise<void>}
|
|
61
68
|
*/
|
|
62
|
-
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist | null, options
|
|
69
|
+
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist | null, options?: {
|
|
63
70
|
skip?: boolean;
|
|
64
71
|
unshift?: boolean;
|
|
65
72
|
member?: GuildMember;
|
|
@@ -82,7 +89,7 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
82
89
|
* See {@link Song#metadata} or {@link Playlist#metadata}
|
|
83
90
|
* @deprecated Message parameter is deprecated, use VoiceChannel instead. See {@link DisTube#play}
|
|
84
91
|
*/
|
|
85
|
-
play(message: Message<true>, song: string | Song | SearchResult | Playlist, options
|
|
92
|
+
play(message: Message<true>, song: string | Song | SearchResult | Playlist, options?: {
|
|
86
93
|
skip?: boolean;
|
|
87
94
|
unshift?: boolean;
|
|
88
95
|
metadata?: any;
|
|
@@ -128,7 +135,7 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
128
135
|
* const playlist = await distube.createCustomPlaylist(songs, {
|
|
129
136
|
* member: message.member,
|
|
130
137
|
* properties: { name: "My playlist name" },
|
|
131
|
-
*
|
|
138
|
+
* parallel: true
|
|
132
139
|
* });
|
|
133
140
|
* distube.play(voiceChannel, playlist, { ... });
|
|
134
141
|
*/
|
|
@@ -185,7 +192,7 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
185
192
|
}): Promise<Array<SearchResult>>;
|
|
186
193
|
/**
|
|
187
194
|
* Get the guild queue
|
|
188
|
-
* @param {
|
|
195
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
189
196
|
* @returns {Queue?}
|
|
190
197
|
* @throws {Error}
|
|
191
198
|
* @example
|
|
@@ -201,24 +208,24 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
201
208
|
* }
|
|
202
209
|
* });
|
|
203
210
|
*/
|
|
204
|
-
getQueue(queue:
|
|
211
|
+
getQueue(queue: GuildIdResolvable): Queue | undefined;
|
|
205
212
|
/**
|
|
206
213
|
* Pause the guild stream
|
|
207
|
-
* @param {
|
|
214
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
208
215
|
* @returns {Queue} The guild queue
|
|
209
216
|
* @throws {Error}
|
|
210
217
|
*/
|
|
211
|
-
pause(queue:
|
|
218
|
+
pause(queue: GuildIdResolvable): Queue;
|
|
212
219
|
/**
|
|
213
220
|
* Resume the guild stream
|
|
214
|
-
* @param {
|
|
221
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
215
222
|
* @returns {Queue} The guild queue
|
|
216
223
|
* @throws {Error}
|
|
217
224
|
*/
|
|
218
|
-
resume(queue:
|
|
225
|
+
resume(queue: GuildIdResolvable): Queue;
|
|
219
226
|
/**
|
|
220
227
|
* Stop the guild stream
|
|
221
|
-
* @param {
|
|
228
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
222
229
|
* @returns {Promise<void>}
|
|
223
230
|
* @throws {Error}
|
|
224
231
|
* @example
|
|
@@ -232,10 +239,10 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
232
239
|
* }
|
|
233
240
|
* });
|
|
234
241
|
*/
|
|
235
|
-
stop(queue:
|
|
242
|
+
stop(queue: GuildIdResolvable): Promise<void>;
|
|
236
243
|
/**
|
|
237
244
|
* Set the guild stream's volume
|
|
238
|
-
* @param {
|
|
245
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
239
246
|
* @param {number} percent The percentage of volume you want to set
|
|
240
247
|
* @returns {Queue} The guild queue
|
|
241
248
|
* @throws {Error}
|
|
@@ -248,12 +255,12 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
248
255
|
* distube.setVolume(message, Number(args[0]));
|
|
249
256
|
* });
|
|
250
257
|
*/
|
|
251
|
-
setVolume(queue:
|
|
258
|
+
setVolume(queue: GuildIdResolvable, percent: number): Queue;
|
|
252
259
|
/**
|
|
253
260
|
* Skip the playing song if there is a next song in the queue.
|
|
254
261
|
* <info>If {@link Queue#autoplay} is `true` and there is no up next song,
|
|
255
262
|
* DisTube will add and play a related song.</info>
|
|
256
|
-
* @param {
|
|
263
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
257
264
|
* @returns {Promise<Song>} The new Song will be played
|
|
258
265
|
* @throws {Error}
|
|
259
266
|
* @example
|
|
@@ -265,10 +272,10 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
265
272
|
* distube.skip(message);
|
|
266
273
|
* });
|
|
267
274
|
*/
|
|
268
|
-
skip(queue:
|
|
275
|
+
skip(queue: GuildIdResolvable): Promise<Song>;
|
|
269
276
|
/**
|
|
270
277
|
* Play the previous song
|
|
271
|
-
* @param {
|
|
278
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
272
279
|
* @returns {Promise<Song>} The new Song will be played
|
|
273
280
|
* @throws {Error}
|
|
274
281
|
* @example
|
|
@@ -280,10 +287,10 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
280
287
|
* distube.previous(message);
|
|
281
288
|
* });
|
|
282
289
|
*/
|
|
283
|
-
previous(queue:
|
|
290
|
+
previous(queue: GuildIdResolvable): Promise<Song>;
|
|
284
291
|
/**
|
|
285
292
|
* Shuffle the guild queue songs
|
|
286
|
-
* @param {
|
|
293
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
287
294
|
* @returns {Promise<Queue>} The guild queue
|
|
288
295
|
* @example
|
|
289
296
|
* client.on('message', (message) => {
|
|
@@ -294,12 +301,12 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
294
301
|
* distube.shuffle(message);
|
|
295
302
|
* });
|
|
296
303
|
*/
|
|
297
|
-
shuffle(queue:
|
|
304
|
+
shuffle(queue: GuildIdResolvable): Promise<Queue>;
|
|
298
305
|
/**
|
|
299
306
|
* Jump to the song number in the queue.
|
|
300
307
|
* The next one is 1, 2,...
|
|
301
308
|
* The previous one is -1, -2,...
|
|
302
|
-
* @param {
|
|
309
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
303
310
|
* @param {number} num The song number to play
|
|
304
311
|
* @returns {Promise<Queue>} The guild queue
|
|
305
312
|
* @throws {Error} if `num` is invalid number (0 < num < {@link Queue#songs}.length)
|
|
@@ -313,11 +320,11 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
313
320
|
* .catch(err => message.channel.send("Invalid song number."));
|
|
314
321
|
* });
|
|
315
322
|
*/
|
|
316
|
-
jump(queue:
|
|
323
|
+
jump(queue: GuildIdResolvable, num: number): Promise<Queue>;
|
|
317
324
|
/**
|
|
318
325
|
* Set the repeat mode of the guild queue.\
|
|
319
326
|
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
320
|
-
* @param {
|
|
327
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
321
328
|
* @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
|
|
322
329
|
* @returns {RepeatMode} The new repeat mode
|
|
323
330
|
* @example
|
|
@@ -347,10 +354,10 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
347
354
|
* }
|
|
348
355
|
* message.channel.send("Set repeat mode to `" + mode + "`");
|
|
349
356
|
*/
|
|
350
|
-
setRepeatMode(queue:
|
|
357
|
+
setRepeatMode(queue: GuildIdResolvable, mode?: number): number;
|
|
351
358
|
/**
|
|
352
359
|
* Toggle autoplay mode
|
|
353
|
-
* @param {
|
|
360
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
354
361
|
* @returns {boolean} Autoplay mode state
|
|
355
362
|
* @throws {Error}
|
|
356
363
|
* @example
|
|
@@ -364,17 +371,17 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
364
371
|
* }
|
|
365
372
|
* });
|
|
366
373
|
*/
|
|
367
|
-
toggleAutoplay(queue:
|
|
374
|
+
toggleAutoplay(queue: GuildIdResolvable): boolean;
|
|
368
375
|
/**
|
|
369
376
|
* Add related song to the queue
|
|
370
|
-
* @param {
|
|
377
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
371
378
|
* @returns {Promise<Song>} The guild queue
|
|
372
379
|
*/
|
|
373
|
-
addRelatedSong(queue:
|
|
380
|
+
addRelatedSong(queue: GuildIdResolvable): Promise<Song>;
|
|
374
381
|
/**
|
|
375
382
|
* Enable or disable filter(s) of the queue.
|
|
376
383
|
* Available filters: {@link Filters}
|
|
377
|
-
* @param {
|
|
384
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
378
385
|
* @param {string|false} filter A filter name, `false` to clear all the filters
|
|
379
386
|
* @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled
|
|
380
387
|
* @returns {Array<string>} Enabled filters.
|
|
@@ -389,10 +396,10 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
389
396
|
* }
|
|
390
397
|
* });
|
|
391
398
|
*/
|
|
392
|
-
setFilter(queue:
|
|
399
|
+
setFilter(queue: GuildIdResolvable, filter: string | false, force?: boolean): Array<string>;
|
|
393
400
|
/**
|
|
394
401
|
* Set the playing time to another position
|
|
395
|
-
* @param {
|
|
402
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
396
403
|
* @param {number} time Time in seconds
|
|
397
404
|
* @returns {Queue} Seeked queue
|
|
398
405
|
* @example
|
|
@@ -404,7 +411,7 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
404
411
|
* distube.seek(message, Number(args[0]));
|
|
405
412
|
* });
|
|
406
413
|
*/
|
|
407
|
-
seek(queue:
|
|
414
|
+
seek(queue: GuildIdResolvable, time: number): Queue;
|
|
408
415
|
/**
|
|
409
416
|
* Emit error event
|
|
410
417
|
* @param {Error} error error
|
package/dist/DisTube.d.ts.map
CHANGED
|
@@ -1 +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,EACZ,IAAI,EAQL,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,OAAO,EAAe,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;
|
|
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,EACZ,IAAI,EAQL,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,OAAO,EAAe,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EA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,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAM3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,aAAa,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM;IAM9D;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO;IAOjD;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAMvD;;;;;;;;;;;;;;;;;OAiBG;IACH,SAAS,CAAC,KAAK,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,KAAK,UAAQ,GAAG,KAAK,CAAC,MAAM,CAAC;IAMzF;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK;IAOnD;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI;CAe/D;AAED,eAAe,OAAO,CAAC;AAEvB;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG"}
|
package/dist/DisTube.js
CHANGED
|
@@ -3,13 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DisTube = void 0;
|
|
6
|
+
exports.DisTube = exports.version = void 0;
|
|
7
7
|
const ytpl_1 = __importDefault(require("@distube/ytpl"));
|
|
8
8
|
const ytsr_1 = __importDefault(require("@distube/ytsr"));
|
|
9
9
|
const util_1 = require("./util");
|
|
10
10
|
const tiny_typed_emitter_1 = require("tiny-typed-emitter");
|
|
11
11
|
const _1 = require(".");
|
|
12
12
|
// TODO: remove deprecated stuff on the next major version
|
|
13
|
+
// Cannot be `import` as it's not under TS root dir
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
|
15
|
+
exports.version = require("../package.json").version;
|
|
13
16
|
/**
|
|
14
17
|
* DisTube class
|
|
15
18
|
* @extends EventEmitter
|
|
@@ -84,10 +87,19 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
84
87
|
*/
|
|
85
88
|
this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
|
|
86
89
|
}
|
|
90
|
+
static get version() {
|
|
91
|
+
return exports.version;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* DisTube version
|
|
95
|
+
* @type {string}
|
|
96
|
+
*/
|
|
97
|
+
get version() {
|
|
98
|
+
return exports.version;
|
|
99
|
+
}
|
|
87
100
|
async play(voiceChannel, song, options = {}) {
|
|
88
|
-
var _a, _b;
|
|
89
101
|
if ((0, _1.isMessageInstance)(voiceChannel)) {
|
|
90
|
-
process.emitWarning("Passing Message for DisTube#play is deprecated, use
|
|
102
|
+
process.emitWarning("Passing Message for DisTube#play is deprecated, use BaseGuildVoiceChannel instead.", "DeprecationWarning");
|
|
91
103
|
const message = voiceChannel;
|
|
92
104
|
if (!song)
|
|
93
105
|
throw new _1.DisTubeError("INVALID_TYPE", ["string", "Song", "SearchResult", "Playlist"], song, "song");
|
|
@@ -111,8 +123,9 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
111
123
|
metadata,
|
|
112
124
|
});
|
|
113
125
|
}
|
|
114
|
-
if (!(0, _1.isSupportedVoiceChannel)(voiceChannel))
|
|
115
|
-
throw new _1.DisTubeError("
|
|
126
|
+
if (!(0, _1.isSupportedVoiceChannel)(voiceChannel)) {
|
|
127
|
+
throw new _1.DisTubeError("INVALID_TYPE", "BaseGuildVoiceChannel", voiceChannel, "voiceChannel");
|
|
128
|
+
}
|
|
116
129
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
117
130
|
throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
118
131
|
}
|
|
@@ -135,7 +148,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
135
148
|
let queue = this.getQueue(voiceChannel);
|
|
136
149
|
const queuing = !!queue && !queue.taskQueue.hasResolveTask;
|
|
137
150
|
if (queuing)
|
|
138
|
-
await
|
|
151
|
+
await queue?.taskQueue.queuing(true);
|
|
139
152
|
try {
|
|
140
153
|
if (song instanceof _1.SearchResult && song.type === "playlist")
|
|
141
154
|
song = song.url;
|
|
@@ -154,7 +167,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
154
167
|
if (song instanceof _1.Playlist) {
|
|
155
168
|
await this.handler.handlePlaylist(voiceChannel, song, { textChannel, skip, unshift });
|
|
156
169
|
}
|
|
157
|
-
else if (!this.options.nsfw && song.age_restricted && !
|
|
170
|
+
else if (!this.options.nsfw && song.age_restricted && !textChannel?.nsfw) {
|
|
158
171
|
throw new _1.DisTubeError("NON_NSFW");
|
|
159
172
|
}
|
|
160
173
|
else {
|
|
@@ -178,14 +191,14 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
178
191
|
}
|
|
179
192
|
finally {
|
|
180
193
|
if (queuing)
|
|
181
|
-
queue
|
|
194
|
+
queue?.taskQueue.resolve();
|
|
182
195
|
}
|
|
183
196
|
}
|
|
184
197
|
catch (e) {
|
|
185
198
|
if (!(e instanceof _1.DisTubeError)) {
|
|
186
199
|
try {
|
|
187
200
|
e.name = "PlayError";
|
|
188
|
-
e.message = `${
|
|
201
|
+
e.message = `${song?.url || song}\n${e.message}`;
|
|
189
202
|
}
|
|
190
203
|
catch { }
|
|
191
204
|
}
|
|
@@ -229,7 +242,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
229
242
|
* const playlist = await distube.createCustomPlaylist(songs, {
|
|
230
243
|
* member: message.member,
|
|
231
244
|
* properties: { name: "My playlist name" },
|
|
232
|
-
*
|
|
245
|
+
* parallel: true
|
|
233
246
|
* });
|
|
234
247
|
* distube.play(voiceChannel, playlist, { ... });
|
|
235
248
|
*/
|
|
@@ -283,7 +296,6 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
283
296
|
* @deprecated Use {@link DisTube#createCustomPlaylist} and {@link DisTube#play} instead
|
|
284
297
|
*/
|
|
285
298
|
async playCustomPlaylist(message, songs, properties = {}, options = {}) {
|
|
286
|
-
var _a, _b, _c;
|
|
287
299
|
process.emitWarning("DisTube#playCustomPlaylist is deprecated, use DisTube#createCustomPlaylist and DisTube#play instead.", "DeprecationWarning");
|
|
288
300
|
try {
|
|
289
301
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
@@ -297,22 +309,22 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
297
309
|
const queue = this.getQueue(message);
|
|
298
310
|
const queuing = queue && !queue.taskQueue.hasResolveTask;
|
|
299
311
|
if (queuing)
|
|
300
|
-
await
|
|
312
|
+
await queue?.taskQueue.queuing(true);
|
|
301
313
|
try {
|
|
302
314
|
const playlist = await this.createCustomPlaylist(songs, {
|
|
303
|
-
member:
|
|
315
|
+
member: message.member ?? undefined,
|
|
304
316
|
properties,
|
|
305
317
|
parallel,
|
|
306
318
|
metadata,
|
|
307
319
|
});
|
|
308
|
-
const voice =
|
|
320
|
+
const voice = message.member?.voice?.channel;
|
|
309
321
|
if (!voice)
|
|
310
322
|
throw new _1.DisTubeError("NOT_IN_VOICE");
|
|
311
323
|
await this.play(voice, playlist, { textChannel: message.channel, skip, unshift, metadata });
|
|
312
324
|
}
|
|
313
325
|
finally {
|
|
314
326
|
if (queuing)
|
|
315
|
-
queue
|
|
327
|
+
queue?.taskQueue.resolve();
|
|
316
328
|
}
|
|
317
329
|
}
|
|
318
330
|
catch (e) {
|
|
@@ -359,7 +371,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
359
371
|
}
|
|
360
372
|
/**
|
|
361
373
|
* Get the guild queue
|
|
362
|
-
* @param {
|
|
374
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
363
375
|
* @returns {Queue?}
|
|
364
376
|
* @throws {Error}
|
|
365
377
|
* @example
|
|
@@ -380,7 +392,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
380
392
|
}
|
|
381
393
|
/**
|
|
382
394
|
* Pause the guild stream
|
|
383
|
-
* @param {
|
|
395
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
384
396
|
* @returns {Queue} The guild queue
|
|
385
397
|
* @throws {Error}
|
|
386
398
|
*/
|
|
@@ -392,7 +404,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
392
404
|
}
|
|
393
405
|
/**
|
|
394
406
|
* Resume the guild stream
|
|
395
|
-
* @param {
|
|
407
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
396
408
|
* @returns {Queue} The guild queue
|
|
397
409
|
* @throws {Error}
|
|
398
410
|
*/
|
|
@@ -404,7 +416,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
404
416
|
}
|
|
405
417
|
/**
|
|
406
418
|
* Stop the guild stream
|
|
407
|
-
* @param {
|
|
419
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
408
420
|
* @returns {Promise<void>}
|
|
409
421
|
* @throws {Error}
|
|
410
422
|
* @example
|
|
@@ -426,7 +438,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
426
438
|
}
|
|
427
439
|
/**
|
|
428
440
|
* Set the guild stream's volume
|
|
429
|
-
* @param {
|
|
441
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
430
442
|
* @param {number} percent The percentage of volume you want to set
|
|
431
443
|
* @returns {Queue} The guild queue
|
|
432
444
|
* @throws {Error}
|
|
@@ -449,7 +461,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
449
461
|
* Skip the playing song if there is a next song in the queue.
|
|
450
462
|
* <info>If {@link Queue#autoplay} is `true` and there is no up next song,
|
|
451
463
|
* DisTube will add and play a related song.</info>
|
|
452
|
-
* @param {
|
|
464
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
453
465
|
* @returns {Promise<Song>} The new Song will be played
|
|
454
466
|
* @throws {Error}
|
|
455
467
|
* @example
|
|
@@ -469,7 +481,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
469
481
|
}
|
|
470
482
|
/**
|
|
471
483
|
* Play the previous song
|
|
472
|
-
* @param {
|
|
484
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
473
485
|
* @returns {Promise<Song>} The new Song will be played
|
|
474
486
|
* @throws {Error}
|
|
475
487
|
* @example
|
|
@@ -489,7 +501,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
489
501
|
}
|
|
490
502
|
/**
|
|
491
503
|
* Shuffle the guild queue songs
|
|
492
|
-
* @param {
|
|
504
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
493
505
|
* @returns {Promise<Queue>} The guild queue
|
|
494
506
|
* @example
|
|
495
507
|
* client.on('message', (message) => {
|
|
@@ -510,7 +522,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
510
522
|
* Jump to the song number in the queue.
|
|
511
523
|
* The next one is 1, 2,...
|
|
512
524
|
* The previous one is -1, -2,...
|
|
513
|
-
* @param {
|
|
525
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
514
526
|
* @param {number} num The song number to play
|
|
515
527
|
* @returns {Promise<Queue>} The guild queue
|
|
516
528
|
* @throws {Error} if `num` is invalid number (0 < num < {@link Queue#songs}.length)
|
|
@@ -533,7 +545,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
533
545
|
/**
|
|
534
546
|
* Set the repeat mode of the guild queue.\
|
|
535
547
|
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
536
|
-
* @param {
|
|
548
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
537
549
|
* @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
|
|
538
550
|
* @returns {RepeatMode} The new repeat mode
|
|
539
551
|
* @example
|
|
@@ -571,7 +583,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
571
583
|
}
|
|
572
584
|
/**
|
|
573
585
|
* Toggle autoplay mode
|
|
574
|
-
* @param {
|
|
586
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
575
587
|
* @returns {boolean} Autoplay mode state
|
|
576
588
|
* @throws {Error}
|
|
577
589
|
* @example
|
|
@@ -594,7 +606,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
594
606
|
}
|
|
595
607
|
/**
|
|
596
608
|
* Add related song to the queue
|
|
597
|
-
* @param {
|
|
609
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
598
610
|
* @returns {Promise<Song>} The guild queue
|
|
599
611
|
*/
|
|
600
612
|
addRelatedSong(queue) {
|
|
@@ -606,7 +618,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
606
618
|
/**
|
|
607
619
|
* Enable or disable filter(s) of the queue.
|
|
608
620
|
* Available filters: {@link Filters}
|
|
609
|
-
* @param {
|
|
621
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
610
622
|
* @param {string|false} filter A filter name, `false` to clear all the filters
|
|
611
623
|
* @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled
|
|
612
624
|
* @returns {Array<string>} Enabled filters.
|
|
@@ -629,7 +641,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
629
641
|
}
|
|
630
642
|
/**
|
|
631
643
|
* Set the playing time to another position
|
|
632
|
-
* @param {
|
|
644
|
+
* @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}
|
|
633
645
|
* @param {number} time Time in seconds
|
|
634
646
|
* @returns {Queue} Seeked queue
|
|
635
647
|
* @example
|