distube 5.0.6 → 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 +472 -464
- package/dist/index.d.ts +474 -464
- package/dist/index.js +1616 -1613
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1614 -1611
- package/dist/index.mjs.map +1 -1
- package/package.json +26 -32
package/dist/index.d.ts
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,150 +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(): 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
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Class representing a playlist.
|
|
403
|
-
*/
|
|
404
|
-
declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
405
|
-
#private;
|
|
406
|
-
/**
|
|
407
|
-
* Playlist source.
|
|
408
|
-
*/
|
|
409
|
-
source: string;
|
|
410
|
-
/**
|
|
411
|
-
* Songs in the playlist.
|
|
412
|
-
*/
|
|
413
|
-
songs: Song[];
|
|
414
|
-
/**
|
|
415
|
-
* Playlist ID.
|
|
416
|
-
*/
|
|
417
|
-
id?: string;
|
|
418
|
-
/**
|
|
419
|
-
* Playlist name.
|
|
420
|
-
*/
|
|
421
|
-
name?: string;
|
|
422
|
-
/**
|
|
423
|
-
* Playlist URL.
|
|
424
|
-
*/
|
|
425
|
-
url?: string;
|
|
426
|
-
/**
|
|
427
|
-
* Playlist thumbnail.
|
|
428
|
-
*/
|
|
429
|
-
thumbnail?: string;
|
|
430
|
-
/**
|
|
431
|
-
* Create a Playlist
|
|
432
|
-
* @param playlist - Raw playlist info
|
|
433
|
-
* @param options - Optional data
|
|
434
|
-
*/
|
|
435
|
-
constructor(playlist: PlaylistInfo, { member, metadata }?: ResolveOptions<T>);
|
|
436
|
-
/**
|
|
437
|
-
* Playlist duration in second.
|
|
438
|
-
*/
|
|
439
|
-
get duration(): number;
|
|
440
|
-
/**
|
|
441
|
-
* Formatted duration string `hh:mm:ss`.
|
|
442
|
-
*/
|
|
443
|
-
get formattedDuration(): string;
|
|
444
|
-
/**
|
|
445
|
-
* User requested.
|
|
446
|
-
*/
|
|
447
|
-
get member(): GuildMember | undefined;
|
|
448
|
-
set member(member: GuildMember | undefined);
|
|
449
|
-
/**
|
|
450
|
-
* User requested.
|
|
451
|
-
*/
|
|
452
|
-
get user(): discord_js.User | undefined;
|
|
453
|
-
/**
|
|
454
|
-
* Optional metadata that can be used to identify the playlist.
|
|
455
|
-
*/
|
|
456
|
-
get metadata(): T;
|
|
457
|
-
set metadata(metadata: T);
|
|
458
|
-
toString(): string;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
326
|
/**
|
|
462
327
|
* Class representing a song.
|
|
463
328
|
*/
|
|
@@ -578,129 +443,102 @@ declare class Song<T = unknown> {
|
|
|
578
443
|
toString(): string;
|
|
579
444
|
}
|
|
580
445
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
446
|
+
/**
|
|
447
|
+
* Class representing a playlist.
|
|
448
|
+
*/
|
|
449
|
+
declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
450
|
+
#private;
|
|
584
451
|
/**
|
|
585
|
-
*
|
|
586
|
-
* @param eventName - Event name
|
|
587
|
-
* @param args - arguments
|
|
452
|
+
* Playlist source.
|
|
588
453
|
*/
|
|
589
|
-
|
|
454
|
+
source: string;
|
|
590
455
|
/**
|
|
591
|
-
*
|
|
592
|
-
* @param error - error
|
|
593
|
-
* @param queue - The queue encountered the error
|
|
594
|
-
* @param song - The playing song when encountered the error
|
|
456
|
+
* Songs in the playlist.
|
|
595
457
|
*/
|
|
596
|
-
|
|
458
|
+
songs: Song[];
|
|
597
459
|
/**
|
|
598
|
-
*
|
|
599
|
-
* @param message - debug message
|
|
460
|
+
* Playlist ID.
|
|
600
461
|
*/
|
|
601
|
-
|
|
462
|
+
id?: string;
|
|
602
463
|
/**
|
|
603
|
-
*
|
|
464
|
+
* Playlist name.
|
|
604
465
|
*/
|
|
605
|
-
|
|
466
|
+
name?: string;
|
|
606
467
|
/**
|
|
607
|
-
*
|
|
468
|
+
* Playlist URL.
|
|
608
469
|
*/
|
|
609
|
-
|
|
470
|
+
url?: string;
|
|
610
471
|
/**
|
|
611
|
-
*
|
|
472
|
+
* Playlist thumbnail.
|
|
612
473
|
*/
|
|
613
|
-
|
|
474
|
+
thumbnail?: string;
|
|
614
475
|
/**
|
|
615
|
-
*
|
|
476
|
+
* Create a Playlist
|
|
477
|
+
* @param playlist - Raw playlist info
|
|
478
|
+
* @param options - Optional data
|
|
616
479
|
*/
|
|
617
|
-
|
|
480
|
+
constructor(playlist: PlaylistInfo, { member, metadata }?: ResolveOptions<T>);
|
|
618
481
|
/**
|
|
619
|
-
*
|
|
482
|
+
* Playlist duration in second.
|
|
620
483
|
*/
|
|
621
|
-
get
|
|
484
|
+
get duration(): number;
|
|
622
485
|
/**
|
|
623
|
-
*
|
|
486
|
+
* Formatted duration string `hh:mm:ss`.
|
|
624
487
|
*/
|
|
625
|
-
get
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
/**
|
|
629
|
-
* Create a voice connection to the voice channel
|
|
630
|
-
*/
|
|
631
|
-
declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
632
|
-
#private;
|
|
633
|
-
readonly id: Snowflake;
|
|
634
|
-
readonly voices: DisTubeVoiceManager;
|
|
635
|
-
readonly audioPlayer: AudioPlayer;
|
|
636
|
-
connection: VoiceConnection;
|
|
637
|
-
emittedError: boolean;
|
|
638
|
-
isDisconnected: boolean;
|
|
639
|
-
stream?: DisTubeStream;
|
|
640
|
-
pausingStream?: DisTubeStream;
|
|
641
|
-
constructor(voiceManager: DisTubeVoiceManager, channel: VoiceBasedChannel);
|
|
488
|
+
get formattedDuration(): string;
|
|
642
489
|
/**
|
|
643
|
-
*
|
|
490
|
+
* User requested.
|
|
644
491
|
*/
|
|
645
|
-
get
|
|
646
|
-
|
|
647
|
-
set channel(channel: VoiceBasedChannel);
|
|
492
|
+
get member(): GuildMember | undefined;
|
|
493
|
+
set member(member: GuildMember | undefined);
|
|
648
494
|
/**
|
|
649
|
-
*
|
|
650
|
-
* @param channel - A voice channel
|
|
495
|
+
* User requested.
|
|
651
496
|
*/
|
|
652
|
-
|
|
497
|
+
get user(): discord_js.User | undefined;
|
|
653
498
|
/**
|
|
654
|
-
*
|
|
655
|
-
* @param error - Optional, an error to emit with 'error' event.
|
|
499
|
+
* Optional metadata that can be used to identify the playlist.
|
|
656
500
|
*/
|
|
657
|
-
|
|
501
|
+
get metadata(): T;
|
|
502
|
+
set metadata(metadata: T);
|
|
503
|
+
toString(): string;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* DisTube's Handler
|
|
508
|
+
*/
|
|
509
|
+
declare class DisTubeHandler extends DisTubeBase {
|
|
510
|
+
#private;
|
|
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>;
|
|
658
522
|
/**
|
|
659
|
-
*
|
|
660
|
-
* @param
|
|
661
|
-
* if the {@link DisTubeStream#audioResource} has silence padding frames.
|
|
662
|
-
*/
|
|
663
|
-
stop(force?: boolean): void;
|
|
664
|
-
/**
|
|
665
|
-
* Play a {@link DisTubeStream}
|
|
666
|
-
* @param dtStream - DisTubeStream
|
|
667
|
-
*/
|
|
668
|
-
play(dtStream: DisTubeStream): Promise<void>;
|
|
669
|
-
set volume(volume: number);
|
|
670
|
-
/**
|
|
671
|
-
* Get or set the volume percentage
|
|
672
|
-
*/
|
|
673
|
-
get volume(): number;
|
|
674
|
-
/**
|
|
675
|
-
* Playback duration of the audio resource in seconds
|
|
676
|
-
*/
|
|
677
|
-
get playbackDuration(): number;
|
|
678
|
-
pause(): void;
|
|
679
|
-
unpause(): void;
|
|
680
|
-
/**
|
|
681
|
-
* Whether the bot is self-deafened
|
|
682
|
-
*/
|
|
683
|
-
get selfDeaf(): boolean;
|
|
684
|
-
/**
|
|
685
|
-
* Whether the bot is self-muted
|
|
686
|
-
*/
|
|
687
|
-
get selfMute(): boolean;
|
|
688
|
-
/**
|
|
689
|
-
* Self-deafens/undeafens the bot.
|
|
690
|
-
* @param selfDeaf - Whether or not the bot should be self-deafened
|
|
691
|
-
* @returns true if the voice state was successfully updated, otherwise false
|
|
692
|
-
*/
|
|
693
|
-
setSelfDeaf(selfDeaf: boolean): boolean;
|
|
694
|
-
/**
|
|
695
|
-
* Self-mutes/unmutes the bot.
|
|
696
|
-
* @param selfMute - Whether or not the bot should be self-muted
|
|
697
|
-
* @returns true if the voice state was successfully updated, otherwise false
|
|
698
|
-
*/
|
|
699
|
-
setSelfMute(selfMute: boolean): boolean;
|
|
700
|
-
/**
|
|
701
|
-
* The voice state of this connection
|
|
523
|
+
* Get {@link Song}'s stream info and attach it to the song.
|
|
524
|
+
* @param song - A Song
|
|
702
525
|
*/
|
|
703
|
-
|
|
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);
|
|
704
542
|
}
|
|
705
543
|
|
|
706
544
|
/**
|
|
@@ -748,41 +586,81 @@ declare class VolumeTransformer extends Transform {
|
|
|
748
586
|
}
|
|
749
587
|
|
|
750
588
|
/**
|
|
751
|
-
*
|
|
589
|
+
* Create a voice connection to the voice channel
|
|
752
590
|
*/
|
|
753
|
-
declare class
|
|
591
|
+
declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
754
592
|
#private;
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
type: T;
|
|
765
|
-
}) | 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);
|
|
766
602
|
/**
|
|
767
|
-
*
|
|
768
|
-
* @param song - A Song
|
|
603
|
+
* The voice channel id the bot is in
|
|
769
604
|
*/
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
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;
|
|
786
664
|
}
|
|
787
665
|
|
|
788
666
|
/**
|
|
@@ -830,6 +708,31 @@ declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
|
830
708
|
leave(guild: GuildIdResolvable): void;
|
|
831
709
|
}
|
|
832
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
|
+
|
|
833
736
|
/**
|
|
834
737
|
* Manage filters of a playing {@link Queue}
|
|
835
738
|
*/
|
|
@@ -878,23 +781,26 @@ declare class FilterManager extends BaseManager<Filter> {
|
|
|
878
781
|
}
|
|
879
782
|
|
|
880
783
|
/**
|
|
881
|
-
*
|
|
784
|
+
* Task queuing system
|
|
882
785
|
*/
|
|
883
|
-
declare class
|
|
786
|
+
declare class TaskQueue {
|
|
884
787
|
#private;
|
|
885
788
|
/**
|
|
886
|
-
*
|
|
887
|
-
* @param channel - A voice channel
|
|
888
|
-
* @param textChannel - Default text channel
|
|
889
|
-
* @returns Returns `true` if encounter an error
|
|
789
|
+
* Waits for last task finished and queues a new task
|
|
890
790
|
*/
|
|
891
|
-
|
|
791
|
+
queuing(isPlay?: boolean): Promise<void>;
|
|
892
792
|
/**
|
|
893
|
-
*
|
|
894
|
-
* @param queue - The guild queue to play
|
|
895
|
-
* @param emitPlaySong - Whether or not emit {@link Events.PLAY_SONG} event
|
|
793
|
+
* Removes the finished task and processes the next task
|
|
896
794
|
*/
|
|
897
|
-
|
|
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;
|
|
898
804
|
}
|
|
899
805
|
|
|
900
806
|
/**
|
|
@@ -953,13 +859,9 @@ declare class Queue extends DisTubeBase {
|
|
|
953
859
|
*/
|
|
954
860
|
_beginTime: number;
|
|
955
861
|
/**
|
|
956
|
-
* Whether or not the
|
|
957
|
-
*/
|
|
958
|
-
_next: boolean;
|
|
959
|
-
/**
|
|
960
|
-
* Whether or not the last song was skipped to previous song.
|
|
862
|
+
* Whether or not the queue is being updated manually (skip, jump, previous)
|
|
961
863
|
*/
|
|
962
|
-
|
|
864
|
+
_manualUpdate: boolean;
|
|
963
865
|
/**
|
|
964
866
|
* Task queuing system
|
|
965
867
|
*/
|
|
@@ -1043,9 +945,10 @@ declare class Queue extends DisTubeBase {
|
|
|
1043
945
|
* Skip the playing song if there is a next song in the queue. <info>If {@link
|
|
1044
946
|
* Queue#autoplay} is `true` and there is no up next song, DisTube will add and
|
|
1045
947
|
* play a related song.</info>
|
|
948
|
+
* @param options - Skip options
|
|
1046
949
|
* @returns The song will skip to
|
|
1047
950
|
*/
|
|
1048
|
-
skip(): Promise<Song>;
|
|
951
|
+
skip(options?: JumpOptions): Promise<Song>;
|
|
1049
952
|
/**
|
|
1050
953
|
* Play the previous song if exists
|
|
1051
954
|
* @returns The guild queue
|
|
@@ -1061,9 +964,10 @@ declare class Queue extends DisTubeBase {
|
|
|
1061
964
|
* one is -1, -2,...
|
|
1062
965
|
* if `num` is invalid number
|
|
1063
966
|
* @param position - The song position to play
|
|
967
|
+
* @param options - Skip options
|
|
1064
968
|
* @returns The new Song will be played
|
|
1065
969
|
*/
|
|
1066
|
-
jump(position: number): Promise<Song>;
|
|
970
|
+
jump(position: number, options?: JumpOptions): Promise<Song>;
|
|
1067
971
|
/**
|
|
1068
972
|
* Set the repeat mode of the guild queue.
|
|
1069
973
|
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
@@ -1103,177 +1007,42 @@ declare class Queue extends DisTubeBase {
|
|
|
1103
1007
|
}
|
|
1104
1008
|
|
|
1105
1009
|
/**
|
|
1106
|
-
* DisTube
|
|
1010
|
+
* DisTube class
|
|
1107
1011
|
*/
|
|
1108
|
-
declare
|
|
1012
|
+
declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
1013
|
+
#private;
|
|
1109
1014
|
/**
|
|
1110
|
-
*
|
|
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
|
|
1111
1019
|
*/
|
|
1112
|
-
|
|
1020
|
+
static readonly [Events.ADD_LIST]: (queue: Queue, playlist: Playlist) => Awaitable;
|
|
1113
1021
|
/**
|
|
1114
|
-
*
|
|
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
|
|
1115
1026
|
*/
|
|
1116
|
-
|
|
1117
|
-
init(distube: DisTube): void;
|
|
1027
|
+
static readonly [Events.ADD_SONG]: (queue: Queue, song: Song) => Awaitable;
|
|
1118
1028
|
/**
|
|
1119
|
-
*
|
|
1120
|
-
* @
|
|
1029
|
+
* @event
|
|
1030
|
+
* Emitted when a {@link Queue} is deleted with any reasons.
|
|
1031
|
+
* @param queue - The guild queue
|
|
1121
1032
|
*/
|
|
1122
|
-
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
/**
|
|
1126
|
-
* This plugin can extract the info, search, and play a song directly from its source
|
|
1127
|
-
*/
|
|
1128
|
-
declare abstract class ExtractorPlugin extends Plugin {
|
|
1129
|
-
readonly type = PluginType.EXTRACTOR;
|
|
1033
|
+
static readonly [Events.DELETE_QUEUE]: (queue: Queue) => Awaitable;
|
|
1130
1034
|
/**
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1035
|
+
* @event
|
|
1036
|
+
* Emitted when the bot is disconnected to a voice channel.
|
|
1037
|
+
* @param queue - The guild queue
|
|
1133
1038
|
*/
|
|
1134
|
-
|
|
1039
|
+
static readonly [Events.DISCONNECT]: (queue: Queue) => Awaitable;
|
|
1135
1040
|
/**
|
|
1136
|
-
*
|
|
1137
|
-
*
|
|
1138
|
-
* @param
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
/**
|
|
1142
|
-
* Search for a Song which playable from this plugin's source
|
|
1143
|
-
* @param query - Search query
|
|
1144
|
-
* @param options - Optional options
|
|
1145
|
-
*/
|
|
1146
|
-
abstract searchSong<T>(query: string, options: ResolveOptions<T>): Awaitable<Song<T> | null>;
|
|
1147
|
-
/**
|
|
1148
|
-
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
1149
|
-
* Not needed if the plugin plays song from YouTube.
|
|
1150
|
-
* @param song - Input song
|
|
1151
|
-
*/
|
|
1152
|
-
abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
/**
|
|
1156
|
-
* This plugin only can extract the info from supported links, but not play song directly from its source
|
|
1157
|
-
*/
|
|
1158
|
-
declare abstract class InfoExtractorPlugin extends Plugin {
|
|
1159
|
-
readonly type = PluginType.INFO_EXTRACTOR;
|
|
1160
|
-
/**
|
|
1161
|
-
* Check if the url is working with this plugin
|
|
1162
|
-
* @param url - Input url
|
|
1163
|
-
*/
|
|
1164
|
-
abstract validate(url: string): Awaitable<boolean>;
|
|
1165
|
-
/**
|
|
1166
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1167
|
-
* @param url - URL
|
|
1168
|
-
* @param options - Optional options
|
|
1169
|
-
*/
|
|
1170
|
-
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1171
|
-
/**
|
|
1172
|
-
* Create a search query to be used in {@link ExtractorPlugin#searchSong}
|
|
1173
|
-
* @param song - Input song
|
|
1174
|
-
*/
|
|
1175
|
-
abstract createSearchQuery<T>(song: Song<T>): Awaitable<string>;
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
/**
|
|
1179
|
-
* This plugin can extract and play song from supported links, but cannot search for songs from its source
|
|
1180
|
-
*/
|
|
1181
|
-
declare abstract class PlayableExtractorPlugin extends Plugin {
|
|
1182
|
-
readonly type = PluginType.PLAYABLE_EXTRACTOR;
|
|
1183
|
-
/**
|
|
1184
|
-
* Check if the url is working with this plugin
|
|
1185
|
-
* @param url - Input url
|
|
1186
|
-
*/
|
|
1187
|
-
abstract validate(url: string): Awaitable<boolean>;
|
|
1188
|
-
/**
|
|
1189
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
1190
|
-
* @param url - URL
|
|
1191
|
-
* @param options - Optional options
|
|
1192
|
-
*/
|
|
1193
|
-
abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
|
|
1194
|
-
/**
|
|
1195
|
-
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
1196
|
-
* Not needed if the plugin plays song from YouTube.
|
|
1197
|
-
* @param song - Input song
|
|
1198
|
-
*/
|
|
1199
|
-
abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
/**
|
|
1203
|
-
* Format duration to string
|
|
1204
|
-
* @param sec - Duration in seconds
|
|
1205
|
-
*/
|
|
1206
|
-
declare function formatDuration(sec: number): string;
|
|
1207
|
-
declare const SUPPORTED_PROTOCOL: readonly ["https:", "http:", "file:"];
|
|
1208
|
-
/**
|
|
1209
|
-
* Check if the string is an URL
|
|
1210
|
-
* @param input - input
|
|
1211
|
-
*/
|
|
1212
|
-
declare function isURL(input: any): input is `${(typeof SUPPORTED_PROTOCOL)[number]}//${string}`;
|
|
1213
|
-
/**
|
|
1214
|
-
* Check if the Client has enough intents to using DisTube
|
|
1215
|
-
* @param options - options
|
|
1216
|
-
*/
|
|
1217
|
-
declare function checkIntents(options: ClientOptions): void;
|
|
1218
|
-
/**
|
|
1219
|
-
* Check if the voice channel is empty
|
|
1220
|
-
* @param voiceState - voiceState
|
|
1221
|
-
*/
|
|
1222
|
-
declare function isVoiceChannelEmpty(voiceState: VoiceState): boolean;
|
|
1223
|
-
declare function isSnowflake(id: any): id is Snowflake;
|
|
1224
|
-
declare function isMemberInstance(member: any): member is GuildMember;
|
|
1225
|
-
declare function isTextChannelInstance(channel: any): channel is GuildTextBasedChannel;
|
|
1226
|
-
declare function isMessageInstance(message: any): message is Message<true>;
|
|
1227
|
-
declare function isSupportedVoiceChannel(channel: any): channel is VoiceBasedChannel;
|
|
1228
|
-
declare function isGuildInstance(guild: any): guild is Guild;
|
|
1229
|
-
declare function resolveGuildId(resolvable: GuildIdResolvable): Snowflake;
|
|
1230
|
-
declare function isClientInstance(client: any): client is Client;
|
|
1231
|
-
declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
|
|
1232
|
-
declare function isObject(obj: any): obj is object;
|
|
1233
|
-
type KeyOf<T> = T extends object ? (keyof T)[] : [];
|
|
1234
|
-
declare function objectKeys<T>(obj: T): KeyOf<T>;
|
|
1235
|
-
declare function isNsfwChannel(channel?: GuildTextBasedChannel): boolean;
|
|
1236
|
-
type Falsy = undefined | null | false | 0 | "";
|
|
1237
|
-
declare const isTruthy: <T>(x: T | Falsy) => x is T;
|
|
1238
|
-
declare const checkEncryptionLibraries: () => Promise<boolean>;
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* DisTube class
|
|
1242
|
-
*/
|
|
1243
|
-
declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
1244
|
-
#private;
|
|
1245
|
-
/**
|
|
1246
|
-
* @event
|
|
1247
|
-
* Emitted after DisTube add a new playlist to the playing {@link Queue}.
|
|
1248
|
-
* @param queue - The guild queue
|
|
1249
|
-
* @param playlist - Playlist info
|
|
1250
|
-
*/
|
|
1251
|
-
static readonly [Events.ADD_LIST]: (queue: Queue, playlist: Playlist) => Awaitable;
|
|
1252
|
-
/**
|
|
1253
|
-
* @event
|
|
1254
|
-
* Emitted after DisTube add a new song to the playing {@link Queue}.
|
|
1255
|
-
* @param queue - The guild queue
|
|
1256
|
-
* @param song - Added song
|
|
1257
|
-
*/
|
|
1258
|
-
static readonly [Events.ADD_SONG]: (queue: Queue, song: Song) => Awaitable;
|
|
1259
|
-
/**
|
|
1260
|
-
* @event
|
|
1261
|
-
* Emitted when a {@link Queue} is deleted with any reasons.
|
|
1262
|
-
* @param queue - The guild queue
|
|
1263
|
-
*/
|
|
1264
|
-
static readonly [Events.DELETE_QUEUE]: (queue: Queue) => Awaitable;
|
|
1265
|
-
/**
|
|
1266
|
-
* @event
|
|
1267
|
-
* Emitted when the bot is disconnected to a voice channel.
|
|
1268
|
-
* @param queue - The guild queue
|
|
1269
|
-
*/
|
|
1270
|
-
static readonly [Events.DISCONNECT]: (queue: Queue) => Awaitable;
|
|
1271
|
-
/**
|
|
1272
|
-
* @event
|
|
1273
|
-
* Emitted when DisTube encounters an error while playing songs.
|
|
1274
|
-
* @param error - error
|
|
1275
|
-
* @param queue - The queue encountered the error
|
|
1276
|
-
* @param song - The playing song when encountered the error
|
|
1041
|
+
* @event
|
|
1042
|
+
* Emitted when DisTube encounters an error while playing songs.
|
|
1043
|
+
* @param error - error
|
|
1044
|
+
* @param queue - The queue encountered the error
|
|
1045
|
+
* @param song - The playing song when encountered the error
|
|
1277
1046
|
*/
|
|
1278
1047
|
static readonly [Events.ERROR]: (error: Error, queue: Queue, song?: Song) => Awaitable;
|
|
1279
1048
|
/**
|
|
@@ -1417,7 +1186,7 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1417
1186
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
1418
1187
|
* @returns The new Song will be played
|
|
1419
1188
|
*/
|
|
1420
|
-
skip(guild: GuildIdResolvable): Promise<Song>;
|
|
1189
|
+
skip(guild: GuildIdResolvable, options?: JumpOptions): Promise<Song>;
|
|
1421
1190
|
/**
|
|
1422
1191
|
* Play the previous song
|
|
1423
1192
|
* @param guild - The type can be resolved to give a {@link Queue}
|
|
@@ -1437,7 +1206,7 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1437
1206
|
* @param num - The song number to play
|
|
1438
1207
|
* @returns The new Song will be played
|
|
1439
1208
|
*/
|
|
1440
|
-
jump(guild: GuildIdResolvable, num: number): Promise<Song>;
|
|
1209
|
+
jump(guild: GuildIdResolvable, num: number, options?: JumpOptions): Promise<Song>;
|
|
1441
1210
|
/**
|
|
1442
1211
|
* Set the repeat mode of the guild queue.
|
|
1443
1212
|
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
@@ -1479,12 +1248,253 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
|
1479
1248
|
debug(message: string): void;
|
|
1480
1249
|
}
|
|
1481
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
|
+
|
|
1482
1363
|
/**
|
|
1483
|
-
*
|
|
1484
|
-
*
|
|
1485
|
-
* Note to developers:
|
|
1486
|
-
* This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild
|
|
1364
|
+
* DisTube Plugin
|
|
1487
1365
|
*/
|
|
1488
|
-
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>;
|
|
1489
1497
|
|
|
1490
|
-
|
|
1498
|
+
// @ts-ignore
|
|
1499
|
+
export = DisTube;
|
|
1500
|
+
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, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };
|