distube 4.0.0-dev.5 → 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 +110 -91
- package/dist/index.js +643 -644
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +646 -646
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -21
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 as StreamType$1, 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
|
|
|
@@ -99,11 +97,12 @@ interface Chapter {
|
|
|
99
97
|
interface PlaylistInfo {
|
|
100
98
|
source: string;
|
|
101
99
|
member?: GuildMember;
|
|
102
|
-
user?: User;
|
|
103
100
|
songs: Song[];
|
|
104
101
|
name?: string;
|
|
105
102
|
url?: string;
|
|
106
103
|
thumbnail?: string;
|
|
104
|
+
title?: string;
|
|
105
|
+
webpage_url?: string;
|
|
107
106
|
}
|
|
108
107
|
declare type RelatedSong = Omit<Song, "related">;
|
|
109
108
|
declare type PlayHandlerOptions = {
|
|
@@ -165,7 +164,7 @@ declare const defaultOptions: {
|
|
|
165
164
|
};
|
|
166
165
|
|
|
167
166
|
declare const ERROR_MESSAGES: {
|
|
168
|
-
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;
|
|
169
168
|
NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
|
|
170
169
|
EMPTY_ARRAY: (name: string) => string;
|
|
171
170
|
EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
|
|
@@ -235,7 +234,7 @@ declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
235
234
|
url?: string;
|
|
236
235
|
thumbnail?: string;
|
|
237
236
|
[x: string]: any;
|
|
238
|
-
constructor(playlist: Song[] |
|
|
237
|
+
constructor(playlist: Song[] | PlaylistInfo, options?: {
|
|
239
238
|
member?: GuildMember;
|
|
240
239
|
properties?: Record<string, any>;
|
|
241
240
|
metadata?: T;
|
|
@@ -249,23 +248,33 @@ declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
249
248
|
set metadata(metadata: T);
|
|
250
249
|
}
|
|
251
250
|
|
|
252
|
-
declare class
|
|
251
|
+
declare abstract class ISearchResult {
|
|
253
252
|
source: "youtube";
|
|
254
|
-
type: SearchResultType;
|
|
253
|
+
abstract type: SearchResultType;
|
|
255
254
|
id: string;
|
|
256
255
|
name: string;
|
|
257
256
|
url: string;
|
|
258
|
-
views?: number;
|
|
259
|
-
isLive?: boolean;
|
|
260
|
-
duration?: number;
|
|
261
|
-
formattedDuration?: string;
|
|
262
|
-
thumbnail?: string;
|
|
263
257
|
uploader: {
|
|
264
258
|
name?: string;
|
|
265
259
|
url?: string;
|
|
266
260
|
};
|
|
267
261
|
constructor(info: Video | Playlist$1);
|
|
268
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;
|
|
269
278
|
|
|
270
279
|
declare class Song<T = unknown> {
|
|
271
280
|
#private;
|
|
@@ -306,29 +315,6 @@ declare class Song<T = unknown> {
|
|
|
306
315
|
set metadata(metadata: T);
|
|
307
316
|
}
|
|
308
317
|
|
|
309
|
-
declare class Options {
|
|
310
|
-
#private;
|
|
311
|
-
plugins: (CustomPlugin | ExtractorPlugin)[];
|
|
312
|
-
emitNewSongOnly: boolean;
|
|
313
|
-
leaveOnFinish: boolean;
|
|
314
|
-
leaveOnStop: boolean;
|
|
315
|
-
leaveOnEmpty: boolean;
|
|
316
|
-
emptyCooldown: number;
|
|
317
|
-
savePreviousSongs: boolean;
|
|
318
|
-
searchSongs: number;
|
|
319
|
-
searchCooldown: number;
|
|
320
|
-
youtubeCookie?: string;
|
|
321
|
-
youtubeIdentityToken?: string;
|
|
322
|
-
customFilters?: Filters;
|
|
323
|
-
ytdlOptions: ytdl.getInfoOptions;
|
|
324
|
-
nsfw: boolean;
|
|
325
|
-
emitAddSongWhenCreatingQueue: boolean;
|
|
326
|
-
emitAddListWhenCreatingQueue: boolean;
|
|
327
|
-
joinNewVoiceChannel: boolean;
|
|
328
|
-
streamType: StreamType;
|
|
329
|
-
constructor(options: DisTubeOptions);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
318
|
declare abstract class DisTubeBase {
|
|
333
319
|
distube: DisTube;
|
|
334
320
|
constructor(distube: DisTube);
|
|
@@ -341,55 +327,6 @@ declare abstract class DisTubeBase {
|
|
|
341
327
|
get handler(): DisTubeHandler;
|
|
342
328
|
}
|
|
343
329
|
|
|
344
|
-
interface StreamOptions {
|
|
345
|
-
seek?: number;
|
|
346
|
-
ffmpegArgs?: string[];
|
|
347
|
-
isLive?: boolean;
|
|
348
|
-
type?: StreamType;
|
|
349
|
-
}
|
|
350
|
-
declare const chooseBestVideoFormat: (formats: ytdl.videoFormat[], isLive?: boolean) => ytdl.videoFormat;
|
|
351
|
-
declare class DisTubeStream {
|
|
352
|
-
static YouTube(formats: ytdl.videoFormat[] | undefined, options?: StreamOptions): DisTubeStream;
|
|
353
|
-
static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
|
|
354
|
-
type: StreamType$1;
|
|
355
|
-
stream: FFmpeg;
|
|
356
|
-
url: string;
|
|
357
|
-
constructor(url: string, options: StreamOptions);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
declare abstract class BaseManager<V> extends DisTubeBase {
|
|
361
|
-
collection: Collection<string, V>;
|
|
362
|
-
get size(): number;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
declare abstract class GuildIdManager<V> extends BaseManager<V> {
|
|
366
|
-
add(idOrInstance: GuildIdResolvable, data: V): this | _discordjs_collection.Collection<string, V>;
|
|
367
|
-
get(idOrInstance: GuildIdResolvable): V | undefined;
|
|
368
|
-
remove(idOrInstance: GuildIdResolvable): boolean;
|
|
369
|
-
has(idOrInstance: GuildIdResolvable): boolean;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
declare class QueueManager extends GuildIdManager<Queue> {
|
|
373
|
-
#private;
|
|
374
|
-
create(channel: VoiceBasedChannel, song: Song[] | Song, textChannel?: GuildTextBasedChannel): Promise<Queue | true>;
|
|
375
|
-
createStream(queue: Queue): DisTubeStream;
|
|
376
|
-
playSong(queue: Queue): Promise<boolean>;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
declare class FilterManager extends BaseManager<FilterResolvable> {
|
|
380
|
-
#private;
|
|
381
|
-
queue: Queue;
|
|
382
|
-
constructor(queue: Queue);
|
|
383
|
-
add(filterOrFilters: FilterResolvable | FilterResolvable[], override?: boolean): this;
|
|
384
|
-
clear(): this;
|
|
385
|
-
set(filters: FilterResolvable[]): this;
|
|
386
|
-
remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
|
|
387
|
-
has(filter: FilterResolvable): boolean;
|
|
388
|
-
get names(): string[];
|
|
389
|
-
get values(): string[];
|
|
390
|
-
toString(): string;
|
|
391
|
-
}
|
|
392
|
-
|
|
393
330
|
declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
394
331
|
#private;
|
|
395
332
|
readonly id: Snowflake;
|
|
@@ -418,12 +355,45 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
418
355
|
get voiceState(): VoiceState | undefined;
|
|
419
356
|
}
|
|
420
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
|
+
|
|
421
370
|
declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
422
371
|
create(channel: VoiceBasedChannel): DisTubeVoice;
|
|
423
372
|
join(channel: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
424
373
|
leave(guild: GuildIdResolvable): void;
|
|
425
374
|
}
|
|
426
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
|
+
|
|
427
397
|
declare class DisTubeHandler extends DisTubeBase {
|
|
428
398
|
constructor(distube: DisTube);
|
|
429
399
|
get ytdlOptions(): ytdl.getInfoOptions;
|
|
@@ -443,6 +413,45 @@ declare class DisTubeHandler extends DisTubeBase {
|
|
|
443
413
|
playSong(voiceChannel: VoiceBasedChannel, song: Song, options?: PlayHandlerOptions): Promise<void>;
|
|
444
414
|
}
|
|
445
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
|
+
|
|
446
455
|
declare class Queue extends DisTubeBase {
|
|
447
456
|
#private;
|
|
448
457
|
readonly id: Snowflake;
|
|
@@ -531,10 +540,8 @@ declare function isGuildInstance(guild: any): guild is Guild;
|
|
|
531
540
|
declare function resolveGuildId(resolvable: GuildIdResolvable): Snowflake;
|
|
532
541
|
declare function isClientInstance(client: any): client is Client;
|
|
533
542
|
declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
|
|
534
|
-
declare function entersState<T extends VoiceConnection | AudioPlayer>(target: T, status: T extends VoiceConnection ? VoiceConnectionStatus : AudioPlayerStatus, maxTime: number): Promise<EventEmitter | T>;
|
|
535
543
|
declare function isObject(obj: any): obj is object;
|
|
536
|
-
declare function isRecord(obj: any): obj is Record<string,
|
|
537
|
-
declare function getClientMember(guild: Guild): GuildMember | undefined;
|
|
544
|
+
declare function isRecord<T = unknown>(obj: any): obj is Record<string, T>;
|
|
538
545
|
|
|
539
546
|
declare class HTTPPlugin extends ExtractorPlugin {
|
|
540
547
|
validate(url: string): Promise<boolean>;
|
|
@@ -580,11 +587,23 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
580
587
|
metadata?: any;
|
|
581
588
|
}): Promise<Playlist>;
|
|
582
589
|
search(string: string, options?: {
|
|
583
|
-
type?:
|
|
590
|
+
type?: SearchResultType;
|
|
584
591
|
limit?: number;
|
|
585
592
|
safeSearch?: boolean;
|
|
586
593
|
retried?: boolean;
|
|
587
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>>;
|
|
588
607
|
getQueue(guild: GuildIdResolvable): Queue | undefined;
|
|
589
608
|
pause(guild: GuildIdResolvable): Queue;
|
|
590
609
|
resume(guild: GuildIdResolvable): Queue;
|
|
@@ -601,4 +620,4 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
601
620
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
602
621
|
}
|
|
603
622
|
|
|
604
|
-
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, StreamType, 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 };
|