discord-player 6.6.2 → 6.6.3-dev.0

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
@@ -1,6 +1,6 @@
1
1
  # Discord Player
2
2
 
3
- Discord Player is a robust framework for developing Discord Music bots using JavaScript and TypeScript. It is built on top of the [@discordjs/voice](https://npm.im/@discordjs/voice) library and offers a comprehensive set of customizable tools, making it one of the most feature enrich framework in town.
3
+ Discord Player is a robust framework for developing Discord Music bots using JavaScript and TypeScript. It is built on top of the [discord-voip](https://npm.im/discord-voip) library and offers a comprehensive set of customizable tools, making it one of the most feature enrich framework in town.
4
4
 
5
5
  [![downloadsBadge](https://img.shields.io/npm/dt/discord-player?style=for-the-badge)](https://npmjs.com/discord-player)
6
6
  [![versionBadge](https://img.shields.io/npm/v/discord-player?style=for-the-badge)](https://npmjs.com/discord-player)
package/dist/index.d.ts CHANGED
@@ -5,8 +5,8 @@ import * as _discord_player_equalizer from '@discord-player/equalizer';
5
5
  import { EqualizerBand, BiquadFilters, PCMFilters, FiltersChain } from '@discord-player/equalizer';
6
6
  export { AF_NIGHTCORE_RATE, AF_VAPORWAVE_RATE, BASS_EQ_BANDS, FilterType as BiquadFilterType, BiquadFilters, FiltersChain, AudioFilters as PCMAudioFilters, PCMFilters, Q_BUTTERWORTH, VolumeTransformer } from '@discord-player/equalizer';
7
7
  import { Readable, Duplex } from 'stream';
8
- import { StreamType, AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, AudioPlayerStatus, EndBehaviorType } from '@discordjs/voice';
9
- export { AudioPlayer, CreateAudioPlayerOptions, createAudioPlayer } from '@discordjs/voice';
8
+ import { StreamType, AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, AudioPlayerStatus, EndBehaviorType } from 'discord-voip';
9
+ export { AudioPlayer, CreateAudioPlayerOptions, createAudioPlayer } from 'discord-voip';
10
10
  import { RequestOptions } from 'http';
11
11
  import { downloadOptions } from 'ytdl-core';
12
12
  import { BridgeProvider } from '@discord-player/extractor';
@@ -1267,6 +1267,131 @@ declare class GuildQueue<Meta = unknown> {
1267
1267
  get hasDebugger(): boolean;
1268
1268
  }
1269
1269
 
1270
+ type TrackResolvable = Track | string | number;
1271
+ type WithMetadata<T extends object, M> = T & {
1272
+ metadata: M;
1273
+ requestMetadata(): Promise<M>;
1274
+ };
1275
+ declare class Track<T = unknown> {
1276
+ readonly player: Player;
1277
+ title: string;
1278
+ description: string;
1279
+ author: string;
1280
+ url: string;
1281
+ thumbnail: string;
1282
+ duration: string;
1283
+ views: number;
1284
+ requestedBy: User | null;
1285
+ playlist?: Playlist;
1286
+ queryType: SearchQueryType | null | undefined;
1287
+ raw: RawTrackData;
1288
+ extractor: BaseExtractor | null;
1289
+ readonly id: string;
1290
+ private __metadata;
1291
+ private __reqMetadataFn;
1292
+ /**
1293
+ * Track constructor
1294
+ * @param player The player that instantiated this Track
1295
+ * @param data Track data
1296
+ */
1297
+ constructor(player: Player, data: Partial<WithMetadata<RawTrackData, T>>);
1298
+ /**
1299
+ * Request metadata for this track
1300
+ */
1301
+ requestMetadata(): Promise<T | null>;
1302
+ /**
1303
+ * Set metadata for this track
1304
+ */
1305
+ setMetadata(m: T | null): void;
1306
+ /**
1307
+ * Metadata of this track
1308
+ */
1309
+ get metadata(): T | null;
1310
+ /**
1311
+ * If this track has metadata
1312
+ */
1313
+ get hasMetadata(): boolean;
1314
+ /**
1315
+ * The queue in which this track is located
1316
+ */
1317
+ get queue(): GuildQueue;
1318
+ /**
1319
+ * The track duration in millisecond
1320
+ */
1321
+ get durationMS(): number;
1322
+ /**
1323
+ * Discord hyperlink representation of this track
1324
+ */
1325
+ toHyperlink(): string;
1326
+ /**
1327
+ * Returns source of this track
1328
+ */
1329
+ get source(): TrackSource;
1330
+ /**
1331
+ * String representation of this track
1332
+ */
1333
+ toString(): string;
1334
+ /**
1335
+ * Raw JSON representation of this track
1336
+ */
1337
+ toJSON(hidePlaylist?: boolean): TrackJSON;
1338
+ /**
1339
+ * Get belonging queues of this track
1340
+ */
1341
+ getBelongingQueues(): Collection<string, GuildQueue<unknown>>;
1342
+ /**
1343
+ * Play this track to the given voice channel. If queue exists and another track is being played, this track will be added to the queue.
1344
+ * @param channel Voice channel on which this track shall be played
1345
+ * @param options Node initialization options
1346
+ */
1347
+ play<T = unknown>(channel: GuildVoiceChannelResolvable, options?: PlayerNodeInitializerOptions<T>): Promise<PlayerNodeInitializationResult<T>>;
1348
+ }
1349
+
1350
+ declare class Playlist {
1351
+ readonly player: Player;
1352
+ tracks: Track[];
1353
+ title: string;
1354
+ description: string;
1355
+ thumbnail: string;
1356
+ type: 'album' | 'playlist';
1357
+ source: TrackSource;
1358
+ author: {
1359
+ name: string;
1360
+ url: string;
1361
+ };
1362
+ id: string;
1363
+ url: string;
1364
+ readonly rawPlaylist?: any;
1365
+ /**
1366
+ * Playlist constructor
1367
+ * @param {Player} player The player
1368
+ * @param {PlaylistInitData} data The data
1369
+ */
1370
+ constructor(player: Player, data: PlaylistInitData);
1371
+ [Symbol.iterator](): Generator<Track<unknown>, void, undefined>;
1372
+ /**
1373
+ * Estimated duration of this playlist
1374
+ */
1375
+ get estimatedDuration(): number;
1376
+ /**
1377
+ * Formatted estimated duration of this playlist
1378
+ */
1379
+ get durationFormatted(): string;
1380
+ /**
1381
+ * JSON representation of this playlist
1382
+ * @param {boolean} [withTracks=true] If it should build json with tracks
1383
+ * @returns {PlaylistJSON}
1384
+ */
1385
+ toJSON(withTracks?: boolean): PlaylistJSON;
1386
+ /**
1387
+ * Play this playlist to the given voice channel. If queue exists and another track is being played, this playlist will be added to the queue.
1388
+ * @param channel Voice channel on which this playlist shall be played
1389
+ * @param options Node initialization options
1390
+ */
1391
+ play<T = unknown>(channel: GuildVoiceChannelResolvable, options?: PlayerNodeInitializerOptions<T>): Promise<PlayerNodeInitializationResult<T>>;
1392
+ }
1393
+
1394
+ declare const knownExtractorKeys: readonly ["SpotifyExtractor", "AppleMusicExtractor", "SoundCloudExtractor", "YouTubeExtractor", "VimeoExtractor", "ReverbnationExtractor", "AttachmentExtractor"];
1270
1395
  interface ExtractorExecutionEvents {
1271
1396
  /**
1272
1397
  * Emitted when a extractor is registered
@@ -1306,7 +1431,7 @@ declare class ExtractorExecutionContext extends PlayerEventsEmitter<ExtractorExe
1306
1431
  /**
1307
1432
  * Load default extractors from `@discord-player/extractor`
1308
1433
  */
1309
- loadDefault(): Promise<{
1434
+ loadDefault(filter?: (ext: (typeof knownExtractorKeys)[number]) => boolean): Promise<{
1310
1435
  success: boolean;
1311
1436
  error: Error;
1312
1437
  } | {
@@ -1446,130 +1571,6 @@ interface ExtractorSearchContext {
1446
1571
  requestOptions?: RequestOptions;
1447
1572
  }
1448
1573
 
1449
- type TrackResolvable = Track | string | number;
1450
- type WithMetadata<T extends object, M> = T & {
1451
- metadata: M;
1452
- requestMetadata(): Promise<M>;
1453
- };
1454
- declare class Track<T = unknown> {
1455
- readonly player: Player;
1456
- title: string;
1457
- description: string;
1458
- author: string;
1459
- url: string;
1460
- thumbnail: string;
1461
- duration: string;
1462
- views: number;
1463
- requestedBy: User | null;
1464
- playlist?: Playlist;
1465
- queryType: SearchQueryType | null | undefined;
1466
- raw: RawTrackData;
1467
- extractor: BaseExtractor | null;
1468
- readonly id: string;
1469
- private __metadata;
1470
- private __reqMetadataFn;
1471
- /**
1472
- * Track constructor
1473
- * @param player The player that instantiated this Track
1474
- * @param data Track data
1475
- */
1476
- constructor(player: Player, data: Partial<WithMetadata<RawTrackData, T>>);
1477
- /**
1478
- * Request metadata for this track
1479
- */
1480
- requestMetadata(): Promise<T | null>;
1481
- /**
1482
- * Set metadata for this track
1483
- */
1484
- setMetadata(m: T | null): void;
1485
- /**
1486
- * Metadata of this track
1487
- */
1488
- get metadata(): T | null;
1489
- /**
1490
- * If this track has metadata
1491
- */
1492
- get hasMetadata(): boolean;
1493
- /**
1494
- * The queue in which this track is located
1495
- */
1496
- get queue(): GuildQueue;
1497
- /**
1498
- * The track duration in millisecond
1499
- */
1500
- get durationMS(): number;
1501
- /**
1502
- * Discord hyperlink representation of this track
1503
- */
1504
- toHyperlink(): string;
1505
- /**
1506
- * Returns source of this track
1507
- */
1508
- get source(): TrackSource;
1509
- /**
1510
- * String representation of this track
1511
- */
1512
- toString(): string;
1513
- /**
1514
- * Raw JSON representation of this track
1515
- */
1516
- toJSON(hidePlaylist?: boolean): TrackJSON;
1517
- /**
1518
- * Get belonging queues of this track
1519
- */
1520
- getBelongingQueues(): Collection<string, GuildQueue<unknown>>;
1521
- /**
1522
- * Play this track to the given voice channel. If queue exists and another track is being played, this track will be added to the queue.
1523
- * @param channel Voice channel on which this track shall be played
1524
- * @param options Node initialization options
1525
- */
1526
- play<T = unknown>(channel: GuildVoiceChannelResolvable, options?: PlayerNodeInitializerOptions<T>): Promise<PlayerNodeInitializationResult<T>>;
1527
- }
1528
-
1529
- declare class Playlist {
1530
- readonly player: Player;
1531
- tracks: Track[];
1532
- title: string;
1533
- description: string;
1534
- thumbnail: string;
1535
- type: 'album' | 'playlist';
1536
- source: TrackSource;
1537
- author: {
1538
- name: string;
1539
- url: string;
1540
- };
1541
- id: string;
1542
- url: string;
1543
- readonly rawPlaylist?: any;
1544
- /**
1545
- * Playlist constructor
1546
- * @param {Player} player The player
1547
- * @param {PlaylistInitData} data The data
1548
- */
1549
- constructor(player: Player, data: PlaylistInitData);
1550
- [Symbol.iterator](): Generator<Track<unknown>, void, undefined>;
1551
- /**
1552
- * Estimated duration of this playlist
1553
- */
1554
- get estimatedDuration(): number;
1555
- /**
1556
- * Formatted estimated duration of this playlist
1557
- */
1558
- get durationFormatted(): string;
1559
- /**
1560
- * JSON representation of this playlist
1561
- * @param {boolean} [withTracks=true] If it should build json with tracks
1562
- * @returns {PlaylistJSON}
1563
- */
1564
- toJSON(withTracks?: boolean): PlaylistJSON;
1565
- /**
1566
- * Play this playlist to the given voice channel. If queue exists and another track is being played, this playlist will be added to the queue.
1567
- * @param channel Voice channel on which this playlist shall be played
1568
- * @param options Node initialization options
1569
- */
1570
- play<T = unknown>(channel: GuildVoiceChannelResolvable, options?: PlayerNodeInitializerOptions<T>): Promise<PlayerNodeInitializationResult<T>>;
1571
- }
1572
-
1573
1574
  interface SearchResultData {
1574
1575
  query: string;
1575
1576
  queryType?: SearchQueryType | QueryExtractorSearch | null;
@@ -1641,6 +1642,39 @@ declare class SearchResult {
1641
1642
  };
1642
1643
  }
1643
1644
 
1645
+ interface QueryCacheOptions {
1646
+ checkInterval?: number;
1647
+ }
1648
+ interface QueryCacheProvider<T> {
1649
+ getData(): Promise<DiscordPlayerQueryResultCache<T>[]>;
1650
+ addData(data: SearchResult): Promise<void>;
1651
+ resolve(context: QueryCacheResolverContext): Promise<SearchResult>;
1652
+ }
1653
+ declare class QueryCache implements QueryCacheProvider<Track> {
1654
+ #private;
1655
+ player: Player;
1656
+ options: QueryCacheOptions;
1657
+ timer: NodeJS.Timer;
1658
+ constructor(player: Player, options?: QueryCacheOptions);
1659
+ get checkInterval(): number;
1660
+ cleanup(): Promise<void>;
1661
+ clear(): Promise<void>;
1662
+ getData(): Promise<DiscordPlayerQueryResultCache<Track<unknown>>[]>;
1663
+ addData(data: SearchResult): Promise<void>;
1664
+ resolve(context: QueryCacheResolverContext): Promise<SearchResult>;
1665
+ }
1666
+ declare class DiscordPlayerQueryResultCache<T = unknown> {
1667
+ data: T;
1668
+ expireAfter: number;
1669
+ constructor(data: T, expireAfter?: number);
1670
+ hasExpired(): boolean;
1671
+ }
1672
+ interface QueryCacheResolverContext {
1673
+ query: string;
1674
+ requestedBy?: User;
1675
+ queryType?: SearchQueryType | `ext:${string}`;
1676
+ }
1677
+
1644
1678
  declare class VoiceUtils {
1645
1679
  player: Player;
1646
1680
  /**
@@ -1692,34 +1726,6 @@ declare class VoiceUtils {
1692
1726
  getConnection(guild: Snowflake, group?: string): VoiceConnection | undefined;
1693
1727
  }
1694
1728
 
1695
- interface QueryCacheOptions {
1696
- checkInterval?: number;
1697
- }
1698
- declare class QueryCache {
1699
- #private;
1700
- player: Player;
1701
- options: QueryCacheOptions;
1702
- timer: NodeJS.Timer;
1703
- constructor(player: Player, options?: QueryCacheOptions);
1704
- get checkInterval(): number;
1705
- cleanup(): Promise<void>;
1706
- clear(): Promise<void>;
1707
- getData(): Promise<DiscordPlayerQueryResultCache<Track<unknown>>[]>;
1708
- addData(data: SearchResult): Promise<void>;
1709
- resolve(context: QueryCacheResolverContext): Promise<SearchResult>;
1710
- }
1711
- declare class DiscordPlayerQueryResultCache<T = unknown> {
1712
- data: T;
1713
- expireAfter: number;
1714
- constructor(data: T, expireAfter?: number);
1715
- hasExpired(): boolean;
1716
- }
1717
- interface QueryCacheResolverContext {
1718
- query: string;
1719
- requestedBy?: User;
1720
- queryType?: SearchQueryType | `ext:${string}`;
1721
- }
1722
-
1723
1729
  interface PlayerNodeInitializationResult<T = unknown> {
1724
1730
  track: Track;
1725
1731
  extractor: BaseExtractor | null;
@@ -1782,7 +1788,7 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
1782
1788
  /**
1783
1789
  * The current query cache provider in use
1784
1790
  */
1785
- get queryCache(): QueryCache | null;
1791
+ get queryCache(): QueryCacheProvider<any> | null;
1786
1792
  /**
1787
1793
  * Alias to `Player.nodes`.
1788
1794
  */
@@ -1888,7 +1894,7 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
1888
1894
  */
1889
1895
  search(searchQuery: string | Track | Track[] | Playlist | SearchResult, options?: SearchOptions): Promise<SearchResult>;
1890
1896
  /**
1891
- * Generates a report of the dependencies used by the `@discordjs/voice` module. Useful for debugging.
1897
+ * Generates a report of the dependencies used by the `discord-voip` module. Useful for debugging.
1892
1898
  * @example ```typescript
1893
1899
  * console.log(player.scanDeps());
1894
1900
  * // -> logs dependencies report
@@ -2300,7 +2306,7 @@ interface PlayerInitOptions {
2300
2306
  lockVoiceStateHandler?: boolean;
2301
2307
  blockExtractors?: string[];
2302
2308
  blockStreamFrom?: string[];
2303
- queryCache?: QueryCache | null;
2309
+ queryCache?: QueryCacheProvider<any> | null;
2304
2310
  ignoreInstance?: boolean;
2305
2311
  useLegacyFFmpeg?: boolean;
2306
2312
  bridgeProvider?: BridgeProvider;
@@ -2543,4 +2549,4 @@ declare function createHook<T extends HookDeclaration<(...args: any[]) => any>>(
2543
2549
 
2544
2550
  declare const version: string;
2545
2551
 
2546
- export { AFilterGraph, AsyncQueue, AsyncQueueAcquisitionOptions, AsyncQueueEntry, AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, CreateStreamOps, DiscordPlayerQueryResultCache, EqualizerConfigurationPreset, ExtractorExecutionContext, ExtractorExecutionEvents, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorSearchContext, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, FFmpegStreamOptions, FilterGraph, FiltersName, GuildNodeCreateOptions, GuildNodeInit, GuildNodeManager, GuildQueue, GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvent, GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, GuildQueueStatistics, GuildQueueStatisticsMetadata, HookDeclaration, HookDeclarationContext, NextFunction, NodeResolvable, OnAfterCreateStreamHandler, OnBeforeCreateStreamHandler, PlayOptions, Player, PlayerEvent, PlayerEvents, PlayerEventsEmitter, PlayerInitOptions, PlayerNodeInitializationResult, PlayerNodeInitializerOptions, PlayerProgressbarOptions, PlayerSearchResult, PlayerTimestamp, PlayerTriggeredReason, Playlist, PlaylistInitData, PlaylistJSON, PostProcessedResult, QueryCache, QueryCacheOptions, QueryCacheResolverContext, QueryExtractorSearch, QueryResolver, QueryType, QueueFilters, QueueRepeatMode, RawTrackData, RawTrackInit, ResolvedQuery, ResourcePlayOptions, SearchOptions, SearchQueryType, SearchResult, SearchResultData, StreamConfig, StreamDispatcher, TimeData, TimelineDispatcherOptions, Track, TrackJSON, TrackLike, TrackResolvable, TrackSource, TypeUtil, Util, VALIDATE_QUEUE_CAP, VoiceConnectConfig, VoiceEvents, VoiceReceiverNode, VoiceReceiverOptions, VoiceStateHandler, VoiceUtils, WithMetadata, createFFmpegStream, createHook, onAfterCreateStream, onBeforeCreateStream, useHistory, useMainPlayer, useMasterPlayer, useMetadata, usePlayer, useQueue, useTimeline, useVolume, version };
2552
+ export { AFilterGraph, AsyncQueue, AsyncQueueAcquisitionOptions, AsyncQueueEntry, AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, CreateStreamOps, DiscordPlayerQueryResultCache, EqualizerConfigurationPreset, ExtractorExecutionContext, ExtractorExecutionEvents, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorSearchContext, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, FFmpegStreamOptions, FilterGraph, FiltersName, GuildNodeCreateOptions, GuildNodeInit, GuildNodeManager, GuildQueue, GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvent, GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, GuildQueueStatistics, GuildQueueStatisticsMetadata, HookDeclaration, HookDeclarationContext, NextFunction, NodeResolvable, OnAfterCreateStreamHandler, OnBeforeCreateStreamHandler, PlayOptions, Player, PlayerEvent, PlayerEvents, PlayerEventsEmitter, PlayerInitOptions, PlayerNodeInitializationResult, PlayerNodeInitializerOptions, PlayerProgressbarOptions, PlayerSearchResult, PlayerTimestamp, PlayerTriggeredReason, Playlist, PlaylistInitData, PlaylistJSON, PostProcessedResult, QueryCache, QueryCacheOptions, QueryCacheProvider, QueryCacheResolverContext, QueryExtractorSearch, QueryResolver, QueryType, QueueFilters, QueueRepeatMode, RawTrackData, RawTrackInit, ResolvedQuery, ResourcePlayOptions, SearchOptions, SearchQueryType, SearchResult, SearchResultData, StreamConfig, StreamDispatcher, TimeData, TimelineDispatcherOptions, Track, TrackJSON, TrackLike, TrackResolvable, TrackSource, TypeUtil, Util, VALIDATE_QUEUE_CAP, VoiceConnectConfig, VoiceEvents, VoiceReceiverNode, VoiceReceiverOptions, VoiceStateHandler, VoiceUtils, WithMetadata, createFFmpegStream, createHook, onAfterCreateStream, onBeforeCreateStream, useHistory, useMainPlayer, useMasterPlayer, useMetadata, usePlayer, useQueue, useTimeline, useVolume, version };