distube 4.0.2 → 4.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/index.d.ts +90 -65
- package/dist/index.js +712 -629
- package/dist/index.js.map +1 -1
- package/package.json +10 -14
- package/dist/index.mjs +0 -2360
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<p>
|
|
3
|
-
<a href="https://
|
|
3
|
+
<a href="https://www.npmjs.com/package/distube" target="_blank"><img src="https://nodei.co/npm/distube.png?downloads=true&downloadRank=true&stars=true"></a>
|
|
4
4
|
</p>
|
|
5
5
|
<p>
|
|
6
|
-
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/skick1234/DisTube/Testing?label=Tests&logo=github&style=flat-square">
|
|
7
|
-
<img alt="node-current" src="https://img.shields.io/node/v/distube?logo=node.js&logoColor=white&style=flat-square">
|
|
8
|
-
<img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/distube/peer/discord.js?label=discord.js&logo=discord&logoColor=white&style=flat-square">
|
|
9
|
-
<img alt="Depfu" src="https://img.shields.io/depfu/skick1234/DisTube?style=flat-square">
|
|
10
|
-
<img alt="Codecov branch" src="https://img.shields.io/codecov/c/github/skick1234/DisTube/main?logo=codecov&logoColor=white&style=flat-square&token=WWDYRRSEQW">
|
|
6
|
+
<a href="https://github.com/skick1234/DisTube/actions" target="_blank"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/skick1234/DisTube/Testing?label=Tests&logo=github&style=flat-square"></a>
|
|
7
|
+
<a href="https://nodejs.org/" target="_blank"><img alt="node-current" src="https://img.shields.io/node/v/distube?logo=node.js&logoColor=white&style=flat-square"></a>
|
|
8
|
+
<a href="https://discord.js.org/" target="_blank"><img alt="npm peer dependency version" src="https://img.shields.io/npm/dependency-version/distube/peer/discord.js?label=discord.js&logo=discord&logoColor=white&style=flat-square"></a>
|
|
9
|
+
<a href="https://depfu.com/github/skick1234/DisTube?project_id=36112" target="_blank"><img alt="Depfu" src="https://img.shields.io/depfu/dependencies/github/skick1234/DisTube?style=flat-square"></a>
|
|
10
|
+
<a href="https://app.codecov.io/gh/skick1234/DisTube" target="_blank"><img alt="Codecov branch" src="https://img.shields.io/codecov/c/github/skick1234/DisTube/main?logo=codecov&logoColor=white&style=flat-square&token=WWDYRRSEQW"></a>
|
|
11
11
|
<br>
|
|
12
|
-
<img alt="npm" src="https://img.shields.io/npm/dt/distube?logo=npm&style=flat-square">
|
|
13
|
-
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/skick1234/DisTube?logo=github&logoColor=white&style=flat-square">
|
|
14
|
-
<img alt="Discord" src="https://img.shields.io/discord/732254550689316914?logo=discord&logoColor=white&style=flat-square">
|
|
12
|
+
<a href="https://www.npmjs.com/package/distube" target="_blank"><img alt="npm" src="https://img.shields.io/npm/dt/distube?logo=npm&style=flat-square"></a>
|
|
13
|
+
<a href="https://github.com/skick1234/DisTube/stargazers" target="_blank"><img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/skick1234/DisTube?logo=github&logoColor=white&style=flat-square"></a>
|
|
14
|
+
<a href="https://discord.gg/feaDd9h" target="_blank"><img alt="Discord" src="https://img.shields.io/discord/732254550689316914?logo=discord&logoColor=white&style=flat-square"></a>
|
|
15
15
|
</p>
|
|
16
16
|
</div>
|
|
17
17
|
|
|
@@ -42,7 +42,7 @@ A Discord.js module to simplify your music commands and play songs with audio fi
|
|
|
42
42
|
## Installation
|
|
43
43
|
|
|
44
44
|
```npm
|
|
45
|
-
npm install distube@
|
|
45
|
+
npm install distube@latest
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
## Documentation
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import ytdl from '@distube/ytdl-core';
|
|
2
2
|
import * as discord_js from 'discord.js';
|
|
3
3
|
import { GuildTextBasedChannel, Message, Snowflake, VoiceBasedChannel, VoiceState, Guild, GuildMember, Interaction, Client, Collection, ClientOptions } from 'discord.js';
|
|
4
|
+
import ytpl from '@distube/ytpl';
|
|
4
5
|
import { Video, Playlist as Playlist$1 } from '@distube/ytsr';
|
|
5
6
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
6
7
|
import { AudioPlayer, VoiceConnection, AudioResource, StreamType as StreamType$1 } from '@discordjs/voice';
|
|
@@ -14,22 +15,25 @@ declare type DisTubeVoiceEvents = {
|
|
|
14
15
|
finish: () => Awaitable;
|
|
15
16
|
};
|
|
16
17
|
declare type DisTubeEvents = {
|
|
17
|
-
error:
|
|
18
|
-
addList:
|
|
19
|
-
addSong:
|
|
20
|
-
playSong:
|
|
21
|
-
finishSong:
|
|
22
|
-
empty:
|
|
23
|
-
finish:
|
|
24
|
-
initQueue:
|
|
25
|
-
noRelated:
|
|
26
|
-
disconnect:
|
|
27
|
-
deleteQueue:
|
|
28
|
-
searchCancel:
|
|
29
|
-
searchNoResult:
|
|
30
|
-
searchDone:
|
|
31
|
-
searchInvalidAnswer:
|
|
32
|
-
searchResult:
|
|
18
|
+
error: [channel: GuildTextBasedChannel | undefined, error: Error];
|
|
19
|
+
addList: [queue: Queue, playlist: Playlist];
|
|
20
|
+
addSong: [queue: Queue, song: Song];
|
|
21
|
+
playSong: [queue: Queue, song: Song];
|
|
22
|
+
finishSong: [queue: Queue, song: Song];
|
|
23
|
+
empty: [queue: Queue];
|
|
24
|
+
finish: [queue: Queue];
|
|
25
|
+
initQueue: [queue: Queue];
|
|
26
|
+
noRelated: [queue: Queue];
|
|
27
|
+
disconnect: [queue: Queue];
|
|
28
|
+
deleteQueue: [queue: Queue];
|
|
29
|
+
searchCancel: [message: Message<true>, query: string];
|
|
30
|
+
searchNoResult: [message: Message<true>, query: string];
|
|
31
|
+
searchDone: [message: Message<true>, answer: Message<true>, query: string];
|
|
32
|
+
searchInvalidAnswer: [message: Message<true>, answer: Message<true>, query: string];
|
|
33
|
+
searchResult: [message: Message<true>, results: SearchResult[], query: string];
|
|
34
|
+
};
|
|
35
|
+
declare type TypedDisTubeEvents = {
|
|
36
|
+
[K in keyof DisTubeEvents]: (...args: DisTubeEvents[K]) => Awaitable;
|
|
33
37
|
};
|
|
34
38
|
interface Filter {
|
|
35
39
|
name: string;
|
|
@@ -60,7 +64,7 @@ interface DisTubeOptions {
|
|
|
60
64
|
}
|
|
61
65
|
declare type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
|
|
62
66
|
interface OtherSongInfo {
|
|
63
|
-
src
|
|
67
|
+
src: string;
|
|
64
68
|
id?: string;
|
|
65
69
|
title?: string;
|
|
66
70
|
name?: string;
|
|
@@ -142,6 +146,24 @@ declare enum StreamType {
|
|
|
142
146
|
OPUS = 0,
|
|
143
147
|
RAW = 1
|
|
144
148
|
}
|
|
149
|
+
declare enum Events {
|
|
150
|
+
ERROR = "error",
|
|
151
|
+
ADD_LIST = "addList",
|
|
152
|
+
ADD_SONG = "addSong",
|
|
153
|
+
PLAY_SONG = "playSong",
|
|
154
|
+
FINISH_SONG = "finishSong",
|
|
155
|
+
EMPTY = "empty",
|
|
156
|
+
FINISH = "finish",
|
|
157
|
+
INIT_QUEUE = "initQueue",
|
|
158
|
+
NO_RELATED = "noRelated",
|
|
159
|
+
DISCONNECT = "disconnect",
|
|
160
|
+
DELETE_QUEUE = "deleteQueue",
|
|
161
|
+
SEARCH_CANCEL = "searchCancel",
|
|
162
|
+
SEARCH_NO_RESULT = "searchNoResult",
|
|
163
|
+
SEARCH_DONE = "searchDone",
|
|
164
|
+
SEARCH_INVALID_ANSWER = "searchInvalidAnswer",
|
|
165
|
+
SEARCH_RESULT = "searchResult"
|
|
166
|
+
}
|
|
145
167
|
|
|
146
168
|
declare const defaultFilters: Filters;
|
|
147
169
|
declare const defaultOptions: {
|
|
@@ -299,7 +321,7 @@ declare class Song<T = unknown> {
|
|
|
299
321
|
age_restricted: boolean;
|
|
300
322
|
chapters: Chapter[];
|
|
301
323
|
reposts: number;
|
|
302
|
-
constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo | RelatedSong, options?: {
|
|
324
|
+
constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo | RelatedSong | ytpl.result["items"][number], options?: {
|
|
303
325
|
member?: GuildMember;
|
|
304
326
|
source?: string;
|
|
305
327
|
metadata?: T;
|
|
@@ -337,6 +359,7 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
337
359
|
emittedError: boolean;
|
|
338
360
|
isDisconnected: boolean;
|
|
339
361
|
constructor(voiceManager: DisTubeVoiceManager, channel: VoiceBasedChannel);
|
|
362
|
+
get channelId(): string | undefined;
|
|
340
363
|
get channel(): VoiceBasedChannel;
|
|
341
364
|
set channel(channel: VoiceBasedChannel);
|
|
342
365
|
join(channel?: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
@@ -355,45 +378,6 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
|
|
|
355
378
|
get voiceState(): VoiceState | undefined;
|
|
356
379
|
}
|
|
357
380
|
|
|
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
|
-
|
|
370
|
-
declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
371
|
-
create(channel: VoiceBasedChannel): DisTubeVoice;
|
|
372
|
-
join(channel: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
373
|
-
leave(guild: GuildIdResolvable): void;
|
|
374
|
-
}
|
|
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
|
-
|
|
397
381
|
declare class DisTubeHandler extends DisTubeBase {
|
|
398
382
|
constructor(distube: DisTube);
|
|
399
383
|
get ytdlOptions(): ytdl.getInfoOptions;
|
|
@@ -453,6 +437,45 @@ declare class DisTubeStream {
|
|
|
453
437
|
constructor(url: string, options: StreamOptions);
|
|
454
438
|
}
|
|
455
439
|
|
|
440
|
+
declare abstract class BaseManager<V> extends DisTubeBase {
|
|
441
|
+
collection: Collection<string, V>;
|
|
442
|
+
get size(): number;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
declare abstract class GuildIdManager<V> extends BaseManager<V> {
|
|
446
|
+
add(idOrInstance: GuildIdResolvable, data: V): this | _discordjs_collection.Collection<string, V>;
|
|
447
|
+
get(idOrInstance: GuildIdResolvable): V | undefined;
|
|
448
|
+
remove(idOrInstance: GuildIdResolvable): boolean;
|
|
449
|
+
has(idOrInstance: GuildIdResolvable): boolean;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
|
|
453
|
+
create(channel: VoiceBasedChannel): DisTubeVoice;
|
|
454
|
+
join(channel: VoiceBasedChannel): Promise<DisTubeVoice>;
|
|
455
|
+
leave(guild: GuildIdResolvable): void;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
declare class FilterManager extends BaseManager<FilterResolvable> {
|
|
459
|
+
#private;
|
|
460
|
+
queue: Queue;
|
|
461
|
+
constructor(queue: Queue);
|
|
462
|
+
add(filterOrFilters: FilterResolvable | FilterResolvable[], override?: boolean): this;
|
|
463
|
+
clear(): this;
|
|
464
|
+
set(filters: FilterResolvable[]): this;
|
|
465
|
+
remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
|
|
466
|
+
has(filter: FilterResolvable): boolean;
|
|
467
|
+
get names(): string[];
|
|
468
|
+
get values(): string[];
|
|
469
|
+
toString(): string;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
declare class QueueManager extends GuildIdManager<Queue> {
|
|
473
|
+
#private;
|
|
474
|
+
create(channel: VoiceBasedChannel, song: Song[] | Song, textChannel?: GuildTextBasedChannel): Promise<Queue | true>;
|
|
475
|
+
createStream(queue: Queue): DisTubeStream;
|
|
476
|
+
playSong(queue: Queue): Promise<boolean>;
|
|
477
|
+
}
|
|
478
|
+
|
|
456
479
|
declare class Queue extends DisTubeBase {
|
|
457
480
|
#private;
|
|
458
481
|
readonly id: Snowflake;
|
|
@@ -543,6 +566,8 @@ declare function isClientInstance(client: any): client is Client;
|
|
|
543
566
|
declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
|
|
544
567
|
declare function isObject(obj: any): obj is object;
|
|
545
568
|
declare function isRecord<T = unknown>(obj: any): obj is Record<string, T>;
|
|
569
|
+
declare type KeyOf<T> = T extends object ? (keyof T)[] : [];
|
|
570
|
+
declare function objectKeys<T>(obj: T): KeyOf<T>;
|
|
546
571
|
|
|
547
572
|
declare class DirectLinkPlugin extends ExtractorPlugin {
|
|
548
573
|
validate(url: string): Promise<boolean>;
|
|
@@ -553,7 +578,7 @@ declare class DirectLinkPlugin extends ExtractorPlugin {
|
|
|
553
578
|
}
|
|
554
579
|
|
|
555
580
|
declare const version: string;
|
|
556
|
-
declare class DisTube extends TypedEmitter<
|
|
581
|
+
declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
|
|
557
582
|
readonly handler: DisTubeHandler;
|
|
558
583
|
readonly options: Options;
|
|
559
584
|
readonly client: Client;
|
|
@@ -567,12 +592,6 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
567
592
|
get version(): string;
|
|
568
593
|
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist, options?: PlayOptions): Promise<void>;
|
|
569
594
|
createCustomPlaylist(songs: (string | Song | SearchResult)[], options?: CustomPlaylistOptions): Promise<Playlist>;
|
|
570
|
-
search(string: string, options?: {
|
|
571
|
-
type?: SearchResultType;
|
|
572
|
-
limit?: number;
|
|
573
|
-
safeSearch?: boolean;
|
|
574
|
-
retried?: boolean;
|
|
575
|
-
}): Promise<Array<SearchResult>>;
|
|
576
595
|
search(string: string, options?: {
|
|
577
596
|
type?: SearchResultType.VIDEO;
|
|
578
597
|
limit?: number;
|
|
@@ -585,6 +604,12 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
585
604
|
safeSearch?: boolean;
|
|
586
605
|
retried?: boolean;
|
|
587
606
|
}): Promise<Array<SearchResultPlaylist>>;
|
|
607
|
+
search(string: string, options?: {
|
|
608
|
+
type?: SearchResultType;
|
|
609
|
+
limit?: number;
|
|
610
|
+
safeSearch?: boolean;
|
|
611
|
+
retried?: boolean;
|
|
612
|
+
}): Promise<Array<SearchResult>>;
|
|
588
613
|
getQueue(guild: GuildIdResolvable): Queue | undefined;
|
|
589
614
|
pause(guild: GuildIdResolvable): Queue;
|
|
590
615
|
resume(guild: GuildIdResolvable): Queue;
|
|
@@ -601,4 +626,4 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
601
626
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
602
627
|
}
|
|
603
628
|
|
|
604
|
-
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 };
|
|
629
|
+
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DirectLinkPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, Events, 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, TypedDisTubeEvents, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, objectKeys, parseNumber, resolveGuildId, toSecond, version };
|