discord-player 6.0.0-dev.3 → 6.0.0-dev.5
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/dist/index.d.ts +310 -101
- package/dist/index.js +503 -208
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +460 -171
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ListenerSignature, DefaultListener, EventEmitter, Collection, Queue, QueueStrategy } from '@discord-player/utils';
|
|
2
|
+
import * as discord_js from 'discord.js';
|
|
3
|
+
import { User, VoiceChannel, StageChannel, UserResolvable, Guild, VoiceState, VoiceBasedChannel, GuildVoiceChannelResolvable, Snowflake, Client, GuildResolvable } from 'discord.js';
|
|
2
4
|
import * as _discordjs_voice from '@discordjs/voice';
|
|
3
|
-
import { AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, AudioPlayerStatus, StreamType } from '@discordjs/voice';
|
|
5
|
+
import { AudioPlayerError, AudioResource, VoiceConnection, AudioPlayer, AudioPlayerStatus, StreamType, EndBehaviorType } from '@discordjs/voice';
|
|
6
|
+
import { Readable, Duplex } from 'stream';
|
|
4
7
|
import * as _discord_player_equalizer from '@discord-player/equalizer';
|
|
5
8
|
import { PCMFilters, EqualizerBand, BiquadFilters, FiltersChain } from '@discord-player/equalizer';
|
|
6
9
|
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
|
-
import {
|
|
8
|
-
import { Readable, Duplex } from 'stream';
|
|
9
|
-
import Fuse from 'fuse.js';
|
|
10
|
+
import { RequestOptions } from 'http';
|
|
10
11
|
import { downloadOptions } from 'ytdl-core';
|
|
11
12
|
|
|
13
|
+
declare class PlayerEventsEmitter<L extends ListenerSignature<L> = DefaultListener> extends EventEmitter<L> {
|
|
14
|
+
requiredEvents: Array<keyof L>;
|
|
15
|
+
constructor(requiredEvents?: Array<keyof L>);
|
|
16
|
+
emit<K extends keyof L>(name: K, ...args: Parameters<L[K]>): boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
declare class Playlist {
|
|
13
20
|
readonly player: Player;
|
|
14
21
|
tracks: Track[];
|
|
@@ -31,6 +38,14 @@ declare class Playlist {
|
|
|
31
38
|
*/
|
|
32
39
|
constructor(player: Player, data: PlaylistInitData);
|
|
33
40
|
[Symbol.iterator](): Generator<Track, void, undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Estimated duration of this playlist
|
|
43
|
+
*/
|
|
44
|
+
get estimatedDuration(): number;
|
|
45
|
+
/**
|
|
46
|
+
* Formatted estimated duration of this playlist
|
|
47
|
+
*/
|
|
48
|
+
get durationFormatted(): string;
|
|
34
49
|
/**
|
|
35
50
|
* JSON representation of this playlist
|
|
36
51
|
* @param {boolean} [withTracks=true] If it should build json with tracks
|
|
@@ -39,6 +54,104 @@ declare class Playlist {
|
|
|
39
54
|
toJSON(withTracks?: boolean): PlaylistJSON;
|
|
40
55
|
}
|
|
41
56
|
|
|
57
|
+
declare class ExtractorExecutionContext {
|
|
58
|
+
player: Player;
|
|
59
|
+
store: Collection<string, BaseExtractor>;
|
|
60
|
+
constructor(player: Player);
|
|
61
|
+
loadDefault(): Promise<{
|
|
62
|
+
success: boolean;
|
|
63
|
+
error: Error;
|
|
64
|
+
} | {
|
|
65
|
+
success: boolean;
|
|
66
|
+
error: null;
|
|
67
|
+
}>;
|
|
68
|
+
isRegistered(identifier: string): boolean;
|
|
69
|
+
get size(): number;
|
|
70
|
+
get(identifier: string): BaseExtractor | undefined;
|
|
71
|
+
register(_extractor: typeof BaseExtractor): Promise<void>;
|
|
72
|
+
unregister<K extends string | BaseExtractor>(_extractor: K): Promise<void>;
|
|
73
|
+
unregisterAll(): Promise<void>;
|
|
74
|
+
run<T = unknown>(fn: ExtractorExecutionFN<T>, filterBlocked?: boolean): Promise<ExtractorExecutionResult<T> | null>;
|
|
75
|
+
}
|
|
76
|
+
interface ExtractorExecutionResult<T = unknown> {
|
|
77
|
+
extractor: BaseExtractor;
|
|
78
|
+
result: T;
|
|
79
|
+
}
|
|
80
|
+
type ExtractorExecutionFN<T = unknown> = (extractor: BaseExtractor) => Promise<T | boolean>;
|
|
81
|
+
|
|
82
|
+
declare class BaseExtractor {
|
|
83
|
+
context: ExtractorExecutionContext;
|
|
84
|
+
/**
|
|
85
|
+
* Identifier for this extractor
|
|
86
|
+
*/
|
|
87
|
+
static identifier: string;
|
|
88
|
+
/**
|
|
89
|
+
* Extractor constructor
|
|
90
|
+
* @param context Context that instantiated this extractor
|
|
91
|
+
*/
|
|
92
|
+
constructor(context: ExtractorExecutionContext);
|
|
93
|
+
/**
|
|
94
|
+
* Identifier of this extractor
|
|
95
|
+
*/
|
|
96
|
+
get identifier(): string;
|
|
97
|
+
/**
|
|
98
|
+
* This method will be executed when this extractor is activated
|
|
99
|
+
*/
|
|
100
|
+
activate(): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* This method will be executed when this extractor is deactivated
|
|
103
|
+
*/
|
|
104
|
+
deactivate(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Validate incoming query
|
|
107
|
+
* @param query The query to validate
|
|
108
|
+
*/
|
|
109
|
+
validate(query: string, type?: SearchQueryType | null): Promise<boolean>;
|
|
110
|
+
/**
|
|
111
|
+
* Stream the given track
|
|
112
|
+
* @param info The track to stream
|
|
113
|
+
*/
|
|
114
|
+
stream(info: Track): Promise<Readable | string>;
|
|
115
|
+
/**
|
|
116
|
+
* Handle the given query
|
|
117
|
+
* @param query The query to handle
|
|
118
|
+
*/
|
|
119
|
+
handle(query: string, context: ExtractorSearchContext): Promise<ExtractorInfo>;
|
|
120
|
+
/**
|
|
121
|
+
* A stream middleware to handle streams before passing it to the player
|
|
122
|
+
* @param stream The incoming stream
|
|
123
|
+
* @param next The next function
|
|
124
|
+
*/
|
|
125
|
+
handlePostStream(stream: Readable, next: NextFunction): void;
|
|
126
|
+
/**
|
|
127
|
+
* Dispatch an event to the player
|
|
128
|
+
* @param event The event to dispatch
|
|
129
|
+
* @param args The data to dispatch
|
|
130
|
+
*/
|
|
131
|
+
emit<K extends keyof PlayerEvents>(event: K, ...args: Parameters<PlayerEvents[K]>): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Create extractor response
|
|
134
|
+
* @param playlist The playlist
|
|
135
|
+
* @param tracks The track array
|
|
136
|
+
*/
|
|
137
|
+
createResponse(playlist?: Playlist | null, tracks?: Track[]): ExtractorInfo;
|
|
138
|
+
/**
|
|
139
|
+
* Write debug message
|
|
140
|
+
* @param message The debug message
|
|
141
|
+
*/
|
|
142
|
+
debug(message: string): boolean;
|
|
143
|
+
}
|
|
144
|
+
type NextFunction = (error?: Error | null, stream?: Readable) => void;
|
|
145
|
+
interface ExtractorInfo {
|
|
146
|
+
playlist: Playlist | null;
|
|
147
|
+
tracks: Track[];
|
|
148
|
+
}
|
|
149
|
+
interface ExtractorSearchContext {
|
|
150
|
+
type?: SearchQueryType | null;
|
|
151
|
+
requestedBy?: User | null;
|
|
152
|
+
requestOptions?: RequestOptions;
|
|
153
|
+
}
|
|
154
|
+
|
|
42
155
|
type TrackResolvable = Track | string | number;
|
|
43
156
|
declare class Track {
|
|
44
157
|
player: Player;
|
|
@@ -52,7 +165,8 @@ declare class Track {
|
|
|
52
165
|
requestedBy: User | null;
|
|
53
166
|
playlist?: Playlist;
|
|
54
167
|
queryType: SearchQueryType | null | undefined;
|
|
55
|
-
|
|
168
|
+
raw: RawTrackData;
|
|
169
|
+
extractor: BaseExtractor | null;
|
|
56
170
|
readonly id: string;
|
|
57
171
|
/**
|
|
58
172
|
* Track constructor
|
|
@@ -118,6 +232,7 @@ declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
|
118
232
|
readonly connectionTimeout: number;
|
|
119
233
|
readonly voiceConnection: VoiceConnection;
|
|
120
234
|
readonly audioPlayer: AudioPlayer;
|
|
235
|
+
receiver: VoiceReceiverNode;
|
|
121
236
|
channel: VoiceChannel | StageChannel;
|
|
122
237
|
audioResource?: AudioResource<Track> | null;
|
|
123
238
|
private readyLock;
|
|
@@ -150,6 +265,26 @@ declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
|
150
265
|
* Whether or not the player is currently idle
|
|
151
266
|
*/
|
|
152
267
|
isIdle(): boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Whether or not the voice connection has been destroyed
|
|
270
|
+
*/
|
|
271
|
+
isDestroyed(): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Whether or not the voice connection has been destroyed
|
|
274
|
+
*/
|
|
275
|
+
isDisconnected(): boolean;
|
|
276
|
+
/**
|
|
277
|
+
* Whether or not the voice connection is ready to play
|
|
278
|
+
*/
|
|
279
|
+
isReady(): boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Whether or not the voice connection is signalling
|
|
282
|
+
*/
|
|
283
|
+
isSignalling(): boolean;
|
|
284
|
+
/**
|
|
285
|
+
* Whether or not the voice connection is connecting
|
|
286
|
+
*/
|
|
287
|
+
isConnecting(): boolean;
|
|
153
288
|
/**
|
|
154
289
|
* Creates stream
|
|
155
290
|
* @param {Readable} src The stream source
|
|
@@ -211,6 +346,30 @@ declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
|
211
346
|
get streamTime(): number;
|
|
212
347
|
}
|
|
213
348
|
|
|
349
|
+
interface VoiceReceiverOptions {
|
|
350
|
+
mode?: 'opus' | 'pcm';
|
|
351
|
+
end?: EndBehaviorType;
|
|
352
|
+
silenceDuration?: number;
|
|
353
|
+
crc?: boolean;
|
|
354
|
+
}
|
|
355
|
+
type RawTrackInit = Partial<Omit<RawTrackData, 'author' | 'playlist' | 'source' | 'engine' | 'raw' | 'queryType' | 'description' | 'views'>>;
|
|
356
|
+
declare class VoiceReceiverNode {
|
|
357
|
+
dispatcher: StreamDispatcher;
|
|
358
|
+
constructor(dispatcher: StreamDispatcher);
|
|
359
|
+
createRawTrack(stream: Readable, data?: RawTrackInit): Track;
|
|
360
|
+
/**
|
|
361
|
+
* Merge multiple streams together
|
|
362
|
+
* @param streams The array of streams to merge
|
|
363
|
+
*/
|
|
364
|
+
mergeRecordings(streams: Readable[]): void;
|
|
365
|
+
/**
|
|
366
|
+
* Record a user in voice channel
|
|
367
|
+
* @param user The user to record
|
|
368
|
+
* @param options Recording options
|
|
369
|
+
*/
|
|
370
|
+
recordUser(user: UserResolvable, options?: VoiceReceiverOptions): Readable;
|
|
371
|
+
}
|
|
372
|
+
|
|
214
373
|
declare class GuildQueueHistory<Meta = unknown> {
|
|
215
374
|
queue: GuildQueue<Meta>;
|
|
216
375
|
tracks: Queue<Track>;
|
|
@@ -231,6 +390,11 @@ declare class GuildQueueHistory<Meta = unknown> {
|
|
|
231
390
|
* If history is disabled
|
|
232
391
|
*/
|
|
233
392
|
get disabled(): boolean;
|
|
393
|
+
/**
|
|
394
|
+
* Gets the size of the queue
|
|
395
|
+
*/
|
|
396
|
+
get size(): number;
|
|
397
|
+
getSize(): number;
|
|
234
398
|
/**
|
|
235
399
|
* If history is empty
|
|
236
400
|
*/
|
|
@@ -247,11 +411,15 @@ declare class GuildQueueHistory<Meta = unknown> {
|
|
|
247
411
|
/**
|
|
248
412
|
* Play the next track in the queue
|
|
249
413
|
*/
|
|
250
|
-
next(): void
|
|
414
|
+
next(): Promise<void>;
|
|
251
415
|
/**
|
|
252
416
|
* Play the previous track in the queue
|
|
253
417
|
*/
|
|
254
|
-
previous(): void
|
|
418
|
+
previous(preserveCurrent?: boolean): Promise<void>;
|
|
419
|
+
/**
|
|
420
|
+
* Alias to [GuildQueueHistory].previous()
|
|
421
|
+
*/
|
|
422
|
+
back(): Promise<void>;
|
|
255
423
|
}
|
|
256
424
|
|
|
257
425
|
declare const FFMPEG_SRATE_REGEX: RegExp;
|
|
@@ -392,6 +560,11 @@ declare class GuildQueuePlayerNode<Meta = unknown> {
|
|
|
392
560
|
* @param force Whether or not to forcefully stop the playback
|
|
393
561
|
*/
|
|
394
562
|
stop(force?: boolean): boolean;
|
|
563
|
+
/**
|
|
564
|
+
* Play raw audio resource
|
|
565
|
+
* @param resource The audio resource to play
|
|
566
|
+
*/
|
|
567
|
+
playRaw(resource: AudioResource): Promise<void>;
|
|
395
568
|
/**
|
|
396
569
|
* Play the given track
|
|
397
570
|
* @param res The track to play
|
|
@@ -631,6 +804,18 @@ interface GuildQueueEvents<Meta = unknown> {
|
|
|
631
804
|
* @param tracks The tracks array
|
|
632
805
|
*/
|
|
633
806
|
audioTracksAdd: (queue: GuildQueue<Meta>, track: Track[]) => unknown;
|
|
807
|
+
/**
|
|
808
|
+
* Emitted when audio track is removed from the queue
|
|
809
|
+
* @param queue The queue where this event occurred
|
|
810
|
+
* @param track The track
|
|
811
|
+
*/
|
|
812
|
+
audioTrackRemove: (queue: GuildQueue<Meta>, track: Track) => unknown;
|
|
813
|
+
/**
|
|
814
|
+
* Emitted when audio tracks are removed from the queue
|
|
815
|
+
* @param queue The queue where this event occurred
|
|
816
|
+
* @param track The track
|
|
817
|
+
*/
|
|
818
|
+
audioTracksRemove: (queue: GuildQueue<Meta>, track: Track[]) => unknown;
|
|
634
819
|
/**
|
|
635
820
|
* Emitted when a connection is created
|
|
636
821
|
* @param queue The queue where this event occurred
|
|
@@ -718,6 +903,18 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
718
903
|
timeouts: Collection<string, NodeJS.Timeout>;
|
|
719
904
|
stats: GuildQueueStatistics<Meta>;
|
|
720
905
|
constructor(player: Player, options: GuildNodeInit<Meta>);
|
|
906
|
+
/**
|
|
907
|
+
* Estimated duration of this queue in ms
|
|
908
|
+
*/
|
|
909
|
+
get estimatedDuration(): number;
|
|
910
|
+
/**
|
|
911
|
+
* Formatted duration of this queue
|
|
912
|
+
*/
|
|
913
|
+
get durationFormatted(): string;
|
|
914
|
+
/**
|
|
915
|
+
* The voice receiver for this queue
|
|
916
|
+
*/
|
|
917
|
+
get voiceReceiver(): VoiceReceiverNode | null;
|
|
721
918
|
/**
|
|
722
919
|
* Write a debug message to this queue
|
|
723
920
|
* @param m The message to write
|
|
@@ -777,6 +974,18 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
777
974
|
* @param mode The repeat mode to apply
|
|
778
975
|
*/
|
|
779
976
|
setRepeatMode(mode: QueueRepeatMode): void;
|
|
977
|
+
/**
|
|
978
|
+
* Gets the size of the queue
|
|
979
|
+
*/
|
|
980
|
+
get size(): number;
|
|
981
|
+
/**
|
|
982
|
+
* The size of this queue
|
|
983
|
+
*/
|
|
984
|
+
getSize(): number;
|
|
985
|
+
/**
|
|
986
|
+
* Clear this queue
|
|
987
|
+
*/
|
|
988
|
+
clear(): void;
|
|
780
989
|
/**
|
|
781
990
|
* Check if this queue has no tracks left in it
|
|
782
991
|
*/
|
|
@@ -786,10 +995,21 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
786
995
|
*/
|
|
787
996
|
isPlaying(): boolean;
|
|
788
997
|
/**
|
|
789
|
-
* Add track to the queue
|
|
998
|
+
* Add track to the queue. This will emit `audioTracksAdd` when multiple tracks are added, otherwise `audioTrackAdd`.
|
|
790
999
|
* @param track Track or playlist or array of tracks to add
|
|
791
1000
|
*/
|
|
792
1001
|
addTrack(track: Track | Track[] | Playlist): void;
|
|
1002
|
+
/**
|
|
1003
|
+
* Remove a track from queue
|
|
1004
|
+
* @param track The track to remove
|
|
1005
|
+
*/
|
|
1006
|
+
removeTrack(track: TrackResolvable): Track | null;
|
|
1007
|
+
/**
|
|
1008
|
+
* Inserts the track to the given index
|
|
1009
|
+
* @param track The track to insert
|
|
1010
|
+
* @param index The index to insert the track at (defaults to 0)
|
|
1011
|
+
*/
|
|
1012
|
+
insertTrack(track: Track, index?: number): void;
|
|
793
1013
|
/**
|
|
794
1014
|
* Connect to a voice channel
|
|
795
1015
|
* @param channelResolvable The voice channel to connect to
|
|
@@ -804,10 +1024,27 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
804
1024
|
* Delete this queue
|
|
805
1025
|
*/
|
|
806
1026
|
delete(): void;
|
|
1027
|
+
/**
|
|
1028
|
+
* Revives this queue
|
|
1029
|
+
* @returns
|
|
1030
|
+
*/
|
|
1031
|
+
revive(): void;
|
|
807
1032
|
/**
|
|
808
1033
|
* Wait for this queue to initialize
|
|
809
1034
|
*/
|
|
810
1035
|
awaitInitialization(): Promise<boolean>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Set self deaf
|
|
1038
|
+
* @param mode On/Off state
|
|
1039
|
+
* @param reason Reason
|
|
1040
|
+
*/
|
|
1041
|
+
setSelfDeaf(mode?: boolean, reason?: string): Promise<discord_js.GuildMember>;
|
|
1042
|
+
/**
|
|
1043
|
+
* Set self mute
|
|
1044
|
+
* @param mode On/Off state
|
|
1045
|
+
* @param reason Reason
|
|
1046
|
+
*/
|
|
1047
|
+
setSelfMute(mode?: boolean, reason?: string): Promise<discord_js.GuildMember>;
|
|
811
1048
|
}
|
|
812
1049
|
|
|
813
1050
|
interface GuildQueueStatisticsMetadata {
|
|
@@ -882,91 +1119,6 @@ declare class VoiceUtils {
|
|
|
882
1119
|
getConnection(guild: Snowflake): StreamDispatcher | VoiceConnection | undefined;
|
|
883
1120
|
}
|
|
884
1121
|
|
|
885
|
-
declare class BaseExtractor {
|
|
886
|
-
context: ExtractorExecutionContext;
|
|
887
|
-
/**
|
|
888
|
-
* Identifier for this extractor
|
|
889
|
-
*/
|
|
890
|
-
static identifier: string;
|
|
891
|
-
/**
|
|
892
|
-
* Extractor constructor
|
|
893
|
-
* @param context Context that instantiated this extractor
|
|
894
|
-
*/
|
|
895
|
-
constructor(context: ExtractorExecutionContext);
|
|
896
|
-
/**
|
|
897
|
-
* Identifier of this extractor
|
|
898
|
-
*/
|
|
899
|
-
get identifier(): string;
|
|
900
|
-
/**
|
|
901
|
-
* This method will be executed when this extractor is activated
|
|
902
|
-
*/
|
|
903
|
-
activate(): Promise<void>;
|
|
904
|
-
/**
|
|
905
|
-
* This method will be executed when this extractor is deactivated
|
|
906
|
-
*/
|
|
907
|
-
deactivate(): Promise<void>;
|
|
908
|
-
/**
|
|
909
|
-
* Validate incoming query
|
|
910
|
-
* @param query The query to validate
|
|
911
|
-
*/
|
|
912
|
-
validate(query: string, type?: SearchQueryType | null): Promise<boolean>;
|
|
913
|
-
/**
|
|
914
|
-
* Stream the given track
|
|
915
|
-
* @param info The track to stream
|
|
916
|
-
*/
|
|
917
|
-
stream(info: Track): Promise<Readable | string>;
|
|
918
|
-
/**
|
|
919
|
-
* Handle the given query
|
|
920
|
-
* @param query The query to handle
|
|
921
|
-
*/
|
|
922
|
-
handle(query: string, context: ExtractorSearchContext): Promise<ExtractorInfo>;
|
|
923
|
-
/**
|
|
924
|
-
* A stream middleware to handle streams before passing it to the player
|
|
925
|
-
* @param stream The incoming stream
|
|
926
|
-
* @param next The next function
|
|
927
|
-
*/
|
|
928
|
-
handlePostStream(stream: Readable, next: NextFunction): void;
|
|
929
|
-
/**
|
|
930
|
-
* Dispatch an event to the player
|
|
931
|
-
* @param event The event to dispatch
|
|
932
|
-
* @param args The data to dispatch
|
|
933
|
-
*/
|
|
934
|
-
emit<K extends keyof PlayerEvents>(event: K, ...args: Parameters<PlayerEvents[K]>): boolean;
|
|
935
|
-
/**
|
|
936
|
-
* Create extractor response
|
|
937
|
-
* @param playlist The playlist
|
|
938
|
-
* @param tracks The track array
|
|
939
|
-
*/
|
|
940
|
-
createResponse(playlist?: Playlist | null, tracks?: Track[]): ExtractorInfo;
|
|
941
|
-
}
|
|
942
|
-
type NextFunction = (error?: Error | null, stream?: Readable) => void;
|
|
943
|
-
interface ExtractorInfo {
|
|
944
|
-
playlist: Playlist | null;
|
|
945
|
-
tracks: Track[];
|
|
946
|
-
}
|
|
947
|
-
interface ExtractorSearchContext {
|
|
948
|
-
type?: SearchQueryType | null;
|
|
949
|
-
requestedBy?: User | null;
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
declare class ExtractorExecutionContext {
|
|
953
|
-
player: Player;
|
|
954
|
-
store: Collection<string, BaseExtractor>;
|
|
955
|
-
constructor(player: Player);
|
|
956
|
-
isRegistered(identifier: string): boolean;
|
|
957
|
-
get size(): number;
|
|
958
|
-
get(identifier: string): BaseExtractor | undefined;
|
|
959
|
-
register(_extractor: typeof BaseExtractor): Promise<void>;
|
|
960
|
-
unregister<K extends string | BaseExtractor>(_extractor: K): Promise<void>;
|
|
961
|
-
unregisterAll(): Promise<void>;
|
|
962
|
-
run<T = unknown>(fn: ExtractorExecutionFN<T>, filterBlocked?: boolean): Promise<ExtractorExecutionResult<T> | null>;
|
|
963
|
-
}
|
|
964
|
-
interface ExtractorExecutionResult<T = unknown> {
|
|
965
|
-
extractor: BaseExtractor;
|
|
966
|
-
result: T;
|
|
967
|
-
}
|
|
968
|
-
type ExtractorExecutionFN<T = unknown> = (extractor: BaseExtractor) => Promise<T | boolean>;
|
|
969
|
-
|
|
970
1122
|
interface SearchResultData {
|
|
971
1123
|
query: string;
|
|
972
1124
|
queryType?: SearchQueryType | QueryExtractorSearch | null;
|
|
@@ -979,6 +1131,12 @@ declare class SearchResult {
|
|
|
979
1131
|
player: Player;
|
|
980
1132
|
private _data;
|
|
981
1133
|
constructor(player: Player, _data: SearchResultData);
|
|
1134
|
+
setQueryType(type: SearchQueryType | QueryExtractorSearch): this;
|
|
1135
|
+
setRequestedBy(user: User): this;
|
|
1136
|
+
setExtractor(extractor: BaseExtractor): this;
|
|
1137
|
+
setTracks(tracks: Track[]): this;
|
|
1138
|
+
setQuery(query: string): this;
|
|
1139
|
+
setPlaylist(playlist: Playlist): this;
|
|
982
1140
|
/**
|
|
983
1141
|
* The search query
|
|
984
1142
|
*/
|
|
@@ -1040,7 +1198,6 @@ declare class QueryCache {
|
|
|
1040
1198
|
player: Player;
|
|
1041
1199
|
options: QueryCacheOptions;
|
|
1042
1200
|
timer: NodeJS.Timer;
|
|
1043
|
-
fuse: Fuse<Track>;
|
|
1044
1201
|
constructor(player: Player, options?: QueryCacheOptions);
|
|
1045
1202
|
get checkInterval(): number;
|
|
1046
1203
|
cleanup(): Promise<void>;
|
|
@@ -1061,7 +1218,7 @@ interface QueryCacheResolverContext {
|
|
|
1061
1218
|
queryType?: SearchQueryType | `ext:${string}`;
|
|
1062
1219
|
}
|
|
1063
1220
|
|
|
1064
|
-
declare class Player extends
|
|
1221
|
+
declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
1065
1222
|
#private;
|
|
1066
1223
|
static _singletonKey: symbol;
|
|
1067
1224
|
readonly id: string;
|
|
@@ -1069,15 +1226,15 @@ declare class Player extends EventEmitter<PlayerEvents> {
|
|
|
1069
1226
|
readonly options: PlayerInitOptions;
|
|
1070
1227
|
nodes: GuildNodeManager<unknown>;
|
|
1071
1228
|
readonly voiceUtils: VoiceUtils;
|
|
1072
|
-
requiredEvents: string[];
|
|
1073
1229
|
extractors: ExtractorExecutionContext;
|
|
1074
|
-
events:
|
|
1230
|
+
events: PlayerEventsEmitter<GuildQueueEvents<unknown>>;
|
|
1075
1231
|
/**
|
|
1076
1232
|
* Creates new Discord Player
|
|
1077
1233
|
* @param {Client} client The Discord Client
|
|
1078
1234
|
* @param {PlayerInitOptions} [options] The player init options
|
|
1079
1235
|
*/
|
|
1080
1236
|
constructor(client: Client, options?: PlayerInitOptions);
|
|
1237
|
+
debug(m: string): boolean;
|
|
1081
1238
|
/**
|
|
1082
1239
|
* Creates discord-player singleton instance.
|
|
1083
1240
|
* @param client The client that instantiated player
|
|
@@ -1170,7 +1327,6 @@ declare class Player extends EventEmitter<PlayerEvents> {
|
|
|
1170
1327
|
* @returns {string}
|
|
1171
1328
|
*/
|
|
1172
1329
|
scanDeps(): string;
|
|
1173
|
-
emit<U extends keyof PlayerEvents>(eventName: U, ...args: Parameters<PlayerEvents[U]>): boolean;
|
|
1174
1330
|
[Symbol.iterator](): Generator<GuildQueue<unknown>, void, undefined>;
|
|
1175
1331
|
/**
|
|
1176
1332
|
* Creates `Playlist` instance
|
|
@@ -1576,6 +1732,7 @@ interface PlaylistJSON {
|
|
|
1576
1732
|
* @property {string[]} [blockExtractors] List of extractors to disable querying metadata from
|
|
1577
1733
|
* @property {string[]} [blockStreamFrom] List of extractors to disable streaming from
|
|
1578
1734
|
* @property {QueryCache | null} [queryCache] Query cache provider
|
|
1735
|
+
* @property {boolean} [ignoreInstance] Ignore player instance
|
|
1579
1736
|
*/
|
|
1580
1737
|
interface PlayerInitOptions {
|
|
1581
1738
|
autoRegisterExtractor?: boolean;
|
|
@@ -1587,6 +1744,7 @@ interface PlayerInitOptions {
|
|
|
1587
1744
|
blockExtractors?: string[];
|
|
1588
1745
|
blockStreamFrom?: string[];
|
|
1589
1746
|
queryCache?: QueryCache | null;
|
|
1747
|
+
ignoreInstance?: boolean;
|
|
1590
1748
|
}
|
|
1591
1749
|
|
|
1592
1750
|
declare class AudioFilters {
|
|
@@ -1663,7 +1821,20 @@ declare class Util {
|
|
|
1663
1821
|
* @param {string} id Node require id
|
|
1664
1822
|
* @returns {any}
|
|
1665
1823
|
*/
|
|
1666
|
-
static require(id: string):
|
|
1824
|
+
static require(id: string): {
|
|
1825
|
+
module: any;
|
|
1826
|
+
error: null;
|
|
1827
|
+
} | {
|
|
1828
|
+
module: null;
|
|
1829
|
+
error: unknown;
|
|
1830
|
+
};
|
|
1831
|
+
static import(id: string): Promise<{
|
|
1832
|
+
module: any;
|
|
1833
|
+
error: null;
|
|
1834
|
+
} | {
|
|
1835
|
+
module: null;
|
|
1836
|
+
error: unknown;
|
|
1837
|
+
}>;
|
|
1667
1838
|
/**
|
|
1668
1839
|
* Asynchronous timeout
|
|
1669
1840
|
* @param {number} time The time in ms to wait
|
|
@@ -1675,6 +1846,44 @@ declare class Util {
|
|
|
1675
1846
|
static warn(message: string, code?: string, detail?: string): void;
|
|
1676
1847
|
}
|
|
1677
1848
|
|
|
1849
|
+
declare class QueryResolver {
|
|
1850
|
+
/**
|
|
1851
|
+
* Query resolver
|
|
1852
|
+
*/
|
|
1853
|
+
private constructor();
|
|
1854
|
+
static get regex(): {
|
|
1855
|
+
spotifyAlbumRegex: RegExp;
|
|
1856
|
+
spotifyPlaylistRegex: RegExp;
|
|
1857
|
+
spotifySongRegex: RegExp;
|
|
1858
|
+
vimeoRegex: RegExp;
|
|
1859
|
+
reverbnationRegex: RegExp;
|
|
1860
|
+
attachmentRegex: RegExp;
|
|
1861
|
+
appleMusicAlbumRegex: RegExp;
|
|
1862
|
+
appleMusicPlaylistRegex: RegExp;
|
|
1863
|
+
appleMusicSongRegex: RegExp;
|
|
1864
|
+
};
|
|
1865
|
+
/**
|
|
1866
|
+
* Resolves the given search query
|
|
1867
|
+
* @param {string} query The query
|
|
1868
|
+
* @returns {QueryType}
|
|
1869
|
+
*/
|
|
1870
|
+
static resolve(query: string): (typeof QueryType)[keyof typeof QueryType];
|
|
1871
|
+
/**
|
|
1872
|
+
* Parses vimeo id from url
|
|
1873
|
+
* @param {string} query The query
|
|
1874
|
+
* @returns {string}
|
|
1875
|
+
*/
|
|
1876
|
+
static getVimeoID(query: string): string | null | undefined;
|
|
1877
|
+
static validateId(q: string): boolean;
|
|
1878
|
+
static validateURL(q: string): boolean;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
declare function useHistory<Meta = unknown>(node: NodeResolvable): GuildQueueHistory<Meta> | null;
|
|
1882
|
+
|
|
1883
|
+
declare function usePlayer<Meta = unknown>(node: NodeResolvable): GuildQueuePlayerNode<Meta> | null;
|
|
1884
|
+
|
|
1885
|
+
declare function useQueue<Meta = unknown>(node: NodeResolvable): GuildQueue<Meta> | null;
|
|
1886
|
+
|
|
1678
1887
|
declare const version: string;
|
|
1679
1888
|
|
|
1680
|
-
export { AFilterGraph, AudioFilters, BaseExtractor, DiscordPlayerQueryResultCache, EqualizerConfigurationPreset, ErrorStatusCode, ExtractorExecutionContext, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorSearchContext, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, FFmpegStreamOptions, FilterGraph, FiltersName, GuildNodeCreateOptions, GuildNodeInit, GuildNodeManager, GuildQueue, GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, NextFunction, NodeResolvable, OnAfterCreateStreamHandler, OnBeforeCreateStreamHandler, PlayOptions, Player, PlayerError, PlayerEvents, PlayerInitOptions, PlayerProgressbarOptions, PlayerSearchResult, PlayerTimestamp, PlayerTriggeredReason, Playlist, PlaylistInitData, PlaylistJSON, PostProcessedResult, QueryCache, QueryCacheOptions, QueryCacheResolverContext, QueryExtractorSearch, QueryType, QueueFilters, QueueRepeatMode, RawTrackData, ResourcePlayOptions, SearchOptions, SearchQueryType, SearchResult, SearchResultData, StreamDispatcher, TimeData, Track, TrackJSON, TrackResolvable, TrackSource, Util, VoiceConnectConfig, VoiceEvents, VoiceUtils, createFFmpegStream, version };
|
|
1889
|
+
export { AFilterGraph, AudioFilters, BaseExtractor, DiscordPlayerQueryResultCache, EqualizerConfigurationPreset, ErrorStatusCode, ExtractorExecutionContext, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorSearchContext, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, FFmpegStreamOptions, FilterGraph, FiltersName, GuildNodeCreateOptions, GuildNodeInit, GuildNodeManager, GuildQueue, GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, NextFunction, NodeResolvable, OnAfterCreateStreamHandler, OnBeforeCreateStreamHandler, PlayOptions, Player, PlayerError, PlayerEvents, PlayerEventsEmitter, PlayerInitOptions, 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, Track, TrackJSON, TrackResolvable, TrackSource, Util, VoiceConnectConfig, VoiceEvents, VoiceReceiverNode, VoiceReceiverOptions, VoiceUtils, createFFmpegStream, useHistory, usePlayer, useQueue, version };
|