distube 5.0.7 → 5.1.0
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/README.md +52 -38
- package/dist/index.d.mts +467 -463
- package/dist/index.d.ts +469 -463
- package/dist/index.js +1605 -1606
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1611 -1612
- package/dist/index.mjs.map +1 -1
- package/package.json +26 -30
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as discord_js from 'discord.js';
|
|
2
|
-
import { GuildMember, Snowflake, Message, GuildTextBasedChannel, VoiceBasedChannel, VoiceState, Guild, Interaction,
|
|
2
|
+
import { GuildMember, Snowflake, Message, GuildTextBasedChannel, VoiceBasedChannel, VoiceState, Guild, Interaction, Collection, Client, ClientOptions } from 'discord.js';
|
|
3
|
+
import { AudioResource, AudioPlayer, VoiceConnection } from '@discordjs/voice';
|
|
3
4
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
4
|
-
import {
|
|
5
|
-
import { Transform, TransformCallback } from 'stream';
|
|
6
|
-
import { ChildProcess } from 'child_process';
|
|
5
|
+
import { ChildProcess } from 'node:child_process';
|
|
6
|
+
import { Transform, TransformCallback } from 'node:stream';
|
|
7
7
|
|
|
8
8
|
type Awaitable<T = any> = T | PromiseLike<T>;
|
|
9
9
|
declare enum Events {
|
|
@@ -200,6 +200,13 @@ type PlayHandlerOptions = {
|
|
|
200
200
|
*/
|
|
201
201
|
textChannel?: GuildTextBasedChannel;
|
|
202
202
|
};
|
|
203
|
+
interface JumpOptions {
|
|
204
|
+
/**
|
|
205
|
+
* [Default: false] Whether or not skipped song(s) will be added to the end of the
|
|
206
|
+
* queue
|
|
207
|
+
*/
|
|
208
|
+
requeue?: boolean;
|
|
209
|
+
}
|
|
203
210
|
interface PlayOptions<T = unknown> extends PlayHandlerOptions, ResolveOptions<T> {
|
|
204
211
|
/**
|
|
205
212
|
* Called message (For built-in search events. If this is a {@link
|
|
@@ -300,6 +307,8 @@ type FFmpegOptions = {
|
|
|
300
307
|
args: FFmpegArgs;
|
|
301
308
|
};
|
|
302
309
|
|
|
310
|
+
declare const version: string;
|
|
311
|
+
|
|
303
312
|
/**
|
|
304
313
|
* Default DisTube audio filters.
|
|
305
314
|
*/
|
|
@@ -314,154 +323,6 @@ declare const defaultOptions: {
|
|
|
314
323
|
joinNewVoiceChannel: true;
|
|
315
324
|
};
|
|
316
325
|
|
|
317
|
-
declare const ERROR_MESSAGES: {
|
|
318
|
-
INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) => string;
|
|
319
|
-
NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
|
|
320
|
-
EMPTY_ARRAY: (name: string) => string;
|
|
321
|
-
EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
|
|
322
|
-
EMPTY_STRING: (name: string) => string;
|
|
323
|
-
INVALID_KEY: (obj: string, key: string) => string;
|
|
324
|
-
MISSING_KEY: (obj: string, key: string) => string;
|
|
325
|
-
MISSING_KEYS: (obj: string, key: string[], all: boolean) => string;
|
|
326
|
-
MISSING_INTENTS: (i: string) => string;
|
|
327
|
-
DISABLED_OPTION: (o: string) => string;
|
|
328
|
-
ENABLED_OPTION: (o: string) => string;
|
|
329
|
-
NOT_IN_VOICE: string;
|
|
330
|
-
VOICE_FULL: string;
|
|
331
|
-
VOICE_ALREADY_CREATED: string;
|
|
332
|
-
VOICE_CONNECT_FAILED: (s: number) => string;
|
|
333
|
-
VOICE_MISSING_PERMS: string;
|
|
334
|
-
VOICE_RECONNECT_FAILED: string;
|
|
335
|
-
VOICE_DIFFERENT_GUILD: string;
|
|
336
|
-
VOICE_DIFFERENT_CLIENT: string;
|
|
337
|
-
FFMPEG_EXITED: (code: number) => string;
|
|
338
|
-
FFMPEG_NOT_INSTALLED: (path: string) => string;
|
|
339
|
-
ENCRYPTION_LIBRARIES_MISSING: string;
|
|
340
|
-
NO_QUEUE: string;
|
|
341
|
-
QUEUE_EXIST: string;
|
|
342
|
-
QUEUE_STOPPED: string;
|
|
343
|
-
PAUSED: string;
|
|
344
|
-
RESUMED: string;
|
|
345
|
-
NO_PREVIOUS: string;
|
|
346
|
-
NO_UP_NEXT: string;
|
|
347
|
-
NO_SONG_POSITION: string;
|
|
348
|
-
NO_PLAYING_SONG: string;
|
|
349
|
-
NO_EXTRACTOR_PLUGIN: string;
|
|
350
|
-
NO_RELATED: string;
|
|
351
|
-
CANNOT_PLAY_RELATED: string;
|
|
352
|
-
UNAVAILABLE_VIDEO: string;
|
|
353
|
-
UNPLAYABLE_FORMATS: string;
|
|
354
|
-
NON_NSFW: string;
|
|
355
|
-
NOT_SUPPORTED_URL: string;
|
|
356
|
-
NOT_SUPPORTED_SONG: (song: string) => string;
|
|
357
|
-
NO_VALID_SONG: string;
|
|
358
|
-
CANNOT_RESOLVE_SONG: (t: any) => string;
|
|
359
|
-
CANNOT_GET_STREAM_URL: (song: string) => string;
|
|
360
|
-
CANNOT_GET_SEARCH_QUERY: (song: string) => string;
|
|
361
|
-
NO_RESULT: (query: string) => string;
|
|
362
|
-
NO_STREAM_URL: (song: string) => string;
|
|
363
|
-
EMPTY_FILTERED_PLAYLIST: string;
|
|
364
|
-
EMPTY_PLAYLIST: string;
|
|
365
|
-
};
|
|
366
|
-
type ErrorMessage = typeof ERROR_MESSAGES;
|
|
367
|
-
type ErrorCode = keyof ErrorMessage;
|
|
368
|
-
type StaticErrorCode = {
|
|
369
|
-
[K in ErrorCode]-?: ErrorMessage[K] extends string ? K : never;
|
|
370
|
-
}[ErrorCode];
|
|
371
|
-
type TemplateErrorCode = Exclude<keyof typeof ERROR_MESSAGES, StaticErrorCode>;
|
|
372
|
-
declare class DisTubeError<T extends string = any> extends Error {
|
|
373
|
-
errorCode: string;
|
|
374
|
-
constructor(code: T extends StaticErrorCode ? T : never);
|
|
375
|
-
constructor(code: T extends TemplateErrorCode ? T : never, ...args: Parameters<ErrorMessage[typeof code]>);
|
|
376
|
-
constructor(code: TemplateErrorCode, _: never);
|
|
377
|
-
constructor(code: T extends ErrorCode ? never : T, message: string);
|
|
378
|
-
get name(): string;
|
|
379
|
-
get code(): string;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Task queuing system
|
|
384
|
-
*/
|
|
385
|
-
declare class TaskQueue {
|
|
386
|
-
#private;
|
|
387
|
-
/**
|
|
388
|
-
* Waits for last task finished and queues a new task
|
|
389
|
-
*/
|
|
390
|
-
queuing(isPlay?: boolean): Promise<void>;
|
|
391
|
-
/**
|
|
392
|
-
* Removes the finished task and processes the next task
|
|
393
|
-
*/
|
|
394
|
-
resolve(): void;
|
|
395
|
-
/**
|
|
396
|
-
* The remaining number of tasks
|
|
397
|
-
*/
|
|
398
|
-
get remaining(): number;
|
|
399
|
-
/**
|
|
400
|
-
* Whether or not having a play task
|
|
401
|
-
*/
|
|
402
|
-
get hasPlayTask(): boolean;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Class representing a playlist.
|
|
407
|
-
*/
|
|
408
|
-
declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
409
|
-
#private;
|
|
410
|
-
/**
|
|
411
|
-
* Playlist source.
|
|
412
|
-
*/
|
|
413
|
-
source: string;
|
|
414
|
-
/**
|
|
415
|
-
* Songs in the playlist.
|
|
416
|
-
*/
|
|
417
|
-
songs: Song[];
|
|
418
|
-
/**
|
|
419
|
-
* Playlist ID.
|
|
420
|
-
*/
|
|
421
|
-
id?: string;
|
|
422
|
-
/**
|
|
423
|
-
* Playlist name.
|
|
424
|
-
*/
|
|
425
|
-
name?: string;
|
|
426
|
-
/**
|
|
427
|
-
* Playlist URL.
|
|
428
|
-
*/
|
|
429
|
-
url?: string;
|
|
430
|
-
/**
|
|
431
|
-
* Playlist thumbnail.
|
|
432
|
-
*/
|
|
433
|
-
thumbnail?: string;
|
|
434
|
-
/**
|
|
435
|
-
* Create a Playlist
|
|
436
|
-
* @param playlist - Raw playlist info
|
|
437
|
-
* @param options - Optional data
|
|
438
|
-
*/
|
|
439
|
-
constructor(playlist: PlaylistInfo, { member, metadata }?: ResolveOptions<T>);
|
|
440
|
-
/**
|
|
441
|
-
* Playlist duration in second.
|
|
442
|
-
*/
|
|
443
|
-
get duration(): number;
|
|
444
|
-
/**
|
|
445
|
-
* Formatted duration string `hh:mm:ss`.
|
|
446
|
-
*/
|
|
447
|
-
get formattedDuration(): string;
|
|
448
|
-
/**
|
|
449
|
-
* User requested.
|
|
450
|
-
*/
|
|
451
|
-
get member(): GuildMember | undefined;
|
|
452
|
-
set member(member: GuildMember | undefined);
|
|
453
|
-
/**
|
|
454
|
-
* User requested.
|
|
455
|
-
*/
|
|
456
|
-
get user(): discord_js.User | undefined;
|
|
457
|
-
/**
|
|
458
|
-
* Optional metadata that can be used to identify the playlist.
|
|
459
|
-
*/
|
|
460
|
-
get metadata(): T;
|
|
461
|
-
set metadata(metadata: T);
|
|
462
|
-
toString(): string;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
326
|
/**
|
|
466
327
|
* Class representing a song.
|
|
467
328
|
*/
|
|
@@ -582,129 +443,102 @@ declare class Song<T = unknown> {
|
|
|
582
443
|
toString(): string;
|
|
583
444
|
}
|
|
584
445
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
446
|
+
/**
|
|
447
|
+
* Class representing a playlist.
|
|
448
|
+
*/
|
|
449
|
+
declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
450
|
+
#private;
|
|
588
451
|
/**
|
|
589
|
-
*
|
|
590
|
-
* @param eventName - Event name
|
|
591
|
-
* @param args - arguments
|
|
452
|
+
* Playlist source.
|
|
592
453
|
*/
|
|
593
|
-
|
|
454
|
+
source: string;
|
|
594
455
|
/**
|
|
595
|
-
*
|
|
596
|
-
* @param error - error
|
|
597
|
-
* @param queue - The queue encountered the error
|
|
598
|
-
* @param song - The playing song when encountered the error
|
|
456
|
+
* Songs in the playlist.
|
|
599
457
|
*/
|
|
600
|
-
|
|
458
|
+
songs: Song[];
|
|
601
459
|
/**
|
|
602
|
-
*
|
|
603
|
-
* @param message - debug message
|
|
460
|
+
* Playlist ID.
|
|
604
461
|
*/
|
|
605
|
-
|
|
462
|
+
id?: string;
|
|
606
463
|
/**
|
|
607
|
-
*
|
|
464
|
+
* Playlist name.
|
|
608
465
|
*/
|
|
609
|
-
|
|
466
|
+
name?: string;
|
|
610
467
|
/**
|
|
611
|
-
*
|
|
468
|
+
* Playlist URL.
|
|
612
469
|
*/
|
|
613
|
-
|
|
470
|
+
url?: string;
|
|
614
471
|
/**
|
|
615
|
-
*
|
|
472
|
+
* Playlist thumbnail.
|
|
616
473
|
*/
|
|
617
|
-
|
|
474
|
+
thumbnail?: string;
|
|
618
475
|
/**
|
|
619
|
-
*
|
|
476
|
+
* Create a Playlist
|
|
477
|
+
* @param playlist - Raw playlist info
|
|
478
|
+
* @param options - Optional data
|
|
620
479
|
*/
|
|
621
|
-
|
|
480
|
+
constructor(playlist: PlaylistInfo, { member, metadata }?: ResolveOptions<T>);
|
|
622
481
|
/**
|
|
623
|
-
*
|
|
482
|
+
* Playlist duration in second.
|
|
624
483
|
*/
|
|
625
|
-
get
|
|
484
|
+
get duration(): number;
|
|
626
485
|
/**
|
|
627
|
-
*
|
|
486
|
+
* Formatted duration string `hh:mm:ss`.
|
|
628
487
|
*/
|
|
629
|
-
get
|
|
488
|
+
get formattedDuration(): string;
|
|
489
|
+
/**
|
|
490
|
+
* User requested.
|
|
491
|
+
*/
|
|
492
|
+
get member(): GuildMember | undefined;
|
|
493
|
+
set member(member: GuildMember | undefined);
|
|
494
|
+
/**
|
|
495
|
+
* User requested.
|
|
496
|
+
*/
|
|
497
|
+
get user(): discord_js.User | undefined;
|
|
498
|
+
/**
|
|
499
|
+
* Optional metadata that can be used to identify the playlist.
|
|
500
|
+
*/
|
|
501
|
+
get metadata(): T;
|
|
502
|
+
set metadata(metadata: T);
|
|
503
|
+
toString(): string;
|
|
630
504
|
}
|
|
631
505
|
|
|
632
506
|
/**
|
|
633
|
-
*
|
|
507
|
+
* DisTube's Handler
|
|
634
508
|
*/
|
|
635
|
-
declare class
|
|
509
|
+
declare class DisTubeHandler extends DisTubeBase {
|
|
636
510
|
#private;
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
*/
|
|
649
|
-
get channelId(): string | undefined;
|
|
650
|
-
get channel(): VoiceBasedChannel;
|
|
651
|
-
set channel(channel: VoiceBasedChannel);
|
|
511
|
+
resolve<T = unknown>(song: Song<T>, options?: Omit<ResolveOptions, "metadata">): Promise<Song<T>>;
|
|
512
|
+
resolve<T = unknown>(song: Playlist<T>, options?: Omit<ResolveOptions, "metadata">): Promise<Playlist<T>>;
|
|
513
|
+
resolve<T = unknown>(song: string, options?: ResolveOptions<T>): Promise<Song<T> | Playlist<T>>;
|
|
514
|
+
resolve<T = unknown>(song: Song, options: ResolveOptions<T>): Promise<Song<T>>;
|
|
515
|
+
resolve<T = unknown>(song: Playlist, options: ResolveOptions<T>): Promise<Playlist<T>>;
|
|
516
|
+
resolve(song: string | Song | Playlist, options?: ResolveOptions): Promise<Song | Playlist>;
|
|
517
|
+
_getPluginFromURL(url: string): Promise<DisTubePlugin | null>;
|
|
518
|
+
_getPluginFromSong(song: Song): Promise<DisTubePlugin | null>;
|
|
519
|
+
_getPluginFromSong<T extends PluginType>(song: Song, types: T[], validate?: boolean): Promise<(DisTubePlugin & {
|
|
520
|
+
type: T;
|
|
521
|
+
}) | null>;
|
|
652
522
|
/**
|
|
653
|
-
*
|
|
654
|
-
* @param
|
|
523
|
+
* Get {@link Song}'s stream info and attach it to the song.
|
|
524
|
+
* @param song - A Song
|
|
655
525
|
*/
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
play(dtStream: DisTubeStream): Promise<void>;
|
|
673
|
-
set volume(volume: number);
|
|
674
|
-
/**
|
|
675
|
-
* Get or set the volume percentage
|
|
676
|
-
*/
|
|
677
|
-
get volume(): number;
|
|
678
|
-
/**
|
|
679
|
-
* Playback duration of the audio resource in seconds
|
|
680
|
-
*/
|
|
681
|
-
get playbackDuration(): number;
|
|
682
|
-
pause(): void;
|
|
683
|
-
unpause(): void;
|
|
684
|
-
/**
|
|
685
|
-
* Whether the bot is self-deafened
|
|
686
|
-
*/
|
|
687
|
-
get selfDeaf(): boolean;
|
|
688
|
-
/**
|
|
689
|
-
* Whether the bot is self-muted
|
|
690
|
-
*/
|
|
691
|
-
get selfMute(): boolean;
|
|
692
|
-
/**
|
|
693
|
-
* Self-deafens/undeafens the bot.
|
|
694
|
-
* @param selfDeaf - Whether or not the bot should be self-deafened
|
|
695
|
-
* @returns true if the voice state was successfully updated, otherwise false
|
|
696
|
-
*/
|
|
697
|
-
setSelfDeaf(selfDeaf: boolean): boolean;
|
|
698
|
-
/**
|
|
699
|
-
* Self-mutes/unmutes the bot.
|
|
700
|
-
* @param selfMute - Whether or not the bot should be self-muted
|
|
701
|
-
* @returns true if the voice state was successfully updated, otherwise false
|
|
702
|
-
*/
|
|
703
|
-
setSelfMute(selfMute: boolean): boolean;
|
|
704
|
-
/**
|
|
705
|
-
* The voice state of this connection
|
|
706
|
-
*/
|
|
707
|
-
get voiceState(): VoiceState | undefined;
|
|
526
|
+
attachStreamInfo(song: Song): Promise<void>;
|
|
527
|
+
followRedirectLink(url: string, maxRedirect?: number): Promise<string>;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
declare class Options {
|
|
531
|
+
#private;
|
|
532
|
+
plugins: DisTubePlugin[];
|
|
533
|
+
emitNewSongOnly: boolean;
|
|
534
|
+
savePreviousSongs: boolean;
|
|
535
|
+
customFilters?: Filters;
|
|
536
|
+
nsfw: boolean;
|
|
537
|
+
emitAddSongWhenCreatingQueue: boolean;
|
|
538
|
+
emitAddListWhenCreatingQueue: boolean;
|
|
539
|
+
joinNewVoiceChannel: boolean;
|
|
540
|
+
ffmpeg: FFmpegOptions;
|
|
541
|
+
constructor(options: DisTubeOptions);
|
|
708
542
|
}
|
|
709
543
|
|
|
710
544
|
/**
|
|
@@ -752,41 +586,81 @@ declare class VolumeTransformer extends Transform {
|
|
|
752
586
|
}
|
|
753
587
|
|
|
754
588
|
/**
|
|
755
|
-
*
|
|
589
|
+
* Create a voice connection to the voice channel
|
|
756
590
|
*/
|
|
757
|
-
declare class
|
|
591
|
+
declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
758
592
|
#private;
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
type: T;
|
|
769
|
-
}) | null>;
|
|
593
|
+
readonly id: Snowflake;
|
|
594
|
+
readonly voices: DisTubeVoiceManager;
|
|
595
|
+
readonly audioPlayer: AudioPlayer;
|
|
596
|
+
connection: VoiceConnection;
|
|
597
|
+
emittedError: boolean;
|
|
598
|
+
isDisconnected: boolean;
|
|
599
|
+
stream?: DisTubeStream;
|
|
600
|
+
pausingStream?: DisTubeStream;
|
|
601
|
+
constructor(voiceManager: DisTubeVoiceManager, channel: VoiceBasedChannel);
|
|
770
602
|
/**
|
|
771
|
-
*
|
|
772
|
-
* @param song - A Song
|
|
603
|
+
* The voice channel id the bot is in
|
|
773
604
|
*/
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
605
|
+
get channelId(): string | undefined;
|
|
606
|
+
get channel(): VoiceBasedChannel;
|
|
607
|
+
set channel(channel: VoiceBasedChannel);
|
|
608
|
+
/**
|
|
609
|
+
* Join a voice channel with this connection
|
|
610
|
+
* @param channel - A voice channel
|
|
611
|
+
*/
|
|
612
|
+
join(channel?: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
613
|
+
/**
|
|
614
|
+
* Leave the voice channel of this connection
|
|
615
|
+
* @param error - Optional, an error to emit with 'error' event.
|
|
616
|
+
*/
|
|
617
|
+
leave(error?: Error): void;
|
|
618
|
+
/**
|
|
619
|
+
* Stop the playing stream
|
|
620
|
+
* @param force - If true, will force the {@link DisTubeVoice#audioPlayer} to enter the Idle state even
|
|
621
|
+
* if the {@link DisTubeStream#audioResource} has silence padding frames.
|
|
622
|
+
*/
|
|
623
|
+
stop(force?: boolean): void;
|
|
624
|
+
/**
|
|
625
|
+
* Play a {@link DisTubeStream}
|
|
626
|
+
* @param dtStream - DisTubeStream
|
|
627
|
+
*/
|
|
628
|
+
play(dtStream: DisTubeStream): Promise<void>;
|
|
629
|
+
set volume(volume: number);
|
|
630
|
+
/**
|
|
631
|
+
* Get or set the volume percentage
|
|
632
|
+
*/
|
|
633
|
+
get volume(): number;
|
|
634
|
+
/**
|
|
635
|
+
* Playback duration of the audio resource in seconds
|
|
636
|
+
*/
|
|
637
|
+
get playbackDuration(): number;
|
|
638
|
+
pause(): void;
|
|
639
|
+
unpause(): void;
|
|
640
|
+
/**
|
|
641
|
+
* Whether the bot is self-deafened
|
|
642
|
+
*/
|
|
643
|
+
get selfDeaf(): boolean;
|
|
644
|
+
/**
|
|
645
|
+
* Whether the bot is self-muted
|
|
646
|
+
*/
|
|
647
|
+
get selfMute(): boolean;
|
|
648
|
+
/**
|
|
649
|
+
* Self-deafens/undeafens the bot.
|
|
650
|
+
* @param selfDeaf - Whether or not the bot should be self-deafened
|
|
651
|
+
* @returns true if the voice state was successfully updated, otherwise false
|
|
652
|
+
*/
|
|
653
|
+
setSelfDeaf(selfDeaf: boolean): boolean;
|
|
654
|
+
/**
|
|
655
|
+
* Self-mutes/unmutes the bot.
|
|
656
|
+
* @param selfMute - Whether or not the bot should be self-muted
|
|
657
|
+
* @returns true if the voice state was successfully updated, otherwise false
|
|
658
|
+
*/
|
|
659
|
+
setSelfMute(selfMute: boolean): boolean;
|
|
660
|
+
/**
|
|
661
|
+
* The voice state of this connection
|
|
662
|
+
*/
|
|
663
|
+
get voiceState(): VoiceState | undefined;
|
|
790
664
|
}
|
|
791
665
|
|
|
792
666
|
/**
|
|
@@ -834,6 +708,31 @@ declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
|
834
708
|
leave(guild: GuildIdResolvable): void;
|
|
835
709
|
}
|
|
836
710
|
|
|
711
|
+
/**
|
|
712
|
+
* Queue manager
|
|
713
|
+
*/
|
|
714
|
+
declare class QueueManager extends GuildIdManager<Queue> {
|
|
715
|
+
#private;
|
|
716
|
+
/**
|
|
717
|
+
* Create a {@link Queue}
|
|
718
|
+
* @param channel - A voice channel
|
|
719
|
+
* @param textChannel - Default text channel
|
|
720
|
+
* @returns Returns `true` if encounter an error
|
|
721
|
+
*/
|
|
722
|
+
create(channel: VoiceBasedChannel, textChannel?: GuildTextBasedChannel): Promise<Queue>;
|
|
723
|
+
/**
|
|
724
|
+
* Handle the queue when a Song finish
|
|
725
|
+
* @param queue - queue
|
|
726
|
+
*/
|
|
727
|
+
handleSongFinish(queue: Queue): Promise<void>;
|
|
728
|
+
/**
|
|
729
|
+
* Play a song on voice connection with queue properties
|
|
730
|
+
* @param queue - The guild queue to play
|
|
731
|
+
* @param emitPlaySong - Whether or not emit {@link Events.PLAY_SONG} event
|
|
732
|
+
*/
|
|
733
|
+
playSong(queue: Queue, emitPlaySong?: boolean): Promise<void>;
|
|
734
|
+
}
|
|
735
|
+
|
|
837
736
|
/**
|
|
838
737
|
* Manage filters of a playing {@link Queue}
|
|
839
738
|
*/
|
|
@@ -882,23 +781,26 @@ declare class FilterManager extends BaseManager<Filter> {
|
|
|
882
781
|
}
|
|
883
782
|
|
|
884
783
|
/**
|
|
885
|
-
*
|
|
784
|
+
* Task queuing system
|
|
886
785
|
*/
|
|
887
|
-
declare class
|
|
786
|
+
declare class TaskQueue {
|
|
888
787
|
#private;
|
|
889
788
|
/**
|
|
890
|
-
*
|
|
891
|
-
* @param channel - A voice channel
|
|
892
|
-
* @param textChannel - Default text channel
|
|
893
|
-
* @returns Returns `true` if encounter an error
|
|
789
|
+
* Waits for last task finished and queues a new task
|
|
894
790
|
*/
|
|
895
|
-
|
|
791
|
+
queuing(isPlay?: boolean): Promise<void>;
|
|
896
792
|
/**
|
|
897
|
-
*
|
|
898
|
-
* @param queue - The guild queue to play
|
|
899
|
-
* @param emitPlaySong - Whether or not emit {@link Events.PLAY_SONG} event
|
|
793
|
+
* Removes the finished task and processes the next task
|
|
900
794
|
*/
|
|
901
|
-
|
|
795
|
+
resolve(): void;
|
|
796
|
+
/**
|
|
797
|
+
* The remaining number of tasks
|
|
798
|
+
*/
|
|
799
|
+
get remaining(): number;
|
|
800
|
+
/**
|
|
801
|
+
* Whether or not having a play task
|
|
802
|
+
*/
|
|
803
|
+
get hasPlayTask(): boolean;
|
|
902
804
|
}
|
|
903
805
|
|
|
904
806
|
/**
|
|
@@ -957,13 +859,9 @@ declare class Queue extends DisTubeBase {
|
|
|
957
859
|
*/
|
|
958
860
|
_beginTime: number;
|
|
959
861
|
/**
|
|
960
|
-
* Whether or not the
|
|
961
|
-
*/
|
|
962
|
-
_next: boolean;
|
|
963
|
-
/**
|
|
964
|
-
* Whether or not the last song was skipped to previous song.
|
|
862
|
+
* Whether or not the queue is being updated manually (skip, jump, previous)
|
|
965
863
|
*/
|
|
966
|
-
|
|
864
|
+
_manualUpdate: boolean;
|
|
967
865
|
/**
|
|
968
866
|
* Task queuing system
|
|
969
867
|
*/
|
|
@@ -1047,9 +945,10 @@ declare class Queue extends DisTubeBase {
|
|
|
1047
945
|
* Skip the playing song if there is a next song in the queue. <info>If {@link
|
|
1048
946
|
* Queue#autoplay} is `true` and there is no up next song, DisTube will add and
|
|
1049
947
|
* play a related song.</info>
|
|
948
|
+
* @param options - Skip options
|
|
1050
949
|
* @returns The song will skip to
|
|
1051
950
|
*/
|
|
1052
|
-
skip(): Promise<Song>;
|
|
951
|
+
skip(options?: JumpOptions): Promise<Song>;
|
|
1053
952
|
/**
|
|
1054
953
|
* Play the previous song if exists
|
|
1055
954
|
* @returns The guild queue
|
|
@@ -1065,9 +964,10 @@ declare class Queue extends DisTubeBase {
|
|
|
1065
964
|
* one is -1, -2,...
|
|
1066
965
|
* if `num` is invalid number
|
|
1067
966
|
* @param position - The song position to play
|
|
967
|
+
* @param options - Skip options
|
|
1068
968
|
* @returns The new Song will be played
|
|
1069
969
|
*/
|
|
1070
|
-
jump(position: number): Promise<Song>;
|
|
970
|
+
jump(position: number, options?: JumpOptions): Promise<Song>;
|
|
1071
971
|
/**
|
|
1072
972
|
* Set the repeat mode of the guild queue.
|
|
1073
973
|
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
@@ -1107,169 +1007,34 @@ declare class Queue extends DisTubeBase {
|
|
|
1107
1007
|
}
|
|
1108
1008
|
|
|
1109
1009
|
/**
|
|
1110
|
-
* DisTube
|
|
1010
|
+
* DisTube class
|
|
1111
1011
|
*/
|
|
1112
|
-
declare
|
|
1012
|
+
declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
1013
|
+
#private;
|
|
1113
1014
|
/**
|
|
1114
|
-
*
|
|
1015
|
+
* @event
|
|
1016
|
+
* Emitted after DisTube add a new playlist to the playing {@link Queue}.
|
|
1017
|
+
* @param queue - The guild queue
|
|
1018
|
+
* @param playlist - Playlist info
|
|
1115
1019
|
*/
|
|
1116
|
-
|
|
1020
|
+
static readonly [Events.ADD_LIST]: (queue: Queue, playlist: Playlist) => Awaitable;
|
|
1117
1021
|
/**
|
|
1118
|
-
*
|
|
1022
|
+
* @event
|
|
1023
|
+
* Emitted after DisTube add a new song to the playing {@link Queue}.
|
|
1024
|
+
* @param queue - The guild queue
|
|
1025
|
+
* @param song - Added song
|
|
1119
1026
|
*/
|
|
1120
|
-
|
|
1121
|
-
init(distube: DisTube): void;
|
|
1027
|
+
static readonly [Events.ADD_SONG]: (queue: Queue, song: Song) => Awaitable;
|
|
1122
1028
|
/**
|
|
1123
|
-
*
|
|
1124
|
-
* @
|
|
1029
|
+
* @event
|
|
1030
|
+
* Emitted when a {@link Queue} is deleted with any reasons.
|
|
1031
|
+
* @param queue - The guild queue
|
|
1125
1032
|
*/
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
/**
|
|
1130
|
-
* This plugin can extract the info, search, and play a song directly from its source
|
|
1131
|
-
*/
|
|
1132
|
-
declare abstract class ExtractorPlugin extends Plugin {
|
|
1133
|
-
readonly type = PluginType.EXTRACTOR;
|
|
1033
|
+
static readonly [Events.DELETE_QUEUE]: (queue: Queue) => Awaitable;
|
|
1134
1034
|
/**
|
|
1135
|
-
*
|
|
1136
|
-
*
|
|
1137
|
-
|
|
1138
|
-
abstract validate(url: string): Awaitable<boolean>;
|
|
1139
|
-
/**
|
|
1140
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1141
|
-
* @param url - URL
|
|
1142
|
-
* @param options - Optional options
|
|
1143
|
-
*/
|
|
1144
|
-
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1145
|
-
/**
|
|
1146
|
-
* Search for a Song which playable from this plugin's source
|
|
1147
|
-
* @param query - Search query
|
|
1148
|
-
* @param options - Optional options
|
|
1149
|
-
*/
|
|
1150
|
-
abstract searchSong<T>(query: string, options: ResolveOptions<T>): Awaitable<Song<T> | null>;
|
|
1151
|
-
/**
|
|
1152
|
-
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
1153
|
-
* Not needed if the plugin plays song from YouTube.
|
|
1154
|
-
* @param song - Input song
|
|
1155
|
-
*/
|
|
1156
|
-
abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
/**
|
|
1160
|
-
* This plugin only can extract the info from supported links, but not play song directly from its source
|
|
1161
|
-
*/
|
|
1162
|
-
declare abstract class InfoExtractorPlugin extends Plugin {
|
|
1163
|
-
readonly type = PluginType.INFO_EXTRACTOR;
|
|
1164
|
-
/**
|
|
1165
|
-
* Check if the url is working with this plugin
|
|
1166
|
-
* @param url - Input url
|
|
1167
|
-
*/
|
|
1168
|
-
abstract validate(url: string): Awaitable<boolean>;
|
|
1169
|
-
/**
|
|
1170
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1171
|
-
* @param url - URL
|
|
1172
|
-
* @param options - Optional options
|
|
1173
|
-
*/
|
|
1174
|
-
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1175
|
-
/**
|
|
1176
|
-
* Create a search query to be used in {@link ExtractorPlugin#searchSong}
|
|
1177
|
-
* @param song - Input song
|
|
1178
|
-
*/
|
|
1179
|
-
abstract createSearchQuery<T>(song: Song<T>): Awaitable<string>;
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
|
-
/**
|
|
1183
|
-
* This plugin can extract and play song from supported links, but cannot search for songs from its source
|
|
1184
|
-
*/
|
|
1185
|
-
declare abstract class PlayableExtractorPlugin extends Plugin {
|
|
1186
|
-
readonly type = PluginType.PLAYABLE_EXTRACTOR;
|
|
1187
|
-
/**
|
|
1188
|
-
* Check if the url is working with this plugin
|
|
1189
|
-
* @param url - Input url
|
|
1190
|
-
*/
|
|
1191
|
-
abstract validate(url: string): Awaitable<boolean>;
|
|
1192
|
-
/**
|
|
1193
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1194
|
-
* @param url - URL
|
|
1195
|
-
* @param options - Optional options
|
|
1196
|
-
*/
|
|
1197
|
-
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1198
|
-
/**
|
|
1199
|
-
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
1200
|
-
* Not needed if the plugin plays song from YouTube.
|
|
1201
|
-
* @param song - Input song
|
|
1202
|
-
*/
|
|
1203
|
-
abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
/**
|
|
1207
|
-
* Format duration to string
|
|
1208
|
-
* @param sec - Duration in seconds
|
|
1209
|
-
*/
|
|
1210
|
-
declare function formatDuration(sec: number): string;
|
|
1211
|
-
declare const SUPPORTED_PROTOCOL: readonly ["https:", "http:", "file:"];
|
|
1212
|
-
/**
|
|
1213
|
-
* Check if the string is an URL
|
|
1214
|
-
* @param input - input
|
|
1215
|
-
*/
|
|
1216
|
-
declare function isURL(input: any): input is `${(typeof SUPPORTED_PROTOCOL)[number]}//${string}`;
|
|
1217
|
-
/**
|
|
1218
|
-
* Check if the Client has enough intents to using DisTube
|
|
1219
|
-
* @param options - options
|
|
1220
|
-
*/
|
|
1221
|
-
declare function checkIntents(options: ClientOptions): void;
|
|
1222
|
-
/**
|
|
1223
|
-
* Check if the voice channel is empty
|
|
1224
|
-
* @param voiceState - voiceState
|
|
1225
|
-
*/
|
|
1226
|
-
declare function isVoiceChannelEmpty(voiceState: VoiceState): boolean;
|
|
1227
|
-
declare function isSnowflake(id: any): id is Snowflake;
|
|
1228
|
-
declare function isMemberInstance(member: any): member is GuildMember;
|
|
1229
|
-
declare function isTextChannelInstance(channel: any): channel is GuildTextBasedChannel;
|
|
1230
|
-
declare function isMessageInstance(message: any): message is Message<true>;
|
|
1231
|
-
declare function isSupportedVoiceChannel(channel: any): channel is VoiceBasedChannel;
|
|
1232
|
-
declare function isGuildInstance(guild: any): guild is Guild;
|
|
1233
|
-
declare function resolveGuildId(resolvable: GuildIdResolvable): Snowflake;
|
|
1234
|
-
declare function isClientInstance(client: any): client is Client;
|
|
1235
|
-
declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
|
|
1236
|
-
declare function isObject(obj: any): obj is object;
|
|
1237
|
-
type KeyOf<T> = T extends object ? (keyof T)[] : [];
|
|
1238
|
-
declare function objectKeys<T>(obj: T): KeyOf<T>;
|
|
1239
|
-
declare function isNsfwChannel(channel?: GuildTextBasedChannel): boolean;
|
|
1240
|
-
type Falsy = undefined | null | false | 0 | "";
|
|
1241
|
-
declare const isTruthy: <T>(x: T | Falsy) => x is T;
|
|
1242
|
-
declare const checkEncryptionLibraries: () => Promise<boolean>;
|
|
1243
|
-
|
|
1244
|
-
/**
|
|
1245
|
-
* DisTube class
|
|
1246
|
-
*/
|
|
1247
|
-
declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
1248
|
-
#private;
|
|
1249
|
-
/**
|
|
1250
|
-
* @event
|
|
1251
|
-
* Emitted after DisTube add a new playlist to the playing {@link Queue}.
|
|
1252
|
-
* @param queue - The guild queue
|
|
1253
|
-
* @param playlist - Playlist info
|
|
1254
|
-
*/
|
|
1255
|
-
static readonly [Events.ADD_LIST]: (queue: Queue, playlist: Playlist) => Awaitable;
|
|
1256
|
-
/**
|
|
1257
|
-
* @event
|
|
1258
|
-
* Emitted after DisTube add a new song to the playing {@link Queue}.
|
|
1259
|
-
* @param queue - The guild queue
|
|
1260
|
-
* @param song - Added song
|
|
1261
|
-
*/
|
|
1262
|
-
static readonly [Events.ADD_SONG]: (queue: Queue, song: Song) => Awaitable;
|
|
1263
|
-
/**
|
|
1264
|
-
* @event
|
|
1265
|
-
* Emitted when a {@link Queue} is deleted with any reasons.
|
|
1266
|
-
* @param queue - The guild queue
|
|
1267
|
-
*/
|
|
1268
|
-
static readonly [Events.DELETE_QUEUE]: (queue: Queue) => Awaitable;
|
|
1269
|
-
/**
|
|
1270
|
-
* @event
|
|
1271
|
-
* Emitted when the bot is disconnected to a voice channel.
|
|
1272
|
-
* @param queue - The guild queue
|
|
1035
|
+
* @event
|
|
1036
|
+
* Emitted when the bot is disconnected to a voice channel.
|
|
1037
|
+
* @param queue - The guild queue
|
|
1273
1038
|
*/
|
|
1274
1039
|
static readonly [Events.DISCONNECT]: (queue: Queue) => Awaitable;
|
|
1275
1040
|
/**
|
|
@@ -1421,7 +1186,7 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1421
1186
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
1422
1187
|
* @returns The new Song will be played
|
|
1423
1188
|
*/
|
|
1424
|
-
skip(guild: GuildIdResolvable): Promise<Song>;
|
|
1189
|
+
skip(guild: GuildIdResolvable, options?: JumpOptions): Promise<Song>;
|
|
1425
1190
|
/**
|
|
1426
1191
|
* Play the previous song
|
|
1427
1192
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
@@ -1441,7 +1206,7 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1441
1206
|
* @param num - The song number to play
|
|
1442
1207
|
* @returns The new Song will be played
|
|
1443
1208
|
*/
|
|
1444
|
-
jump(guild: GuildIdResolvable, num: number): Promise<Song>;
|
|
1209
|
+
jump(guild: GuildIdResolvable, num: number, options?: JumpOptions): Promise<Song>;
|
|
1445
1210
|
/**
|
|
1446
1211
|
* Set the repeat mode of the guild queue.
|
|
1447
1212
|
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
@@ -1483,12 +1248,251 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1483
1248
|
debug(message: string): void;
|
|
1484
1249
|
}
|
|
1485
1250
|
|
|
1251
|
+
declare abstract class DisTubeBase {
|
|
1252
|
+
distube: DisTube;
|
|
1253
|
+
constructor(distube: DisTube);
|
|
1254
|
+
/**
|
|
1255
|
+
* Emit the {@link DisTube} of this base
|
|
1256
|
+
* @param eventName - Event name
|
|
1257
|
+
* @param args - arguments
|
|
1258
|
+
*/
|
|
1259
|
+
emit(eventName: keyof DisTubeEvents, ...args: any): boolean;
|
|
1260
|
+
/**
|
|
1261
|
+
* Emit error event
|
|
1262
|
+
* @param error - error
|
|
1263
|
+
* @param queue - The queue encountered the error
|
|
1264
|
+
* @param song - The playing song when encountered the error
|
|
1265
|
+
*/
|
|
1266
|
+
emitError(error: Error, queue: Queue, song?: Song): void;
|
|
1267
|
+
/**
|
|
1268
|
+
* Emit debug event
|
|
1269
|
+
* @param message - debug message
|
|
1270
|
+
*/
|
|
1271
|
+
debug(message: string): void;
|
|
1272
|
+
/**
|
|
1273
|
+
* The queue manager
|
|
1274
|
+
*/
|
|
1275
|
+
get queues(): QueueManager;
|
|
1276
|
+
/**
|
|
1277
|
+
* The voice manager
|
|
1278
|
+
*/
|
|
1279
|
+
get voices(): DisTubeVoiceManager;
|
|
1280
|
+
/**
|
|
1281
|
+
* Discord.js client
|
|
1282
|
+
*/
|
|
1283
|
+
get client(): Client;
|
|
1284
|
+
/**
|
|
1285
|
+
* DisTube options
|
|
1286
|
+
*/
|
|
1287
|
+
get options(): Options;
|
|
1288
|
+
/**
|
|
1289
|
+
* DisTube handler
|
|
1290
|
+
*/
|
|
1291
|
+
get handler(): DisTubeHandler;
|
|
1292
|
+
/**
|
|
1293
|
+
* DisTube plugins
|
|
1294
|
+
*/
|
|
1295
|
+
get plugins(): DisTubePlugin[];
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
declare const ERROR_MESSAGES: {
|
|
1299
|
+
INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) => string;
|
|
1300
|
+
NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
|
|
1301
|
+
EMPTY_ARRAY: (name: string) => string;
|
|
1302
|
+
EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
|
|
1303
|
+
EMPTY_STRING: (name: string) => string;
|
|
1304
|
+
INVALID_KEY: (obj: string, key: string) => string;
|
|
1305
|
+
MISSING_KEY: (obj: string, key: string) => string;
|
|
1306
|
+
MISSING_KEYS: (obj: string, key: string[], all: boolean) => string;
|
|
1307
|
+
MISSING_INTENTS: (i: string) => string;
|
|
1308
|
+
DISABLED_OPTION: (o: string) => string;
|
|
1309
|
+
ENABLED_OPTION: (o: string) => string;
|
|
1310
|
+
NOT_IN_VOICE: string;
|
|
1311
|
+
VOICE_FULL: string;
|
|
1312
|
+
VOICE_ALREADY_CREATED: string;
|
|
1313
|
+
VOICE_CONNECT_FAILED: (s: number) => string;
|
|
1314
|
+
VOICE_MISSING_PERMS: string;
|
|
1315
|
+
VOICE_RECONNECT_FAILED: string;
|
|
1316
|
+
VOICE_DIFFERENT_GUILD: string;
|
|
1317
|
+
VOICE_DIFFERENT_CLIENT: string;
|
|
1318
|
+
FFMPEG_EXITED: (code: number) => string;
|
|
1319
|
+
FFMPEG_NOT_INSTALLED: (path: string) => string;
|
|
1320
|
+
ENCRYPTION_LIBRARIES_MISSING: string;
|
|
1321
|
+
NO_QUEUE: string;
|
|
1322
|
+
QUEUE_EXIST: string;
|
|
1323
|
+
QUEUE_STOPPED: string;
|
|
1324
|
+
PAUSED: string;
|
|
1325
|
+
RESUMED: string;
|
|
1326
|
+
NO_PREVIOUS: string;
|
|
1327
|
+
NO_UP_NEXT: string;
|
|
1328
|
+
NO_SONG_POSITION: string;
|
|
1329
|
+
NO_PLAYING_SONG: string;
|
|
1330
|
+
NO_EXTRACTOR_PLUGIN: string;
|
|
1331
|
+
NO_RELATED: string;
|
|
1332
|
+
CANNOT_PLAY_RELATED: string;
|
|
1333
|
+
UNAVAILABLE_VIDEO: string;
|
|
1334
|
+
UNPLAYABLE_FORMATS: string;
|
|
1335
|
+
NON_NSFW: string;
|
|
1336
|
+
NOT_SUPPORTED_URL: string;
|
|
1337
|
+
NOT_SUPPORTED_SONG: (song: string) => string;
|
|
1338
|
+
NO_VALID_SONG: string;
|
|
1339
|
+
CANNOT_RESOLVE_SONG: (t: any) => string;
|
|
1340
|
+
CANNOT_GET_STREAM_URL: (song: string) => string;
|
|
1341
|
+
CANNOT_GET_SEARCH_QUERY: (song: string) => string;
|
|
1342
|
+
NO_RESULT: (query: string) => string;
|
|
1343
|
+
NO_STREAM_URL: (song: string) => string;
|
|
1344
|
+
EMPTY_FILTERED_PLAYLIST: string;
|
|
1345
|
+
EMPTY_PLAYLIST: string;
|
|
1346
|
+
};
|
|
1347
|
+
type ErrorMessage = typeof ERROR_MESSAGES;
|
|
1348
|
+
type ErrorCode = keyof ErrorMessage;
|
|
1349
|
+
type StaticErrorCode = {
|
|
1350
|
+
[K in ErrorCode]-?: ErrorMessage[K] extends string ? K : never;
|
|
1351
|
+
}[ErrorCode];
|
|
1352
|
+
type TemplateErrorCode = Exclude<keyof typeof ERROR_MESSAGES, StaticErrorCode>;
|
|
1353
|
+
declare class DisTubeError<T extends string = any> extends Error {
|
|
1354
|
+
errorCode: string;
|
|
1355
|
+
constructor(code: T extends StaticErrorCode ? T : never);
|
|
1356
|
+
constructor(code: T extends TemplateErrorCode ? T : never, ...args: Parameters<ErrorMessage[typeof code]>);
|
|
1357
|
+
constructor(code: TemplateErrorCode, _: never);
|
|
1358
|
+
constructor(code: T extends ErrorCode ? never : T, message: string);
|
|
1359
|
+
get name(): string;
|
|
1360
|
+
get code(): string;
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1486
1363
|
/**
|
|
1487
|
-
*
|
|
1488
|
-
*
|
|
1489
|
-
* Note to developers:
|
|
1490
|
-
* This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
|
|
1364
|
+
* DisTube Plugin
|
|
1491
1365
|
*/
|
|
1492
|
-
declare
|
|
1366
|
+
declare abstract class Plugin {
|
|
1367
|
+
/**
|
|
1368
|
+
* Type of the plugin
|
|
1369
|
+
*/
|
|
1370
|
+
abstract readonly type: PluginType;
|
|
1371
|
+
/**
|
|
1372
|
+
* DisTube
|
|
1373
|
+
*/
|
|
1374
|
+
distube: DisTube;
|
|
1375
|
+
init(distube: DisTube): void;
|
|
1376
|
+
/**
|
|
1377
|
+
* Get related songs from a supported url.
|
|
1378
|
+
* @param song - Input song
|
|
1379
|
+
*/
|
|
1380
|
+
abstract getRelatedSongs(song: Song): Awaitable<Song[]>;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
/**
|
|
1384
|
+
* This plugin can extract the info, search, and play a song directly from its source
|
|
1385
|
+
*/
|
|
1386
|
+
declare abstract class ExtractorPlugin extends Plugin {
|
|
1387
|
+
readonly type = PluginType.EXTRACTOR;
|
|
1388
|
+
/**
|
|
1389
|
+
* Check if the url is working with this plugin
|
|
1390
|
+
* @param url - Input url
|
|
1391
|
+
*/
|
|
1392
|
+
abstract validate(url: string): Awaitable<boolean>;
|
|
1393
|
+
/**
|
|
1394
|
+
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1395
|
+
* @param url - URL
|
|
1396
|
+
* @param options - Optional options
|
|
1397
|
+
*/
|
|
1398
|
+
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1399
|
+
/**
|
|
1400
|
+
* Search for a Song which playable from this plugin's source
|
|
1401
|
+
* @param query - Search query
|
|
1402
|
+
* @param options - Optional options
|
|
1403
|
+
*/
|
|
1404
|
+
abstract searchSong<T>(query: string, options: ResolveOptions<T>): Awaitable<Song<T> | null>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
1407
|
+
* Not needed if the plugin plays song from YouTube.
|
|
1408
|
+
* @param song - Input song
|
|
1409
|
+
*/
|
|
1410
|
+
abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
/**
|
|
1414
|
+
* This plugin only can extract the info from supported links, but not play song directly from its source
|
|
1415
|
+
*/
|
|
1416
|
+
declare abstract class InfoExtractorPlugin extends Plugin {
|
|
1417
|
+
readonly type = PluginType.INFO_EXTRACTOR;
|
|
1418
|
+
/**
|
|
1419
|
+
* Check if the url is working with this plugin
|
|
1420
|
+
* @param url - Input url
|
|
1421
|
+
*/
|
|
1422
|
+
abstract validate(url: string): Awaitable<boolean>;
|
|
1423
|
+
/**
|
|
1424
|
+
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1425
|
+
* @param url - URL
|
|
1426
|
+
* @param options - Optional options
|
|
1427
|
+
*/
|
|
1428
|
+
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1429
|
+
/**
|
|
1430
|
+
* Create a search query to be used in {@link ExtractorPlugin#searchSong}
|
|
1431
|
+
* @param song - Input song
|
|
1432
|
+
*/
|
|
1433
|
+
abstract createSearchQuery<T>(song: Song<T>): Awaitable<string>;
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
/**
|
|
1437
|
+
* This plugin can extract and play song from supported links, but cannot search for songs from its source
|
|
1438
|
+
*/
|
|
1439
|
+
declare abstract class PlayableExtractorPlugin extends Plugin {
|
|
1440
|
+
readonly type = PluginType.PLAYABLE_EXTRACTOR;
|
|
1441
|
+
/**
|
|
1442
|
+
* Check if the url is working with this plugin
|
|
1443
|
+
* @param url - Input url
|
|
1444
|
+
*/
|
|
1445
|
+
abstract validate(url: string): Awaitable<boolean>;
|
|
1446
|
+
/**
|
|
1447
|
+
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1448
|
+
* @param url - URL
|
|
1449
|
+
* @param options - Optional options
|
|
1450
|
+
*/
|
|
1451
|
+
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1452
|
+
/**
|
|
1453
|
+
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
1454
|
+
* Not needed if the plugin plays song from YouTube.
|
|
1455
|
+
* @param song - Input song
|
|
1456
|
+
*/
|
|
1457
|
+
abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
|
|
1458
|
+
}
|
|
1459
|
+
|
|
1460
|
+
/**
|
|
1461
|
+
* Format duration to string
|
|
1462
|
+
* @param sec - Duration in seconds
|
|
1463
|
+
*/
|
|
1464
|
+
declare function formatDuration(sec: number): string;
|
|
1465
|
+
declare const SUPPORTED_PROTOCOL: readonly ["https:", "http:", "file:"];
|
|
1466
|
+
/**
|
|
1467
|
+
* Check if the string is an URL
|
|
1468
|
+
* @param input - input
|
|
1469
|
+
*/
|
|
1470
|
+
declare function isURL(input: any): input is `${(typeof SUPPORTED_PROTOCOL)[number]}//${string}`;
|
|
1471
|
+
/**
|
|
1472
|
+
* Check if the Client has enough intents to using DisTube
|
|
1473
|
+
* @param options - options
|
|
1474
|
+
*/
|
|
1475
|
+
declare function checkIntents(options: ClientOptions): void;
|
|
1476
|
+
/**
|
|
1477
|
+
* Check if the voice channel is empty
|
|
1478
|
+
* @param voiceState - voiceState
|
|
1479
|
+
*/
|
|
1480
|
+
declare function isVoiceChannelEmpty(voiceState: VoiceState): boolean;
|
|
1481
|
+
declare function isSnowflake(id: any): id is Snowflake;
|
|
1482
|
+
declare function isMemberInstance(member: any): member is GuildMember;
|
|
1483
|
+
declare function isTextChannelInstance(channel: any): channel is GuildTextBasedChannel;
|
|
1484
|
+
declare function isMessageInstance(message: any): message is Message<true>;
|
|
1485
|
+
declare function isSupportedVoiceChannel(channel: any): channel is VoiceBasedChannel;
|
|
1486
|
+
declare function isGuildInstance(guild: any): guild is Guild;
|
|
1487
|
+
declare function resolveGuildId(resolvable: GuildIdResolvable): Snowflake;
|
|
1488
|
+
declare function isClientInstance(client: any): client is Client;
|
|
1489
|
+
declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
|
|
1490
|
+
declare function isObject(obj: any): obj is object;
|
|
1491
|
+
type KeyOf<T> = T extends object ? (keyof T)[] : [];
|
|
1492
|
+
declare function objectKeys<T>(obj: T): KeyOf<T>;
|
|
1493
|
+
declare function isNsfwChannel(channel?: GuildTextBasedChannel): boolean;
|
|
1494
|
+
type Falsy = undefined | null | false | 0 | "";
|
|
1495
|
+
declare const isTruthy: <T>(x: T | Falsy) => x is T;
|
|
1496
|
+
declare const checkEncryptionLibraries: () => Promise<boolean>;
|
|
1493
1497
|
|
|
1494
|
-
export { type Awaitable, BaseManager, type CustomPlaylistOptions, DisTube, DisTubeBase, DisTubeError, type DisTubeEvents, DisTubeHandler, type DisTubeOptions, type DisTubePlugin, DisTubeStream, DisTubeVoice, type DisTubeVoiceEvents, DisTubeVoiceManager, Events, ExtractorPlugin, type FFmpegArg, type FFmpegArgs, type FFmpegOptions, type Falsy, type Filter, FilterManager, type FilterResolvable, type Filters, GuildIdManager, type GuildIdResolvable, InfoExtractorPlugin, type KeyOf, Options, type PlayHandlerOptions, type PlayOptions, PlayableExtractorPlugin, Playlist, type PlaylistInfo, Plugin, PluginType, Queue, QueueManager, type RelatedSong, RepeatMode, type ResolveOptions, type ResolvePlaylistOptions, Song, type SongInfo, type StreamOptions, TaskQueue, type TypedDisTubeEvents, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, DisTube as default, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|
|
1498
|
+
export { type Awaitable, BaseManager, type CustomPlaylistOptions, DisTube, DisTubeBase, DisTubeError, type DisTubeEvents, DisTubeHandler, type DisTubeOptions, type DisTubePlugin, DisTubeStream, DisTubeVoice, type DisTubeVoiceEvents, DisTubeVoiceManager, Events, ExtractorPlugin, type FFmpegArg, type FFmpegArgs, type FFmpegOptions, type Falsy, type Filter, FilterManager, type FilterResolvable, type Filters, GuildIdManager, type GuildIdResolvable, InfoExtractorPlugin, type JumpOptions, type KeyOf, Options, type PlayHandlerOptions, type PlayOptions, PlayableExtractorPlugin, Playlist, type PlaylistInfo, Plugin, PluginType, Queue, QueueManager, type RelatedSong, RepeatMode, type ResolveOptions, type ResolvePlaylistOptions, Song, type SongInfo, type StreamOptions, TaskQueue, type TypedDisTubeEvents, checkEncryptionLibraries, checkFFmpeg, checkIntents, checkInvalidKey, DisTube as default, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|