discord-player 6.1.0 → 6.2.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 +11 -10
- package/dist/index.d.ts +282 -44
- package/dist/index.js +364 -136
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +350 -127
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -30,8 +30,8 @@ Discord Player requires Discord.js 14.0 or higher. PLease make sure you have a c
|
|
|
30
30
|
#### Main Library
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
$
|
|
34
|
-
$
|
|
33
|
+
$ yarn add discord-player # main library
|
|
34
|
+
$ yarn add @discord-player/extractor # extractors provider
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
> Discord Player recognizes `@discord-player/extractor` and loads it automatically by default.
|
|
@@ -41,8 +41,8 @@ $ npm install @discord-player/extractor # extractors provider
|
|
|
41
41
|
Discord Player is a high level framework for Discord VoIP. Discord only accepts opus packets, thus you need to install opus library. You can install any of these:
|
|
42
42
|
|
|
43
43
|
```bash
|
|
44
|
-
$
|
|
45
|
-
$
|
|
44
|
+
$ yarn add @discordjs/opus
|
|
45
|
+
$ yarn add opusscript
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
#### FFmpeg or Avconv
|
|
@@ -50,7 +50,7 @@ $ npm install opusscript
|
|
|
50
50
|
FFmpeg or Avconv is required for media transcoding. You can get it from [https://ffmpeg.org](https://www.ffmpeg.org/download.html) or by installing it from npm:
|
|
51
51
|
|
|
52
52
|
```bash
|
|
53
|
-
$
|
|
53
|
+
$ yarn add ffmpeg-static
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
You can get avconv from [https://libav.org/download](https://libav.org/download).
|
|
@@ -60,9 +60,9 @@ You can get avconv from [https://libav.org/download](https://libav.org/download)
|
|
|
60
60
|
You also need to install streaming library if you want to add support for youtube playback. You can install one of these libraries:
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
|
-
$
|
|
64
|
-
$
|
|
65
|
-
$
|
|
63
|
+
$ yarn add ytdl-core
|
|
64
|
+
$ yarn add play-dl
|
|
65
|
+
$ yarn add @distube/ytdl-core
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
Done with all these? Let's write a simple music bot then.
|
|
@@ -125,6 +125,7 @@ That's all it takes to build your own music bot.
|
|
|
125
125
|
|
|
126
126
|
#### Check out the [Documentation](https://discord-player.js.org) for more info.
|
|
127
127
|
|
|
128
|
-
##
|
|
128
|
+
## Community Resources
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
A curated list of resources (such as open source music bots, extractors, etc.) built by Discord Player community.
|
|
131
|
+
[https://discord-player.js.org/docs/guides/community-resources](https://discord-player.js.org/docs/guides/community-resources)
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as discord_js from 'discord.js';
|
|
|
3
3
|
import { User, VoiceChannel, StageChannel, UserResolvable, Guild, VoiceState, VoiceBasedChannel, GuildVoiceChannelResolvable, Snowflake, Client, GuildResolvable } from 'discord.js';
|
|
4
4
|
import * as _discordjs_voice from '@discordjs/voice';
|
|
5
5
|
import { AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, AudioPlayerStatus, StreamType, EndBehaviorType } from '@discordjs/voice';
|
|
6
|
+
export { AudioPlayer, CreateAudioPlayerOptions, createAudioPlayer } from '@discordjs/voice';
|
|
6
7
|
import { Readable, Duplex } from 'stream';
|
|
7
8
|
import * as _discord_player_equalizer from '@discord-player/equalizer';
|
|
8
9
|
import { PCMFilters, EqualizerBand, BiquadFilters, FiltersChain } from '@discord-player/equalizer';
|
|
@@ -88,7 +89,7 @@ interface ExtractorExecutionEvents {
|
|
|
88
89
|
}
|
|
89
90
|
declare class ExtractorExecutionContext extends PlayerEventsEmitter<ExtractorExecutionEvents> {
|
|
90
91
|
player: Player;
|
|
91
|
-
store: Collection<string, BaseExtractor
|
|
92
|
+
store: Collection<string, BaseExtractor<object>>;
|
|
92
93
|
constructor(player: Player);
|
|
93
94
|
/**
|
|
94
95
|
* Load default extractors from `@discord-player/extractor`
|
|
@@ -113,13 +114,13 @@ declare class ExtractorExecutionContext extends PlayerEventsEmitter<ExtractorExe
|
|
|
113
114
|
* Get single extractor
|
|
114
115
|
* @param identifier The extractor to get
|
|
115
116
|
*/
|
|
116
|
-
get(identifier: string): BaseExtractor | undefined;
|
|
117
|
+
get(identifier: string): BaseExtractor<object> | undefined;
|
|
117
118
|
/**
|
|
118
119
|
* Register single extractor
|
|
119
120
|
* @param _extractor The extractor to register
|
|
120
121
|
* @param options Options supplied to the extractor
|
|
121
122
|
*/
|
|
122
|
-
register(_extractor:
|
|
123
|
+
register<O extends object, T extends typeof BaseExtractor<O>>(_extractor: T, options: ConstructorParameters<T>['1']): Promise<void>;
|
|
123
124
|
/**
|
|
124
125
|
* Unregister single extractor
|
|
125
126
|
* @param _extractor The extractor to unregister
|
|
@@ -134,17 +135,18 @@ declare class ExtractorExecutionContext extends PlayerEventsEmitter<ExtractorExe
|
|
|
134
135
|
* @param fn The runner function
|
|
135
136
|
* @param filterBlocked Filter blocked extractors
|
|
136
137
|
*/
|
|
137
|
-
run<T = unknown>(fn: ExtractorExecutionFN<T>, filterBlocked?: boolean): Promise<ExtractorExecutionResult<T> |
|
|
138
|
+
run<T = unknown>(fn: ExtractorExecutionFN<T>, filterBlocked?: boolean): Promise<ExtractorExecutionResult<T> | undefined>;
|
|
138
139
|
}
|
|
139
140
|
interface ExtractorExecutionResult<T = unknown> {
|
|
140
141
|
extractor: BaseExtractor;
|
|
142
|
+
error: Error | null;
|
|
141
143
|
result: T;
|
|
142
144
|
}
|
|
143
145
|
type ExtractorExecutionFN<T = unknown> = (extractor: BaseExtractor) => Promise<T | boolean>;
|
|
144
146
|
|
|
145
|
-
declare class BaseExtractor {
|
|
147
|
+
declare class BaseExtractor<T extends object = object> {
|
|
146
148
|
context: ExtractorExecutionContext;
|
|
147
|
-
options:
|
|
149
|
+
options: T;
|
|
148
150
|
/**
|
|
149
151
|
* Identifier for this extractor
|
|
150
152
|
*/
|
|
@@ -154,11 +156,16 @@ declare class BaseExtractor {
|
|
|
154
156
|
* @param context Context that instantiated this extractor
|
|
155
157
|
* @param options Initialization options for this extractor
|
|
156
158
|
*/
|
|
157
|
-
constructor(context: ExtractorExecutionContext, options?:
|
|
159
|
+
constructor(context: ExtractorExecutionContext, options?: T);
|
|
158
160
|
/**
|
|
159
161
|
* Identifier of this extractor
|
|
160
162
|
*/
|
|
161
163
|
get identifier(): string;
|
|
164
|
+
/**
|
|
165
|
+
* Reconfigures this extractor
|
|
166
|
+
* @param options The new options to apply
|
|
167
|
+
*/
|
|
168
|
+
reconfigure(options: T): Promise<void>;
|
|
162
169
|
/**
|
|
163
170
|
* This method will be executed when this extractor is activated
|
|
164
171
|
*/
|
|
@@ -313,7 +320,7 @@ declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
|
313
320
|
* @param {VoiceChannel|StageChannel} channel The connected channel
|
|
314
321
|
* @private
|
|
315
322
|
*/
|
|
316
|
-
constructor(connection: VoiceConnection, channel: VoiceChannel | StageChannel, queue: GuildQueue, connectionTimeout?: number);
|
|
323
|
+
constructor(connection: VoiceConnection, channel: VoiceChannel | StageChannel, queue: GuildQueue, connectionTimeout?: number, audioPlayer?: AudioPlayer);
|
|
317
324
|
/**
|
|
318
325
|
* Check if the player has been paused manually
|
|
319
326
|
*/
|
|
@@ -492,6 +499,73 @@ declare class GuildQueueHistory<Meta = unknown> {
|
|
|
492
499
|
back(): Promise<void>;
|
|
493
500
|
}
|
|
494
501
|
|
|
502
|
+
interface AsyncQueueAcquisitionOptions {
|
|
503
|
+
/**
|
|
504
|
+
* AbortSignal to cancel this entry
|
|
505
|
+
*/
|
|
506
|
+
signal?: AbortSignal;
|
|
507
|
+
}
|
|
508
|
+
declare class AsyncQueue {
|
|
509
|
+
/**
|
|
510
|
+
* The queued entries
|
|
511
|
+
*/
|
|
512
|
+
entries: Array<AsyncQueueEntry>;
|
|
513
|
+
/**
|
|
514
|
+
* Clear entries queue
|
|
515
|
+
* @param consume Whether or not to consume all entries before clearing
|
|
516
|
+
*/
|
|
517
|
+
clear(consume?: boolean): void;
|
|
518
|
+
/**
|
|
519
|
+
* The total number of entries in this queue. Returns `0` if no entries are available.
|
|
520
|
+
*/
|
|
521
|
+
get size(): number;
|
|
522
|
+
/**
|
|
523
|
+
* Acquire an entry.
|
|
524
|
+
*
|
|
525
|
+
* ```typescript
|
|
526
|
+
* // lock the queue
|
|
527
|
+
* const entry = asyncQueue.acquire();
|
|
528
|
+
* // wait until previous task is completed
|
|
529
|
+
* await entry.getTask();
|
|
530
|
+
* // do something expensive
|
|
531
|
+
* await performSomethingExpensive();
|
|
532
|
+
* // make sure to release the lock once done
|
|
533
|
+
* asyncQueue.release();
|
|
534
|
+
* ```
|
|
535
|
+
*/
|
|
536
|
+
acquire(options?: AsyncQueueAcquisitionOptions): AsyncQueueEntry;
|
|
537
|
+
/**
|
|
538
|
+
* Release the current acquisition and move to next entry.
|
|
539
|
+
*/
|
|
540
|
+
release(): void;
|
|
541
|
+
/**
|
|
542
|
+
* Cancel all entries
|
|
543
|
+
*/
|
|
544
|
+
cancelAll(): void;
|
|
545
|
+
/**
|
|
546
|
+
* Remove the given entry from the queue
|
|
547
|
+
* @param entry The entry to remove
|
|
548
|
+
*/
|
|
549
|
+
removeEntry(entry: AsyncQueueEntry): boolean;
|
|
550
|
+
}
|
|
551
|
+
declare class AsyncQueueEntry {
|
|
552
|
+
queue: AsyncQueue;
|
|
553
|
+
options?: AsyncQueueAcquisitionOptions | undefined;
|
|
554
|
+
readonly id: string;
|
|
555
|
+
private readonly promise;
|
|
556
|
+
signal: AbortSignal | null;
|
|
557
|
+
onAbort: (() => void) | null;
|
|
558
|
+
private resolve;
|
|
559
|
+
private reject;
|
|
560
|
+
constructor(queue: AsyncQueue, options?: AsyncQueueAcquisitionOptions | undefined);
|
|
561
|
+
setAbortSignal(signal: AbortSignal): void;
|
|
562
|
+
consume(): void;
|
|
563
|
+
release(): void;
|
|
564
|
+
cancel(): void;
|
|
565
|
+
cleanup(): void;
|
|
566
|
+
getTask(): Promise<void>;
|
|
567
|
+
}
|
|
568
|
+
|
|
495
569
|
declare const FFMPEG_SRATE_REGEX: RegExp;
|
|
496
570
|
interface ResourcePlayOptions {
|
|
497
571
|
queue?: boolean;
|
|
@@ -512,6 +586,7 @@ interface PlayerTimestamp {
|
|
|
512
586
|
declare class GuildQueuePlayerNode<Meta = unknown> {
|
|
513
587
|
#private;
|
|
514
588
|
queue: GuildQueue<Meta>;
|
|
589
|
+
tasksQueue: AsyncQueue;
|
|
515
590
|
constructor(queue: GuildQueue<Meta>);
|
|
516
591
|
/**
|
|
517
592
|
* If the player is currently in idle mode
|
|
@@ -533,6 +608,10 @@ declare class GuildQueuePlayerNode<Meta = unknown> {
|
|
|
533
608
|
* Reset progress history
|
|
534
609
|
*/
|
|
535
610
|
resetProgress(): void;
|
|
611
|
+
/**
|
|
612
|
+
* Set player progress
|
|
613
|
+
*/
|
|
614
|
+
setProgress(progress: number): void;
|
|
536
615
|
/**
|
|
537
616
|
* The stream time for current session
|
|
538
617
|
*/
|
|
@@ -625,6 +704,24 @@ declare class GuildQueuePlayerNode<Meta = unknown> {
|
|
|
625
704
|
* @param index The position to insert to, defaults to 0.
|
|
626
705
|
*/
|
|
627
706
|
insert(track: Track, index?: number): void;
|
|
707
|
+
/**
|
|
708
|
+
* Moves a track in the queue
|
|
709
|
+
* @param from The track to move
|
|
710
|
+
* @param to The position to move to
|
|
711
|
+
*/
|
|
712
|
+
move(from: TrackResolvable, to: number): void;
|
|
713
|
+
/**
|
|
714
|
+
* Copy a track in the queue
|
|
715
|
+
* @param from The track to clone
|
|
716
|
+
* @param to The position to clone at
|
|
717
|
+
*/
|
|
718
|
+
copy(from: TrackResolvable, to: number): void;
|
|
719
|
+
/**
|
|
720
|
+
* Swap two tracks in the queue
|
|
721
|
+
* @param first The first track to swap
|
|
722
|
+
* @param second The second track to swap
|
|
723
|
+
*/
|
|
724
|
+
swap(first: TrackResolvable, second: TrackResolvable): void;
|
|
628
725
|
/**
|
|
629
726
|
* Stop the playback
|
|
630
727
|
* @param force Whether or not to forcefully stop the playback
|
|
@@ -811,7 +908,7 @@ declare class AFilterGraph<Meta = unknown> {
|
|
|
811
908
|
get ffmpeg(): (keyof QueueFilters)[];
|
|
812
909
|
get equalizer(): EqualizerBand[];
|
|
813
910
|
get biquad(): null;
|
|
814
|
-
get filters(): ("8D" | "Tremolo" | "Vibrato"
|
|
911
|
+
get filters(): ("8D" | "Tremolo" | "Vibrato")[];
|
|
815
912
|
get volume(): _discord_player_equalizer.VolumeTransformer | null;
|
|
816
913
|
get resampler(): _discord_player_equalizer.PCMResampler | null;
|
|
817
914
|
dump(): FilterGraph;
|
|
@@ -849,10 +946,12 @@ interface GuildNodeInit<Meta = unknown> {
|
|
|
849
946
|
selfDeaf?: boolean;
|
|
850
947
|
metadata?: Meta | null;
|
|
851
948
|
bufferingTimeout: number;
|
|
949
|
+
noEmitInsert: boolean;
|
|
852
950
|
}
|
|
853
951
|
interface VoiceConnectConfig {
|
|
854
952
|
deaf?: boolean;
|
|
855
953
|
timeout?: number;
|
|
954
|
+
audioPlayer?: AudioPlayer;
|
|
856
955
|
}
|
|
857
956
|
interface PostProcessedResult {
|
|
858
957
|
stream: Readable;
|
|
@@ -925,7 +1024,35 @@ declare enum GuildQueueEvent {
|
|
|
925
1024
|
/**
|
|
926
1025
|
* Emitted when the voice state is updated. Consuming this event may disable default voice state update handler if `Player.isVoiceStateHandlerLocked()` returns `false`.
|
|
927
1026
|
*/
|
|
928
|
-
voiceStateUpdate = "voiceStateUpdate"
|
|
1027
|
+
voiceStateUpdate = "voiceStateUpdate",
|
|
1028
|
+
/**
|
|
1029
|
+
* Emitted when volume is updated
|
|
1030
|
+
*/
|
|
1031
|
+
volumeChange = "volumeChange",
|
|
1032
|
+
/**
|
|
1033
|
+
* Emitted when player is paused
|
|
1034
|
+
*/
|
|
1035
|
+
playerPause = "playerPause",
|
|
1036
|
+
/**
|
|
1037
|
+
* Emitted when player is resumed
|
|
1038
|
+
*/
|
|
1039
|
+
playerResume = "playerResume",
|
|
1040
|
+
/**
|
|
1041
|
+
* Biquad Filters Update
|
|
1042
|
+
*/
|
|
1043
|
+
biquadFiltersUpdate = "biquadFiltersUpdate",
|
|
1044
|
+
/**
|
|
1045
|
+
* Equalizer Update
|
|
1046
|
+
*/
|
|
1047
|
+
equalizerUpdate = "equalizerUpdate",
|
|
1048
|
+
/**
|
|
1049
|
+
* DSP update
|
|
1050
|
+
*/
|
|
1051
|
+
dspUpdate = "dspUpdate",
|
|
1052
|
+
/**
|
|
1053
|
+
* Audio Filters Update
|
|
1054
|
+
*/
|
|
1055
|
+
audioFiltersUpdate = "audioFiltersUpdate"
|
|
929
1056
|
}
|
|
930
1057
|
interface GuildQueueEvents<Meta = unknown> {
|
|
931
1058
|
/**
|
|
@@ -1022,6 +1149,51 @@ interface GuildQueueEvents<Meta = unknown> {
|
|
|
1022
1149
|
* @param newState The new voice state
|
|
1023
1150
|
*/
|
|
1024
1151
|
voiceStateUpdate: (queue: GuildQueue<Meta>, oldState: VoiceState, newState: VoiceState) => unknown;
|
|
1152
|
+
/**
|
|
1153
|
+
* Emitted when audio player is paused
|
|
1154
|
+
* @param queue The queue where this event occurred
|
|
1155
|
+
*/
|
|
1156
|
+
playerPause: (queue: GuildQueue<Meta>) => unknown;
|
|
1157
|
+
/**
|
|
1158
|
+
* Emitted when audio player is resumed
|
|
1159
|
+
* @param queue The queue where this event occurred
|
|
1160
|
+
*/
|
|
1161
|
+
playerResume: (queue: GuildQueue<Meta>) => unknown;
|
|
1162
|
+
/**
|
|
1163
|
+
* Emitted when audio player's volume is changed
|
|
1164
|
+
* @param queue The queue where this event occurred
|
|
1165
|
+
* @param oldVolume The old volume
|
|
1166
|
+
* @param newVolume The updated volume
|
|
1167
|
+
*/
|
|
1168
|
+
volumeChange: (queue: GuildQueue<Meta>, oldVolume: number, newVolume: number) => unknown;
|
|
1169
|
+
/**
|
|
1170
|
+
* Emitted when equalizer config is updated
|
|
1171
|
+
* @param queue The queue where this event occurred
|
|
1172
|
+
* @param oldFilters Old filters
|
|
1173
|
+
* @param newFilters New filters
|
|
1174
|
+
*/
|
|
1175
|
+
equalizerUpdate: (queue: GuildQueue<Meta>, oldFilters: EqualizerBand[], newFilters: EqualizerBand[]) => unknown;
|
|
1176
|
+
/**
|
|
1177
|
+
* Emitted when biquad filters is updated
|
|
1178
|
+
* @param queue The queue where this event occurred
|
|
1179
|
+
* @param oldFilters Old filters
|
|
1180
|
+
* @param newFilters New filters
|
|
1181
|
+
*/
|
|
1182
|
+
biquadFiltersUpdate: (queue: GuildQueue<Meta>, oldFilters: BiquadFilters | null, newFilters: BiquadFilters | null) => unknown;
|
|
1183
|
+
/**
|
|
1184
|
+
* Emitted when dsp filters is updated
|
|
1185
|
+
* @param queue The queue where this event occurred
|
|
1186
|
+
* @param oldFilters Old filters
|
|
1187
|
+
* @param newFilters New filters
|
|
1188
|
+
*/
|
|
1189
|
+
dspUpdate: (queue: GuildQueue<Meta>, oldFilters: PCMFilters[], newFilters: PCMFilters[]) => unknown;
|
|
1190
|
+
/**
|
|
1191
|
+
* Emitted when ffmpeg audio filters is updated
|
|
1192
|
+
* @param queue The queue where this event occurred
|
|
1193
|
+
* @param oldFilters Old filters
|
|
1194
|
+
* @param newFilters New filters
|
|
1195
|
+
*/
|
|
1196
|
+
audioFiltersUpdate: (queue: GuildQueue<Meta>, oldFilters: FiltersName[], newFilters: FiltersName[]) => unknown;
|
|
1025
1197
|
}
|
|
1026
1198
|
declare class GuildQueue<Meta = unknown> {
|
|
1027
1199
|
#private;
|
|
@@ -1038,6 +1210,7 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1038
1210
|
repeatMode: QueueRepeatMode;
|
|
1039
1211
|
timeouts: Collection<string, NodeJS.Timeout>;
|
|
1040
1212
|
stats: GuildQueueStatistics<Meta>;
|
|
1213
|
+
tasksQueue: AsyncQueue;
|
|
1041
1214
|
constructor(player: Player, options: GuildNodeInit<Meta>);
|
|
1042
1215
|
/**
|
|
1043
1216
|
* Estimated duration of this queue in ms
|
|
@@ -1059,18 +1232,13 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1059
1232
|
/**
|
|
1060
1233
|
* The metadata of this queue
|
|
1061
1234
|
*/
|
|
1062
|
-
get metadata(): Meta
|
|
1063
|
-
set metadata(m: Meta
|
|
1235
|
+
get metadata(): Meta;
|
|
1236
|
+
set metadata(m: Meta);
|
|
1064
1237
|
/**
|
|
1065
1238
|
* Set metadata for this queue
|
|
1066
1239
|
* @param m Metadata to set
|
|
1067
1240
|
*/
|
|
1068
|
-
setMetadata(m: Meta
|
|
1069
|
-
/**
|
|
1070
|
-
* Indicates if this queue is currently initializing
|
|
1071
|
-
*/
|
|
1072
|
-
get initializing(): boolean;
|
|
1073
|
-
set initializing(v: boolean);
|
|
1241
|
+
setMetadata(m: Meta): void;
|
|
1074
1242
|
/**
|
|
1075
1243
|
* Indicates current track of this queue
|
|
1076
1244
|
*/
|
|
@@ -1146,6 +1314,24 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1146
1314
|
* @param index The index to insert the track at (defaults to 0)
|
|
1147
1315
|
*/
|
|
1148
1316
|
insertTrack(track: Track, index?: number): void;
|
|
1317
|
+
/**
|
|
1318
|
+
* Moves a track in the queue
|
|
1319
|
+
* @param from The track to move
|
|
1320
|
+
* @param to The position to move to
|
|
1321
|
+
*/
|
|
1322
|
+
moveTrack(track: TrackResolvable, index?: number): void;
|
|
1323
|
+
/**
|
|
1324
|
+
* Copy a track in the queue
|
|
1325
|
+
* @param from The track to clone
|
|
1326
|
+
* @param to The position to clone at
|
|
1327
|
+
*/
|
|
1328
|
+
copyTrack(track: TrackResolvable, index?: number): void;
|
|
1329
|
+
/**
|
|
1330
|
+
* Swap two tracks in the queue
|
|
1331
|
+
* @param src The first track to swap
|
|
1332
|
+
* @param dest The second track to swap
|
|
1333
|
+
*/
|
|
1334
|
+
swapTracks(src: TrackResolvable, dest: TrackResolvable): void;
|
|
1149
1335
|
/**
|
|
1150
1336
|
* Connect to a voice channel
|
|
1151
1337
|
* @param channelResolvable The voice channel to connect to
|
|
@@ -1165,10 +1351,6 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1165
1351
|
* @returns
|
|
1166
1352
|
*/
|
|
1167
1353
|
revive(): void;
|
|
1168
|
-
/**
|
|
1169
|
-
* Wait for this queue to initialize
|
|
1170
|
-
*/
|
|
1171
|
-
awaitInitialization(): Promise<boolean>;
|
|
1172
1354
|
/**
|
|
1173
1355
|
* Set self deaf
|
|
1174
1356
|
* @param mode On/Off state
|
|
@@ -1231,6 +1413,7 @@ declare class VoiceUtils {
|
|
|
1231
1413
|
deaf?: boolean;
|
|
1232
1414
|
maxTime?: number;
|
|
1233
1415
|
queue: GuildQueue;
|
|
1416
|
+
audioPlayer?: AudioPlayer;
|
|
1234
1417
|
}): Promise<StreamDispatcher>;
|
|
1235
1418
|
/**
|
|
1236
1419
|
* Joins a voice channel
|
|
@@ -1285,7 +1468,7 @@ declare class SearchResult {
|
|
|
1285
1468
|
/**
|
|
1286
1469
|
* The extractor
|
|
1287
1470
|
*/
|
|
1288
|
-
get extractor(): BaseExtractor | null;
|
|
1471
|
+
get extractor(): BaseExtractor<object> | null;
|
|
1289
1472
|
/**
|
|
1290
1473
|
* Playlist result
|
|
1291
1474
|
*/
|
|
@@ -1385,28 +1568,47 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1385
1568
|
*/
|
|
1386
1569
|
static singleton(client: Client, options?: PlayerInitOptions): Player;
|
|
1387
1570
|
/**
|
|
1388
|
-
* Get all active player instances
|
|
1571
|
+
* Get all active master player instances
|
|
1389
1572
|
*/
|
|
1390
1573
|
static getAllPlayers(): Player[];
|
|
1391
1574
|
/**
|
|
1392
|
-
* Clear all player instances
|
|
1575
|
+
* Clear all master player instances
|
|
1393
1576
|
*/
|
|
1394
1577
|
static clearAllPlayers(): void;
|
|
1395
1578
|
/**
|
|
1396
|
-
* The current query cache provider
|
|
1579
|
+
* The current query cache provider in use
|
|
1397
1580
|
*/
|
|
1398
1581
|
get queryCache(): QueryCache | null;
|
|
1399
1582
|
/**
|
|
1400
|
-
* Alias to `Player.nodes
|
|
1583
|
+
* Alias to `Player.nodes`.
|
|
1401
1584
|
*/
|
|
1402
1585
|
get queues(): GuildNodeManager<unknown>;
|
|
1403
1586
|
/**
|
|
1404
|
-
* Event loop
|
|
1587
|
+
* Event loop latency in ms. If your bot is laggy and this returns a number above 20ms for example,
|
|
1588
|
+
* some expensive task is being executed on the current thread which is slowing down the event loop.
|
|
1405
1589
|
* @type {number}
|
|
1406
1590
|
*/
|
|
1407
1591
|
get eventLoopLag(): number;
|
|
1408
1592
|
/**
|
|
1409
|
-
* Generates statistics
|
|
1593
|
+
* Generates statistics that could be useful. Statistics generator is still experimental.
|
|
1594
|
+
* @example ```typescript
|
|
1595
|
+
* const stats = player.generateStatistics();
|
|
1596
|
+
*
|
|
1597
|
+
* console.log(stats);
|
|
1598
|
+
*
|
|
1599
|
+
* // outputs something like
|
|
1600
|
+
* // {
|
|
1601
|
+
* // instances: number,
|
|
1602
|
+
* // queuesCount: number,
|
|
1603
|
+
* // queryCacheEnabled: boolean,
|
|
1604
|
+
* // queues: [
|
|
1605
|
+
* // GuildQueueStatisticsMetadata,
|
|
1606
|
+
* // GuildQueueStatisticsMetadata,
|
|
1607
|
+
* // GuildQueueStatisticsMetadata,
|
|
1608
|
+
* // ...
|
|
1609
|
+
* // ]
|
|
1610
|
+
* // }
|
|
1611
|
+
* ```
|
|
1410
1612
|
*/
|
|
1411
1613
|
generateStatistics(): {
|
|
1412
1614
|
instances: number;
|
|
@@ -1415,7 +1617,11 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1415
1617
|
queues: GuildQueueStatisticsMetadata[];
|
|
1416
1618
|
};
|
|
1417
1619
|
/**
|
|
1418
|
-
* Destroy player
|
|
1620
|
+
* Destroy every single queues managed by this master player instance
|
|
1621
|
+
* @example ```typescript
|
|
1622
|
+
* // use me when you want to immediately terminate every single queues in existence 🔪
|
|
1623
|
+
* await player.destroy();
|
|
1624
|
+
* ```
|
|
1419
1625
|
*/
|
|
1420
1626
|
destroy(): Promise<void>;
|
|
1421
1627
|
private _handleVoiceState;
|
|
@@ -1424,18 +1630,26 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1424
1630
|
* @param {VoiceState} oldState The old voice state
|
|
1425
1631
|
* @param {VoiceState} newState The new voice state
|
|
1426
1632
|
* @returns {void}
|
|
1633
|
+
* @example ```typescript
|
|
1634
|
+
* // passing voice state update data to this method will trigger voice state handler
|
|
1635
|
+
*
|
|
1636
|
+
* client.on('voiceStateUpdate', (oldState, newState) => {
|
|
1637
|
+
* // this is definitely a rocket science, right here
|
|
1638
|
+
* player.handleVoiceState(oldState, newState);
|
|
1639
|
+
* });
|
|
1640
|
+
* ```
|
|
1427
1641
|
*/
|
|
1428
1642
|
handleVoiceState(oldState: VoiceState, newState: VoiceState): void;
|
|
1429
1643
|
/**
|
|
1430
|
-
* Lock voice state handler
|
|
1644
|
+
* Lock voice state handler. When this method is called, discord-player will keep using the default voice state update handler, even if custom implementation exists.
|
|
1431
1645
|
*/
|
|
1432
1646
|
lockVoiceStateHandler(): void;
|
|
1433
1647
|
/**
|
|
1434
|
-
* Unlock voice state handler
|
|
1648
|
+
* Unlock voice state handler. When this method is called, discord-player will stop using the default voice state update handler if custom implementation exists.
|
|
1435
1649
|
*/
|
|
1436
1650
|
unlockVoiceStateHandler(): void;
|
|
1437
1651
|
/**
|
|
1438
|
-
* Checks if voice state handler is locked
|
|
1652
|
+
* Checks if voice state handler is locked.
|
|
1439
1653
|
*/
|
|
1440
1654
|
isVoiceStateHandlerLocked(): boolean;
|
|
1441
1655
|
/**
|
|
@@ -1443,26 +1657,42 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
1443
1657
|
* @param channel The voice channel on which the music should be played
|
|
1444
1658
|
* @param query The track or source to play
|
|
1445
1659
|
* @param options Options for player
|
|
1660
|
+
* @example ```typescript
|
|
1661
|
+
* // no need to worry about queue management, just use this method 😄
|
|
1662
|
+
* const query = 'this is my super cool search query that I want to play';
|
|
1663
|
+
*
|
|
1664
|
+
* try {
|
|
1665
|
+
* const { track } = await player.play(voiceChannel, query);
|
|
1666
|
+
* console.log(`🎉 I am playing ${track.title} 🎉`);
|
|
1667
|
+
* } catch(e) {
|
|
1668
|
+
* console.log(`😭 Failed to play error oh no:\n\n${e}`);
|
|
1669
|
+
* }
|
|
1670
|
+
* ```
|
|
1446
1671
|
*/
|
|
1447
1672
|
play<T = unknown>(channel: GuildVoiceChannelResolvable, query: string | Track | SearchResult | Track[] | Playlist, options?: SearchOptions & {
|
|
1448
1673
|
nodeOptions?: GuildNodeCreateOptions<T>;
|
|
1449
1674
|
connectionOptions?: VoiceConnectConfig;
|
|
1450
1675
|
afterSearch?: (result: SearchResult) => Promise<SearchResult>;
|
|
1451
1676
|
}): Promise<PlayerNodeInitializationResult<T>>;
|
|
1452
|
-
/**
|
|
1453
|
-
* @typedef {object} PlayerSearchResult
|
|
1454
|
-
* @property {Playlist} [playlist] The playlist (if any)
|
|
1455
|
-
* @property {Track[]} tracks The tracks
|
|
1456
|
-
*/
|
|
1457
1677
|
/**
|
|
1458
1678
|
* Search tracks
|
|
1459
1679
|
* @param {string | Track | Track[] | Playlist | SearchResult} query The search query
|
|
1460
1680
|
* @param {SearchOptions} options The search options
|
|
1461
1681
|
* @returns {Promise<SearchResult>}
|
|
1682
|
+
* @example ```typescript
|
|
1683
|
+
* const searchQuery = 'pass url or text or discord-player track constructable objects, we got you covered 😎';
|
|
1684
|
+
* const result = await player.search(searchQuery);
|
|
1685
|
+
*
|
|
1686
|
+
* console.log(result); // Logs `SearchResult` object
|
|
1687
|
+
* ```
|
|
1462
1688
|
*/
|
|
1463
1689
|
search(query: string | Track | Track[] | Playlist | SearchResult, options?: SearchOptions): Promise<SearchResult>;
|
|
1464
1690
|
/**
|
|
1465
1691
|
* Generates a report of the dependencies used by the `@discordjs/voice` module. Useful for debugging.
|
|
1692
|
+
* @example ```typescript
|
|
1693
|
+
* console.log(player.scanDeps());
|
|
1694
|
+
* // -> logs dependencies report
|
|
1695
|
+
* ```
|
|
1466
1696
|
* @returns {string}
|
|
1467
1697
|
*/
|
|
1468
1698
|
scanDeps(): string;
|
|
@@ -1497,6 +1727,7 @@ interface GuildNodeCreateOptions<T = unknown> {
|
|
|
1497
1727
|
connectionTimeout?: number;
|
|
1498
1728
|
defaultFFmpegFilters?: FiltersName[];
|
|
1499
1729
|
bufferingTimeout?: number;
|
|
1730
|
+
noEmitInsert?: boolean;
|
|
1500
1731
|
}
|
|
1501
1732
|
type NodeResolvable = GuildQueue | GuildResolvable;
|
|
1502
1733
|
declare class GuildNodeManager<Meta = unknown> {
|
|
@@ -1694,6 +1925,7 @@ interface PlayerProgressbarOptions {
|
|
|
1694
1925
|
* - SPOTIFY_SONG
|
|
1695
1926
|
* - SPOTIFY_ALBUM
|
|
1696
1927
|
* - SPOTIFY_PLAYLIST
|
|
1928
|
+
* - SPOTIFY_SEARCH
|
|
1697
1929
|
* - FACEBOOK
|
|
1698
1930
|
* - VIMEO
|
|
1699
1931
|
* - ARBITRARY
|
|
@@ -1706,7 +1938,8 @@ interface PlayerProgressbarOptions {
|
|
|
1706
1938
|
* - APPLE_MUSIC_PLAYLIST
|
|
1707
1939
|
* - APPLE_MUSIC_SEARCH
|
|
1708
1940
|
* - FILE
|
|
1709
|
-
*
|
|
1941
|
+
* - AUTO_SEARCH
|
|
1942
|
+
* @typedef {string} QueryType
|
|
1710
1943
|
*/
|
|
1711
1944
|
declare const QueryType: {
|
|
1712
1945
|
readonly AUTO: "auto";
|
|
@@ -1718,6 +1951,7 @@ declare const QueryType: {
|
|
|
1718
1951
|
readonly SPOTIFY_SONG: "spotifySong";
|
|
1719
1952
|
readonly SPOTIFY_ALBUM: "spotifyAlbum";
|
|
1720
1953
|
readonly SPOTIFY_PLAYLIST: "spotifyPlaylist";
|
|
1954
|
+
readonly SPOTIFY_SEARCH: "spotifySearch";
|
|
1721
1955
|
readonly FACEBOOK: "facebook";
|
|
1722
1956
|
readonly VIMEO: "vimeo";
|
|
1723
1957
|
readonly ARBITRARY: "arbitrary";
|
|
@@ -1730,6 +1964,7 @@ declare const QueryType: {
|
|
|
1730
1964
|
readonly APPLE_MUSIC_PLAYLIST: "appleMusicPlaylist";
|
|
1731
1965
|
readonly APPLE_MUSIC_SEARCH: "appleMusicSearch";
|
|
1732
1966
|
readonly FILE: "file";
|
|
1967
|
+
readonly AUTO_SEARCH: "autoSearch";
|
|
1733
1968
|
};
|
|
1734
1969
|
type SearchQueryType = keyof typeof QueryType | (typeof QueryType)[keyof typeof QueryType];
|
|
1735
1970
|
interface PlayerEvents {
|
|
@@ -1759,15 +1994,17 @@ type QueryExtractorSearch = `ext:${string}`;
|
|
|
1759
1994
|
/**
|
|
1760
1995
|
* @typedef {object} SearchOptions
|
|
1761
1996
|
* @property {UserResolvable} requestedBy The user who requested this search
|
|
1762
|
-
* @property {typeof QueryType|string} [searchEngine=
|
|
1997
|
+
* @property {typeof QueryType|string} [searchEngine='auto'] The query search engine, can be extractor name to target specific one (custom)
|
|
1763
1998
|
* @property {string[]} [blockExtractors[]] List of the extractors to block
|
|
1764
1999
|
* @property {boolean} [ignoreCache] If it should ignore query cache lookup
|
|
2000
|
+
* @property {SearchQueryType} [fallbackSearchEngine='autoSearch'] Fallback search engine to use
|
|
1765
2001
|
*/
|
|
1766
2002
|
interface SearchOptions {
|
|
1767
2003
|
requestedBy?: UserResolvable;
|
|
1768
2004
|
searchEngine?: SearchQueryType | QueryExtractorSearch;
|
|
1769
2005
|
blockExtractors?: string[];
|
|
1770
2006
|
ignoreCache?: boolean;
|
|
2007
|
+
fallbackSearchEngine?: (typeof QueryType)[keyof typeof QueryType];
|
|
1771
2008
|
}
|
|
1772
2009
|
/**
|
|
1773
2010
|
* The queue repeat mode. This can be one of:
|
|
@@ -2001,6 +2238,7 @@ declare class TypeUtil {
|
|
|
2001
2238
|
static isBoolean(t: unknown): t is boolean;
|
|
2002
2239
|
static isNullish(t: unknown): t is null | undefined;
|
|
2003
2240
|
static isArray(t: unknown): t is unknown[];
|
|
2241
|
+
static isError(t: unknown): t is Error;
|
|
2004
2242
|
}
|
|
2005
2243
|
|
|
2006
2244
|
declare class QueryResolver {
|
|
@@ -2022,9 +2260,8 @@ declare class QueryResolver {
|
|
|
2022
2260
|
/**
|
|
2023
2261
|
* Resolves the given search query
|
|
2024
2262
|
* @param {string} query The query
|
|
2025
|
-
* @returns {QueryType}
|
|
2026
2263
|
*/
|
|
2027
|
-
static resolve(query: string): (typeof QueryType)[keyof typeof QueryType];
|
|
2264
|
+
static resolve(query: string, fallbackSearchEngine?: (typeof QueryType)[keyof typeof QueryType]): (typeof QueryType)[keyof typeof QueryType];
|
|
2028
2265
|
/**
|
|
2029
2266
|
* Parses vimeo id from url
|
|
2030
2267
|
* @param {string} query The query
|
|
@@ -2043,7 +2280,8 @@ declare function useQueue<Meta = unknown>(node: NodeResolvable): GuildQueue<Meta
|
|
|
2043
2280
|
|
|
2044
2281
|
declare function useMasterPlayer(): Player | null;
|
|
2045
2282
|
|
|
2046
|
-
|
|
2283
|
+
type SetterFN<T, P> = (previous: P) => T;
|
|
2284
|
+
declare function useMetadata<T = unknown>(node: NodeResolvable): readonly [() => T, (metadata: T | SetterFN<T, T>) => void];
|
|
2047
2285
|
|
|
2048
2286
|
interface TimelineDispatcherOptions {
|
|
2049
2287
|
ignoreFilters: boolean;
|
|
@@ -2064,4 +2302,4 @@ declare function onBeforeCreateStream(handler: OnBeforeCreateStreamHandler): voi
|
|
|
2064
2302
|
|
|
2065
2303
|
declare const version: string;
|
|
2066
2304
|
|
|
2067
|
-
export { AFilterGraph, AudioFilters, BaseExtractor, DiscordPlayerQueryResultCache, EqualizerConfigurationPreset, ErrorStatusCode, 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, NextFunction, NodeResolvable, OnAfterCreateStreamHandler, OnBeforeCreateStreamHandler, PlayOptions, Player, PlayerError, PlayerEvent, PlayerEvents, PlayerEventsEmitter, PlayerInitOptions, PlayerNodeInitializationResult, PlayerProgressbarOptions, PlayerSearchResult, PlayerTimestamp, PlayerTriggeredReason, Playlist, PlaylistInitData, PlaylistJSON, PostProcessedResult, QueryCache, QueryCacheOptions, QueryCacheResolverContext, QueryExtractorSearch, QueryResolver, QueryType, QueueFilters, QueueRepeatMode, RawTrackData, RawTrackInit, ResourcePlayOptions, SearchOptions, SearchQueryType, SearchResult, SearchResultData, StreamDispatcher, TimeData, TimelineDispatcherOptions, Track, TrackJSON, TrackResolvable, TrackSource, TypeUtil, Util, VoiceConnectConfig, VoiceEvents, VoiceReceiverNode, VoiceReceiverOptions, VoiceUtils, createFFmpegStream, onAfterCreateStream, onBeforeCreateStream, useHistory, useMasterPlayer, useMetadata, usePlayer, useQueue, useTimeline, version };
|
|
2305
|
+
export { AFilterGraph, AsyncQueue, AsyncQueueAcquisitionOptions, AsyncQueueEntry, AudioFilters, BaseExtractor, DiscordPlayerQueryResultCache, EqualizerConfigurationPreset, ErrorStatusCode, 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, NextFunction, NodeResolvable, OnAfterCreateStreamHandler, OnBeforeCreateStreamHandler, PlayOptions, Player, PlayerError, PlayerEvent, PlayerEvents, PlayerEventsEmitter, PlayerInitOptions, PlayerNodeInitializationResult, PlayerProgressbarOptions, PlayerSearchResult, PlayerTimestamp, PlayerTriggeredReason, Playlist, PlaylistInitData, PlaylistJSON, PostProcessedResult, QueryCache, QueryCacheOptions, QueryCacheResolverContext, QueryExtractorSearch, QueryResolver, QueryType, QueueFilters, QueueRepeatMode, RawTrackData, RawTrackInit, ResourcePlayOptions, SearchOptions, SearchQueryType, SearchResult, SearchResultData, StreamDispatcher, TimeData, TimelineDispatcherOptions, Track, TrackJSON, TrackResolvable, TrackSource, TypeUtil, Util, VoiceConnectConfig, VoiceEvents, VoiceReceiverNode, VoiceReceiverOptions, VoiceUtils, createFFmpegStream, onAfterCreateStream, onBeforeCreateStream, useHistory, useMasterPlayer, useMetadata, usePlayer, useQueue, useTimeline, version };
|