discord-player 7.0.0 → 7.1.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/dist/index.d.ts +107 -10
- package/dist/index.js +929 -221
- package/dist/index.mjs +10 -0
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import * as discord_js from 'discord.js';
|
|
|
2
2
|
import { Client, User, UserResolvable, GuildVoiceChannelResolvable, VoiceChannel, StageChannel, Guild, VoiceState, VoiceBasedChannel, GuildResolvable, Snowflake } from 'discord.js';
|
|
3
3
|
import Eris from 'eris';
|
|
4
4
|
import { ListenerSignature, DefaultListener, EventEmitter, Collection, Queue, QueueStrategy } from '@discord-player/utils';
|
|
5
|
-
import * as stream from 'stream';
|
|
6
5
|
import { Readable, Duplex } from 'stream';
|
|
7
6
|
import * as _discord_player_equalizer from '@discord-player/equalizer';
|
|
8
7
|
import { EqualizerBand, BiquadFilters, PCMFilters, FiltersChain } from '@discord-player/equalizer';
|
|
9
8
|
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';
|
|
10
9
|
import { AudioResource, StreamType, AudioPlayerError, VoiceConnection, AudioPlayer, AudioPlayerStatus } from 'discord-voip';
|
|
11
|
-
export { AudioPlayer, CreateAudioPlayerOptions, JoinConfig, JoinVoiceChannelOptions, createAudioPlayer, getVoiceConnection, getVoiceConnections, joinVoiceChannel } from 'discord-voip';
|
|
10
|
+
export { AudioPlayer, CreateAudioPlayerOptions, JoinConfig, JoinVoiceChannelOptions, StreamType, createAudioPlayer, createAudioResource, getVoiceConnection, getVoiceConnections, joinVoiceChannel } from 'discord-voip';
|
|
11
|
+
import { Transform, Writable, TransformCallback } from 'node:stream';
|
|
12
12
|
import { RequestOptions } from 'http';
|
|
13
13
|
import { FFmpegLib } from '@discord-player/ffmpeg';
|
|
14
14
|
export * from '@discord-player/ffmpeg';
|
|
@@ -585,7 +585,7 @@ declare class Track<T = unknown> {
|
|
|
585
585
|
|
|
586
586
|
interface CreateStreamOps {
|
|
587
587
|
type?: StreamType;
|
|
588
|
-
data
|
|
588
|
+
data: Track;
|
|
589
589
|
disableVolume?: boolean;
|
|
590
590
|
disableEqualizer?: boolean;
|
|
591
591
|
disableBiquad?: boolean;
|
|
@@ -611,6 +611,7 @@ interface VoiceEvents {
|
|
|
611
611
|
destroyed: () => any;
|
|
612
612
|
}
|
|
613
613
|
declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
614
|
+
#private;
|
|
614
615
|
queue: GuildQueue;
|
|
615
616
|
readonly connectionTimeout: number;
|
|
616
617
|
voiceConnection: VoiceConnection;
|
|
@@ -672,7 +673,7 @@ declare class StreamDispatcher extends EventEmitter<VoiceEvents> {
|
|
|
672
673
|
* @param {object} [ops] Options
|
|
673
674
|
* @returns {AudioResource}
|
|
674
675
|
*/
|
|
675
|
-
createStream(src: Readable, ops
|
|
676
|
+
createStream(src: Readable, ops: CreateStreamOps): Promise<AudioResource<Track<unknown>>>;
|
|
676
677
|
get resampler(): _discord_player_equalizer.PCMResampler | null;
|
|
677
678
|
get filters(): _discord_player_equalizer.AudioFilter | null;
|
|
678
679
|
get biquad(): _discord_player_equalizer.BiquadStream | null;
|
|
@@ -1082,7 +1083,7 @@ declare function FFMPEG_ARGS_PIPED(fmt?: string): string[];
|
|
|
1082
1083
|
* @param stream The source stream
|
|
1083
1084
|
* @param options FFmpeg stream options
|
|
1084
1085
|
*/
|
|
1085
|
-
declare function createFFmpegStream(stream: Readable | Duplex | string, options?: FFmpegStreamOptions): Readable
|
|
1086
|
+
declare function createFFmpegStream(stream: Readable | Duplex | string, options?: FFmpegStreamOptions): Readable;
|
|
1086
1087
|
|
|
1087
1088
|
type Filters = keyof typeof AudioFilters.filters;
|
|
1088
1089
|
type EQPreset = {
|
|
@@ -1135,7 +1136,7 @@ declare class FFmpegFilterer<Meta = unknown> {
|
|
|
1135
1136
|
* @param source The stream source
|
|
1136
1137
|
* @param options The stream options
|
|
1137
1138
|
*/
|
|
1138
|
-
createStream(source: string | Readable, options: FFmpegStreamOptions): Readable
|
|
1139
|
+
createStream(source: string | Readable, options: FFmpegStreamOptions): Readable;
|
|
1139
1140
|
/**
|
|
1140
1141
|
* Set ffmpeg filters
|
|
1141
1142
|
* @param filters The filters
|
|
@@ -1506,6 +1507,7 @@ interface GuildNodeInit<Meta = unknown> {
|
|
|
1506
1507
|
disableBiquad: boolean;
|
|
1507
1508
|
disableResampler: boolean;
|
|
1508
1509
|
disableFallbackStream: boolean;
|
|
1510
|
+
enableStreamInterceptor: boolean;
|
|
1509
1511
|
}
|
|
1510
1512
|
interface VoiceConnectConfig {
|
|
1511
1513
|
deaf?: boolean;
|
|
@@ -1518,7 +1520,7 @@ interface PostProcessedResult {
|
|
|
1518
1520
|
type: StreamType;
|
|
1519
1521
|
}
|
|
1520
1522
|
type OnBeforeCreateStreamHandler = (track: Track, queryType: SearchQueryType, queue: GuildQueue) => Promise<Readable | null>;
|
|
1521
|
-
type OnAfterCreateStreamHandler = (stream: Readable, queue: GuildQueue) => Promise<PostProcessedResult | null>;
|
|
1523
|
+
type OnAfterCreateStreamHandler<T = unknown> = (stream: Readable, queue: GuildQueue, track: Track<T>) => Promise<PostProcessedResult | null>;
|
|
1522
1524
|
type PlayerTriggeredReason = 'filters' | 'normal';
|
|
1523
1525
|
declare const GuildQueueEvent: {
|
|
1524
1526
|
/**
|
|
@@ -1870,6 +1872,10 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1870
1872
|
tasksQueue: AsyncQueue;
|
|
1871
1873
|
syncedLyricsProvider: SyncedLyricsProvider;
|
|
1872
1874
|
constructor(player: Player, options: GuildNodeInit<Meta>);
|
|
1875
|
+
/**
|
|
1876
|
+
* Whether this queue can intercept streams
|
|
1877
|
+
*/
|
|
1878
|
+
canIntercept(): boolean;
|
|
1873
1879
|
/**
|
|
1874
1880
|
* Estimated duration of this queue in ms
|
|
1875
1881
|
*/
|
|
@@ -2139,6 +2145,7 @@ interface GuildNodeCreateOptions<T = unknown> {
|
|
|
2139
2145
|
disableBiquad?: boolean;
|
|
2140
2146
|
disableResampler?: boolean;
|
|
2141
2147
|
disableFallbackStream?: boolean;
|
|
2148
|
+
enableStreamInterceptor?: boolean;
|
|
2142
2149
|
}
|
|
2143
2150
|
type NodeResolvable = GuildQueue | GuildResolvable;
|
|
2144
2151
|
declare class GuildNodeManager<Meta = unknown> {
|
|
@@ -2311,7 +2318,10 @@ declare function useQueue<Meta = unknown>(node: NodeResolvable): GuildQueue<Meta
|
|
|
2311
2318
|
declare function useMainPlayer(): Player;
|
|
2312
2319
|
|
|
2313
2320
|
type SetterFN$1<T, P> = (previous: P) => T;
|
|
2314
|
-
type MetadataDispatch<T> = readonly [
|
|
2321
|
+
type MetadataDispatch<T> = readonly [
|
|
2322
|
+
() => T,
|
|
2323
|
+
(metadata: T | SetterFN$1<T, T>) => void
|
|
2324
|
+
];
|
|
2315
2325
|
/**
|
|
2316
2326
|
* Fetch or manipulate guild queue metadata
|
|
2317
2327
|
* @param node Guild queue node resolvable
|
|
@@ -2353,7 +2363,10 @@ declare function onAfterCreateStream(handler: OnAfterCreateStreamHandler): void;
|
|
|
2353
2363
|
declare function onBeforeCreateStream(handler: OnBeforeCreateStreamHandler): void;
|
|
2354
2364
|
|
|
2355
2365
|
type SetterFN = (previous: number) => number;
|
|
2356
|
-
type VolumeDispatch = readonly [
|
|
2366
|
+
type VolumeDispatch = readonly [
|
|
2367
|
+
() => number,
|
|
2368
|
+
(volume: number | SetterFN) => boolean | undefined
|
|
2369
|
+
];
|
|
2357
2370
|
/**
|
|
2358
2371
|
* Fetch or manipulate player volume
|
|
2359
2372
|
* @param node Guild queue node resolvable
|
|
@@ -2535,6 +2548,80 @@ interface HooksCtx {
|
|
|
2535
2548
|
guild: Guild;
|
|
2536
2549
|
}
|
|
2537
2550
|
|
|
2551
|
+
/**
|
|
2552
|
+
* Represents a stream that can be intercepted and consumed without affecting the original consumer.
|
|
2553
|
+
* @example const stream = new InterceptedStream();
|
|
2554
|
+
*
|
|
2555
|
+
* // real consumer
|
|
2556
|
+
* stream.pipe(fs.createWriteStream('file.txt'));
|
|
2557
|
+
*
|
|
2558
|
+
* // man in the middle consumer
|
|
2559
|
+
* const manInTheMiddle = new Writable({
|
|
2560
|
+
* write(chunk, encoding, callback) {
|
|
2561
|
+
* console.log(chunk.toString());
|
|
2562
|
+
* callback();
|
|
2563
|
+
* }
|
|
2564
|
+
* });
|
|
2565
|
+
*
|
|
2566
|
+
* // stream.interceptors is a Set of Writable streams
|
|
2567
|
+
* stream.interceptors.add(manInTheMiddle);
|
|
2568
|
+
*/
|
|
2569
|
+
declare class InterceptedStream extends Transform {
|
|
2570
|
+
#private;
|
|
2571
|
+
readonly interceptors: Set<Writable>;
|
|
2572
|
+
/**
|
|
2573
|
+
* Start intercepting the stream. This is the default state of InterceptedStream.
|
|
2574
|
+
*/
|
|
2575
|
+
startIntercepting(): void;
|
|
2576
|
+
/**
|
|
2577
|
+
* Stop intercepting the stream. This will prevent the stream from being consumed by the interceptors.
|
|
2578
|
+
* This can be useful when you want to temporarily stop the interception. The stopped state can be resumed by calling startIntercepting again.
|
|
2579
|
+
*/
|
|
2580
|
+
stopIntercepting(): void;
|
|
2581
|
+
/**
|
|
2582
|
+
* Whether the stream is being intercepted
|
|
2583
|
+
*/
|
|
2584
|
+
isIntercepting(): boolean;
|
|
2585
|
+
_transform(chunk: Buffer, encoding: BufferEncoding, callback: TransformCallback): void;
|
|
2586
|
+
_final(callback: TransformCallback): void;
|
|
2587
|
+
_destroy(error: Error, callback: TransformCallback): void;
|
|
2588
|
+
}
|
|
2589
|
+
|
|
2590
|
+
type Awaitable<T> = T | PromiseLike<T>;
|
|
2591
|
+
type ShouldInterceptFunction = <T = any>(queue: GuildQueue<T>, track: Track, format: StreamType, stream: InterceptedStream) => Awaitable<boolean>;
|
|
2592
|
+
type OnInterceptedStreamHandler = <T = any>(queue: GuildQueue<T>, track: Track, format: StreamType, stream: InterceptedStream) => Awaitable<void>;
|
|
2593
|
+
interface PlayerStreamInterceptorOptions {
|
|
2594
|
+
/**
|
|
2595
|
+
* Determines whether the stream should be intercepted.
|
|
2596
|
+
*/
|
|
2597
|
+
shouldIntercept?: ShouldInterceptFunction;
|
|
2598
|
+
}
|
|
2599
|
+
declare class PlayerStreamInterceptor {
|
|
2600
|
+
#private;
|
|
2601
|
+
readonly player: Player;
|
|
2602
|
+
private readonly options;
|
|
2603
|
+
/**
|
|
2604
|
+
* Creates a new PlayerStreamInterceptor instance.
|
|
2605
|
+
* @param player The player instance
|
|
2606
|
+
* @param options The interceptor options
|
|
2607
|
+
*/
|
|
2608
|
+
constructor(player: Player, options: PlayerStreamInterceptorOptions);
|
|
2609
|
+
/**
|
|
2610
|
+
* Handles the intercepted stream.
|
|
2611
|
+
* @param queue The guild queue
|
|
2612
|
+
* @param track The track
|
|
2613
|
+
* @param stream The intercepted stream
|
|
2614
|
+
* @returns Whether the stream was intercepted
|
|
2615
|
+
*/
|
|
2616
|
+
handle<T = unknown>(queue: GuildQueue<T>, track: Track, type: StreamType, stream: InterceptedStream): Promise<boolean>;
|
|
2617
|
+
/**
|
|
2618
|
+
* Adds a new intercepted stream listener.
|
|
2619
|
+
* @param handler The handler
|
|
2620
|
+
* @returns A function to remove the listener
|
|
2621
|
+
*/
|
|
2622
|
+
onStream(handler: OnInterceptedStreamHandler): () => void;
|
|
2623
|
+
}
|
|
2624
|
+
|
|
2538
2625
|
interface PlayerEvents {
|
|
2539
2626
|
debug: (message: string) => any;
|
|
2540
2627
|
error: (error: Error) => any;
|
|
@@ -2800,6 +2887,16 @@ declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
|
2800
2887
|
* @param resource The audio resource
|
|
2801
2888
|
*/
|
|
2802
2889
|
createTrackFromAudioResource(resource: AudioResource): Track<Record<string, unknown>>;
|
|
2890
|
+
/**
|
|
2891
|
+
* Handles intercepting streams
|
|
2892
|
+
* @param stream The stream to intercept
|
|
2893
|
+
*/
|
|
2894
|
+
handleInterceptingStream(queue: GuildQueue, track: Track, format: StreamType, stream: InterceptedStream): Promise<boolean | undefined>;
|
|
2895
|
+
/**
|
|
2896
|
+
* Creates a global stream interceptor
|
|
2897
|
+
* @param options The stream interceptor options
|
|
2898
|
+
*/
|
|
2899
|
+
createStreamInterceptor(options: PlayerStreamInterceptorOptions): PlayerStreamInterceptor;
|
|
2803
2900
|
}
|
|
2804
2901
|
|
|
2805
2902
|
type SerializedPlaylist = ReturnType<Playlist['serialize']>;
|
|
@@ -3318,4 +3415,4 @@ declare const DependencyReportGenerator: {
|
|
|
3318
3415
|
|
|
3319
3416
|
declare const version: string;
|
|
3320
3417
|
|
|
3321
|
-
export { AFilterGraph, AsyncQueue, type AsyncQueueAcquisitionOptions, AsyncQueueEntry, type AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, Context, type ContextReceiver, type CreateStreamOps, type DependenciesReport, DependencyReportGenerator, DiscordPlayerQueryResultCache, type Encodable, EqualizerConfigurationPreset, ExtractorExecutionContext, type ExtractorExecutionEvents, type ExtractorExecutionFN, type ExtractorExecutionResult, type ExtractorInfo, type ExtractorResolvable, type ExtractorSearchContext, type ExtractorSession, type ExtractorStreamable, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, type FFmpegReport, type FFmpegStreamOptions, type FilterGraph, type FiltersName, type GuildNodeCreateOptions, type GuildNodeInit, GuildNodeManager, GuildQueue, type GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvent, type GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, GuildQueueStatistics, type GuildQueueStatisticsMetadata, type GuildQueueTimeline, type LrcGetParams, type LrcGetResult, LrcLib, type LrcSearchParams, type LrcSearchResult, type MaybeNull, type MetadataDispatch, type NextFunction, type NodeResolvable, type OnAfterCreateStreamHandler, type OnBeforeCreateStreamHandler, type PackageJSON, type PlayOptions, Player, PlayerEvent, type PlayerEvents, PlayerEventsEmitter, type PlayerInitOptions, type PlayerNodeInitializationResult, type PlayerNodeInitializerOptions, type PlayerProgressbarOptions, type PlayerSearchResult, type PlayerTimestamp, type PlayerTriggeredReason, Playlist, type PlaylistInitData, type PlaylistJSON, type PostProcessedResult, QueryCache, type QueryCacheOptions, type QueryCacheProvider, type QueryCacheResolverContext, type QueryExtractorSearch, QueryResolver, QueryType, type QueueFilters, QueueRepeatMode, type RawTrackData, type RequestEntity, type ResolvedQuery, type ResourcePlayOptions, type Runtime, type RuntimeType, type SearchOptions, type SearchQueryType, SearchResult, type SearchResultData, SequentialBucket, type SerializedPlaylist, type SerializedTrack, SerializedType, type SetterFN$1 as SetterFN, type SkipOptions, type StreamConfig, StreamDispatcher, type TimeData, type TimelineDispatcherOptions, Track, type TrackJSON, type TrackLike, type TrackResolvable, TrackSkipReason, type TrackSource, TypeUtil, Util, VALIDATE_QUEUE_CAP, type VoiceConnectConfig, type VoiceEvents, type VoiceStateHandler, VoiceUtils, type WithMetadata, createContext, createErisCompat, createFFmpegStream, decode, deserialize, encode, isErisProxy, onAfterCreateStream, onBeforeCreateStream, serialize, tryIntoThumbnailString, useContext, useHistory, useMainPlayer, useMetadata, usePlayer, useQueue, useTimeline, useVolume, version };
|
|
3418
|
+
export { AFilterGraph, AsyncQueue, type AsyncQueueAcquisitionOptions, AsyncQueueEntry, type AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, Context, type ContextReceiver, type CreateStreamOps, type DependenciesReport, DependencyReportGenerator, DiscordPlayerQueryResultCache, type Encodable, EqualizerConfigurationPreset, ExtractorExecutionContext, type ExtractorExecutionEvents, type ExtractorExecutionFN, type ExtractorExecutionResult, type ExtractorInfo, type ExtractorResolvable, type ExtractorSearchContext, type ExtractorSession, type ExtractorStreamable, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFMPEG_SRATE_REGEX, FFmpegFilterer, type FFmpegReport, type FFmpegStreamOptions, type FilterGraph, type FiltersName, type GuildNodeCreateOptions, type GuildNodeInit, GuildNodeManager, GuildQueue, type GuildQueueAFiltersCache, GuildQueueAudioFilters, GuildQueueEvent, type GuildQueueEvents, GuildQueueHistory, GuildQueuePlayerNode, GuildQueueStatistics, type GuildQueueStatisticsMetadata, type GuildQueueTimeline, InterceptedStream, type LrcGetParams, type LrcGetResult, LrcLib, type LrcSearchParams, type LrcSearchResult, type MaybeNull, type MetadataDispatch, type NextFunction, type NodeResolvable, type OnAfterCreateStreamHandler, type OnBeforeCreateStreamHandler, type OnInterceptedStreamHandler, type PackageJSON, type PlayOptions, Player, PlayerEvent, type PlayerEvents, PlayerEventsEmitter, type PlayerInitOptions, type PlayerNodeInitializationResult, type PlayerNodeInitializerOptions, type PlayerProgressbarOptions, type PlayerSearchResult, PlayerStreamInterceptor, type PlayerStreamInterceptorOptions, type PlayerTimestamp, type PlayerTriggeredReason, Playlist, type PlaylistInitData, type PlaylistJSON, type PostProcessedResult, QueryCache, type QueryCacheOptions, type QueryCacheProvider, type QueryCacheResolverContext, type QueryExtractorSearch, QueryResolver, QueryType, type QueueFilters, QueueRepeatMode, type RawTrackData, type RequestEntity, type ResolvedQuery, type ResourcePlayOptions, type Runtime, type RuntimeType, type SearchOptions, type SearchQueryType, SearchResult, type SearchResultData, SequentialBucket, type SerializedPlaylist, type SerializedTrack, SerializedType, type SetterFN$1 as SetterFN, type ShouldInterceptFunction, type SkipOptions, type StreamConfig, StreamDispatcher, type TimeData, type TimelineDispatcherOptions, Track, type TrackJSON, type TrackLike, type TrackResolvable, TrackSkipReason, type TrackSource, TypeUtil, Util, VALIDATE_QUEUE_CAP, type VoiceConnectConfig, type VoiceEvents, type VoiceStateHandler, VoiceUtils, type WithMetadata, createContext, createErisCompat, createFFmpegStream, decode, deserialize, encode, isErisProxy, onAfterCreateStream, onBeforeCreateStream, serialize, tryIntoThumbnailString, useContext, useHistory, useMainPlayer, useMetadata, usePlayer, useQueue, useTimeline, useVolume, version };
|