discord-player 6.6.2 → 6.6.3
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 +35 -19
- package/dist/index.d.ts +210 -156
- package/dist/index.js +194 -64
- package/dist/index.mjs +4 -0
- package/package.json +5 -3
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 [
|
|
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
|
[](https://npmjs.com/discord-player)
|
|
6
6
|
[](https://npmjs.com/discord-player)
|
|
@@ -41,17 +41,33 @@ $ npm install --save @discord-player/extractor # extractors provider
|
|
|
41
41
|
|
|
42
42
|
#### Opus Library
|
|
43
43
|
|
|
44
|
-
Since Discord only accepts opus packets, you need to install the opus library.
|
|
44
|
+
Since Discord only accepts opus packets, you need to install the opus library. Discord Player supports multiple opus libraries, such as:
|
|
45
|
+
|
|
46
|
+
- [mediaplex](https://npmjs.com/mediaplex)
|
|
47
|
+
- [@discordjs/opus](https://npmjs.com/@discordjs/opus)
|
|
48
|
+
- [opusscript](https://npmjs.com/opusscript)
|
|
49
|
+
- [@evan/opus](https://npmjs.com/@evan/opus)
|
|
50
|
+
- [node-opus](https://npmjs.com/node-opus)
|
|
51
|
+
|
|
52
|
+
Among these, mediaplex is the recommended library as it adds more functionalities to discord-player than just libopus interface. You can install opus libraries by running:
|
|
45
53
|
|
|
46
54
|
```bash
|
|
55
|
+
$ npm install --save mediaplex
|
|
56
|
+
# or
|
|
47
57
|
$ npm install --save @discordjs/opus
|
|
48
58
|
# or
|
|
49
59
|
$ npm install --save opusscript
|
|
60
|
+
# or
|
|
61
|
+
$ npm install --save @evan/opus
|
|
62
|
+
# or
|
|
63
|
+
$ npm install --save node-opus
|
|
50
64
|
```
|
|
51
65
|
|
|
52
66
|
#### FFmpeg or Avconv
|
|
53
67
|
|
|
54
|
-
FFmpeg or Avconv is required for media transcoding. You can obtain it from [https://ffmpeg.org](https://ffmpeg.org) or
|
|
68
|
+
FFmpeg or Avconv is required for media transcoding. You can obtain it from [https://ffmpeg.org](https://ffmpeg.org) or via npm.
|
|
69
|
+
|
|
70
|
+
> We do not recommend installing ffmpeg via npm because binaries pulled from npm is known to be unstable. It is recommended to install it from the official source.
|
|
55
71
|
|
|
56
72
|
```bash
|
|
57
73
|
$ npm install --save ffmpeg-static
|
|
@@ -67,30 +83,31 @@ $ npm install --save ffmpeg-binaries
|
|
|
67
83
|
|
|
68
84
|
#### Streaming Library
|
|
69
85
|
|
|
70
|
-
If you want to add support for YouTube playback, you need to install a streaming library.
|
|
86
|
+
YouTube streaming is not supported without installing one of the following package. If you want to add support for YouTube playback, you need to install a streaming library. This step is not needed if you do not plan on using youtube source.
|
|
71
87
|
|
|
72
88
|
```bash
|
|
73
|
-
$ npm install --save
|
|
89
|
+
$ npm install --save youtube-ext
|
|
74
90
|
# or
|
|
75
91
|
$ npm install --save play-dl
|
|
76
92
|
# or
|
|
77
93
|
$ npm install --save @distube/ytdl-core
|
|
78
94
|
# or
|
|
79
95
|
$ npm install --save yt-stream
|
|
96
|
+
# or
|
|
97
|
+
$ npm install --save ytdl-core
|
|
80
98
|
```
|
|
81
99
|
|
|
100
|
+
We recommend using `youtube-ext` for better performance.
|
|
101
|
+
|
|
82
102
|
Once you have completed these installations, let's proceed with writing a simple music bot.
|
|
83
103
|
|
|
84
104
|
### Setup
|
|
85
105
|
|
|
86
106
|
Let's create a main player instance. This instance handles and keeps track of all the queues and its components.
|
|
87
107
|
|
|
88
|
-
```js
|
|
108
|
+
```js index.js
|
|
89
109
|
const { Player } = require('discord-player');
|
|
90
110
|
|
|
91
|
-
// get some extractors if you want to handpick sources
|
|
92
|
-
const { SpotifyExtractor, SoundCloudExtractor } = require('@discord-player/extractor');
|
|
93
|
-
|
|
94
111
|
const client = new Discord.Client({
|
|
95
112
|
// Make sure you have 'GuildVoiceStates' intent enabled
|
|
96
113
|
intents: ['GuildVoiceStates' /* Other intents */]
|
|
@@ -99,17 +116,13 @@ const client = new Discord.Client({
|
|
|
99
116
|
// this is the entrypoint for discord-player based application
|
|
100
117
|
const player = new Player(client);
|
|
101
118
|
|
|
102
|
-
//
|
|
103
|
-
await player.extractors.loadDefault();
|
|
104
|
-
|
|
105
|
-
// If you dont want to use all of the extractors and register only the required ones manually, use
|
|
106
|
-
await player.extractors.register(SpotifyExtractor, {});
|
|
107
|
-
await player.extractors.register(SoundCloudExtractor, {});
|
|
119
|
+
// Now, lets load all the default extractors, except 'YouTubeExtractor'. You can remove the filter if you want to load all the extractors.
|
|
120
|
+
await player.extractors.loadDefault((ext) => ext !== 'YouTubeExtractor');
|
|
108
121
|
```
|
|
109
122
|
|
|
110
123
|
Discord Player is mostly events based. It emits different events based on the context and actions. Let's add a basic event listener to notify the user when a track starts to play:
|
|
111
124
|
|
|
112
|
-
```js
|
|
125
|
+
```js index.js
|
|
113
126
|
// this event is emitted whenever discord-player starts to play a track
|
|
114
127
|
player.events.on('playerStart', (queue, track) => {
|
|
115
128
|
// we will later define queue.metadata object while creating the queue
|
|
@@ -117,10 +130,13 @@ player.events.on('playerStart', (queue, track) => {
|
|
|
117
130
|
});
|
|
118
131
|
```
|
|
119
132
|
|
|
120
|
-
Let's move on to the command part. You can define the command as per your requirements. We will only focus on the command
|
|
133
|
+
Let's move on to the command part. You can define the command as per your requirements. We will only focus on the command part:
|
|
134
|
+
|
|
135
|
+
```js play.js
|
|
136
|
+
const { useMainPlayer } = require('discord-player');
|
|
121
137
|
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
export async function execute(interaction) {
|
|
139
|
+
const player = useMainPlayer();
|
|
124
140
|
const channel = interaction.member.voice.channel;
|
|
125
141
|
if (!channel) return interaction.reply('You are not connected to a voice channel!'); // make sure we have a voice channel
|
|
126
142
|
const query = interaction.options.getString('query', true); // we need input/query to play
|
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 '
|
|
9
|
-
export { AudioPlayer, CreateAudioPlayerOptions, createAudioPlayer } from '
|
|
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
|
} | {
|
|
@@ -1410,7 +1535,7 @@ declare class BaseExtractor<T extends object = object> {
|
|
|
1410
1535
|
* Get related tracks for the given track
|
|
1411
1536
|
* @param track The track source
|
|
1412
1537
|
*/
|
|
1413
|
-
getRelatedTracks(track: Track): Promise<ExtractorInfo>;
|
|
1538
|
+
getRelatedTracks(track: Track, history: GuildQueueHistory): Promise<ExtractorInfo>;
|
|
1414
1539
|
/**
|
|
1415
1540
|
* A stream middleware to handle streams before passing it to the player
|
|
1416
1541
|
* @param stream The incoming stream
|
|
@@ -1434,6 +1559,10 @@ declare class BaseExtractor<T extends object = object> {
|
|
|
1434
1559
|
* @param message The debug message
|
|
1435
1560
|
*/
|
|
1436
1561
|
debug(message: string): boolean;
|
|
1562
|
+
/**
|
|
1563
|
+
* IP rotator instance, if available
|
|
1564
|
+
*/
|
|
1565
|
+
get routePlanner(): IPRotator | null;
|
|
1437
1566
|
}
|
|
1438
1567
|
type NextFunction = (error?: Error | null, stream?: Readable) => void;
|
|
1439
1568
|
interface ExtractorInfo {
|
|
@@ -1446,130 +1575,6 @@ interface ExtractorSearchContext {
|
|
|
1446
1575
|
requestOptions?: RequestOptions;
|
|
1447
1576
|
}
|
|
1448
1577
|
|
|
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
1578
|
interface SearchResultData {
|
|
1574
1579
|
query: string;
|
|
1575
1580
|
queryType?: SearchQueryType | QueryExtractorSearch | null;
|
|
@@ -1641,6 +1646,39 @@ declare class SearchResult {
|
|
|
1641
1646
|
};
|
|
1642
1647
|
}
|
|
1643
1648
|
|
|
1649
|
+
interface QueryCacheOptions {
|
|
1650
|
+
checkInterval?: number;
|
|
1651
|
+
}
|
|
1652
|
+
interface QueryCacheProvider<T> {
|
|
1653
|
+
getData(): Promise<DiscordPlayerQueryResultCache<T>[]>;
|
|
1654
|
+
addData(data: SearchResult): Promise<void>;
|
|
1655
|
+
resolve(context: QueryCacheResolverContext): Promise<SearchResult>;
|
|
1656
|
+
}
|
|
1657
|
+
declare class QueryCache implements QueryCacheProvider<Track> {
|
|
1658
|
+
#private;
|
|
1659
|
+
player: Player;
|
|
1660
|
+
options: QueryCacheOptions;
|
|
1661
|
+
timer: NodeJS.Timer;
|
|
1662
|
+
constructor(player: Player, options?: QueryCacheOptions);
|
|
1663
|
+
get checkInterval(): number;
|
|
1664
|
+
cleanup(): Promise<void>;
|
|
1665
|
+
clear(): Promise<void>;
|
|
1666
|
+
getData(): Promise<DiscordPlayerQueryResultCache<Track<unknown>>[]>;
|
|
1667
|
+
addData(data: SearchResult): Promise<void>;
|
|
1668
|
+
resolve(context: QueryCacheResolverContext): Promise<SearchResult>;
|
|
1669
|
+
}
|
|
1670
|
+
declare class DiscordPlayerQueryResultCache<T = unknown> {
|
|
1671
|
+
data: T;
|
|
1672
|
+
expireAfter: number;
|
|
1673
|
+
constructor(data: T, expireAfter?: number);
|
|
1674
|
+
hasExpired(): boolean;
|
|
1675
|
+
}
|
|
1676
|
+
interface QueryCacheResolverContext {
|
|
1677
|
+
query: string;
|
|
1678
|
+
requestedBy?: User;
|
|
1679
|
+
queryType?: SearchQueryType | `ext:${string}`;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1644
1682
|
declare class VoiceUtils {
|
|
1645
1683
|
player: Player;
|
|
1646
1684
|
/**
|
|
@@ -1692,32 +1730,42 @@ declare class VoiceUtils {
|
|
|
1692
1730
|
getConnection(guild: Snowflake, group?: string): VoiceConnection | undefined;
|
|
1693
1731
|
}
|
|
1694
1732
|
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
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>;
|
|
1733
|
+
declare class IPBlock {
|
|
1734
|
+
block: string;
|
|
1735
|
+
usage: number;
|
|
1736
|
+
readonly cidr: string;
|
|
1737
|
+
readonly cidrSize: number;
|
|
1738
|
+
constructor(block: string);
|
|
1739
|
+
consume(): void;
|
|
1710
1740
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1741
|
+
interface IPRotationConfig {
|
|
1742
|
+
/**
|
|
1743
|
+
* IP blocks to use
|
|
1744
|
+
*/
|
|
1745
|
+
blocks: string[];
|
|
1746
|
+
/**
|
|
1747
|
+
* IPs to exclude
|
|
1748
|
+
*/
|
|
1749
|
+
exclude?: string[];
|
|
1750
|
+
/**
|
|
1751
|
+
* Max retries to find an IP that is not excluded
|
|
1752
|
+
*/
|
|
1753
|
+
maxRetries?: number;
|
|
1716
1754
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1755
|
+
declare class IPRotator {
|
|
1756
|
+
#private;
|
|
1757
|
+
config: IPRotationConfig;
|
|
1758
|
+
blocks: IPBlock[];
|
|
1759
|
+
failures: Map<string, number>;
|
|
1760
|
+
MAX_NEXT_RETRIES: number;
|
|
1761
|
+
constructor(config: IPRotationConfig);
|
|
1762
|
+
getIP(): {
|
|
1763
|
+
ip: string;
|
|
1764
|
+
family: 4 | 6;
|
|
1765
|
+
};
|
|
1766
|
+
isFailedOrExcluded(ip: string): boolean;
|
|
1767
|
+
addFailed(ip: string): void;
|
|
1768
|
+
static getRandomIP(address: string, start?: number, end?: number): string;
|
|
1721
1769
|
}
|
|
1722
1770
|
|
|
1723
1771
|
interface PlayerNodeInitializationResult<T = unknown> {
|
|
@@ -1746,6 +1794,7 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1746
1794
|
readonly voiceUtils: VoiceUtils;
|
|
1747
1795
|
extractors: ExtractorExecutionContext;
|
|
1748
1796
|
events: PlayerEventsEmitter<GuildQueueEvents<any>>;
|
|
1797
|
+
routePlanner: IPRotator | null;
|
|
1749
1798
|
/**
|
|
1750
1799
|
* Creates new Discord Player
|
|
1751
1800
|
* @param {Client} client The Discord Client
|
|
@@ -1782,7 +1831,7 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1782
1831
|
/**
|
|
1783
1832
|
* The current query cache provider in use
|
|
1784
1833
|
*/
|
|
1785
|
-
get queryCache():
|
|
1834
|
+
get queryCache(): QueryCacheProvider<any> | null;
|
|
1786
1835
|
/**
|
|
1787
1836
|
* Alias to `Player.nodes`.
|
|
1788
1837
|
*/
|
|
@@ -1888,7 +1937,7 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1888
1937
|
*/
|
|
1889
1938
|
search(searchQuery: string | Track | Track[] | Playlist | SearchResult, options?: SearchOptions): Promise<SearchResult>;
|
|
1890
1939
|
/**
|
|
1891
|
-
* Generates a report of the dependencies used by the
|
|
1940
|
+
* Generates a report of the dependencies used by the `discord-voip` module. Useful for debugging.
|
|
1892
1941
|
* @example ```typescript
|
|
1893
1942
|
* console.log(player.scanDeps());
|
|
1894
1943
|
* // -> logs dependencies report
|
|
@@ -2014,6 +2063,7 @@ interface QueueFilters {
|
|
|
2014
2063
|
dim?: boolean;
|
|
2015
2064
|
earrape?: boolean;
|
|
2016
2065
|
lofi?: boolean;
|
|
2066
|
+
silenceremove?: boolean;
|
|
2017
2067
|
}
|
|
2018
2068
|
/**
|
|
2019
2069
|
* The track source:
|
|
@@ -2174,12 +2224,14 @@ type QueryExtractorSearch = `ext:${string}`;
|
|
|
2174
2224
|
* @property {string[]} [blockExtractors[]] List of the extractors to block
|
|
2175
2225
|
* @property {boolean} [ignoreCache] If it should ignore query cache lookup
|
|
2176
2226
|
* @property {SearchQueryType} [fallbackSearchEngine='autoSearch'] Fallback search engine to use
|
|
2227
|
+
* @property {any} [requestOptions] The request options
|
|
2177
2228
|
*/
|
|
2178
2229
|
interface SearchOptions {
|
|
2179
2230
|
requestedBy?: UserResolvable;
|
|
2180
2231
|
searchEngine?: SearchQueryType | QueryExtractorSearch;
|
|
2181
2232
|
blockExtractors?: string[];
|
|
2182
2233
|
ignoreCache?: boolean;
|
|
2234
|
+
requestOptions?: any;
|
|
2183
2235
|
fallbackSearchEngine?: (typeof QueryType)[keyof typeof QueryType];
|
|
2184
2236
|
}
|
|
2185
2237
|
/**
|
|
@@ -2292,6 +2344,7 @@ interface PlaylistJSON {
|
|
|
2292
2344
|
* @property {boolean} [ignoreInstance] Ignore player instance
|
|
2293
2345
|
* @property {boolean} [useLegacyFFmpeg] Use legacy version of ffmpeg
|
|
2294
2346
|
* @property {BridgeProvider} [bridgeProvider] Set bridge provider
|
|
2347
|
+
* @property {object} [ipconfig] IP rotator config
|
|
2295
2348
|
*/
|
|
2296
2349
|
interface PlayerInitOptions {
|
|
2297
2350
|
ytdlOptions?: downloadOptions;
|
|
@@ -2300,10 +2353,11 @@ interface PlayerInitOptions {
|
|
|
2300
2353
|
lockVoiceStateHandler?: boolean;
|
|
2301
2354
|
blockExtractors?: string[];
|
|
2302
2355
|
blockStreamFrom?: string[];
|
|
2303
|
-
queryCache?:
|
|
2356
|
+
queryCache?: QueryCacheProvider<any> | null;
|
|
2304
2357
|
ignoreInstance?: boolean;
|
|
2305
2358
|
useLegacyFFmpeg?: boolean;
|
|
2306
2359
|
bridgeProvider?: BridgeProvider;
|
|
2360
|
+
ipconfig?: IPRotationConfig;
|
|
2307
2361
|
}
|
|
2308
2362
|
|
|
2309
2363
|
declare class AudioFilters {
|
|
@@ -2543,4 +2597,4 @@ declare function createHook<T extends HookDeclaration<(...args: any[]) => any>>(
|
|
|
2543
2597
|
|
|
2544
2598
|
declare const version: string;
|
|
2545
2599
|
|
|
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 };
|
|
2600
|
+
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, IPBlock, IPRotationConfig, IPRotator, 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 };
|