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,216 @@
1
+ /// <reference types="node" />
2
+ import type internal from "stream";
3
+ import type { LavalinkNode } from "../Node";
4
+ import type { DestroyReasonsType } from "./Player";
5
+ import type { InvalidLavalinkRestRequest, LavalinkPlayer } from "./Utils";
6
+ /** Ability to manipulate fetch requests */
7
+ export type ModifyRequest = (options: RequestInit & {
8
+ path: string;
9
+ extraQueryUrlParams?: URLSearchParams;
10
+ }) => void;
11
+ export type SponsorBlockSegment = "sponsor" | "selfpromo" | "interaction" | "intro" | "outro" | "preview" | "music_offtopic" | "filler";
12
+ /**
13
+ * Node Options for creating a lavalink node
14
+ */
15
+ export interface LavalinkNodeOptions {
16
+ /** The Lavalink Server-Ip / Domain-URL */
17
+ host: string;
18
+ /** The Lavalink Connection Port */
19
+ port: number;
20
+ /** The Lavalink Password / Authorization-Key */
21
+ authorization: string;
22
+ /** Does the Server use ssl (https) */
23
+ secure?: boolean;
24
+ /** RESUME THE PLAYER? by providing a sessionid on the node-creation */
25
+ sessionId?: string;
26
+ /** Add a Custom ID to the node, for later use */
27
+ id?: string;
28
+ /** Voice Regions of this Node */
29
+ regions?: string[];
30
+ /** The retryAmount for the node. */
31
+ retryAmount?: number;
32
+ /** The retryDelay for the node. */
33
+ retryDelay?: number;
34
+ /** signal for cancelling requests - default: AbortSignal.timeout(options.requestSignalTimeoutMS || 10000) - put <= 0 to disable */
35
+ requestSignalTimeoutMS?: number;
36
+ /** Close on error */
37
+ closeOnError?: boolean;
38
+ /** Heartbeat interval , set to <= 0 to disable heartbeat system */
39
+ heartBeatInterval?: 30000;
40
+ /** Recommended, to check wether the client is still connected or not on the stats endpoint */
41
+ enablePingOnStatsCheck?: boolean;
42
+ }
43
+ /**
44
+ * Memory Stats object from lavalink
45
+ */
46
+ export interface MemoryStats {
47
+ /** The free memory of the allocated amount. */
48
+ free: number;
49
+ /** The used memory of the allocated amount. */
50
+ used: number;
51
+ /** The total allocated memory. */
52
+ allocated: number;
53
+ /** The reservable memory. */
54
+ reservable: number;
55
+ }
56
+ /**
57
+ * CPU Stats object from lavalink
58
+ */
59
+ export interface CPUStats {
60
+ /** The core amount the host machine has. */
61
+ cores: number;
62
+ /** The system load. */
63
+ systemLoad: number;
64
+ /** The lavalink load. */
65
+ lavalinkLoad: number;
66
+ }
67
+ /**
68
+ * FrameStats Object from lavalink
69
+ */
70
+ export interface FrameStats {
71
+ /** The amount of sent frames. */
72
+ sent?: number;
73
+ /** The amount of nulled frames. */
74
+ nulled?: number;
75
+ /** The amount of deficit frames. */
76
+ deficit?: number;
77
+ }
78
+ /**
79
+ * BaseNodeStats object from Lavalink
80
+ */
81
+ export interface BaseNodeStats {
82
+ /** The amount of players on the node. */
83
+ players: number;
84
+ /** The amount of playing players on the node. */
85
+ playingPlayers: number;
86
+ /** The uptime for the node. */
87
+ uptime: number;
88
+ /** The memory stats for the node. */
89
+ memory: MemoryStats;
90
+ /** The cpu stats for the node. */
91
+ cpu: CPUStats;
92
+ /** The frame stats for the node. */
93
+ frameStats: FrameStats;
94
+ }
95
+ /**
96
+ * Interface for nodeStats from lavalink
97
+ */
98
+ export interface NodeStats extends BaseNodeStats {
99
+ /** The frame stats for the node. */
100
+ frameStats: FrameStats;
101
+ }
102
+ /**
103
+ * Entire lavalink information object from lavalink
104
+ */
105
+ export interface LavalinkInfo {
106
+ /** The version of this Lavalink server */
107
+ version: VersionObject;
108
+ /** The millisecond unix timestamp when this Lavalink jar was built */
109
+ buildTime: number;
110
+ /** The git information of this Lavalink server */
111
+ git: GitObject;
112
+ /** The JVM version this Lavalink server runs on */
113
+ jvm: string;
114
+ /** The Lavaplayer version being used by this server */
115
+ lavaplayer: string;
116
+ /** The enabled source managers for this server */
117
+ sourceManagers: string[];
118
+ /** The enabled filters for this server */
119
+ filters: string[];
120
+ /** The enabled plugins for this server */
121
+ plugins: PluginObject[];
122
+ }
123
+ /**
124
+ * Lavalink's version object from lavalink
125
+ */
126
+ export interface VersionObject {
127
+ /** The full version string of this Lavalink server */
128
+ semver: string;
129
+ /** The major version of this Lavalink server */
130
+ major: number;
131
+ /** The minor version of this Lavalink server */
132
+ minor: number;
133
+ /** The patch version of this Lavalink server */
134
+ patch: internal;
135
+ /** The pre-release version according to semver as a . separated list of identifiers */
136
+ preRelease?: string;
137
+ /** The build metadata according to semver as a . separated list of identifiers */
138
+ build?: string;
139
+ }
140
+ /**
141
+ * Git information object from lavalink
142
+ */
143
+ export interface GitObject {
144
+ /** The branch this Lavalink server was built on */
145
+ branch: string;
146
+ /** The commit this Lavalink server was built on */
147
+ commit: string;
148
+ /** The millisecond unix timestamp for when the commit was created */
149
+ commitTime: string;
150
+ }
151
+ /**
152
+ * Lavalink's plugins object from lavalink's plugin
153
+ */
154
+ export interface PluginObject {
155
+ /** The name of the plugin */
156
+ name: string;
157
+ /** The version of the plugin */
158
+ version: string;
159
+ }
160
+ export type LavalinkNodeIdentifier = string;
161
+ export interface NodeManagerEvents {
162
+ /**
163
+ * Emitted when a Node is created.
164
+ * @event Manager.nodeManager#create
165
+ */
166
+ "create": (node: LavalinkNode) => void;
167
+ /**
168
+ * Emitted when a Node is destroyed.
169
+ * @event Manager.nodeManager#destroy
170
+ */
171
+ "destroy": (node: LavalinkNode, destroyReason?: DestroyReasonsType) => void;
172
+ /**
173
+ * Emitted when a Node is connected.
174
+ * @event Manager.nodeManager#connect
175
+ */
176
+ "connect": (node: LavalinkNode) => void;
177
+ /**
178
+ * Emitted when a Node is reconnecting.
179
+ * @event Manager.nodeManager#reconnecting
180
+ */
181
+ "reconnecting": (node: LavalinkNode) => void;
182
+ /**
183
+ * Emitted When a node starts to reconnect (if you have a reconnection delay, the reconnecting event will be emitted after the retryDelay.)
184
+ * Useful to check wether the internal node reconnect system works or not
185
+ * @event Manager.nodeManager#reconnectinprogress
186
+ */
187
+ "reconnectinprogress": (node: LavalinkNode) => void;
188
+ /**
189
+ * Emitted when a Node is disconnects.
190
+ * @event Manager.nodeManager#disconnect
191
+ */
192
+ "disconnect": (node: LavalinkNode, reason: {
193
+ code?: number;
194
+ reason?: string;
195
+ }) => void;
196
+ /**
197
+ * Emitted when a Node is error.
198
+ * @event Manager.nodeManager#error
199
+ */
200
+ "error": (node: LavalinkNode, error: Error, payload?: unknown) => void;
201
+ /**
202
+ * Emits every single Node event.
203
+ * @event Manager.nodeManager#raw
204
+ */
205
+ "raw": (node: LavalinkNode, payload: unknown) => void;
206
+ /**
207
+ * Emits when the node connects resumed. You then need to create all players within this event for your usecase.
208
+ * Aka for that you need to be able to save player data like vc channel + text channel in a db and then sync it again
209
+ * @event Manager.nodeManager#nodeResumed
210
+ */
211
+ "resumed": (node: LavalinkNode, paylaod: {
212
+ resumed: true;
213
+ sessionId: string;
214
+ op: "ready";
215
+ }, players: LavalinkPlayer[] | InvalidLavalinkRestRequest) => void;
216
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,108 @@
1
+ import type { DestroyReasons } from "../Constants";
2
+ import type { LavalinkNode } from "../Node";
3
+ import type { EQBand, FilterData, LavalinkFilterData } from "./Filters";
4
+ import type { Track, UnresolvedTrack } from "./Track";
5
+ import type { Base64, LavalinkPlayerVoiceOptions } from "./Utils";
6
+ export type DestroyReasonsType = keyof typeof DestroyReasons | string;
7
+ export interface PlayerJson {
8
+ /** Guild Id where the player was playing in */
9
+ guildId: string;
10
+ /** Options provided to the player */
11
+ options: PlayerOptions;
12
+ /** Voice Channel Id the player was playing in */
13
+ voiceChannelId: string;
14
+ /** Text Channel Id the player was synced to */
15
+ textChannelId?: string;
16
+ /** Position the player was at */
17
+ position: number;
18
+ /** Lavalink's position the player was at */
19
+ lastPosition: number;
20
+ /** Last time the position was sent from lavalink */
21
+ lastPositionChange: number;
22
+ /** Volume in % from the player (without volumeDecrementer) */
23
+ volume: number;
24
+ /** Real Volume used in lavalink (with the volumeDecrementer) */
25
+ lavalinkVolume: number;
26
+ /** The repeatmode from the player */
27
+ repeatMode: RepeatMode;
28
+ /** Pause state */
29
+ paused: boolean;
30
+ /** Wether the player was playing or not */
31
+ playing: boolean;
32
+ /** When the player was created */
33
+ createdTimeStamp?: number;
34
+ /** All current used fitlers Data */
35
+ filters: FilterData;
36
+ /** The player's ping object */
37
+ ping: {
38
+ /** Ping to the voice websocket server */
39
+ ws: number;
40
+ /** Avg. calc. Ping to the lavalink server */
41
+ lavalink: number;
42
+ };
43
+ /** Equalizer Bands used in lavalink */
44
+ equalizer: EQBand[];
45
+ /** The Id of the last used node */
46
+ nodeId?: string;
47
+ /** The SessionId of the node */
48
+ nodeSessionId?: string;
49
+ }
50
+ export type RepeatMode = "queue" | "track" | "off";
51
+ export interface PlayerOptions {
52
+ /** Guild id of the player */
53
+ guildId: string;
54
+ /** The Voice Channel Id */
55
+ voiceChannelId: string;
56
+ /** The Text Channel Id of the Player */
57
+ textChannelId?: string;
58
+ /** instantly change volume with the one play request */
59
+ volume?: number;
60
+ /** VC Region for node selections */
61
+ vcRegion?: string;
62
+ /** if it should join deafened */
63
+ selfDeaf?: boolean;
64
+ /** If it should join muted */
65
+ selfMute?: boolean;
66
+ /** If it should use a specific lavalink node */
67
+ node?: LavalinkNode | string;
68
+ /** If when applying filters, it should use the insta apply filters fix */
69
+ instaUpdateFiltersFix?: boolean;
70
+ /** If a volume should be applied via filters instead of lavalink-volume */
71
+ applyVolumeAsFilter?: boolean;
72
+ }
73
+ export type anyObject = {
74
+ [key: string | number]: string | number | null | anyObject;
75
+ };
76
+ export interface BasePlayOptions {
77
+ /** The position to start the track. */
78
+ position?: number;
79
+ /** The position to end the track. */
80
+ endTime?: number;
81
+ /** If to start "paused" */
82
+ paused?: boolean;
83
+ /** The Volume to start with */
84
+ volume?: number;
85
+ /** The Lavalink Filters to use | only with the new REST API */
86
+ filters?: Partial<LavalinkFilterData>;
87
+ /** Voice Update for Lavalink */
88
+ voice?: LavalinkPlayerVoiceOptions;
89
+ }
90
+ export interface LavalinkPlayOptions extends BasePlayOptions {
91
+ /** Which Track to play | don't provide, if it should pick from the Queue */
92
+ track?: {
93
+ /** The track encoded base64 string to use instead of the one from the queue system */
94
+ encoded?: Base64 | null;
95
+ /** The identifier of the track to use */
96
+ identifier?: string;
97
+ /** Custom User Data for the track to provide, will then be on the userData object from the track */
98
+ userData?: anyObject;
99
+ /** The Track requester for when u provide encodedTrack / identifer */
100
+ requester?: unknown;
101
+ };
102
+ }
103
+ export interface PlayOptions extends LavalinkPlayOptions {
104
+ /** Whether to not replace the track if a play payload is sent. */
105
+ noReplace?: boolean;
106
+ /** Adds track on queue and skips to it */
107
+ clientTrack?: Track | UnresolvedTrack;
108
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,34 @@
1
+ import type { Track, UnresolvedTrack } from "./Track";
2
+ export interface StoredQueue {
3
+ current: Track | null;
4
+ previous: Track[];
5
+ tracks: (Track | UnresolvedTrack)[];
6
+ }
7
+ export interface QueueStoreManager extends Record<string, any> {
8
+ /** @async get a Value (MUST RETURN UNPARSED!) */
9
+ get: (guildId: unknown) => Promise<unknown>;
10
+ /** @async Set a value inside a guildId (MUST BE UNPARSED) */
11
+ set: (guildId: unknown, value: unknown) => Promise<unknown>;
12
+ /** @async Delete a Database Value based of it's guildId */
13
+ delete: (guildId: unknown) => Promise<unknown>;
14
+ /** @async Transform the value(s) inside of the QueueStoreManager (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
15
+ stringify: (value: unknown) => Promise<unknown>;
16
+ /** @async Parse the saved value back to the Queue (IF YOU DON'T NEED PARSING/STRINGIFY, then just return the value) */
17
+ parse: (value: unknown) => Promise<Partial<StoredQueue>>;
18
+ }
19
+ export interface ManagerQueueOptions {
20
+ /** Maximum Amount of tracks for the queue.previous array. Set to 0 to not save previous songs. Defaults to 25 Tracks */
21
+ maxPreviousTracks?: number;
22
+ /** Custom Queue Store option */
23
+ queueStore?: QueueStoreManager;
24
+ /** Custom Queue Watcher class */
25
+ queueChangesWatcher?: QueueChangesWatcher;
26
+ }
27
+ export interface QueueChangesWatcher {
28
+ /** get a Value (MUST RETURN UNPARSED!) */
29
+ tracksAdd: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
30
+ /** Set a value inside a guildId (MUST BE UNPARSED) */
31
+ tracksRemoved: (guildId: string, tracks: (Track | UnresolvedTrack)[], position: number, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
32
+ /** Set a value inside a guildId (MUST BE UNPARSED) */
33
+ shuffled: (guildId: string, oldStoredQueue: StoredQueue, newStoredQueue: StoredQueue) => void;
34
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
- import { anyObject, Player } from "./Player";
2
- import { Base64 } from "./Utils";
1
+ import type { Player } from "../Player";
2
+ import type { anyObject } from "./Player";
3
+ import type { Base64 } from "./Utils";
3
4
  /** Sourcenames provided by lavalink server */
4
5
  export type LavalinkSourceNames = "youtube" | "youtubemusic" | "soundcloud" | "bandcamp" | "twitch";
5
6
  /** Source Names provided by lava src plugin */
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });