odistube 5.0.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.

Potentially problematic release.


This version of odistube might be problematic. Click here for more details.

@@ -0,0 +1,1471 @@
1
+ import * as discord_js from 'discord.js';
2
+ import { Snowflake, Message, GuildTextBasedChannel, VoiceBasedChannel, VoiceState, Guild, GuildMember, Interaction, Client, Collection, ClientOptions } from 'discord.js';
3
+ import { TypedEmitter } from 'tiny-typed-emitter';
4
+ import { AudioPlayer, VoiceConnection, AudioResource } from '@discordjs/voice';
5
+ import { Transform, TransformCallback } from 'stream';
6
+ import { ChildProcess } from 'child_process';
7
+
8
+ type Awaitable<T = any> = T | PromiseLike<T>;
9
+ declare enum Events {
10
+ ERROR = "error",
11
+ ADD_LIST = "addList",
12
+ ADD_SONG = "addSong",
13
+ PLAY_SONG = "playSong",
14
+ FINISH_SONG = "finishSong",
15
+ EMPTY = "empty",
16
+ FINISH = "finish",
17
+ INIT_QUEUE = "initQueue",
18
+ NO_RELATED = "noRelated",
19
+ DISCONNECT = "disconnect",
20
+ DELETE_QUEUE = "deleteQueue",
21
+ FFMPEG_DEBUG = "ffmpegDebug",
22
+ DEBUG = "debug"
23
+ }
24
+ type DisTubeEvents = {
25
+ [Events.ADD_LIST]: [queue: Queue, playlist: Playlist];
26
+ [Events.ADD_SONG]: [queue: Queue, song: Song];
27
+ [Events.DELETE_QUEUE]: [queue: Queue];
28
+ [Events.DISCONNECT]: [queue: Queue];
29
+ [Events.ERROR]: [error: Error, queue: Queue, song: Song | undefined];
30
+ [Events.FFMPEG_DEBUG]: [debug: string];
31
+ [Events.DEBUG]: [debug: string];
32
+ [Events.FINISH]: [queue: Queue];
33
+ [Events.FINISH_SONG]: [queue: Queue, song: Song];
34
+ [Events.INIT_QUEUE]: [queue: Queue];
35
+ [Events.NO_RELATED]: [queue: Queue, error: DisTubeError];
36
+ [Events.PLAY_SONG]: [queue: Queue, song: Song];
37
+ };
38
+ type TypedDisTubeEvents = {
39
+ [K in keyof DisTubeEvents]: (...args: DisTubeEvents[K]) => Awaitable;
40
+ };
41
+ type DisTubeVoiceEvents = {
42
+ disconnect: (error?: Error) => Awaitable;
43
+ error: (error: Error) => Awaitable;
44
+ finish: () => Awaitable;
45
+ };
46
+ /**
47
+ * An FFmpeg audio filter object
48
+ * ```ts
49
+ * {
50
+ * name: "bassboost",
51
+ * value: "bass=g=10"
52
+ * }
53
+ * ```ts
54
+ */
55
+ interface Filter {
56
+ /**
57
+ * Name of the filter
58
+ */
59
+ name: string;
60
+ /**
61
+ * FFmpeg audio filter argument
62
+ */
63
+ value: string;
64
+ }
65
+ /**
66
+ * Data that resolves to give an FFmpeg audio filter. This can be:
67
+ * - A name of a default filters or custom filters (`string`)
68
+ * - A {@link Filter} object
69
+ * @see {@link defaultFilters}
70
+ * @see {@link DisTubeOptions|DisTubeOptions.customFilters}
71
+ */
72
+ type FilterResolvable = string | Filter;
73
+ /**
74
+ * FFmpeg Filters
75
+ * ```ts
76
+ * {
77
+ * "Filter Name": "Filter Value",
78
+ * "bassboost": "bass=g=10"
79
+ * }
80
+ * ```
81
+ * @see {@link defaultFilters}
82
+ */
83
+ type Filters = Record<string, string>;
84
+ /**
85
+ * DisTube options
86
+ */
87
+ type DisTubeOptions = {
88
+ /**
89
+ * DisTube plugins.
90
+ * The order of this effects the priority of the plugins when verifying the input.
91
+ */
92
+ plugins?: DisTubePlugin[];
93
+ /**
94
+ * Whether or not emitting {@link Events.PLAY_SONG} event when looping a song
95
+ * or next song is the same as the previous one
96
+ */
97
+ emitNewSongOnly?: boolean;
98
+ /**
99
+ * Whether or not saving the previous songs of the queue and enable {@link
100
+ * DisTube#previous} method. Disable it may help to reduce the memory usage
101
+ */
102
+ savePreviousSongs?: boolean;
103
+ /**
104
+ * Override {@link defaultFilters} or add more ffmpeg filters
105
+ */
106
+ customFilters?: Filters;
107
+ /**
108
+ * Whether or not playing age-restricted content and disabling safe search in
109
+ * non-NSFW channel
110
+ */
111
+ nsfw?: boolean;
112
+ /**
113
+ * Whether or not emitting `addSong` event when creating a new Queue
114
+ */
115
+ emitAddSongWhenCreatingQueue?: boolean;
116
+ /**
117
+ * Whether or not emitting `addList` event when creating a new Queue
118
+ */
119
+ emitAddListWhenCreatingQueue?: boolean;
120
+ /**
121
+ * Whether or not joining the new voice channel when using {@link DisTube#play}
122
+ * method
123
+ */
124
+ joinNewVoiceChannel?: boolean;
125
+ /**
126
+ * FFmpeg options
127
+ */
128
+ ffmpeg?: {
129
+ /**
130
+ * FFmpeg path
131
+ */
132
+ path?: string;
133
+ /**
134
+ * FFmpeg default arguments
135
+ */
136
+ args?: Partial<FFmpegArgs>;
137
+ };
138
+ };
139
+ /**
140
+ * Data that can be resolved to give a guild id string. This can be:
141
+ * - A guild id string | a guild {@link https://discord.js.org/#/docs/main/stable/class/Snowflake|Snowflake}
142
+ * - A {@link https://discord.js.org/#/docs/main/stable/class/Guild | Guild}
143
+ * - A {@link https://discord.js.org/#/docs/main/stable/class/Message | Message}
144
+ * - A {@link https://discord.js.org/#/docs/main/stable/class/BaseGuildVoiceChannel
145
+ * | BaseGuildVoiceChannel}
146
+ * - A {@link https://discord.js.org/#/docs/main/stable/class/BaseGuildTextChannel
147
+ * | BaseGuildTextChannel}
148
+ * - A {@link https://discord.js.org/#/docs/main/stable/class/VoiceState |
149
+ * VoiceState}
150
+ * - A {@link https://discord.js.org/#/docs/main/stable/class/GuildMember |
151
+ * GuildMember}
152
+ * - A {@link https://discord.js.org/#/docs/main/stable/class/Interaction |
153
+ * Interaction}
154
+ * - A {@link DisTubeVoice}
155
+ * - A {@link Queue}
156
+ */
157
+ type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
158
+ interface SongInfo {
159
+ plugin: DisTubePlugin | null;
160
+ source: string;
161
+ playFromSource: boolean;
162
+ id: string;
163
+ name?: string;
164
+ isLive?: boolean;
165
+ duration?: number;
166
+ url?: string;
167
+ thumbnail?: string;
168
+ views?: number;
169
+ likes?: number;
170
+ dislikes?: number;
171
+ reposts?: number;
172
+ uploader?: {
173
+ name?: string;
174
+ url?: string;
175
+ };
176
+ ageRestricted?: boolean;
177
+ }
178
+ interface PlaylistInfo {
179
+ source: string;
180
+ songs: Song[];
181
+ id?: string;
182
+ name?: string;
183
+ url?: string;
184
+ thumbnail?: string;
185
+ }
186
+ type RelatedSong = Omit<Song, "related">;
187
+ type PlayHandlerOptions = {
188
+ /**
189
+ * [Default: false] Skip the playing song (if exists) and play the added playlist
190
+ * instantly
191
+ */
192
+ skip?: boolean;
193
+ /**
194
+ * [Default: 0] Position of the song/playlist to add to the queue, \<= 0 to add to
195
+ * the end of the queue
196
+ */
197
+ position?: number;
198
+ /**
199
+ * The default text channel of the queue
200
+ */
201
+ textChannel?: GuildTextBasedChannel;
202
+ };
203
+ interface PlayOptions<T = unknown> extends PlayHandlerOptions, ResolveOptions<T> {
204
+ /**
205
+ * Called message (For built-in search events. If this is a {@link
206
+ * https://developer.mozilla.org/en-US/docs/Glossary/Falsy | falsy value}, it will
207
+ * play the first result instead)
208
+ */
209
+ message?: Message;
210
+ }
211
+ interface ResolveOptions<T = unknown> {
212
+ /**
213
+ * Requested user
214
+ */
215
+ member?: GuildMember;
216
+ /**
217
+ * Metadata
218
+ */
219
+ metadata?: T;
220
+ }
221
+ interface ResolvePlaylistOptions<T = unknown> extends ResolveOptions<T> {
222
+ /**
223
+ * Source of the playlist
224
+ */
225
+ source?: string;
226
+ }
227
+ interface CustomPlaylistOptions {
228
+ /**
229
+ * A guild member creating the playlist
230
+ */
231
+ member?: GuildMember;
232
+ /**
233
+ * Whether or not fetch the songs in parallel
234
+ */
235
+ parallel?: boolean;
236
+ /**
237
+ * Metadata
238
+ */
239
+ metadata?: any;
240
+ /**
241
+ * Playlist name
242
+ */
243
+ name?: string;
244
+ /**
245
+ * Playlist source
246
+ */
247
+ source?: string;
248
+ /**
249
+ * Playlist url
250
+ */
251
+ url?: string;
252
+ /**
253
+ * Playlist thumbnail
254
+ */
255
+ thumbnail?: string;
256
+ }
257
+ /**
258
+ * The repeat mode of a {@link Queue}
259
+ * - `DISABLED` = 0
260
+ * - `SONG` = 1
261
+ * - `QUEUE` = 2
262
+ */
263
+ declare enum RepeatMode {
264
+ DISABLED = 0,
265
+ SONG = 1,
266
+ QUEUE = 2
267
+ }
268
+ /**
269
+ * All available plugin types:
270
+ * - `EXTRACTOR` = `"extractor"`: {@link ExtractorPlugin}
271
+ * - `INFO_EXTRACTOR` = `"info-extractor"`: {@link InfoExtractorPlugin}
272
+ * - `PLAYABLE_EXTRACTOR` = `"playable-extractor"`: {@link PlayableExtractorPlugin}
273
+ */
274
+ declare enum PluginType {
275
+ EXTRACTOR = "extractor",
276
+ INFO_EXTRACTOR = "info-extractor",
277
+ PLAYABLE_EXTRACTOR = "playable-extractor"
278
+ }
279
+ type DisTubePlugin = ExtractorPlugin | InfoExtractorPlugin | PlayableExtractorPlugin;
280
+ type FFmpegArg = Record<string, string | number | boolean | Array<string | null | undefined> | null | undefined>;
281
+ /**
282
+ * FFmpeg arguments for different use cases
283
+ */
284
+ type FFmpegArgs = {
285
+ global: FFmpegArg;
286
+ input: FFmpegArg;
287
+ output: FFmpegArg;
288
+ };
289
+ /**
290
+ * FFmpeg options
291
+ */
292
+ type FFmpegOptions = {
293
+ /**
294
+ * Path to the ffmpeg executable
295
+ */
296
+ path: string;
297
+ /**
298
+ * Arguments
299
+ */
300
+ args: FFmpegArgs;
301
+ };
302
+
303
+ /**
304
+ * Default DisTube audio filters.
305
+ */
306
+ declare const defaultFilters: Filters;
307
+ declare const defaultOptions: {
308
+ plugins: never[];
309
+ emitNewSongOnly: false;
310
+ savePreviousSongs: true;
311
+ nsfw: false;
312
+ emitAddSongWhenCreatingQueue: true;
313
+ emitAddListWhenCreatingQueue: true;
314
+ joinNewVoiceChannel: true;
315
+ };
316
+
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
+ NO_QUEUE: string;
340
+ QUEUE_EXIST: string;
341
+ QUEUE_STOPPED: string;
342
+ PAUSED: string;
343
+ RESUMED: string;
344
+ NO_PREVIOUS: string;
345
+ NO_UP_NEXT: string;
346
+ NO_SONG_POSITION: string;
347
+ NO_PLAYING_SONG: string;
348
+ NO_RELATED: string;
349
+ CANNOT_PLAY_RELATED: string;
350
+ UNAVAILABLE_VIDEO: string;
351
+ UNPLAYABLE_FORMATS: string;
352
+ NON_NSFW: string;
353
+ NOT_SUPPORTED_URL: string;
354
+ NOT_SUPPORTED_SONG: (song: string) => string;
355
+ NO_VALID_SONG: string;
356
+ CANNOT_RESOLVE_SONG: (t: any) => string;
357
+ CANNOT_GET_STREAM_URL: (song: string) => string;
358
+ CANNOT_GET_SEARCH_QUERY: (song: string) => string;
359
+ NO_RESULT: (query: string) => string;
360
+ NO_STREAM_URL: (song: string) => string;
361
+ EMPTY_FILTERED_PLAYLIST: string;
362
+ EMPTY_PLAYLIST: string;
363
+ };
364
+ type ErrorMessage = typeof ERROR_MESSAGES;
365
+ type ErrorCode = keyof ErrorMessage;
366
+ type StaticErrorCode = {
367
+ [K in ErrorCode]-?: ErrorMessage[K] extends string ? K : never;
368
+ }[ErrorCode];
369
+ type TemplateErrorCode = Exclude<keyof typeof ERROR_MESSAGES, StaticErrorCode>;
370
+ declare class DisTubeError<T extends string = any> extends Error {
371
+ errorCode: string;
372
+ constructor(code: T extends StaticErrorCode ? T : never);
373
+ constructor(code: T extends TemplateErrorCode ? T : never, ...args: Parameters<ErrorMessage[typeof code]>);
374
+ constructor(code: TemplateErrorCode, _: never);
375
+ constructor(code: T extends ErrorCode ? never : T, message: string);
376
+ get name(): string;
377
+ get code(): string;
378
+ }
379
+
380
+ /**
381
+ * Task queuing system
382
+ */
383
+ declare class TaskQueue {
384
+ #private;
385
+ /**
386
+ * Waits for last task finished and queues a new task
387
+ */
388
+ queuing(): Promise<void>;
389
+ /**
390
+ * Removes the finished task and processes the next task
391
+ */
392
+ resolve(): void;
393
+ /**
394
+ * The remaining number of tasks
395
+ */
396
+ get remaining(): number;
397
+ }
398
+
399
+ /**
400
+ * Class representing a playlist.
401
+ */
402
+ declare class Playlist<T = unknown> implements PlaylistInfo {
403
+ #private;
404
+ /**
405
+ * Playlist source.
406
+ */
407
+ source: string;
408
+ /**
409
+ * Songs in the playlist.
410
+ */
411
+ songs: Song[];
412
+ /**
413
+ * Playlist ID.
414
+ */
415
+ id?: string;
416
+ /**
417
+ * Playlist name.
418
+ */
419
+ name?: string;
420
+ /**
421
+ * Playlist URL.
422
+ */
423
+ url?: string;
424
+ /**
425
+ * Playlist thumbnail.
426
+ */
427
+ thumbnail?: string;
428
+ /**
429
+ * Create a Playlist
430
+ * @param playlist - Raw playlist info
431
+ * @param options - Optional data
432
+ */
433
+ constructor(playlist: PlaylistInfo, { member, metadata }?: ResolveOptions<T>);
434
+ /**
435
+ * Playlist duration in second.
436
+ */
437
+ get duration(): number;
438
+ /**
439
+ * Formatted duration string `hh:mm:ss`.
440
+ */
441
+ get formattedDuration(): string;
442
+ /**
443
+ * User requested.
444
+ */
445
+ get member(): GuildMember | undefined;
446
+ set member(member: GuildMember | undefined);
447
+ /**
448
+ * User requested.
449
+ */
450
+ get user(): discord_js.User | undefined;
451
+ /**
452
+ * Optional metadata that can be used to identify the playlist.
453
+ */
454
+ get metadata(): T;
455
+ set metadata(metadata: T);
456
+ toString(): string;
457
+ }
458
+
459
+ /**
460
+ * Class representing a song.
461
+ */
462
+ declare class Song<T = unknown> {
463
+ #private;
464
+ /**
465
+ * The source of this song info
466
+ */
467
+ source: string;
468
+ /**
469
+ * Song ID.
470
+ */
471
+ id: string;
472
+ /**
473
+ * Song name.
474
+ */
475
+ name?: string;
476
+ /**
477
+ * Indicates if the song is an active live.
478
+ */
479
+ isLive?: boolean;
480
+ /**
481
+ * Song duration.
482
+ */
483
+ duration: number;
484
+ /**
485
+ * Formatted duration string (`hh:mm:ss`, `mm:ss` or `Live`).
486
+ */
487
+ formattedDuration: string;
488
+ /**
489
+ * Song URL.
490
+ */
491
+ url?: string;
492
+ /**
493
+ * Song thumbnail.
494
+ */
495
+ thumbnail?: string;
496
+ /**
497
+ * Song view count
498
+ */
499
+ views?: number;
500
+ /**
501
+ * Song like count
502
+ */
503
+ likes?: number;
504
+ /**
505
+ * Song dislike count
506
+ */
507
+ dislikes?: number;
508
+ /**
509
+ * Song repost (share) count
510
+ */
511
+ reposts?: number;
512
+ /**
513
+ * Song uploader
514
+ */
515
+ uploader: {
516
+ name?: string;
517
+ url?: string;
518
+ };
519
+ /**
520
+ * Whether or not an age-restricted content
521
+ */
522
+ ageRestricted?: boolean;
523
+ /**
524
+ * Stream info
525
+ */
526
+ stream: {
527
+ /**
528
+ * The stream of this song will be played from source
529
+ */
530
+ playFromSource: true;
531
+ /**
532
+ * Stream URL of this song
533
+ */
534
+ url?: string;
535
+ } | {
536
+ /**
537
+ * The stream of this song will be played from another song
538
+ */
539
+ playFromSource: false;
540
+ /**
541
+ * The song that this song will be played from
542
+ */
543
+ song?: Song<T>;
544
+ };
545
+ /**
546
+ * The plugin that created this song
547
+ */
548
+ plugin: DisTubePlugin | null;
549
+ /**
550
+ * Create a Song
551
+ *
552
+ * @param info - Raw song info
553
+ * @param options - Optional data
554
+ */
555
+ constructor(info: SongInfo, { member, metadata }?: ResolveOptions<T>);
556
+ /**
557
+ * The playlist this song belongs to
558
+ */
559
+ get playlist(): Playlist | undefined;
560
+ set playlist(playlist: Playlist | undefined);
561
+ /**
562
+ * User requested to play this song.
563
+ */
564
+ get member(): GuildMember | undefined;
565
+ set member(member: GuildMember | undefined);
566
+ /**
567
+ * User requested to play this song.
568
+ */
569
+ get user(): discord_js.User | undefined;
570
+ /**
571
+ * Optional metadata that can be used to identify the song. This is attached by the
572
+ * {@link DisTube#play} method.
573
+ */
574
+ get metadata(): T;
575
+ set metadata(metadata: T);
576
+ toString(): string;
577
+ }
578
+
579
+ declare abstract class DisTubeBase {
580
+ distube: DisTube;
581
+ constructor(distube: DisTube);
582
+ /**
583
+ * Emit the {@link DisTube} of this base
584
+ * @param eventName - Event name
585
+ * @param args - arguments
586
+ */
587
+ emit(eventName: keyof DisTubeEvents, ...args: any): boolean;
588
+ /**
589
+ * Emit error event
590
+ * @param error - error
591
+ * @param queue - The queue encountered the error
592
+ * @param song - The playing song when encountered the error
593
+ */
594
+ emitError(error: Error, queue: Queue, song?: Song): void;
595
+ /**
596
+ * Emit debug event
597
+ * @param message - debug message
598
+ */
599
+ debug(message: string): void;
600
+ /**
601
+ * The queue manager
602
+ */
603
+ get queues(): QueueManager;
604
+ /**
605
+ * The voice manager
606
+ */
607
+ get voices(): DisTubeVoiceManager;
608
+ /**
609
+ * Discord.js client
610
+ */
611
+ get client(): Client;
612
+ /**
613
+ * DisTube options
614
+ */
615
+ get options(): Options;
616
+ /**
617
+ * DisTube handler
618
+ */
619
+ get handler(): DisTubeHandler;
620
+ /**
621
+ * DisTube plugins
622
+ */
623
+ get plugins(): DisTubePlugin[];
624
+ }
625
+
626
+ /**
627
+ * Create a voice connection to the voice channel
628
+ */
629
+ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
630
+ #private;
631
+ readonly id: Snowflake;
632
+ readonly voices: DisTubeVoiceManager;
633
+ readonly audioPlayer: AudioPlayer;
634
+ connection: VoiceConnection;
635
+ emittedError: boolean;
636
+ isDisconnected: boolean;
637
+ stream?: DisTubeStream;
638
+ constructor(voiceManager: DisTubeVoiceManager, channel: VoiceBasedChannel);
639
+ /**
640
+ * The voice channel id the bot is in
641
+ */
642
+ get channelId(): string | undefined;
643
+ get channel(): VoiceBasedChannel;
644
+ set channel(channel: VoiceBasedChannel);
645
+ /**
646
+ * Join a voice channel with this connection
647
+ * @param channel - A voice channel
648
+ */
649
+ join(channel?: VoiceBasedChannel): Promise<DisTubeVoice>;
650
+ /**
651
+ * Leave the voice channel of this connection
652
+ * @param error - Optional, an error to emit with 'error' event.
653
+ */
654
+ leave(error?: Error): void;
655
+ /**
656
+ * Stop the playing stream
657
+ * @param force - If true, will force the {@link DisTubeVoice#audioPlayer} to enter the Idle state even
658
+ * if the {@link DisTubeStream#audioResource} has silence padding frames.
659
+ */
660
+ stop(force?: boolean): void;
661
+ /**
662
+ * Play a {@link DisTubeStream}
663
+ * @param dtStream - DisTubeStream
664
+ */
665
+ play(dtStream: DisTubeStream): void;
666
+ set volume(volume: number);
667
+ /**
668
+ * Get or set the volume percentage
669
+ */
670
+ get volume(): number;
671
+ /**
672
+ * Playback duration of the audio resource in seconds
673
+ */
674
+ get playbackDuration(): number;
675
+ pause(): void;
676
+ unpause(): void;
677
+ /**
678
+ * Whether the bot is self-deafened
679
+ */
680
+ get selfDeaf(): boolean;
681
+ /**
682
+ * Whether the bot is self-muted
683
+ */
684
+ get selfMute(): boolean;
685
+ /**
686
+ * Self-deafens/undeafens the bot.
687
+ * @param selfDeaf - Whether or not the bot should be self-deafened
688
+ * @returns true if the voice state was successfully updated, otherwise false
689
+ */
690
+ setSelfDeaf(selfDeaf: boolean): boolean;
691
+ /**
692
+ * Self-mutes/unmutes the bot.
693
+ * @param selfMute - Whether or not the bot should be self-muted
694
+ * @returns true if the voice state was successfully updated, otherwise false
695
+ */
696
+ setSelfMute(selfMute: boolean): boolean;
697
+ /**
698
+ * The voice state of this connection
699
+ */
700
+ get voiceState(): VoiceState | undefined;
701
+ }
702
+
703
+ /**
704
+ * Options for {@link DisTubeStream}
705
+ */
706
+ interface StreamOptions {
707
+ /**
708
+ * FFmpeg options
709
+ */
710
+ ffmpeg: FFmpegOptions;
711
+ /**
712
+ * Seek time (in seconds).
713
+ * @default 0
714
+ */
715
+ seek?: number;
716
+ }
717
+ declare const checkFFmpeg: (distube: DisTube) => void;
718
+ /**
719
+ * Create a stream to play with {@link DisTubeVoice}
720
+ */
721
+ declare class DisTubeStream extends TypedEmitter<{
722
+ debug: (debug: string) => Awaitable;
723
+ error: (error: Error) => Awaitable;
724
+ }> {
725
+ #private;
726
+ process?: ChildProcess;
727
+ stream: VolumeTransformer;
728
+ audioResource: AudioResource;
729
+ /**
730
+ * Create a DisTubeStream to play with {@link DisTubeVoice}
731
+ * @param url - Stream URL
732
+ * @param options - Stream options
733
+ */
734
+ constructor(url: string, options: StreamOptions);
735
+ spawn(): void;
736
+ private debug;
737
+ setVolume(volume: number): void;
738
+ kill(): void;
739
+ }
740
+ declare class VolumeTransformer extends Transform {
741
+ private buffer;
742
+ private readonly extrema;
743
+ vol: number;
744
+ _transform(newChunk: Buffer, _encoding: BufferEncoding, done: TransformCallback): void;
745
+ }
746
+
747
+ /**
748
+ * DisTube's Handler
749
+ */
750
+ declare class DisTubeHandler extends DisTubeBase {
751
+ #private;
752
+ resolve<T = unknown>(song: Song<T>, options?: Omit<ResolveOptions, "metadata">): Promise<Song<T>>;
753
+ resolve<T = unknown>(song: Playlist<T>, options?: Omit<ResolveOptions, "metadata">): Promise<Playlist<T>>;
754
+ resolve<T = unknown>(song: string, options?: ResolveOptions<T>): Promise<Song<T> | Playlist<T>>;
755
+ resolve<T = unknown>(song: Song, options: ResolveOptions<T>): Promise<Song<T>>;
756
+ resolve<T = unknown>(song: Playlist, options: ResolveOptions<T>): Promise<Playlist<T>>;
757
+ resolve(song: string | Song | Playlist, options?: ResolveOptions): Promise<Song | Playlist>;
758
+ _getPluginFromURL(url: string): Promise<DisTubePlugin | null>;
759
+ _getPluginFromSong(song: Song): Promise<DisTubePlugin | null>;
760
+ _getPluginFromSong<T extends PluginType>(song: Song, types: T[], validate?: boolean): Promise<(DisTubePlugin & {
761
+ type: T;
762
+ }) | null>;
763
+ /**
764
+ * Get {@link Song}'s stream info and attach it to the song.
765
+ * @param song - A Song
766
+ */
767
+ attachStreamInfo(song: Song): Promise<void>;
768
+ followRedirectLink(url: string, maxRedirect?: number): Promise<string>;
769
+ }
770
+
771
+ declare class Options {
772
+ #private;
773
+ plugins: DisTubePlugin[];
774
+ emitNewSongOnly: boolean;
775
+ savePreviousSongs: boolean;
776
+ customFilters?: Filters;
777
+ nsfw: boolean;
778
+ emitAddSongWhenCreatingQueue: boolean;
779
+ emitAddListWhenCreatingQueue: boolean;
780
+ joinNewVoiceChannel: boolean;
781
+ ffmpeg: FFmpegOptions;
782
+ constructor(options: DisTubeOptions);
783
+ }
784
+
785
+ /**
786
+ * Manages the collection of a data model.
787
+ */
788
+ declare abstract class BaseManager<V> extends DisTubeBase {
789
+ /**
790
+ * The collection of items for this manager.
791
+ */
792
+ collection: Collection<string, V>;
793
+ /**
794
+ * The size of the collection.
795
+ */
796
+ get size(): number;
797
+ }
798
+
799
+ /**
800
+ * Manages the collection of a data model paired with a guild id.
801
+ */
802
+ declare abstract class GuildIdManager<V> extends BaseManager<V> {
803
+ add(idOrInstance: GuildIdResolvable, data: V): this;
804
+ get(idOrInstance: GuildIdResolvable): V | undefined;
805
+ remove(idOrInstance: GuildIdResolvable): boolean;
806
+ has(idOrInstance: GuildIdResolvable): boolean;
807
+ }
808
+
809
+ /**
810
+ * Manages voice connections
811
+ */
812
+ declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
813
+ /**
814
+ * Create a {@link DisTubeVoice} instance
815
+ * @param channel - A voice chann el to join
816
+ */
817
+ create(channel: VoiceBasedChannel): DisTubeVoice;
818
+ /**
819
+ * Join a voice channel and wait until the connection is ready
820
+ * @param channel - A voice channel to join
821
+ */
822
+ join(channel: VoiceBasedChannel): Promise<DisTubeVoice>;
823
+ /**
824
+ * Leave the connected voice channel in a guild
825
+ * @param guild - Queue Resolvable
826
+ */
827
+ leave(guild: GuildIdResolvable): void;
828
+ }
829
+
830
+ /**
831
+ * Manage filters of a playing {@link Queue}
832
+ */
833
+ declare class FilterManager extends BaseManager<Filter> {
834
+ #private;
835
+ /**
836
+ * The queue to manage
837
+ */
838
+ queue: Queue;
839
+ constructor(queue: Queue);
840
+ /**
841
+ * Enable a filter or multiple filters to the manager
842
+ * @param filterOrFilters - The filter or filters to enable
843
+ * @param override - Wether or not override the applied filter with new filter value
844
+ */
845
+ add(filterOrFilters: FilterResolvable | FilterResolvable[], override?: boolean): this;
846
+ /**
847
+ * Clear enabled filters of the manager
848
+ */
849
+ clear(): this;
850
+ /**
851
+ * Set the filters applied to the manager
852
+ * @param filters - The filters to apply
853
+ */
854
+ set(filters: FilterResolvable[]): this;
855
+ /**
856
+ * Disable a filter or multiple filters
857
+ * @param filterOrFilters - The filter or filters to disable
858
+ */
859
+ remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
860
+ /**
861
+ * Check whether a filter enabled or not
862
+ * @param filter - The filter to check
863
+ */
864
+ has(filter: FilterResolvable): boolean;
865
+ /**
866
+ * Array of enabled filter names
867
+ */
868
+ get names(): string[];
869
+ /**
870
+ * Array of enabled filters
871
+ */
872
+ get values(): Filter[];
873
+ get ffmpegArgs(): FFmpegArg;
874
+ toString(): string;
875
+ }
876
+
877
+ /**
878
+ * Queue manager
879
+ */
880
+ declare class QueueManager extends GuildIdManager<Queue> {
881
+ #private;
882
+ /**
883
+ * Create a {@link Queue}
884
+ * @param channel - A voice channel
885
+ * @param textChannel - Default text channel
886
+ * @returns Returns `true` if encounter an error
887
+ */
888
+ create(channel: VoiceBasedChannel, textChannel?: GuildTextBasedChannel): Promise<Queue>;
889
+ /**
890
+ * Play a song on voice connection with queue properties
891
+ * @param queue - The guild queue to play
892
+ * @param emitPlaySong - Whether or not emit {@link Events.PLAY_SONG} event
893
+ */
894
+ playSong(queue: Queue, emitPlaySong?: boolean): Promise<void>;
895
+ }
896
+
897
+ /**
898
+ * Represents a queue.
899
+ */
900
+ declare class Queue extends DisTubeBase {
901
+ #private;
902
+ /**
903
+ * Queue id (Guild id)
904
+ */
905
+ readonly id: Snowflake;
906
+ /**
907
+ * Voice connection of this queue.
908
+ */
909
+ voice: DisTubeVoice;
910
+ /**
911
+ * List of songs in the queue (The first one is the playing song)
912
+ */
913
+ songs: Song[];
914
+ /**
915
+ * List of the previous songs.
916
+ */
917
+ previousSongs: Song[];
918
+ /**
919
+ * Whether stream is currently stopped.
920
+ */
921
+ stopped: boolean;
922
+ /**
923
+ * Whether or not the stream is currently playing.
924
+ */
925
+ playing: boolean;
926
+ /**
927
+ * Whether or not the stream is currently paused.
928
+ */
929
+ paused: boolean;
930
+ /**
931
+ * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating
932
+ * all the queue). Default value: `0` (disabled)
933
+ */
934
+ repeatMode: RepeatMode;
935
+ /**
936
+ * Whether or not the autoplay mode is enabled. Default value: `false`
937
+ */
938
+ autoplay: boolean;
939
+ /**
940
+ * FFmpeg arguments for the current queue. Default value is defined with {@link DisTubeOptions}.ffmpeg.args.
941
+ * `af` output argument will be replaced with {@link Queue#filters} manager
942
+ */
943
+ ffmpegArgs: FFmpegArgs;
944
+ /**
945
+ * The text channel of the Queue. (Default: where the first command is called).
946
+ */
947
+ textChannel?: GuildTextBasedChannel;
948
+ /**
949
+ * What time in the song to begin (in seconds).
950
+ */
951
+ _beginTime: number;
952
+ /**
953
+ * Whether or not the last song was skipped to next song.
954
+ */
955
+ _next: boolean;
956
+ /**
957
+ * Whether or not the last song was skipped to previous song.
958
+ */
959
+ _prev: boolean;
960
+ /**
961
+ * Task queuing system
962
+ */
963
+ _taskQueue: TaskQueue;
964
+ /**
965
+ * {@link DisTubeVoice} listener
966
+ */
967
+ _listeners?: DisTubeVoiceEvents;
968
+ /**
969
+ * Create a queue for the guild
970
+ * @param distube - DisTube
971
+ * @param voice - Voice connection
972
+ * @param textChannel - Default text channel
973
+ */
974
+ constructor(distube: DisTube, voice: DisTubeVoice, textChannel?: GuildTextBasedChannel);
975
+ /**
976
+ * The client user as a `GuildMember` of this queue's guild
977
+ */
978
+ get clientMember(): discord_js.GuildMember | undefined;
979
+ /**
980
+ * The filter manager of the queue
981
+ */
982
+ get filters(): FilterManager;
983
+ /**
984
+ * Formatted duration string.
985
+ */
986
+ get formattedDuration(): string;
987
+ /**
988
+ * Queue's duration.
989
+ */
990
+ get duration(): number;
991
+ /**
992
+ * What time in the song is playing (in seconds).
993
+ */
994
+ get currentTime(): number;
995
+ /**
996
+ * Formatted {@link Queue#currentTime} string.
997
+ */
998
+ get formattedCurrentTime(): string;
999
+ /**
1000
+ * The voice channel playing in.
1001
+ */
1002
+ get voiceChannel(): discord_js.VoiceBasedChannel | null;
1003
+ /**
1004
+ * Get or set the stream volume. Default value: `50`.
1005
+ */
1006
+ get volume(): number;
1007
+ set volume(value: number);
1008
+ /**
1009
+ * @throws {DisTubeError}
1010
+ * @param song - Song to add
1011
+ * @param position - Position to add, \<= 0 to add to the end of the queue
1012
+ * @returns The guild queue
1013
+ */
1014
+ addToQueue(song: Song | Song[], position?: number): Queue;
1015
+ /**
1016
+ * Pause the guild stream
1017
+ * @returns The guild queue
1018
+ */
1019
+ pause(): Queue;
1020
+ /**
1021
+ * Resume the guild stream
1022
+ * @returns The guild queue
1023
+ */
1024
+ resume(): Queue;
1025
+ /**
1026
+ * Set the guild stream's volume
1027
+ * @param percent - The percentage of volume you want to set
1028
+ * @returns The guild queue
1029
+ */
1030
+ setVolume(percent: number): Queue;
1031
+ /**
1032
+ * Skip the playing song if there is a next song in the queue. <info>If {@link
1033
+ * Queue#autoplay} is `true` and there is no up next song, DisTube will add and
1034
+ * play a related song.</info>
1035
+ * @returns The song will skip to
1036
+ */
1037
+ skip(): Promise<Song>;
1038
+ /**
1039
+ * Play the previous song if exists
1040
+ * @returns The guild queue
1041
+ */
1042
+ previous(): Promise<Song>;
1043
+ /**
1044
+ * Shuffle the queue's songs
1045
+ * @returns The guild queue
1046
+ */
1047
+ shuffle(): Promise<Queue>;
1048
+ /**
1049
+ * Jump to the song position in the queue. The next one is 1, 2,... The previous
1050
+ * one is -1, -2,...
1051
+ * if `num` is invalid number
1052
+ * @param position - The song position to play
1053
+ * @returns The new Song will be played
1054
+ */
1055
+ jump(position: number): Promise<Song>;
1056
+ /**
1057
+ * Set the repeat mode of the guild queue.
1058
+ * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
1059
+ * @param mode - The repeat modes (toggle if `undefined`)
1060
+ * @returns The new repeat mode
1061
+ */
1062
+ setRepeatMode(mode?: RepeatMode): RepeatMode;
1063
+ /**
1064
+ * Set the playing time to another position
1065
+ * @param time - Time in seconds
1066
+ * @returns The guild queue
1067
+ */
1068
+ seek(time: number): Queue;
1069
+ /**
1070
+ * Add a related song of the playing song to the queue
1071
+ * @returns The added song
1072
+ */
1073
+ addRelatedSong(): Promise<Song>;
1074
+ /**
1075
+ * Stop the guild stream and delete the queue
1076
+ */
1077
+ stop(): Promise<void>;
1078
+ /**
1079
+ * Remove the queue from the manager
1080
+ */
1081
+ remove(): void;
1082
+ /**
1083
+ * Toggle autoplay mode
1084
+ * @returns Autoplay mode state
1085
+ */
1086
+ toggleAutoplay(): boolean;
1087
+ /**
1088
+ * Play the queue
1089
+ * @param emitPlaySong - Whether or not emit {@link Events.PLAY_SONG} event
1090
+ */
1091
+ play(emitPlaySong?: boolean): Promise<void>;
1092
+ }
1093
+
1094
+ /**
1095
+ * DisTube Plugin
1096
+ */
1097
+ declare abstract class Plugin {
1098
+ /**
1099
+ * Type of the plugin
1100
+ */
1101
+ abstract readonly type: PluginType;
1102
+ /**
1103
+ * DisTube
1104
+ */
1105
+ distube: DisTube;
1106
+ init(distube: DisTube): void;
1107
+ /**
1108
+ * Get related songs from a supported url.
1109
+ * @param song - Input song
1110
+ */
1111
+ abstract getRelatedSongs(song: Song): Awaitable<Song[]>;
1112
+ }
1113
+
1114
+ /**
1115
+ * This plugin can extract the info, search, and play a song directly from its source
1116
+ */
1117
+ declare abstract class ExtractorPlugin extends Plugin {
1118
+ readonly type = PluginType.EXTRACTOR;
1119
+ /**
1120
+ * Check if the url is working with this plugin
1121
+ * @param url - Input url
1122
+ */
1123
+ abstract validate(url: string): Awaitable<boolean>;
1124
+ /**
1125
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.
1126
+ * @param url - URL
1127
+ * @param options - Optional options
1128
+ */
1129
+ abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
1130
+ /**
1131
+ * Search for a Song which playable from this plugin's source
1132
+ * @param query - Search query
1133
+ * @param options - Optional options
1134
+ */
1135
+ abstract searchSong<T>(query: string, options: ResolveOptions<T>): Awaitable<Song<T> | null>;
1136
+ /**
1137
+ * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
1138
+ * Not needed if the plugin plays song from YouTube.
1139
+ * @param song - Input song
1140
+ */
1141
+ abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
1142
+ }
1143
+
1144
+ /**
1145
+ * This plugin only can extract the info from supported links, but not play song directly from its source
1146
+ */
1147
+ declare abstract class InfoExtractorPlugin extends Plugin {
1148
+ readonly type = PluginType.INFO_EXTRACTOR;
1149
+ /**
1150
+ * Check if the url is working with this plugin
1151
+ * @param url - Input url
1152
+ */
1153
+ abstract validate(url: string): Awaitable<boolean>;
1154
+ /**
1155
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.
1156
+ * @param url - URL
1157
+ * @param options - Optional options
1158
+ */
1159
+ abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
1160
+ /**
1161
+ * Create a search query to be used in {@link ExtractorPlugin#searchSong}
1162
+ * @param song - Input song
1163
+ */
1164
+ abstract createSearchQuery<T>(song: Song<T>): Awaitable<string>;
1165
+ }
1166
+
1167
+ /**
1168
+ * This plugin can extract and play song from supported links, but cannot search for songs from its source
1169
+ */
1170
+ declare abstract class PlayableExtractorPlugin extends Plugin {
1171
+ readonly type = PluginType.PLAYABLE_EXTRACTOR;
1172
+ /**
1173
+ * Check if the url is working with this plugin
1174
+ * @param url - Input url
1175
+ */
1176
+ abstract validate(url: string): Awaitable<boolean>;
1177
+ /**
1178
+ * Resolve the validated url to a {@link Song} or a {@link Playlist}.
1179
+ * @param url - URL
1180
+ * @param options - Optional options
1181
+ */
1182
+ abstract resolve<T>(url: string, options: ResolveOptions<T>): Awaitable<Song<T> | Playlist<T>>;
1183
+ /**
1184
+ * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
1185
+ * Not needed if the plugin plays song from YouTube.
1186
+ * @param song - Input song
1187
+ */
1188
+ abstract getStreamURL<T>(song: Song<T>): Awaitable<string>;
1189
+ }
1190
+
1191
+ /**
1192
+ * Format duration to string
1193
+ * @param sec - Duration in seconds
1194
+ */
1195
+ declare function formatDuration(sec: number): string;
1196
+ declare const SUPPORTED_PROTOCOL: readonly ["https:", "http:", "file:"];
1197
+ /**
1198
+ * Check if the string is an URL
1199
+ * @param input - input
1200
+ */
1201
+ declare function isURL(input: any): input is `${(typeof SUPPORTED_PROTOCOL)[number]}//${string}`;
1202
+ /**
1203
+ * Check if the Client has enough intents to using DisTube
1204
+ * @param options - options
1205
+ */
1206
+ declare function checkIntents(options: ClientOptions): void;
1207
+ /**
1208
+ * Check if the voice channel is empty
1209
+ * @param voiceState - voiceState
1210
+ */
1211
+ declare function isVoiceChannelEmpty(voiceState: VoiceState): boolean;
1212
+ declare function isSnowflake(id: any): id is Snowflake;
1213
+ declare function isMemberInstance(member: any): member is GuildMember;
1214
+ declare function isTextChannelInstance(channel: any): channel is GuildTextBasedChannel;
1215
+ declare function isMessageInstance(message: any): message is Message<true>;
1216
+ declare function isSupportedVoiceChannel(channel: any): channel is VoiceBasedChannel;
1217
+ declare function isGuildInstance(guild: any): guild is Guild;
1218
+ declare function resolveGuildId(resolvable: GuildIdResolvable): Snowflake;
1219
+ declare function isClientInstance(client: any): client is Client;
1220
+ declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
1221
+ declare function isObject(obj: any): obj is object;
1222
+ type KeyOf<T> = T extends object ? (keyof T)[] : [];
1223
+ declare function objectKeys<T>(obj: T): KeyOf<T>;
1224
+ declare function isNsfwChannel(channel?: GuildTextBasedChannel): boolean;
1225
+ type Falsy = undefined | null | false | 0 | "";
1226
+ declare const isTruthy: <T>(x: T | Falsy) => x is T;
1227
+
1228
+ declare const version: string;
1229
+ /**
1230
+ * DisTube class
1231
+ */
1232
+ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
1233
+ #private;
1234
+ /**
1235
+ * @event
1236
+ * Emitted after DisTube add a new playlist to the playing {@link Queue}.
1237
+ * @param queue - The guild queue
1238
+ * @param playlist - Playlist info
1239
+ */
1240
+ static readonly [Events.ADD_LIST]: (queue: Queue, playlist: Playlist) => Awaitable;
1241
+ /**
1242
+ * @event
1243
+ * Emitted after DisTube add a new song to the playing {@link Queue}.
1244
+ * @param queue - The guild queue
1245
+ * @param song - Added song
1246
+ */
1247
+ static readonly [Events.ADD_SONG]: (queue: Queue, song: Song) => Awaitable;
1248
+ /**
1249
+ * @event
1250
+ * Emitted when a {@link Queue} is deleted with any reasons.
1251
+ * @param queue - The guild queue
1252
+ */
1253
+ static readonly [Events.DELETE_QUEUE]: (queue: Queue) => Awaitable;
1254
+ /**
1255
+ * @event
1256
+ * Emitted when the bot is disconnected to a voice channel.
1257
+ * @param queue - The guild queue
1258
+ */
1259
+ static readonly [Events.DISCONNECT]: (queue: Queue) => Awaitable;
1260
+ /**
1261
+ * @event
1262
+ * Emitted when DisTube encounters an error while playing songs.
1263
+ * @param error - error
1264
+ * @param queue - The queue encountered the error
1265
+ * @param song - The playing song when encountered the error
1266
+ */
1267
+ static readonly [Events.ERROR]: (error: Error, queue: Queue, song?: Song) => Awaitable;
1268
+ /**
1269
+ * @event
1270
+ * Emitted for logging FFmpeg debug information.
1271
+ * @param debug - Debug message string.
1272
+ */
1273
+ static readonly [Events.FFMPEG_DEBUG]: (debug: string) => Awaitable;
1274
+ /**
1275
+ * @event
1276
+ * Emitted to provide debug information from DisTube's operation.
1277
+ * Useful for troubleshooting or logging purposes.
1278
+ *
1279
+ * @param debug - Debug message string.
1280
+ */
1281
+ static readonly [Events.DEBUG]: (debug: string) => Awaitable;
1282
+ /**
1283
+ * @event
1284
+ * Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.
1285
+ * @param queue - The guild queue
1286
+ */
1287
+ static readonly [Events.FINISH]: (queue: Queue) => Awaitable;
1288
+ /**
1289
+ * @event
1290
+ * Emitted when DisTube finished a song.
1291
+ * @param queue - The guild queue
1292
+ * @param song - Finished song
1293
+ */
1294
+ static readonly [Events.FINISH_SONG]: (queue: Queue, song: Song) => Awaitable;
1295
+ /**
1296
+ * @event
1297
+ * Emitted when DisTube initialize a queue to change queue default properties.
1298
+ * @param queue - The guild queue
1299
+ */
1300
+ static readonly [Events.INIT_QUEUE]: (queue: Queue) => Awaitable;
1301
+ /**
1302
+ * @event
1303
+ * Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty, and
1304
+ * DisTube cannot find related songs to play.
1305
+ * @param queue - The guild queue
1306
+ */
1307
+ static readonly [Events.NO_RELATED]: (queue: Queue) => Awaitable;
1308
+ /**
1309
+ * @event
1310
+ * Emitted when DisTube play a song.
1311
+ * If {@link DisTubeOptions}.emitNewSongOnly is `true`, this event is not emitted
1312
+ * when looping a song or next song is the previous one.
1313
+ * @param queue - The guild queue
1314
+ * @param song - Playing song
1315
+ */
1316
+ static readonly [Events.PLAY_SONG]: (queue: Queue, song: Song) => Awaitable;
1317
+ /**
1318
+ * DisTube internal handler
1319
+ */
1320
+ readonly handler: DisTubeHandler;
1321
+ /**
1322
+ * DisTube options
1323
+ */
1324
+ readonly options: Options;
1325
+ /**
1326
+ * Discord.js v14 client
1327
+ */
1328
+ readonly client: Client;
1329
+ /**
1330
+ * Queues manager
1331
+ */
1332
+ readonly queues: QueueManager;
1333
+ /**
1334
+ * DisTube voice connections manager
1335
+ */
1336
+ readonly voices: DisTubeVoiceManager;
1337
+ /**
1338
+ * DisTube plugins
1339
+ */
1340
+ readonly plugins: DisTubePlugin[];
1341
+ /**
1342
+ * DisTube ffmpeg audio filters
1343
+ */
1344
+ readonly filters: Filters;
1345
+ /**
1346
+ * Create a new DisTube class.
1347
+ * @throws {@link DisTubeError}
1348
+ * @param client - Discord.JS client
1349
+ * @param opts - Custom DisTube options
1350
+ */
1351
+ constructor(client: Client, opts?: DisTubeOptions);
1352
+ static get version(): string;
1353
+ /**
1354
+ * DisTube version
1355
+ */
1356
+ get version(): string;
1357
+ /**
1358
+ * Play / add a song or playlist from url.
1359
+ * Search and play a song (with {@link ExtractorPlugin}) if it is not a valid url.
1360
+ * @throws {@link DisTubeError}
1361
+ * @param voiceChannel - The channel will be joined if the bot isn't in any channels, the bot will be
1362
+ * moved to this channel if {@link DisTubeOptions}.joinNewVoiceChannel is `true`
1363
+ * @param song - URL | Search string | {@link Song} | {@link Playlist}
1364
+ * @param options - Optional options
1365
+ */
1366
+ play<T = unknown>(voiceChannel: VoiceBasedChannel, song: string | Song | Playlist, options?: PlayOptions<T>): Promise<void>;
1367
+ /**
1368
+ * Create a custom playlist
1369
+ * @param songs - Array of url or Song
1370
+ * @param options - Optional options
1371
+ */
1372
+ createCustomPlaylist(songs: (string | Song)[], { member, parallel, metadata, name, source, url, thumbnail }?: CustomPlaylistOptions): Promise<Playlist>;
1373
+ /**
1374
+ * Get the guild queue
1375
+ * @param guild - The type can be resolved to give a {@link Queue}
1376
+ */
1377
+ getQueue(guild: GuildIdResolvable): Queue | undefined;
1378
+ /**
1379
+ * Pause the guild stream
1380
+ * @param guild - The type can be resolved to give a {@link Queue}
1381
+ * @returns The guild queue
1382
+ */
1383
+ pause(guild: GuildIdResolvable): Queue;
1384
+ /**
1385
+ * Resume the guild stream
1386
+ * @param guild - The type can be resolved to give a {@link Queue}
1387
+ * @returns The guild queue
1388
+ */
1389
+ resume(guild: GuildIdResolvable): Queue;
1390
+ /**
1391
+ * Stop the guild stream
1392
+ * @param guild - The type can be resolved to give a {@link Queue}
1393
+ */
1394
+ stop(guild: GuildIdResolvable): Promise<void>;
1395
+ /**
1396
+ * Set the guild stream's volume
1397
+ * @param guild - The type can be resolved to give a {@link Queue}
1398
+ * @param percent - The percentage of volume you want to set
1399
+ * @returns The guild queue
1400
+ */
1401
+ setVolume(guild: GuildIdResolvable, percent: number): Queue;
1402
+ /**
1403
+ * Skip the playing song if there is a next song in the queue. <info>If {@link
1404
+ * Queue#autoplay} is `true` and there is no up next song, DisTube will add and
1405
+ * play a related song.</info>
1406
+ * @param guild - The type can be resolved to give a {@link Queue}
1407
+ * @returns The new Song will be played
1408
+ */
1409
+ skip(guild: GuildIdResolvable): Promise<Song>;
1410
+ /**
1411
+ * Play the previous song
1412
+ * @param guild - The type can be resolved to give a {@link Queue}
1413
+ * @returns The new Song will be played
1414
+ */
1415
+ previous(guild: GuildIdResolvable): Promise<Song>;
1416
+ /**
1417
+ * Shuffle the guild queue songs
1418
+ * @param guild - The type can be resolved to give a {@link Queue}
1419
+ * @returns The guild queue
1420
+ */
1421
+ shuffle(guild: GuildIdResolvable): Promise<Queue>;
1422
+ /**
1423
+ * Jump to the song number in the queue. The next one is 1, 2,... The previous one
1424
+ * is -1, -2,...
1425
+ * @param guild - The type can be resolved to give a {@link Queue}
1426
+ * @param num - The song number to play
1427
+ * @returns The new Song will be played
1428
+ */
1429
+ jump(guild: GuildIdResolvable, num: number): Promise<Song>;
1430
+ /**
1431
+ * Set the repeat mode of the guild queue.
1432
+ * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
1433
+ * @param guild - The type can be resolved to give a {@link Queue}
1434
+ * @param mode - The repeat modes (toggle if `undefined`)
1435
+ * @returns The new repeat mode
1436
+ */
1437
+ setRepeatMode(guild: GuildIdResolvable, mode?: RepeatMode): RepeatMode;
1438
+ /**
1439
+ * Toggle autoplay mode
1440
+ * @param guild - The type can be resolved to give a {@link Queue}
1441
+ * @returns Autoplay mode state
1442
+ */
1443
+ toggleAutoplay(guild: GuildIdResolvable): boolean;
1444
+ /**
1445
+ * Add related song to the queue
1446
+ * @param guild - The type can be resolved to give a {@link Queue}
1447
+ * @returns The guild queue
1448
+ */
1449
+ addRelatedSong(guild: GuildIdResolvable): Promise<Song>;
1450
+ /**
1451
+ * Set the playing time to another position
1452
+ * @param guild - The type can be resolved to give a {@link Queue}
1453
+ * @param time - Time in seconds
1454
+ * @returns Seeked queue
1455
+ */
1456
+ seek(guild: GuildIdResolvable, time: number): Queue;
1457
+ /**
1458
+ * Emit error event
1459
+ * @param error - error
1460
+ * @param queue - The queue encountered the error
1461
+ * @param song - The playing song when encountered the error
1462
+ */
1463
+ emitError(error: Error, queue: Queue, song?: Song): void;
1464
+ /**
1465
+ * Emit debug event
1466
+ * @param message - debug message
1467
+ */
1468
+ debug(message: string): void;
1469
+ }
1470
+
1471
+ 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, checkFFmpeg, checkIntents, checkInvalidKey, DisTube as default, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isNsfwChannel, isObject, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isTruthy, isURL, isVoiceChannelEmpty, objectKeys, resolveGuildId, version };