distube 4.0.0-dev.5 → 4.0.1
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 +112 -115
- package/dist/index.js +662 -693
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +663 -688
- package/dist/index.mjs.map +1 -1
- package/package.json +27 -27
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +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
|
-
import https from 'https';
|
|
12
|
-
import http from 'http';
|
|
13
9
|
|
|
14
10
|
declare type Awaitable<T = any> = T | PromiseLike<T>;
|
|
15
11
|
declare type DisTubeVoiceEvents = {
|
|
@@ -99,11 +95,12 @@ interface Chapter {
|
|
|
99
95
|
interface PlaylistInfo {
|
|
100
96
|
source: string;
|
|
101
97
|
member?: GuildMember;
|
|
102
|
-
user?: User;
|
|
103
98
|
songs: Song[];
|
|
104
99
|
name?: string;
|
|
105
100
|
url?: string;
|
|
106
101
|
thumbnail?: string;
|
|
102
|
+
title?: string;
|
|
103
|
+
webpage_url?: string;
|
|
107
104
|
}
|
|
108
105
|
declare type RelatedSong = Omit<Song, "related">;
|
|
109
106
|
declare type PlayHandlerOptions = {
|
|
@@ -165,7 +162,7 @@ declare const defaultOptions: {
|
|
|
165
162
|
};
|
|
166
163
|
|
|
167
164
|
declare const ERROR_MESSAGES: {
|
|
168
|
-
INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string
|
|
165
|
+
INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) => string;
|
|
169
166
|
NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
|
|
170
167
|
EMPTY_ARRAY: (name: string) => string;
|
|
171
168
|
EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
|
|
@@ -235,7 +232,7 @@ declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
235
232
|
url?: string;
|
|
236
233
|
thumbnail?: string;
|
|
237
234
|
[x: string]: any;
|
|
238
|
-
constructor(playlist: Song[] |
|
|
235
|
+
constructor(playlist: Song[] | PlaylistInfo, options?: {
|
|
239
236
|
member?: GuildMember;
|
|
240
237
|
properties?: Record<string, any>;
|
|
241
238
|
metadata?: T;
|
|
@@ -249,23 +246,33 @@ declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
249
246
|
set metadata(metadata: T);
|
|
250
247
|
}
|
|
251
248
|
|
|
252
|
-
declare class
|
|
249
|
+
declare abstract class ISearchResult {
|
|
253
250
|
source: "youtube";
|
|
254
|
-
type: SearchResultType;
|
|
251
|
+
abstract type: SearchResultType;
|
|
255
252
|
id: string;
|
|
256
253
|
name: string;
|
|
257
254
|
url: string;
|
|
258
|
-
views?: number;
|
|
259
|
-
isLive?: boolean;
|
|
260
|
-
duration?: number;
|
|
261
|
-
formattedDuration?: string;
|
|
262
|
-
thumbnail?: string;
|
|
263
255
|
uploader: {
|
|
264
256
|
name?: string;
|
|
265
257
|
url?: string;
|
|
266
258
|
};
|
|
267
259
|
constructor(info: Video | Playlist$1);
|
|
268
260
|
}
|
|
261
|
+
declare class SearchResultVideo extends ISearchResult {
|
|
262
|
+
type: SearchResultType.VIDEO;
|
|
263
|
+
views: number;
|
|
264
|
+
isLive: boolean;
|
|
265
|
+
duration: number;
|
|
266
|
+
formattedDuration: string;
|
|
267
|
+
thumbnail: string;
|
|
268
|
+
constructor(info: Video);
|
|
269
|
+
}
|
|
270
|
+
declare type SearchResult = SearchResultVideo | SearchResultPlaylist;
|
|
271
|
+
declare class SearchResultPlaylist extends ISearchResult {
|
|
272
|
+
type: SearchResultType.PLAYLIST;
|
|
273
|
+
length: number;
|
|
274
|
+
constructor(info: Playlist$1);
|
|
275
|
+
}
|
|
269
276
|
|
|
270
277
|
declare class Song<T = unknown> {
|
|
271
278
|
#private;
|
|
@@ -306,29 +313,6 @@ declare class Song<T = unknown> {
|
|
|
306
313
|
set metadata(metadata: T);
|
|
307
314
|
}
|
|
308
315
|
|
|
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
316
|
declare abstract class DisTubeBase {
|
|
333
317
|
distube: DisTube;
|
|
334
318
|
constructor(distube: DisTube);
|
|
@@ -341,55 +325,6 @@ declare abstract class DisTubeBase {
|
|
|
341
325
|
get handler(): DisTubeHandler;
|
|
342
326
|
}
|
|
343
327
|
|
|
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
328
|
declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
394
329
|
#private;
|
|
395
330
|
readonly id: Snowflake;
|
|
@@ -418,12 +353,45 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
418
353
|
get voiceState(): VoiceState | undefined;
|
|
419
354
|
}
|
|
420
355
|
|
|
356
|
+
declare abstract class BaseManager<V> extends DisTubeBase {
|
|
357
|
+
collection: Collection<string, V>;
|
|
358
|
+
get size(): number;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
declare abstract class GuildIdManager<V> extends BaseManager<V> {
|
|
362
|
+
add(idOrInstance: GuildIdResolvable, data: V): this | _discordjs_collection.Collection<string, V>;
|
|
363
|
+
get(idOrInstance: GuildIdResolvable): V | undefined;
|
|
364
|
+
remove(idOrInstance: GuildIdResolvable): boolean;
|
|
365
|
+
has(idOrInstance: GuildIdResolvable): boolean;
|
|
366
|
+
}
|
|
367
|
+
|
|
421
368
|
declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
422
369
|
create(channel: VoiceBasedChannel): DisTubeVoice;
|
|
423
370
|
join(channel: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
424
371
|
leave(guild: GuildIdResolvable): void;
|
|
425
372
|
}
|
|
426
373
|
|
|
374
|
+
declare class FilterManager extends BaseManager<FilterResolvable> {
|
|
375
|
+
#private;
|
|
376
|
+
queue: Queue;
|
|
377
|
+
constructor(queue: Queue);
|
|
378
|
+
add(filterOrFilters: FilterResolvable | FilterResolvable[], override?: boolean): this;
|
|
379
|
+
clear(): this;
|
|
380
|
+
set(filters: FilterResolvable[]): this;
|
|
381
|
+
remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
|
|
382
|
+
has(filter: FilterResolvable): boolean;
|
|
383
|
+
get names(): string[];
|
|
384
|
+
get values(): string[];
|
|
385
|
+
toString(): string;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare class QueueManager extends GuildIdManager<Queue> {
|
|
389
|
+
#private;
|
|
390
|
+
create(channel: VoiceBasedChannel, song: Song[] | Song, textChannel?: GuildTextBasedChannel): Promise<Queue | true>;
|
|
391
|
+
createStream(queue: Queue): DisTubeStream;
|
|
392
|
+
playSong(queue: Queue): Promise<boolean>;
|
|
393
|
+
}
|
|
394
|
+
|
|
427
395
|
declare class DisTubeHandler extends DisTubeBase {
|
|
428
396
|
constructor(distube: DisTube);
|
|
429
397
|
get ytdlOptions(): ytdl.getInfoOptions;
|
|
@@ -443,6 +411,45 @@ declare class DisTubeHandler extends DisTubeBase {
|
|
|
443
411
|
playSong(voiceChannel: VoiceBasedChannel, song: Song, options?: PlayHandlerOptions): Promise<void>;
|
|
444
412
|
}
|
|
445
413
|
|
|
414
|
+
declare class Options {
|
|
415
|
+
#private;
|
|
416
|
+
plugins: (CustomPlugin | ExtractorPlugin)[];
|
|
417
|
+
emitNewSongOnly: boolean;
|
|
418
|
+
leaveOnFinish: boolean;
|
|
419
|
+
leaveOnStop: boolean;
|
|
420
|
+
leaveOnEmpty: boolean;
|
|
421
|
+
emptyCooldown: number;
|
|
422
|
+
savePreviousSongs: boolean;
|
|
423
|
+
searchSongs: number;
|
|
424
|
+
searchCooldown: number;
|
|
425
|
+
youtubeCookie?: string;
|
|
426
|
+
youtubeIdentityToken?: string;
|
|
427
|
+
customFilters?: Filters;
|
|
428
|
+
ytdlOptions: ytdl.getInfoOptions;
|
|
429
|
+
nsfw: boolean;
|
|
430
|
+
emitAddSongWhenCreatingQueue: boolean;
|
|
431
|
+
emitAddListWhenCreatingQueue: boolean;
|
|
432
|
+
joinNewVoiceChannel: boolean;
|
|
433
|
+
streamType: StreamType;
|
|
434
|
+
constructor(options: DisTubeOptions);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
interface StreamOptions {
|
|
438
|
+
seek?: number;
|
|
439
|
+
ffmpegArgs?: string[];
|
|
440
|
+
isLive?: boolean;
|
|
441
|
+
type?: StreamType;
|
|
442
|
+
}
|
|
443
|
+
declare const chooseBestVideoFormat: (formats: ytdl.videoFormat[], isLive?: boolean) => ytdl.videoFormat;
|
|
444
|
+
declare class DisTubeStream {
|
|
445
|
+
static YouTube(formats: ytdl.videoFormat[] | undefined, options?: StreamOptions): DisTubeStream;
|
|
446
|
+
static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
|
|
447
|
+
type: StreamType$1;
|
|
448
|
+
stream: FFmpeg;
|
|
449
|
+
url: string;
|
|
450
|
+
constructor(url: string, options: StreamOptions);
|
|
451
|
+
}
|
|
452
|
+
|
|
446
453
|
declare class Queue extends DisTubeBase {
|
|
447
454
|
#private;
|
|
448
455
|
readonly id: Snowflake;
|
|
@@ -531,27 +538,10 @@ declare function isGuildInstance(guild: any): guild is Guild;
|
|
|
531
538
|
declare function resolveGuildId(resolvable: GuildIdResolvable): Snowflake;
|
|
532
539
|
declare function isClientInstance(client: any): client is Client;
|
|
533
540
|
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
541
|
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;
|
|
542
|
+
declare function isRecord<T = unknown>(obj: any): obj is Record<string, T>;
|
|
538
543
|
|
|
539
|
-
declare class
|
|
540
|
-
validate(url: string): Promise<boolean>;
|
|
541
|
-
resolve(url: string, options?: {
|
|
542
|
-
member?: GuildMember;
|
|
543
|
-
metadata?: any;
|
|
544
|
-
}): Promise<Song<any>>;
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
declare const getResponseHeaders: (httpModule: typeof http | typeof https, url: string) => Promise<http.IncomingHttpHeaders>;
|
|
548
|
-
declare const validateAudioURL: (httpModule: typeof http | typeof https, protocol: string, url: string) => Promise<boolean>;
|
|
549
|
-
declare const resolveHttpSong: (url: string, options: {
|
|
550
|
-
source: "http" | "https";
|
|
551
|
-
member?: GuildMember;
|
|
552
|
-
metadata?: any;
|
|
553
|
-
}) => Promise<Song<any>>;
|
|
554
|
-
declare class HTTPSPlugin extends ExtractorPlugin {
|
|
544
|
+
declare class DirectLinkPlugin extends ExtractorPlugin {
|
|
555
545
|
validate(url: string): Promise<boolean>;
|
|
556
546
|
resolve(url: string, options?: {
|
|
557
547
|
member?: GuildMember;
|
|
@@ -573,18 +563,25 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
573
563
|
static get version(): string;
|
|
574
564
|
get version(): string;
|
|
575
565
|
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist, options?: PlayOptions): Promise<void>;
|
|
576
|
-
createCustomPlaylist(songs: (string | Song | SearchResult)[], options?:
|
|
577
|
-
member?: GuildMember;
|
|
578
|
-
properties?: Record<string, any>;
|
|
579
|
-
parallel?: boolean;
|
|
580
|
-
metadata?: any;
|
|
581
|
-
}): Promise<Playlist>;
|
|
566
|
+
createCustomPlaylist(songs: (string | Song | SearchResult)[], options?: CustomPlaylistOptions): Promise<Playlist>;
|
|
582
567
|
search(string: string, options?: {
|
|
583
|
-
type?:
|
|
568
|
+
type?: SearchResultType;
|
|
584
569
|
limit?: number;
|
|
585
570
|
safeSearch?: boolean;
|
|
586
571
|
retried?: boolean;
|
|
587
572
|
}): Promise<Array<SearchResult>>;
|
|
573
|
+
search(string: string, options?: {
|
|
574
|
+
type?: SearchResultType.VIDEO;
|
|
575
|
+
limit?: number;
|
|
576
|
+
safeSearch?: boolean;
|
|
577
|
+
retried?: boolean;
|
|
578
|
+
}): Promise<Array<SearchResultVideo>>;
|
|
579
|
+
search(string: string, options: {
|
|
580
|
+
type: SearchResultType.PLAYLIST;
|
|
581
|
+
limit?: number;
|
|
582
|
+
safeSearch?: boolean;
|
|
583
|
+
retried?: boolean;
|
|
584
|
+
}): Promise<Array<SearchResultPlaylist>>;
|
|
588
585
|
getQueue(guild: GuildIdResolvable): Queue | undefined;
|
|
589
586
|
pause(guild: GuildIdResolvable): Queue;
|
|
590
587
|
resume(guild: GuildIdResolvable): Queue;
|
|
@@ -601,4 +598,4 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
601
598
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
602
599
|
}
|
|
603
600
|
|
|
604
|
-
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable,
|
|
601
|
+
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DirectLinkPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, 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, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, parseNumber, resolveGuildId, toSecond, version };
|