distube 4.0.4 → 4.0.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
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
- <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>
6
+ <a href="https://github.com/skick1234/DisTube/actions" target="_blank"><img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/skick1234/DisTube/test.yml?branch=main&label=Tests&logo=github&style=flat-square"></a>
7
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
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
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>
@@ -49,14 +49,9 @@ npm install distube@latest
49
49
 
50
50
  Read DisTube's definitions, properties and events details in the [Documentation page](https://distube.js.org/).
51
51
 
52
+ Learn how to build a music bot from scratch with [DisTube Guide](https://distube.js.org/guide)
53
+
52
54
  ## Example Bot
53
55
 
54
56
  - [DisTube Bot](https://skick.xyz/DisTube) - A music bot with reaction controller, filters, DJ mode, user's custom playlist and voting.
55
57
  - [DisTube Example](https://github.com/distubejs/example) - Example bot with simple command handler.
56
- - [DisTube Guide](https://distube.js.org/guide) - How to build a music bot from scratch.
57
-
58
- ## Dependencies
59
-
60
- - [node-ytdl-core](https://github.com/fent/node-ytdl-core): YouTube scraper ([DisTube Fork](https://github.com/distubejs/node-ytdl-core))
61
- - [node-ytsr](https://github.com/TimeForANinja/node-ytsr): YouTube search scraper ([DisTube Fork](https://github.com/distubejs/ytsr))
62
- - [node-ytpl](https://github.com/TimeForANinja/node-ytpl): YouTube playlist resolver ([DisTube Fork](https://github.com/distubejs/ytpl))
package/dist/index.d.ts CHANGED
@@ -8,13 +8,13 @@ import { AudioPlayer, VoiceConnection, AudioResource, StreamType as StreamType$1
8
8
  import { FFmpeg } from 'prism-media';
9
9
  import * as _discordjs_collection from '@discordjs/collection';
10
10
 
11
- declare type Awaitable<T = any> = T | PromiseLike<T>;
12
- declare type DisTubeVoiceEvents = {
11
+ type Awaitable<T = any> = T | PromiseLike<T>;
12
+ type DisTubeVoiceEvents = {
13
13
  disconnect: (error?: Error) => Awaitable;
14
14
  error: (error: Error) => Awaitable;
15
15
  finish: () => Awaitable;
16
16
  };
17
- declare type DisTubeEvents = {
17
+ type DisTubeEvents = {
18
18
  error: [channel: GuildTextBasedChannel | undefined, error: Error];
19
19
  addList: [queue: Queue, playlist: Playlist];
20
20
  addSong: [queue: Queue, song: Song];
@@ -32,15 +32,15 @@ declare type DisTubeEvents = {
32
32
  searchInvalidAnswer: [message: Message<true>, answer: Message<true>, query: string];
33
33
  searchResult: [message: Message<true>, results: SearchResult[], query: string];
34
34
  };
35
- declare type TypedDisTubeEvents = {
35
+ type TypedDisTubeEvents = {
36
36
  [K in keyof DisTubeEvents]: (...args: DisTubeEvents[K]) => Awaitable;
37
37
  };
38
38
  interface Filter {
39
39
  name: string;
40
40
  value: string;
41
41
  }
42
- declare type FilterResolvable = string | Filter;
43
- declare type Filters = Record<string, string>;
42
+ type FilterResolvable = string | Filter;
43
+ type Filters = Record<string, string>;
44
44
  interface DisTubeOptions {
45
45
  plugins?: (CustomPlugin | ExtractorPlugin)[];
46
46
  emitNewSongOnly?: boolean;
@@ -62,7 +62,7 @@ interface DisTubeOptions {
62
62
  streamType?: StreamType;
63
63
  directLink?: boolean;
64
64
  }
65
- declare type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
65
+ type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
66
66
  interface OtherSongInfo {
67
67
  src: string;
68
68
  id?: string;
@@ -107,8 +107,8 @@ interface PlaylistInfo {
107
107
  title?: string;
108
108
  webpage_url?: string;
109
109
  }
110
- declare type RelatedSong = Omit<Song, "related">;
111
- declare type PlayHandlerOptions = {
110
+ type RelatedSong = Omit<Song, "related">;
111
+ type PlayHandlerOptions = {
112
112
  skip?: boolean;
113
113
  position?: number;
114
114
  textChannel?: GuildTextBasedChannel;
@@ -224,12 +224,12 @@ declare const ERROR_MESSAGES: {
224
224
  EMPTY_FILTERED_PLAYLIST: string;
225
225
  EMPTY_PLAYLIST: string;
226
226
  };
227
- declare type ErrorMessage = typeof ERROR_MESSAGES;
228
- declare type ErrorCode = keyof ErrorMessage;
229
- declare type StaticErrorCode = {
227
+ type ErrorMessage = typeof ERROR_MESSAGES;
228
+ type ErrorCode = keyof ErrorMessage;
229
+ type StaticErrorCode = {
230
230
  [K in ErrorCode]-?: ErrorMessage[K] extends string ? K : never;
231
231
  }[ErrorCode];
232
- declare type TemplateErrorCode = Exclude<keyof typeof ERROR_MESSAGES, StaticErrorCode>;
232
+ type TemplateErrorCode = Exclude<keyof typeof ERROR_MESSAGES, StaticErrorCode>;
233
233
  declare class DisTubeError<T extends string> extends Error {
234
234
  errorCode: string;
235
235
  constructor(code: StaticErrorCode);
@@ -291,7 +291,7 @@ declare class SearchResultVideo extends ISearchResult {
291
291
  thumbnail: string;
292
292
  constructor(info: Video);
293
293
  }
294
- declare type SearchResult = SearchResultVideo | SearchResultPlaylist;
294
+ type SearchResult = SearchResultVideo | SearchResultPlaylist;
295
295
  declare class SearchResultPlaylist extends ISearchResult {
296
296
  type: SearchResultType.PLAYLIST;
297
297
  length: number;
@@ -378,6 +378,22 @@ declare class DisTubeVoice extends TypedEmitter<DisTubeVoiceEvents> {
378
378
  get voiceState(): VoiceState | undefined;
379
379
  }
380
380
 
381
+ interface StreamOptions {
382
+ seek?: number;
383
+ ffmpegArgs?: string[];
384
+ isLive?: boolean;
385
+ type?: StreamType;
386
+ }
387
+ declare const chooseBestVideoFormat: (formats: ytdl.videoFormat[], isLive?: boolean) => ytdl.videoFormat;
388
+ declare class DisTubeStream {
389
+ static YouTube(formats: ytdl.videoFormat[] | undefined, options?: StreamOptions): DisTubeStream;
390
+ static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
391
+ type: StreamType$1;
392
+ stream: FFmpeg;
393
+ url: string;
394
+ constructor(url: string, options: StreamOptions);
395
+ }
396
+
381
397
  declare class DisTubeHandler extends DisTubeBase {
382
398
  constructor(distube: DisTube);
383
399
  get ytdlOptions(): ytdl.getInfoOptions;
@@ -395,6 +411,7 @@ declare class DisTubeHandler extends DisTubeBase {
395
411
  createSearchMessageCollector<R extends SearchResult | Song | Playlist>(message: Message<true>, results: Array<R>, query?: string): Promise<R | null>;
396
412
  playPlaylist(voiceChannel: VoiceBasedChannel, playlist: Playlist, options?: PlayHandlerOptions): Promise<void>;
397
413
  playSong(voiceChannel: VoiceBasedChannel, song: Song, options?: PlayHandlerOptions): Promise<void>;
414
+ attachStreamInfo(song: Song): Promise<void>;
398
415
  }
399
416
 
400
417
  declare class Options {
@@ -421,22 +438,6 @@ declare class Options {
421
438
  constructor(options: DisTubeOptions);
422
439
  }
423
440
 
424
- interface StreamOptions {
425
- seek?: number;
426
- ffmpegArgs?: string[];
427
- isLive?: boolean;
428
- type?: StreamType;
429
- }
430
- declare const chooseBestVideoFormat: (formats: ytdl.videoFormat[], isLive?: boolean) => ytdl.videoFormat;
431
- declare class DisTubeStream {
432
- static YouTube(formats: ytdl.videoFormat[] | undefined, options?: StreamOptions): DisTubeStream;
433
- static DirectLink(url: string, options?: StreamOptions): DisTubeStream;
434
- type: StreamType$1;
435
- stream: FFmpeg;
436
- url: string;
437
- constructor(url: string, options: StreamOptions);
438
- }
439
-
440
441
  declare abstract class BaseManager<V> extends DisTubeBase {
441
442
  collection: Collection<string, V>;
442
443
  get size(): number;
@@ -455,7 +456,7 @@ declare class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {
455
456
  leave(guild: GuildIdResolvable): void;
456
457
  }
457
458
 
458
- declare class FilterManager extends BaseManager<FilterResolvable> {
459
+ declare class FilterManager extends BaseManager<Filter> {
459
460
  #private;
460
461
  queue: Queue;
461
462
  constructor(queue: Queue);
@@ -465,7 +466,8 @@ declare class FilterManager extends BaseManager<FilterResolvable> {
465
466
  remove(filterOrFilters: FilterResolvable | FilterResolvable[]): this;
466
467
  has(filter: FilterResolvable): boolean;
467
468
  get names(): string[];
468
- get values(): string[];
469
+ get values(): Filter[];
470
+ get ffmpegArgs(): string[];
469
471
  toString(): string;
470
472
  }
471
473
 
@@ -552,7 +554,8 @@ declare abstract class ExtractorPlugin extends Plugin {
552
554
  declare function formatDuration(sec: number): string;
553
555
  declare function toSecond(input: any): number;
554
556
  declare function parseNumber(input: any): number;
555
- declare function isURL(input: any): input is `http://${string}` | `https://${string}`;
557
+ declare const SUPPORTED_PROTOCOL: readonly ["https:", "http:", "file:"];
558
+ declare function isURL(input: any): input is `${(typeof SUPPORTED_PROTOCOL)[number]}//${string}`;
556
559
  declare function checkIntents(options: ClientOptions): void;
557
560
  declare function isVoiceChannelEmpty(voiceState: VoiceState): boolean;
558
561
  declare function isSnowflake(id: any): id is Snowflake;
@@ -566,8 +569,9 @@ declare function isClientInstance(client: any): client is Client;
566
569
  declare function checkInvalidKey(target: Record<string, any>, source: Record<string, any> | string[], sourceName: string): void;
567
570
  declare function isObject(obj: any): obj is object;
568
571
  declare function isRecord<T = unknown>(obj: any): obj is Record<string, T>;
569
- declare type KeyOf<T> = T extends object ? (keyof T)[] : [];
572
+ type KeyOf<T> = T extends object ? (keyof T)[] : [];
570
573
  declare function objectKeys<T>(obj: T): KeyOf<T>;
574
+ declare function isNsfwChannel(channel?: GuildTextBasedChannel): boolean;
571
575
 
572
576
  declare class DirectLinkPlugin extends ExtractorPlugin {
573
577
  validate(url: string): Promise<boolean>;
@@ -626,4 +630,4 @@ declare class DisTube extends TypedEmitter<TypedDisTubeEvents> {
626
630
  emitError(error: Error, channel?: GuildTextBasedChannel): void;
627
631
  }
628
632
 
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 };
633
+ 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, isNsfwChannel, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, objectKeys, parseNumber, resolveGuildId, toSecond, version };