lavalink-client 2.2.2 → 2.3.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.
Files changed (88) hide show
  1. package/README.md +95 -1
  2. package/dist/cjs/index.d.ts +7 -1
  3. package/dist/cjs/index.js +7 -1
  4. package/dist/cjs/structures/Constants.d.ts +40 -0
  5. package/dist/cjs/structures/Constants.js +244 -0
  6. package/dist/cjs/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  7. package/dist/cjs/structures/Filters.d.ts +2 -217
  8. package/dist/cjs/structures/Filters.js +8 -232
  9. package/dist/cjs/structures/LavalinkManager.d.ts +31 -166
  10. package/dist/cjs/structures/LavalinkManager.js +59 -7
  11. package/dist/cjs/structures/LavalinkManagerStatics.d.ts +1 -1
  12. package/dist/cjs/structures/Node.d.ts +15 -156
  13. package/dist/cjs/structures/Node.js +131 -49
  14. package/dist/cjs/structures/NodeManager.d.ts +54 -52
  15. package/dist/cjs/structures/NodeManager.js +74 -4
  16. package/dist/cjs/structures/Player.d.ts +31 -124
  17. package/dist/cjs/structures/Player.js +77 -43
  18. package/dist/cjs/structures/Queue.d.ts +66 -42
  19. package/dist/cjs/structures/Queue.js +69 -11
  20. package/dist/cjs/structures/Types/Filters.d.ts +190 -0
  21. package/dist/cjs/structures/Types/Manager.d.ts +184 -0
  22. package/dist/cjs/structures/Types/Manager.js +2 -0
  23. package/dist/cjs/structures/Types/Node.d.ts +216 -0
  24. package/dist/cjs/structures/Types/Node.js +2 -0
  25. package/dist/cjs/structures/Types/Player.d.ts +108 -0
  26. package/dist/cjs/structures/Types/Player.js +2 -0
  27. package/dist/cjs/structures/Types/Queue.d.ts +34 -0
  28. package/dist/cjs/structures/Types/Queue.js +2 -0
  29. package/dist/cjs/structures/{Track.d.ts → Types/Track.d.ts} +3 -2
  30. package/dist/cjs/structures/Types/Track.js +2 -0
  31. package/dist/cjs/structures/Types/Utils.d.ts +367 -0
  32. package/dist/cjs/structures/Types/Utils.js +2 -0
  33. package/dist/cjs/structures/Utils.d.ts +13 -369
  34. package/dist/cjs/structures/Utils.js +35 -14
  35. package/dist/esm/index.d.ts +7 -1
  36. package/dist/esm/index.js +7 -1
  37. package/dist/esm/structures/Constants.d.ts +40 -0
  38. package/dist/esm/structures/Constants.js +241 -0
  39. package/dist/esm/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  40. package/dist/esm/structures/Filters.d.ts +2 -217
  41. package/dist/esm/structures/Filters.js +3 -227
  42. package/dist/esm/structures/LavalinkManager.d.ts +31 -166
  43. package/dist/esm/structures/LavalinkManager.js +57 -5
  44. package/dist/esm/structures/LavalinkManagerStatics.d.ts +1 -1
  45. package/dist/esm/structures/Node.d.ts +15 -156
  46. package/dist/esm/structures/Node.js +122 -40
  47. package/dist/esm/structures/NodeManager.d.ts +54 -52
  48. package/dist/esm/structures/NodeManager.js +71 -1
  49. package/dist/esm/structures/Player.d.ts +31 -124
  50. package/dist/esm/structures/Player.js +76 -42
  51. package/dist/esm/structures/Queue.d.ts +66 -42
  52. package/dist/esm/structures/Queue.js +69 -11
  53. package/dist/esm/structures/Types/Filters.d.ts +190 -0
  54. package/dist/esm/structures/Types/Manager.d.ts +184 -0
  55. package/dist/esm/structures/Types/Manager.js +1 -0
  56. package/dist/esm/structures/Types/Node.d.ts +216 -0
  57. package/dist/esm/structures/Types/Node.js +1 -0
  58. package/dist/esm/structures/Types/Player.d.ts +108 -0
  59. package/dist/esm/structures/Types/Player.js +1 -0
  60. package/dist/esm/structures/Types/Queue.d.ts +34 -0
  61. package/dist/esm/structures/Types/Queue.js +1 -0
  62. package/dist/{types/structures → esm/structures/Types}/Track.d.ts +3 -2
  63. package/dist/esm/structures/Types/Track.js +1 -0
  64. package/dist/esm/structures/Types/Utils.d.ts +367 -0
  65. package/dist/esm/structures/Types/Utils.js +1 -0
  66. package/dist/esm/structures/Utils.d.ts +13 -369
  67. package/dist/esm/structures/Utils.js +35 -14
  68. package/dist/types/index.d.ts +7 -1
  69. package/dist/types/structures/Constants.d.ts +40 -0
  70. package/dist/types/structures/CustomSearches/BandCampSearch.d.ts +2 -2
  71. package/dist/types/structures/Filters.d.ts +2 -217
  72. package/dist/types/structures/LavalinkManager.d.ts +31 -166
  73. package/dist/types/structures/LavalinkManagerStatics.d.ts +1 -1
  74. package/dist/types/structures/Node.d.ts +15 -156
  75. package/dist/types/structures/NodeManager.d.ts +54 -52
  76. package/dist/types/structures/Player.d.ts +31 -124
  77. package/dist/types/structures/Queue.d.ts +66 -42
  78. package/dist/types/structures/Types/Filters.d.ts +190 -0
  79. package/dist/types/structures/Types/Manager.d.ts +184 -0
  80. package/dist/types/structures/Types/Node.d.ts +216 -0
  81. package/dist/types/structures/Types/Player.d.ts +108 -0
  82. package/dist/types/structures/Types/Queue.d.ts +34 -0
  83. package/dist/{esm/structures → types/structures/Types}/Track.d.ts +3 -2
  84. package/dist/types/structures/Types/Utils.d.ts +367 -0
  85. package/dist/types/structures/Utils.d.ts +13 -369
  86. package/package.json +1 -1
  87. /package/dist/cjs/structures/{Track.js → Types/Filters.js} +0 -0
  88. /package/dist/esm/structures/{Track.js → Types/Filters.js} +0 -0
@@ -0,0 +1,367 @@
1
+ import type { MiniMap } from "../Utils";
2
+ import type { LavalinkFilterData } from "./Filters";
3
+ import type { NodeStats } from "./Node";
4
+ import type { LavalinkPlayOptions } from "./Player";
5
+ import type { LavalinkTrack, PluginInfo, Track, UnresolvedTrack } from "./Track";
6
+ /** Helper for generating Opaque types. */
7
+ export type Opaque<T, K> = T & {
8
+ __opaque__: K;
9
+ };
10
+ /** Opqaue tyep for integernumber */
11
+ export type IntegerNumber = Opaque<number, 'Int'>;
12
+ /** Opqaue tyep for floatnumber */
13
+ export type FloatNumber = Opaque<number, 'Float'>;
14
+ export type LavaSrcSearchPlatformBase = "spsearch" | "sprec" | "amsearch" | "dzsearch" | "dzisrc" | "ymsearch";
15
+ export type LavaSrcSearchPlatform = LavaSrcSearchPlatformBase | "ftts";
16
+ export type DuncteSearchPlatform = "speak" | "phsearch" | "pornhub" | "porn" | "tts";
17
+ export type LavalinkClientSearchPlatform = "bcsearch";
18
+ export type LavalinkClientSearchPlatformResolve = "bandcamp" | "bc";
19
+ export type LavalinkSearchPlatform = "ytsearch" | "ytmsearch" | "scsearch" | "bcsearch" | LavaSrcSearchPlatform | DuncteSearchPlatform | LavalinkClientSearchPlatform;
20
+ export type ClientCustomSearchPlatformUtils = "local" | "http" | "https" | "link" | "uri";
21
+ export type ClientSearchPlatform = ClientCustomSearchPlatformUtils | // for file/link requests
22
+ "youtube" | "yt" | "youtube music" | "youtubemusic" | "ytm" | "musicyoutube" | "music youtube" | "soundcloud" | "sc" | "am" | "apple music" | "applemusic" | "apple" | "musicapple" | "music apple" | "sp" | "spsuggestion" | "spotify" | "spotify.com" | "spotifycom" | "dz" | "deezer" | "yandex" | "yandex music" | "yandexmusic" | "flowerytts" | "flowery" | "flowery.tts" | LavalinkClientSearchPlatformResolve | LavalinkClientSearchPlatform;
23
+ export type SearchPlatform = LavalinkSearchPlatform | ClientSearchPlatform;
24
+ export type SourcesRegex = "YoutubeRegex" | "YoutubeMusicRegex" | "SoundCloudRegex" | "SoundCloudMobileRegex" | "DeezerTrackRegex" | "DeezerArtistRegex" | "DeezerEpisodeRegex" | "DeezerMixesRegex" | "DeezerPageLinkRegex" | "DeezerPlaylistRegex" | "DeezerAlbumRegex" | "AllDeezerRegex" | "AllDeezerRegexWithoutPageLink" | "SpotifySongRegex" | "SpotifyPlaylistRegex" | "SpotifyArtistRegex" | "SpotifyEpisodeRegex" | "SpotifyShowRegex" | "SpotifyAlbumRegex" | "AllSpotifyRegex" | "mp3Url" | "m3uUrl" | "m3u8Url" | "mp4Url" | "m4aUrl" | "wavUrl" | "aacpUrl" | "tiktok" | "mixcloud" | "musicYandex" | "radiohost" | "bandcamp" | "appleMusic" | "TwitchTv" | "vimeo";
25
+ export interface PlaylistInfo {
26
+ /** The playlist name */
27
+ name: string;
28
+ /** The playlist title (same as name) */
29
+ title: string;
30
+ /** The playlist Author */
31
+ author?: string;
32
+ /** The playlist Thumbnail */
33
+ thumbnail?: string;
34
+ /** A Uri to the playlist */
35
+ uri?: string;
36
+ /** The playlist selected track. */
37
+ selectedTrack: Track | null;
38
+ /** The duration of the entire playlist. (calcualted) */
39
+ duration: number;
40
+ }
41
+ export interface SearchResult {
42
+ loadType: LoadTypes;
43
+ exception: Exception | null;
44
+ pluginInfo: PluginInfo;
45
+ playlist: PlaylistInfo | null;
46
+ tracks: Track[];
47
+ }
48
+ export interface UnresolvedSearchResult {
49
+ loadType: LoadTypes;
50
+ exception: Exception | null;
51
+ pluginInfo: PluginInfo;
52
+ playlist: PlaylistInfo | null;
53
+ tracks: UnresolvedTrack[];
54
+ }
55
+ /**
56
+ * @internal
57
+ */
58
+ export interface MiniMapConstructor {
59
+ new (): MiniMap<unknown, unknown>;
60
+ new <K, V>(entries?: ReadonlyArray<readonly [K, V]> | null): MiniMap<K, V>;
61
+ new <K, V>(iterable: Iterable<readonly [K, V]>): MiniMap<K, V>;
62
+ readonly prototype: MiniMap<unknown, unknown>;
63
+ readonly [Symbol.species]: MiniMapConstructor;
64
+ }
65
+ export type PlayerEvents = TrackStartEvent | TrackEndEvent | TrackStuckEvent | TrackExceptionEvent | WebSocketClosedEvent | SponsorBlockSegmentEvents;
66
+ export type Severity = "COMMON" | "SUSPICIOUS" | "FAULT";
67
+ export interface Exception {
68
+ /** Severity of the error */
69
+ severity: Severity;
70
+ /** Nodejs Error */
71
+ error?: Error;
72
+ /** Message by lavalink */
73
+ message: string;
74
+ /** Cause by lavalink */
75
+ cause: string;
76
+ }
77
+ export interface PlayerEvent {
78
+ op: "event";
79
+ type: PlayerEventType;
80
+ guildId: string;
81
+ }
82
+ export interface TrackStartEvent extends PlayerEvent {
83
+ type: "TrackStartEvent";
84
+ track: LavalinkTrack;
85
+ }
86
+ export interface TrackEndEvent extends PlayerEvent {
87
+ type: "TrackEndEvent";
88
+ track: LavalinkTrack;
89
+ reason: TrackEndReason;
90
+ }
91
+ export interface TrackExceptionEvent extends PlayerEvent {
92
+ type: "TrackExceptionEvent";
93
+ exception?: Exception;
94
+ tracK: LavalinkTrack;
95
+ error: string;
96
+ }
97
+ export interface TrackStuckEvent extends PlayerEvent {
98
+ type: "TrackStuckEvent";
99
+ thresholdMs: number;
100
+ tracK: LavalinkTrack;
101
+ }
102
+ export interface WebSocketClosedEvent extends PlayerEvent {
103
+ type: "WebSocketClosedEvent";
104
+ code: number;
105
+ byRemote: boolean;
106
+ reason: string;
107
+ }
108
+ /**
109
+ * Types & Events for Sponsorblock-plugin from Lavalink: https://github.com/topi314/Sponsorblock-Plugin#segmentsloaded
110
+ */
111
+ export type SponsorBlockSegmentEvents = SponsorBlockSegmentSkipped | SponsorBlockSegmentsLoaded | SponsorBlockChapterStarted | SponsorBlockChaptersLoaded;
112
+ export type SponsorBlockSegmentEventType = "SegmentSkipped" | "SegmentsLoaded" | "ChaptersLoaded" | "ChapterStarted";
113
+ export interface SponsorBlockSegmentsLoaded extends PlayerEvent {
114
+ type: "SegmentsLoaded";
115
+ segments: {
116
+ category: string;
117
+ start: number;
118
+ end: number;
119
+ }[];
120
+ }
121
+ export interface SponsorBlockSegmentSkipped extends PlayerEvent {
122
+ type: "SegmentSkipped";
123
+ segment: {
124
+ category: string;
125
+ start: number;
126
+ end: number;
127
+ };
128
+ }
129
+ export interface SponsorBlockChapterStarted extends PlayerEvent {
130
+ type: "ChapterStarted";
131
+ /** The Chapter which started */
132
+ chapter: {
133
+ /** The Name of the Chapter */
134
+ name: string;
135
+ start: number;
136
+ end: number;
137
+ duration: number;
138
+ };
139
+ }
140
+ export interface SponsorBlockChaptersLoaded extends PlayerEvent {
141
+ type: "ChaptersLoaded";
142
+ /** All Chapters loaded */
143
+ chapters: {
144
+ /** The Name of the Chapter */
145
+ name: string;
146
+ start: number;
147
+ end: number;
148
+ duration: number;
149
+ }[];
150
+ }
151
+ export type LoadTypes = "track" | "playlist" | "search" | "error" | "empty";
152
+ export type State = "CONNECTED" | "CONNECTING" | "DISCONNECTED" | "DISCONNECTING" | "DESTROYING";
153
+ export type PlayerEventType = "TrackStartEvent" | "TrackEndEvent" | "TrackExceptionEvent" | "TrackStuckEvent" | "WebSocketClosedEvent" | SponsorBlockSegmentEventType;
154
+ export type TrackEndReason = "finished" | "loadFailed" | "stopped" | "replaced" | "cleanup";
155
+ export interface InvalidLavalinkRestRequest {
156
+ /** Rest Request Data for when it was made */
157
+ timestamp: number;
158
+ /** Status of the request */
159
+ status: number;
160
+ /** Specific Errro which was sent */
161
+ error: string;
162
+ /** Specific Message which was created */
163
+ message?: string;
164
+ /** The specific error trace from the request */
165
+ trace?: unknown;
166
+ /** Path of where it's from */
167
+ path: string;
168
+ }
169
+ export interface LavalinkPlayerVoice {
170
+ /** The Voice Token */
171
+ token: string;
172
+ /** The Voice Server Endpoint */
173
+ endpoint: string;
174
+ /** The Voice SessionId */
175
+ sessionId: string;
176
+ /** Wether or not the player is connected */
177
+ connected?: boolean;
178
+ /** The Ping to the voice server */
179
+ ping?: number;
180
+ }
181
+ export interface LavalinkPlayerVoiceOptions extends Omit<LavalinkPlayerVoice, 'connected' | 'ping'> {
182
+ }
183
+ export interface FailingAddress {
184
+ /** The failing address */
185
+ failingAddress: string;
186
+ /** The timestamp when the address failed */
187
+ failingTimestamp: number;
188
+ /** The timestamp when the address failed as a pretty string */
189
+ failingTime: string;
190
+ }
191
+ export type RoutePlannerTypes = "RotatingIpRoutePlanner" | "NanoIpRoutePlanner" | "RotatingNanoIpRoutePlanner" | "BalancingIpRoutePlanner";
192
+ export interface RoutePlanner {
193
+ class?: RoutePlannerTypes;
194
+ details?: {
195
+ /** The ip block being used */
196
+ ipBlock: {
197
+ /** The type of the ip block */
198
+ type: "Inet4Address" | "Inet6Address";
199
+ /** The size of the ip block */
200
+ size: string;
201
+ };
202
+ /** The failing addresses */
203
+ failingAddresses: FailingAddress[];
204
+ /** The number of rotations */
205
+ rotateIndex?: string;
206
+ /** The current offset in the block */
207
+ ipIndex?: string;
208
+ /** The current address being used */
209
+ currentAddress?: string;
210
+ /** The current offset in the ip block */
211
+ currentAddressIndex?: string;
212
+ /** The information in which /64 block ips are chosen. This number increases on each ban. */
213
+ blockIndex?: string;
214
+ };
215
+ }
216
+ export interface Session {
217
+ /** Wether or not session is resuming or not */
218
+ resuming: boolean;
219
+ /** For how long a session is lasting while not connected */
220
+ timeout: number;
221
+ }
222
+ export interface GuildShardPayload {
223
+ /** The OP code */
224
+ op: number;
225
+ /** Data to send */
226
+ d: {
227
+ /** Guild id to apply voice settings */
228
+ guild_id: string;
229
+ /** channel to move/connect to, or null to leave it */
230
+ channel_id: string | null;
231
+ /** wether or not mute yourself */
232
+ self_mute: boolean;
233
+ /** wether or not deafen yourself */
234
+ self_deaf: boolean;
235
+ };
236
+ }
237
+ export interface PlayerUpdateInfo {
238
+ /** guild id of the player */
239
+ guildId: string;
240
+ /** Player options to provide to lavalink */
241
+ playerOptions: LavalinkPlayOptions;
242
+ /** Whether or not replace the current track with the new one (true is recommended) */
243
+ noReplace?: boolean;
244
+ }
245
+ export interface LavalinkPlayer {
246
+ /** Guild Id of the player */
247
+ guildId: string;
248
+ /** IF playing a track, all of the track information */
249
+ track?: LavalinkTrack;
250
+ /** Lavalink volume (mind volumedecrementer) */
251
+ volume: number;
252
+ /** Wether it's paused or not */
253
+ paused: boolean;
254
+ /** Voice Endpoint data */
255
+ voice: LavalinkPlayerVoice;
256
+ /** All Audio Filters */
257
+ filters: Partial<LavalinkFilterData>;
258
+ /** Lavalink-Voice-State Variables */
259
+ state: {
260
+ /** Time since connection established */
261
+ time: number;
262
+ /** Position of the track */
263
+ position: number;
264
+ /** COnnected or not */
265
+ connected: boolean;
266
+ /** Ping to voice server */
267
+ ping: number;
268
+ };
269
+ }
270
+ export interface ChannelDeletePacket {
271
+ /** Packet key for channel delete */
272
+ t: "CHANNEL_DELETE";
273
+ /** data which is sent and relevant */
274
+ d: {
275
+ /** guild id */
276
+ guild_id: string;
277
+ /** Channel id */
278
+ id: string;
279
+ };
280
+ }
281
+ export interface VoiceState {
282
+ /** OP key from lavalink */
283
+ op: "voiceUpdate";
284
+ /** GuildId provided by lavalink */
285
+ guildId: string;
286
+ /** Event data */
287
+ event: VoiceServer;
288
+ /** Session Id of the voice connection */
289
+ sessionId?: string;
290
+ /** guild id of the voice channel */
291
+ guild_id: string;
292
+ /** user id from the voice connection */
293
+ user_id: string;
294
+ /** Session Id of the voice connection */
295
+ session_id: string;
296
+ /** Voice Channel Id */
297
+ channel_id: string;
298
+ }
299
+ /** The Base64 decodes tring by lavalink */
300
+ export type Base64 = string;
301
+ export interface VoiceServer {
302
+ /** Voice Token */
303
+ token: string;
304
+ /** Guild Id of the voice server connection */
305
+ guild_id: string;
306
+ /** Server Endpoint */
307
+ endpoint: string;
308
+ }
309
+ export interface VoicePacket {
310
+ /** Voice Packet Keys to send */
311
+ t?: "VOICE_SERVER_UPDATE" | "VOICE_STATE_UPDATE";
312
+ /** Voice Packets to send */
313
+ d: VoiceState | VoiceServer;
314
+ }
315
+ export interface NodeMessage extends NodeStats {
316
+ /** The type of the event */
317
+ type: PlayerEventType;
318
+ /** what ops are applying to that event */
319
+ op: "stats" | "playerUpdate" | "event";
320
+ /** The specific guild id for that message */
321
+ guildId: string;
322
+ }
323
+ /** Specific types to filter for lavasearch, will be filtered to correct types */
324
+ export type LavaSearchType = "track" | "album" | "artist" | "playlist" | "text" | "tracks" | "albums" | "artists" | "playlists" | "texts";
325
+ export interface LavaSearchFilteredResponse {
326
+ /** The Information of a playlist provided by lavasearch */
327
+ info: PlaylistInfo;
328
+ /** additional plugin information */
329
+ pluginInfo: PluginInfo;
330
+ /** List of tracks */
331
+ tracks: Track[];
332
+ }
333
+ export interface LavaSearchResponse {
334
+ /** An array of tracks, only present if track is in types */
335
+ tracks: Track[];
336
+ /** An array of albums, only present if album is in types */
337
+ albums: LavaSearchFilteredResponse[];
338
+ /** An array of artists, only present if artist is in types */
339
+ artists: LavaSearchFilteredResponse[];
340
+ /** An array of playlists, only present if playlist is in types */
341
+ playlists: LavaSearchFilteredResponse[];
342
+ /** An array of text results, only present if text is in types */
343
+ texts: {
344
+ text: string;
345
+ pluginInfo: PluginInfo;
346
+ }[];
347
+ /** Addition result data provided by plugins */
348
+ pluginInfo: PluginInfo;
349
+ }
350
+ /** SearchQuery Object for raw lavalink requests */
351
+ export type SearchQuery = {
352
+ /** lavalink search Query / identifier string */
353
+ query: string;
354
+ /** Extra url query params to use, e.g. for flowertts */
355
+ extraQueryUrlParams?: URLSearchParams;
356
+ /** Source to append to the search query string */
357
+ source?: SearchPlatform;
358
+ } | /** Our just the search query / identifier string */ string;
359
+ /** SearchQuery Object for Lavalink LavaSearch Plugin requests */
360
+ export type LavaSearchQuery = {
361
+ /** lavalink search Query / identifier string */
362
+ query: string;
363
+ /** Source to append to the search query string */
364
+ source: LavaSrcSearchPlatformBase;
365
+ /** The Types to filter the search to */
366
+ types?: LavaSearchType[];
367
+ };
@@ -0,0 +1 @@
1
+ export {};