distube 4.0.0-dev.3 → 4.0.0-dev.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +119 -89
- package/dist/index.js +723 -647
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +720 -645
- package/dist/index.mjs.map +1 -1
- package/package.json +26 -26
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import ytdl from '@distube/ytdl-core';
|
|
2
2
|
import * as discord_js from 'discord.js';
|
|
3
|
-
import { GuildTextBasedChannel, Message, Snowflake, VoiceBasedChannel, VoiceState, Guild, GuildMember, Interaction,
|
|
4
|
-
import ytpl from '@distube/ytpl';
|
|
3
|
+
import { GuildTextBasedChannel, Message, Snowflake, VoiceBasedChannel, VoiceState, Guild, GuildMember, Interaction, Client, Collection, ClientOptions } from 'discord.js';
|
|
5
4
|
import { Video, Playlist as Playlist$1 } from '@distube/ytsr';
|
|
6
5
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
6
|
+
import { AudioPlayer, VoiceConnection, AudioResource, StreamType as StreamType$1 } from '@discordjs/voice';
|
|
7
7
|
import { FFmpeg } from 'prism-media';
|
|
8
|
-
import { StreamType, AudioPlayer, VoiceConnection, AudioResource, VoiceConnectionStatus, AudioPlayerStatus } from '@discordjs/voice';
|
|
9
8
|
import * as _discordjs_collection from '@discordjs/collection';
|
|
10
|
-
import { EventEmitter } from 'node:events';
|
|
11
9
|
import https from 'https';
|
|
12
10
|
import http from 'http';
|
|
13
11
|
|
|
@@ -58,6 +56,8 @@ interface DisTubeOptions {
|
|
|
58
56
|
nsfw?: boolean;
|
|
59
57
|
emitAddSongWhenCreatingQueue?: boolean;
|
|
60
58
|
emitAddListWhenCreatingQueue?: boolean;
|
|
59
|
+
joinNewVoiceChannel?: boolean;
|
|
60
|
+
streamType?: StreamType;
|
|
61
61
|
}
|
|
62
62
|
declare type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
|
|
63
63
|
interface OtherSongInfo {
|
|
@@ -97,11 +97,12 @@ interface Chapter {
|
|
|
97
97
|
interface PlaylistInfo {
|
|
98
98
|
source: string;
|
|
99
99
|
member?: GuildMember;
|
|
100
|
-
user?: User;
|
|
101
100
|
songs: Song[];
|
|
102
101
|
name?: string;
|
|
103
102
|
url?: string;
|
|
104
103
|
thumbnail?: string;
|
|
104
|
+
title?: string;
|
|
105
|
+
webpage_url?: string;
|
|
105
106
|
}
|
|
106
107
|
declare type RelatedSong = Omit<Song, "related">;
|
|
107
108
|
declare type PlayHandlerOptions = {
|
|
@@ -138,6 +139,10 @@ declare enum SearchResultType {
|
|
|
138
139
|
VIDEO = "video",
|
|
139
140
|
PLAYLIST = "playlist"
|
|
140
141
|
}
|
|
142
|
+
declare enum StreamType {
|
|
143
|
+
OPUS = 0,
|
|
144
|
+
RAW = 1
|
|
145
|
+
}
|
|
141
146
|
|
|
142
147
|
declare const defaultFilters: Filters;
|
|
143
148
|
declare const defaultOptions: {
|
|
@@ -155,10 +160,11 @@ declare const defaultOptions: {
|
|
|
155
160
|
emitAddSongWhenCreatingQueue: boolean;
|
|
156
161
|
emitAddListWhenCreatingQueue: boolean;
|
|
157
162
|
joinNewVoiceChannel: boolean;
|
|
163
|
+
streamType: StreamType;
|
|
158
164
|
};
|
|
159
165
|
|
|
160
166
|
declare const ERROR_MESSAGES: {
|
|
161
|
-
INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string
|
|
167
|
+
INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) => string;
|
|
162
168
|
NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
|
|
163
169
|
EMPTY_ARRAY: (name: string) => string;
|
|
164
170
|
EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
|
|
@@ -175,6 +181,7 @@ declare const ERROR_MESSAGES: {
|
|
|
175
181
|
VOICE_MISSING_PERMS: string;
|
|
176
182
|
VOICE_RECONNECT_FAILED: string;
|
|
177
183
|
VOICE_DIFFERENT_GUILD: string;
|
|
184
|
+
VOICE_DIFFERENT_CLIENT: string;
|
|
178
185
|
NO_QUEUE: string;
|
|
179
186
|
QUEUE_EXIST: string;
|
|
180
187
|
PAUSED: string;
|
|
@@ -227,7 +234,7 @@ declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
227
234
|
url?: string;
|
|
228
235
|
thumbnail?: string;
|
|
229
236
|
[x: string]: any;
|
|
230
|
-
constructor(playlist: Song[] |
|
|
237
|
+
constructor(playlist: Song[] | PlaylistInfo, options?: {
|
|
231
238
|
member?: GuildMember;
|
|
232
239
|
properties?: Record<string, any>;
|
|
233
240
|
metadata?: T;
|
|
@@ -241,23 +248,33 @@ declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
241
248
|
set metadata(metadata: T);
|
|
242
249
|
}
|
|
243
250
|
|
|
244
|
-
declare class
|
|
251
|
+
declare abstract class ISearchResult {
|
|
245
252
|
source: "youtube";
|
|
246
|
-
type: SearchResultType;
|
|
253
|
+
abstract type: SearchResultType;
|
|
247
254
|
id: string;
|
|
248
255
|
name: string;
|
|
249
256
|
url: string;
|
|
250
|
-
views?: number;
|
|
251
|
-
isLive?: boolean;
|
|
252
|
-
duration?: number;
|
|
253
|
-
formattedDuration?: string;
|
|
254
|
-
thumbnail?: string;
|
|
255
257
|
uploader: {
|
|
256
258
|
name?: string;
|
|
257
259
|
url?: string;
|
|
258
260
|
};
|
|
259
261
|
constructor(info: Video | Playlist$1);
|
|
260
262
|
}
|
|
263
|
+
declare class SearchResultVideo extends ISearchResult {
|
|
264
|
+
type: SearchResultType.VIDEO;
|
|
265
|
+
views: number;
|
|
266
|
+
isLive: boolean;
|
|
267
|
+
duration: number;
|
|
268
|
+
formattedDuration: string;
|
|
269
|
+
thumbnail: string;
|
|
270
|
+
constructor(info: Video);
|
|
271
|
+
}
|
|
272
|
+
declare class SearchResultPlaylist extends ISearchResult {
|
|
273
|
+
type: SearchResultType.PLAYLIST;
|
|
274
|
+
length: number;
|
|
275
|
+
constructor(info: Playlist$1);
|
|
276
|
+
}
|
|
277
|
+
declare type SearchResult = SearchResultVideo | SearchResultPlaylist;
|
|
261
278
|
|
|
262
279
|
declare class Song<T = unknown> {
|
|
263
280
|
#private;
|
|
@@ -298,28 +315,6 @@ declare class Song<T = unknown> {
|
|
|
298
315
|
set metadata(metadata: T);
|
|
299
316
|
}
|
|
300
317
|
|
|
301
|
-
declare class Options {
|
|
302
|
-
#private;
|
|
303
|
-
plugins: (CustomPlugin | ExtractorPlugin)[];
|
|
304
|
-
emitNewSongOnly: boolean;
|
|
305
|
-
leaveOnFinish: boolean;
|
|
306
|
-
leaveOnStop: boolean;
|
|
307
|
-
leaveOnEmpty: boolean;
|
|
308
|
-
emptyCooldown: number;
|
|
309
|
-
savePreviousSongs: boolean;
|
|
310
|
-
searchSongs: number;
|
|
311
|
-
searchCooldown: number;
|
|
312
|
-
youtubeCookie?: string;
|
|
313
|
-
youtubeIdentityToken?: string;
|
|
314
|
-
customFilters?: Filters;
|
|
315
|
-
ytdlOptions: ytdl.getInfoOptions;
|
|
316
|
-
nsfw: boolean;
|
|
317
|
-
emitAddSongWhenCreatingQueue: boolean;
|
|
318
|
-
emitAddListWhenCreatingQueue: boolean;
|
|
319
|
-
joinNewVoiceChannel: boolean;
|
|
320
|
-
constructor(options: DisTubeOptions);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
318
|
declare abstract class DisTubeBase {
|
|
324
319
|
distube: DisTube;
|
|
325
320
|
constructor(distube: DisTube);
|
|
@@ -332,54 +327,6 @@ declare abstract class DisTubeBase {
|
|
|
332
327
|
get handler(): DisTubeHandler;
|
|
333
328
|
}
|
|
334
329
|
|
|
335
|
-
interface StreamOptions {
|
|
336
|
-
seek?: number;
|
|
337
|
-
ffmpegArgs?: string[];
|
|
338
|
-
isLive?: boolean;
|
|
339
|
-
}
|
|
340
|
-
declare const chooseBestVideoFormat: (formats: ytdl.videoFormat[], isLive?: boolean) => ytdl.videoFormat;
|
|
341
|
-
declare class DisTubeStream {
|
|
342
|
-
static YouTube(formats: ytdl.videoFormat[] | undefined, options?: StreamOptions): DisTubeStream;
|
|
343
|
-
static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
|
|
344
|
-
type: StreamType.Raw;
|
|
345
|
-
stream: FFmpeg;
|
|
346
|
-
url: string;
|
|
347
|
-
constructor(url: string, options: StreamOptions);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
declare abstract class BaseManager<V> extends DisTubeBase {
|
|
351
|
-
collection: Collection<string, V>;
|
|
352
|
-
get size(): number;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
declare abstract class GuildIdManager<V> extends BaseManager<V> {
|
|
356
|
-
add(idOrInstance: GuildIdResolvable, data: V): this | _discordjs_collection.Collection<string, V>;
|
|
357
|
-
get(idOrInstance: GuildIdResolvable): V | undefined;
|
|
358
|
-
remove(idOrInstance: GuildIdResolvable): boolean;
|
|
359
|
-
has(idOrInstance: GuildIdResolvable): boolean;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
declare class QueueManager extends GuildIdManager<Queue> {
|
|
363
|
-
#private;
|
|
364
|
-
create(channel: VoiceBasedChannel, song: Song[] | Song, textChannel?: GuildTextBasedChannel): Promise<Queue | true>;
|
|
365
|
-
createStream(queue: Queue): DisTubeStream;
|
|
366
|
-
playSong(queue: Queue): Promise<boolean>;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
declare class FilterManager extends BaseManager<FilterResolvable> {
|
|
370
|
-
#private;
|
|
371
|
-
queue: Queue;
|
|
372
|
-
constructor(queue: Queue);
|
|
373
|
-
add(filterOrFilters: FilterResolvable | FilterResolvable[], override?: boolean): this;
|
|
374
|
-
clear(): this;
|
|
375
|
-
set(filters: FilterResolvable[]): this;
|
|
376
|
-
remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
|
|
377
|
-
has(filter: FilterResolvable): boolean;
|
|
378
|
-
get names(): string[];
|
|
379
|
-
get values(): string[];
|
|
380
|
-
toString(): string;
|
|
381
|
-
}
|
|
382
|
-
|
|
383
330
|
declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
384
331
|
#private;
|
|
385
332
|
readonly id: Snowflake;
|
|
@@ -408,12 +355,45 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
408
355
|
get voiceState(): VoiceState | undefined;
|
|
409
356
|
}
|
|
410
357
|
|
|
358
|
+
declare abstract class BaseManager<V> extends DisTubeBase {
|
|
359
|
+
collection: Collection<string, V>;
|
|
360
|
+
get size(): number;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
declare abstract class GuildIdManager<V> extends BaseManager<V> {
|
|
364
|
+
add(idOrInstance: GuildIdResolvable, data: V): this | _discordjs_collection.Collection<string, V>;
|
|
365
|
+
get(idOrInstance: GuildIdResolvable): V | undefined;
|
|
366
|
+
remove(idOrInstance: GuildIdResolvable): boolean;
|
|
367
|
+
has(idOrInstance: GuildIdResolvable): boolean;
|
|
368
|
+
}
|
|
369
|
+
|
|
411
370
|
declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
412
371
|
create(channel: VoiceBasedChannel): DisTubeVoice;
|
|
413
372
|
join(channel: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
414
373
|
leave(guild: GuildIdResolvable): void;
|
|
415
374
|
}
|
|
416
375
|
|
|
376
|
+
declare class FilterManager extends BaseManager<FilterResolvable> {
|
|
377
|
+
#private;
|
|
378
|
+
queue: Queue;
|
|
379
|
+
constructor(queue: Queue);
|
|
380
|
+
add(filterOrFilters: FilterResolvable | FilterResolvable[], override?: boolean): this;
|
|
381
|
+
clear(): this;
|
|
382
|
+
set(filters: FilterResolvable[]): this;
|
|
383
|
+
remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
|
|
384
|
+
has(filter: FilterResolvable): boolean;
|
|
385
|
+
get names(): string[];
|
|
386
|
+
get values(): string[];
|
|
387
|
+
toString(): string;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
declare class QueueManager extends GuildIdManager<Queue> {
|
|
391
|
+
#private;
|
|
392
|
+
create(channel: VoiceBasedChannel, song: Song[] | Song, textChannel?: GuildTextBasedChannel): Promise<Queue | true>;
|
|
393
|
+
createStream(queue: Queue): DisTubeStream;
|
|
394
|
+
playSong(queue: Queue): Promise<boolean>;
|
|
395
|
+
}
|
|
396
|
+
|
|
417
397
|
declare class DisTubeHandler extends DisTubeBase {
|
|
418
398
|
constructor(distube: DisTube);
|
|
419
399
|
get ytdlOptions(): ytdl.getInfoOptions;
|
|
@@ -433,6 +413,45 @@ declare class DisTubeHandler extends DisTubeBase {
|
|
|
433
413
|
playSong(voiceChannel: VoiceBasedChannel, song: Song, options?: PlayHandlerOptions): Promise<void>;
|
|
434
414
|
}
|
|
435
415
|
|
|
416
|
+
declare class Options {
|
|
417
|
+
#private;
|
|
418
|
+
plugins: (CustomPlugin | ExtractorPlugin)[];
|
|
419
|
+
emitNewSongOnly: boolean;
|
|
420
|
+
leaveOnFinish: boolean;
|
|
421
|
+
leaveOnStop: boolean;
|
|
422
|
+
leaveOnEmpty: boolean;
|
|
423
|
+
emptyCooldown: number;
|
|
424
|
+
savePreviousSongs: boolean;
|
|
425
|
+
searchSongs: number;
|
|
426
|
+
searchCooldown: number;
|
|
427
|
+
youtubeCookie?: string;
|
|
428
|
+
youtubeIdentityToken?: string;
|
|
429
|
+
customFilters?: Filters;
|
|
430
|
+
ytdlOptions: ytdl.getInfoOptions;
|
|
431
|
+
nsfw: boolean;
|
|
432
|
+
emitAddSongWhenCreatingQueue: boolean;
|
|
433
|
+
emitAddListWhenCreatingQueue: boolean;
|
|
434
|
+
joinNewVoiceChannel: boolean;
|
|
435
|
+
streamType: StreamType;
|
|
436
|
+
constructor(options: DisTubeOptions);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
interface StreamOptions {
|
|
440
|
+
seek?: number;
|
|
441
|
+
ffmpegArgs?: string[];
|
|
442
|
+
isLive?: boolean;
|
|
443
|
+
type?: StreamType;
|
|
444
|
+
}
|
|
445
|
+
declare const chooseBestVideoFormat: (formats: ytdl.videoFormat[], isLive?: boolean) => ytdl.videoFormat;
|
|
446
|
+
declare class DisTubeStream {
|
|
447
|
+
static YouTube(formats: ytdl.videoFormat[] | undefined, options?: StreamOptions): DisTubeStream;
|
|
448
|
+
static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
|
|
449
|
+
type: StreamType$1;
|
|
450
|
+
stream: FFmpeg;
|
|
451
|
+
url: string;
|
|
452
|
+
constructor(url: string, options: StreamOptions);
|
|
453
|
+
}
|
|
454
|
+
|
|
436
455
|
declare class Queue extends DisTubeBase {
|
|
437
456
|
#private;
|
|
438
457
|
readonly id: Snowflake;
|
|
@@ -449,10 +468,10 @@ declare class Queue extends DisTubeBase {
|
|
|
449
468
|
beginTime: number;
|
|
450
469
|
textChannel?: GuildTextBasedChannel;
|
|
451
470
|
_emptyTimeout?: NodeJS.Timeout;
|
|
452
|
-
clientMember: GuildMember;
|
|
453
471
|
_taskQueue: TaskQueue;
|
|
454
472
|
_listeners?: DisTubeVoiceEvents;
|
|
455
473
|
constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel);
|
|
474
|
+
get clientMember(): discord_js.GuildMember | undefined;
|
|
456
475
|
get filters(): FilterManager;
|
|
457
476
|
get formattedDuration(): string;
|
|
458
477
|
get duration(): number;
|
|
@@ -521,9 +540,8 @@ declare function isGuildInstance(guild: any): guild is Guild;
|
|
|
521
540
|
declare function resolveGuildId(resolvable: GuildIdResolvable): Snowflake;
|
|
522
541
|
declare function isClientInstance(client: any): client is Client;
|
|
523
542
|
declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
|
|
524
|
-
declare function entersState<T extends VoiceConnection | AudioPlayer>(target: T, status: T extends VoiceConnection ? VoiceConnectionStatus : AudioPlayerStatus, maxTime: number): Promise<EventEmitter | T>;
|
|
525
543
|
declare function isObject(obj: any): obj is object;
|
|
526
|
-
declare function isRecord(obj: any): obj is Record<string,
|
|
544
|
+
declare function isRecord<T = unknown>(obj: any): obj is Record<string, T>;
|
|
527
545
|
|
|
528
546
|
declare class HTTPPlugin extends ExtractorPlugin {
|
|
529
547
|
validate(url: string): Promise<boolean>;
|
|
@@ -569,11 +587,23 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
569
587
|
metadata?: any;
|
|
570
588
|
}): Promise<Playlist>;
|
|
571
589
|
search(string: string, options?: {
|
|
572
|
-
type?:
|
|
590
|
+
type?: SearchResultType;
|
|
573
591
|
limit?: number;
|
|
574
592
|
safeSearch?: boolean;
|
|
575
593
|
retried?: boolean;
|
|
576
594
|
}): Promise<Array<SearchResult>>;
|
|
595
|
+
search(string: string, options?: {
|
|
596
|
+
type?: SearchResultType.VIDEO;
|
|
597
|
+
limit?: number;
|
|
598
|
+
safeSearch?: boolean;
|
|
599
|
+
retried?: boolean;
|
|
600
|
+
}): Promise<Array<SearchResultVideo>>;
|
|
601
|
+
search(string: string, options: {
|
|
602
|
+
type: SearchResultType.PLAYLIST;
|
|
603
|
+
limit?: number;
|
|
604
|
+
safeSearch?: boolean;
|
|
605
|
+
retried?: boolean;
|
|
606
|
+
}): Promise<Array<SearchResultPlaylist>>;
|
|
577
607
|
getQueue(guild: GuildIdResolvable): Queue | undefined;
|
|
578
608
|
pause(guild: GuildIdResolvable): Queue;
|
|
579
609
|
resume(guild: GuildIdResolvable): Queue;
|
|
@@ -590,4 +620,4 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
590
620
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
591
621
|
}
|
|
592
622
|
|
|
593
|
-
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, HTTPPlugin, HTTPSPlugin, Options, OtherSongInfo, PlayHandlerOptions, PlayOptions, Playlist, PlaylistInfo, Plugin, PluginType, Queue, QueueManager, RelatedSong, RepeatMode, ResolveOptions, ResolvePlaylistOptions, SearchResult, SearchResultType, Song, TaskQueue, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions,
|
|
623
|
+
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, HTTPPlugin, HTTPSPlugin, Options, OtherSongInfo, PlayHandlerOptions, PlayOptions, Playlist, PlaylistInfo, Plugin, PluginType, Queue, QueueManager, RelatedSong, RepeatMode, ResolveOptions, ResolvePlaylistOptions, SearchResult, SearchResultPlaylist, SearchResultType, SearchResultVideo, Song, StreamType, TaskQueue, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions, formatDuration, getResponseHeaders, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, parseNumber, resolveGuildId, resolveHttpSong, toSecond, validateAudioURL, version };
|