discord-player 6.6.8-dev.3 → 6.6.9-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +250 -1
- package/dist/index.js +430 -21
- package/dist/index.mjs +4 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -726,6 +726,196 @@ declare class GuildQueueStatistics<Meta = unknown> {
|
|
|
726
726
|
generate(): GuildQueueStatisticsMetadata;
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
+
type RequestEntity = () => Promise<Response>;
|
|
730
|
+
declare class SequentialBucket {
|
|
731
|
+
limit: number;
|
|
732
|
+
remaining: number;
|
|
733
|
+
resetAfter: number;
|
|
734
|
+
queue: AsyncQueue;
|
|
735
|
+
MAX_RETRIES: number;
|
|
736
|
+
/**
|
|
737
|
+
* Checks if the bucket is rate limited.
|
|
738
|
+
*/
|
|
739
|
+
isRateLimited(): boolean;
|
|
740
|
+
/**
|
|
741
|
+
* Enqueues a request.
|
|
742
|
+
* @param req The request function to enqueue
|
|
743
|
+
*/
|
|
744
|
+
enqueue(req: RequestEntity): Promise<Response>;
|
|
745
|
+
private _request;
|
|
746
|
+
private _patchHeaders;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
interface LrcSearchParams {
|
|
750
|
+
/**
|
|
751
|
+
* The query to search for. Either this or trackName is required.
|
|
752
|
+
*/
|
|
753
|
+
q?: string;
|
|
754
|
+
/**
|
|
755
|
+
* The track name to search for. Either this or query is required.
|
|
756
|
+
*/
|
|
757
|
+
trackName?: string;
|
|
758
|
+
/**
|
|
759
|
+
* The artist name
|
|
760
|
+
*/
|
|
761
|
+
artistName?: string;
|
|
762
|
+
/**
|
|
763
|
+
* The album name
|
|
764
|
+
*/
|
|
765
|
+
albumName?: string;
|
|
766
|
+
}
|
|
767
|
+
interface LrcGetParams extends Required<Omit<LrcSearchParams, 'query'>> {
|
|
768
|
+
/**
|
|
769
|
+
* The duration of the track
|
|
770
|
+
*/
|
|
771
|
+
duration: number;
|
|
772
|
+
}
|
|
773
|
+
interface LrcSearchResult {
|
|
774
|
+
/**
|
|
775
|
+
* The track id
|
|
776
|
+
*/
|
|
777
|
+
id: number;
|
|
778
|
+
/**
|
|
779
|
+
* The track name
|
|
780
|
+
*/
|
|
781
|
+
name: string;
|
|
782
|
+
/**
|
|
783
|
+
* The artist name
|
|
784
|
+
*/
|
|
785
|
+
trackName: string;
|
|
786
|
+
/**
|
|
787
|
+
* The album name
|
|
788
|
+
*/
|
|
789
|
+
artistName: string;
|
|
790
|
+
/**
|
|
791
|
+
* The album name
|
|
792
|
+
*/
|
|
793
|
+
albumName: string;
|
|
794
|
+
/**
|
|
795
|
+
* The duration of the track
|
|
796
|
+
*/
|
|
797
|
+
duration: number;
|
|
798
|
+
/**
|
|
799
|
+
* The release date of the track
|
|
800
|
+
*/
|
|
801
|
+
instrumental: boolean;
|
|
802
|
+
/**
|
|
803
|
+
* The release date of the track
|
|
804
|
+
*/
|
|
805
|
+
plainLyrics: string;
|
|
806
|
+
/**
|
|
807
|
+
* The release date of the track
|
|
808
|
+
*/
|
|
809
|
+
syncedLyrics?: string;
|
|
810
|
+
}
|
|
811
|
+
type LrcGetResult = Omit<LrcSearchResult, 'name'>;
|
|
812
|
+
declare class LrcLib {
|
|
813
|
+
readonly player: Player;
|
|
814
|
+
/**
|
|
815
|
+
* The API URL
|
|
816
|
+
*/
|
|
817
|
+
api: string;
|
|
818
|
+
/**
|
|
819
|
+
* The request timeout. Default is 15 seconds.
|
|
820
|
+
*/
|
|
821
|
+
timeout: number;
|
|
822
|
+
/**
|
|
823
|
+
* The request bucket
|
|
824
|
+
*/
|
|
825
|
+
bucket: SequentialBucket;
|
|
826
|
+
/**
|
|
827
|
+
* Creates a new LrcLib instance
|
|
828
|
+
* @param {Player} player The player instance
|
|
829
|
+
*/
|
|
830
|
+
constructor(player: Player);
|
|
831
|
+
/**
|
|
832
|
+
* Sets the request timeout
|
|
833
|
+
* @param {number} timeout The timeout in milliseconds
|
|
834
|
+
*/
|
|
835
|
+
setRequestTimeout(timeout: number): void;
|
|
836
|
+
/**
|
|
837
|
+
* Sets the retry limit. Default is 5.
|
|
838
|
+
* @param {number} limit The retry limit
|
|
839
|
+
*/
|
|
840
|
+
setRetryLimit(limit: number): void;
|
|
841
|
+
/**
|
|
842
|
+
* Gets lyrics
|
|
843
|
+
* @param params The get params
|
|
844
|
+
*/
|
|
845
|
+
get(params: LrcGetParams): Promise<LrcSearchResult>;
|
|
846
|
+
/**
|
|
847
|
+
* Gets lyrics by ID
|
|
848
|
+
* @param id The lyrics ID
|
|
849
|
+
*/
|
|
850
|
+
getById(id: `${number}` | number): Promise<LrcSearchResult>;
|
|
851
|
+
/**
|
|
852
|
+
* Gets cached lyrics
|
|
853
|
+
* @param params The get params
|
|
854
|
+
*/
|
|
855
|
+
getCached(params: LrcGetParams): Promise<LrcSearchResult>;
|
|
856
|
+
/**
|
|
857
|
+
* Searches for lyrics
|
|
858
|
+
* @param params The search params
|
|
859
|
+
*/
|
|
860
|
+
search(params: LrcSearchParams): Promise<LrcSearchResult[]>;
|
|
861
|
+
/**
|
|
862
|
+
* Requests the API
|
|
863
|
+
* @param path The path
|
|
864
|
+
* @param options The request options
|
|
865
|
+
*/
|
|
866
|
+
request<T>(path: string, options?: RequestInit): Promise<T>;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
type LyricsData = Map<number, string>;
|
|
870
|
+
type Unsubscribe = () => void;
|
|
871
|
+
type LyricsCallback = (lyrics: string, timestamp: number) => unknown;
|
|
872
|
+
type LyricsAt = {
|
|
873
|
+
timestamp: number;
|
|
874
|
+
line: string;
|
|
875
|
+
};
|
|
876
|
+
declare class SyncedLyricsProvider {
|
|
877
|
+
#private;
|
|
878
|
+
readonly queue: GuildQueue;
|
|
879
|
+
readonly raw?: LrcSearchResult | LrcGetResult | undefined;
|
|
880
|
+
interval: number;
|
|
881
|
+
readonly lyrics: LyricsData;
|
|
882
|
+
constructor(queue: GuildQueue, raw?: LrcSearchResult | LrcGetResult | undefined);
|
|
883
|
+
isSubscribed(): boolean;
|
|
884
|
+
load(lyrics: string): void;
|
|
885
|
+
/**
|
|
886
|
+
* Returns the lyrics at a specific time or at the closest time (±2 seconds)
|
|
887
|
+
* @param time The time in milliseconds
|
|
888
|
+
*/
|
|
889
|
+
at(time: number): LyricsAt | null;
|
|
890
|
+
/**
|
|
891
|
+
* Callback for the lyrics change.
|
|
892
|
+
* @param callback The callback function
|
|
893
|
+
*/
|
|
894
|
+
onChange(callback: LyricsCallback): void;
|
|
895
|
+
/**
|
|
896
|
+
* Callback to detect when the provider is unsubscribed.
|
|
897
|
+
* @param callback The callback function
|
|
898
|
+
*/
|
|
899
|
+
onUnsubscribe(callback: Unsubscribe): void;
|
|
900
|
+
/**
|
|
901
|
+
* Unsubscribes from the queue.
|
|
902
|
+
*/
|
|
903
|
+
unsubscribe(): void;
|
|
904
|
+
/**
|
|
905
|
+
* Subscribes to the queue to monitor the current time.
|
|
906
|
+
* @returns The unsubscribe function
|
|
907
|
+
*/
|
|
908
|
+
subscribe(): Unsubscribe;
|
|
909
|
+
/**
|
|
910
|
+
* Pauses the lyrics provider.
|
|
911
|
+
*/
|
|
912
|
+
pause(): boolean;
|
|
913
|
+
/**
|
|
914
|
+
* Resumes the lyrics provider.
|
|
915
|
+
*/
|
|
916
|
+
resume(): boolean;
|
|
917
|
+
}
|
|
918
|
+
|
|
729
919
|
interface GuildNodeInit<Meta = unknown> {
|
|
730
920
|
guild: Guild;
|
|
731
921
|
queueStrategy: QueueStrategy;
|
|
@@ -1094,6 +1284,7 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1094
1284
|
timeouts: Collection<string, NodeJS.Timeout>;
|
|
1095
1285
|
stats: GuildQueueStatistics<Meta>;
|
|
1096
1286
|
tasksQueue: AsyncQueue;
|
|
1287
|
+
syncedLyricsProvider: SyncedLyricsProvider;
|
|
1097
1288
|
constructor(player: Player, options: GuildNodeInit<Meta>);
|
|
1098
1289
|
/**
|
|
1099
1290
|
* Estimated duration of this queue in ms
|
|
@@ -1107,6 +1298,20 @@ declare class GuildQueue<Meta = unknown> {
|
|
|
1107
1298
|
* The voice receiver for this queue
|
|
1108
1299
|
*/
|
|
1109
1300
|
get voiceReceiver(): VoiceReceiverNode | null;
|
|
1301
|
+
/**
|
|
1302
|
+
* The sync lyrics provider for this queue.
|
|
1303
|
+
* @example const lyrics = await player.lyrics.search({ q: 'Alan Walker Faded' });
|
|
1304
|
+
* const syncedLyrics = queue.syncedLyrics(lyrics[0]);
|
|
1305
|
+
* console.log(syncedLyrics.at(10_000));
|
|
1306
|
+
* // subscribe to lyrics change
|
|
1307
|
+
* const unsubscribe = syncedLyrics.onChange((lyrics, timestamp) => {
|
|
1308
|
+
* console.log(lyrics, timestamp);
|
|
1309
|
+
* });
|
|
1310
|
+
* // unsubscribe from lyrics change
|
|
1311
|
+
* unsubscribe(); // or
|
|
1312
|
+
* syncedLyrics.unsubscribe();
|
|
1313
|
+
*/
|
|
1314
|
+
syncedLyrics(lyrics: LrcGetResult | LrcSearchResult): SyncedLyricsProvider;
|
|
1110
1315
|
/**
|
|
1111
1316
|
* Write a debug message to this queue
|
|
1112
1317
|
* @param m The message to write
|
|
@@ -2113,16 +2318,51 @@ interface PlayerNodeInitializerOptions<T> extends SearchOptions {
|
|
|
2113
2318
|
type VoiceStateHandler = (player: Player, queue: GuildQueue, oldVoiceState: VoiceState, newVoiceState: VoiceState) => Awaited<void>;
|
|
2114
2319
|
declare class Player extends PlayerEventsEmitter<PlayerEvents> {
|
|
2115
2320
|
#private;
|
|
2321
|
+
/**
|
|
2322
|
+
* The version of discord-player
|
|
2323
|
+
*/
|
|
2116
2324
|
static readonly version: string;
|
|
2117
2325
|
static _singletonKey: symbol;
|
|
2326
|
+
/**
|
|
2327
|
+
* The unique identifier of this player instance
|
|
2328
|
+
*/
|
|
2118
2329
|
readonly id: string;
|
|
2330
|
+
/**
|
|
2331
|
+
* The discord.js client
|
|
2332
|
+
*/
|
|
2119
2333
|
readonly client: Client;
|
|
2334
|
+
/**
|
|
2335
|
+
* The player options
|
|
2336
|
+
*/
|
|
2120
2337
|
readonly options: PlayerInitOptions;
|
|
2338
|
+
/**
|
|
2339
|
+
* The player nodes (queue) manager
|
|
2340
|
+
*/
|
|
2121
2341
|
nodes: GuildNodeManager<unknown>;
|
|
2342
|
+
/**
|
|
2343
|
+
* The voice api utilities
|
|
2344
|
+
*/
|
|
2122
2345
|
readonly voiceUtils: VoiceUtils;
|
|
2346
|
+
/**
|
|
2347
|
+
* The extractors manager
|
|
2348
|
+
*/
|
|
2123
2349
|
extractors: ExtractorExecutionContext;
|
|
2350
|
+
/**
|
|
2351
|
+
* The player events channel
|
|
2352
|
+
*/
|
|
2124
2353
|
events: PlayerEventsEmitter<GuildQueueEvents<any>>;
|
|
2354
|
+
/**
|
|
2355
|
+
* The route planner
|
|
2356
|
+
*/
|
|
2125
2357
|
routePlanner: IPRotator | null;
|
|
2358
|
+
/**
|
|
2359
|
+
* The player version
|
|
2360
|
+
*/
|
|
2361
|
+
readonly version: string;
|
|
2362
|
+
/**
|
|
2363
|
+
* The lyrics api
|
|
2364
|
+
*/
|
|
2365
|
+
readonly lyrics: LrcLib;
|
|
2126
2366
|
/**
|
|
2127
2367
|
* Creates new Discord Player
|
|
2128
2368
|
* @param {Client} client The Discord Client
|
|
@@ -2882,11 +3122,20 @@ declare class AudioFilters {
|
|
|
2882
3122
|
}[]): void;
|
|
2883
3123
|
}
|
|
2884
3124
|
|
|
3125
|
+
type RuntimeType = 'node' | 'deno' | 'bun' | 'unknown';
|
|
3126
|
+
interface Runtime {
|
|
3127
|
+
name: RuntimeType;
|
|
3128
|
+
version: string;
|
|
3129
|
+
}
|
|
2885
3130
|
declare class Util {
|
|
2886
3131
|
/**
|
|
2887
3132
|
* Utils
|
|
2888
3133
|
*/
|
|
2889
3134
|
private constructor();
|
|
3135
|
+
/**
|
|
3136
|
+
* Gets the runtime information
|
|
3137
|
+
*/
|
|
3138
|
+
static getRuntime(): Runtime;
|
|
2890
3139
|
/**
|
|
2891
3140
|
* Creates duration string
|
|
2892
3141
|
* @param {object} durObj The duration object
|
|
@@ -3005,4 +3254,4 @@ declare class QueryResolver {
|
|
|
3005
3254
|
|
|
3006
3255
|
declare const version: string;
|
|
3007
3256
|
|
|
3008
|
-
export { AFilterGraph, AsyncQueue, AsyncQueueAcquisitionOptions, AsyncQueueEntry, AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, Context, ContextReceiver, CreateStreamOps, DiscordPlayerQueryResultCache, Encodable, EqualizerConfigurationPreset, ExtractorExecutionContext, ExtractorExecutionEvents, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorLoaderOptionDict, ExtractorResolvable, ExtractorSearchContext, ExtractorStreamable, 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, MetadataDispatch, 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, SerializedPlaylist, SerializedTrack, SerializedType, SetterFN$1 as SetterFN, SkipOptions, StreamConfig, StreamDispatcher, TimeData, TimelineDispatcherOptions, Track, TrackJSON, TrackLike, TrackResolvable, TrackSkipReason, TrackSource, TypeUtil, Util, VALIDATE_QUEUE_CAP, VoiceConnectConfig, VoiceEvents, VoiceReceiverNode, VoiceReceiverOptions, VoiceStateHandler, VoiceUtils, WithMetadata, createContext, createFFmpegStream, createHook, decode, deserialize, encode, onAfterCreateStream, onBeforeCreateStream, serialize, tryIntoThumbnailString, useContext, useHistory, useMainPlayer, useMasterPlayer, useMetadata, usePlayer, useQueue, useTimeline, useVolume, version };
|
|
3257
|
+
export { AFilterGraph, AsyncQueue, AsyncQueueAcquisitionOptions, AsyncQueueEntry, AsyncQueueExceptionHandler, AudioFilters, BaseExtractor, Context, ContextReceiver, CreateStreamOps, DiscordPlayerQueryResultCache, Encodable, EqualizerConfigurationPreset, ExtractorExecutionContext, ExtractorExecutionEvents, ExtractorExecutionFN, ExtractorExecutionResult, ExtractorInfo, ExtractorLoaderOptionDict, ExtractorResolvable, ExtractorSearchContext, ExtractorStreamable, 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, LrcGetParams, LrcGetResult, LrcLib, LrcSearchParams, LrcSearchResult, MetadataDispatch, 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, RequestEntity, ResolvedQuery, ResourcePlayOptions, Runtime, RuntimeType, SearchOptions, SearchQueryType, SearchResult, SearchResultData, SequentialBucket, SerializedPlaylist, SerializedTrack, SerializedType, SetterFN$1 as SetterFN, SkipOptions, StreamConfig, StreamDispatcher, TimeData, TimelineDispatcherOptions, Track, TrackJSON, TrackLike, TrackResolvable, TrackSkipReason, TrackSource, TypeUtil, Util, VALIDATE_QUEUE_CAP, VoiceConnectConfig, VoiceEvents, VoiceReceiverNode, VoiceReceiverOptions, VoiceStateHandler, VoiceUtils, WithMetadata, createContext, createFFmpegStream, createHook, decode, deserialize, encode, onAfterCreateStream, onBeforeCreateStream, serialize, tryIntoThumbnailString, useContext, useHistory, useMainPlayer, useMasterPlayer, useMetadata, usePlayer, useQueue, useTimeline, useVolume, version };
|