magmastream 2.10.2-dev.4 → 2.10.2

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.
@@ -1,347 +0,0 @@
1
- import { Filters } from "./Filters";
2
- import { Manager } from "./Manager";
3
- import { Node } from "./Node";
4
- import { AnyMessage, IQueue, Lyrics, PlayerOptions, PlayerVoiceState, PlayOptions, SearchQuery, SearchResult, Track } from "./Types";
5
- import { SponsorBlockSegment, StateTypes } from "./Enums";
6
- import { WebSocket } from "ws";
7
- export declare class Player {
8
- options: PlayerOptions;
9
- /** The Queue for the Player. */
10
- queue: IQueue;
11
- /** The filters applied to the audio. */
12
- filters: Filters;
13
- /** Whether the queue repeats the track. */
14
- trackRepeat: boolean;
15
- /** Whether the queue repeats the queue. */
16
- queueRepeat: boolean;
17
- /**Whether the queue repeats and shuffles after each song. */
18
- dynamicRepeat: boolean;
19
- /** The time the player is in the track. */
20
- position: number;
21
- /** Whether the player is playing. */
22
- playing: boolean;
23
- /** Whether the player is paused. */
24
- paused: boolean;
25
- /** The volume for the player */
26
- volume: number;
27
- /** The Node for the Player. */
28
- node: Node;
29
- /** The guild ID for the player. */
30
- guildId: string;
31
- /** The voice channel for the player. */
32
- voiceChannelId: string | null;
33
- /** The text channel for the player. */
34
- textChannelId: string | null;
35
- /**The now playing message. */
36
- nowPlayingMessage?: AnyMessage;
37
- /** The current state of the player. */
38
- state: StateTypes;
39
- /** The equalizer bands array. */
40
- bands: number[];
41
- /** The voice state object from the node. */
42
- voiceState: PlayerVoiceState;
43
- /** The Manager. */
44
- manager: Manager;
45
- /** The autoplay state of the player. */
46
- isAutoplay: boolean;
47
- /** The number of times to try autoplay before emitting queueEnd. */
48
- autoplayTries: number;
49
- /** The cluster ID for the player. */
50
- clusterId: number;
51
- private readonly data;
52
- private dynamicLoopInterval;
53
- dynamicRepeatIntervalMs: number | null;
54
- private static _manager;
55
- /** Should only be used when the node is a NodeLink */
56
- protected voiceReceiverWsClient: WebSocket | null;
57
- protected isConnectToVoiceReceiver: boolean;
58
- protected voiceReceiverReconnectTimeout: NodeJS.Timeout | null;
59
- protected voiceReceiverAttempt: number;
60
- protected voiceReceiverReconnectTries: number;
61
- /**
62
- * Creates a new player, returns one if it already exists.
63
- * @param options The player options.
64
- * @see https://docs.magmastream.com/main/introduction/getting-started
65
- */
66
- constructor(options: PlayerOptions);
67
- /**
68
- * Initializes the static properties of the Player class.
69
- * @hidden
70
- * @param manager The Manager to use.
71
- */
72
- static init(manager: Manager): void;
73
- /**
74
- * Set custom data.
75
- * @param key - The key to set the data for.
76
- * @param value - The value to set the data to.
77
- */
78
- set(key: string, value: unknown): void;
79
- /**
80
- * Retrieves custom data associated with a given key.
81
- * @template T - The expected type of the data.
82
- * @param {string} key - The key to retrieve the data for.
83
- * @returns {T} - The data associated with the key, cast to the specified type.
84
- */
85
- get<T>(key: string): T;
86
- /**
87
- * Same as Manager#search() but a shortcut on the player itself.
88
- * @param query
89
- * @param requester
90
- */
91
- search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
92
- /**
93
- * Connects the player to the voice channel.
94
- * @throws {RangeError} If no voice channel has been set.
95
- * @returns {void}
96
- */
97
- connect(): void;
98
- /**
99
- * Disconnects the player from the voice channel.
100
- * @returns {this} The player instance.
101
- */
102
- disconnect(): Promise<this>;
103
- /**
104
- * Destroys the player and clears the queue.
105
- * @param {boolean} disconnect - Whether to disconnect the player from the voice channel.
106
- * @returns {Promise<boolean>} - Whether the player was successfully destroyed.
107
- * @emits {PlayerDestroy} - Emitted when the player is destroyed.
108
- * @emits {PlayerStateUpdate} - Emitted when the player state is updated.
109
- */
110
- destroy(disconnect?: boolean): Promise<boolean>;
111
- /**
112
- * Sets the player voice channel.
113
- * @param {string} channel - The new voice channel ID.
114
- * @returns {this} - The player instance.
115
- * @throws {TypeError} If the channel parameter is not a string.
116
- */
117
- setVoiceChannelId(channel: string): this;
118
- /**
119
- * Sets the player text channel.
120
- *
121
- * This method updates the text channel associated with the player. It also
122
- * emits a player state update event indicating the change in the channel.
123
- *
124
- * @param {string} channel - The new text channel ID.
125
- * @returns {this} - The player instance for method chaining.
126
- * @throws {TypeError} If the channel parameter is not a string.
127
- */
128
- setTextChannelId(channel: string): this;
129
- /**
130
- * Sets the now playing message.
131
- *
132
- * @param message - The message of the now playing message.
133
- * @returns The now playing message.
134
- */
135
- setNowPlayingMessage(message: AnyMessage): AnyMessage;
136
- /**
137
- * Plays the next track.
138
- *
139
- * If a track is provided, it will be played. Otherwise, the next track in the queue will be played.
140
- * If the queue is not empty, but the current track has not finished yet, it will be replaced with the provided track.
141
- *
142
- * @param {object} [optionsOrTrack] - The track to play or the options to play with.
143
- * @param {object} [playOptions] - The options to play with.
144
- *
145
- * @returns {Promise<void>}
146
- */
147
- play(): Promise<Player>;
148
- play(track: Track): Promise<Player>;
149
- play(options: PlayOptions): Promise<Player>;
150
- play(track: Track, options: PlayOptions): Promise<Player>;
151
- /**
152
- * Sets the autoplay-state of the player.
153
- *
154
- * Autoplay is a feature that makes the player play a recommended
155
- * track when the current track ends.
156
- *
157
- * @param {boolean} autoplayState - Whether or not autoplay should be enabled.
158
- * @param {object} AutoplayUser - The user-object that should be used as the bot-user.
159
- * @param {number} [tries=3] - The number of times the player should try to find a
160
- * recommended track if the first one doesn't work.
161
- * @returns {this} - The player instance.
162
- */
163
- setAutoplay<T = unknown>(autoplayState: boolean, AutoplayUser?: T, tries?: number): this;
164
- /**
165
- * Gets recommended tracks and returns an array of tracks.
166
- * @param {Track} track - The track to find recommendations for.
167
- * @returns {Promise<Track[]>} - Array of recommended tracks.
168
- */
169
- getRecommendedTracks(track: Track): Promise<Track[]>;
170
- /**
171
- * Sets the volume of the player.
172
- * @param {number} volume - The new volume. Must be between 0 and 500 when using filter mode (100 = 100%).
173
- * @returns {Promise<Player>} - The updated player.
174
- * @throws {TypeError} If the volume is not a number.
175
- * @throws {RangeError} If the volume is not between 0 and 500 when using filter mode (100 = 100%).
176
- * @emits {PlayerStateUpdate} - Emitted when the volume is changed.
177
- * @example
178
- * player.setVolume(50);
179
- */
180
- setVolume(volume: number): Promise<this>;
181
- /**
182
- * Sets the sponsorblock for the player. This will set the sponsorblock segments for the player to the given segments.
183
- * @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
184
- * @returns {Promise<void>} The promise is resolved when the operation is complete.
185
- */
186
- setSponsorBlock(segments?: SponsorBlockSegment[]): Promise<void>;
187
- /**
188
- * Gets the sponsorblock for the player.
189
- * @returns {Promise<SponsorBlockSegment[]>} The sponsorblock segments.
190
- */
191
- getSponsorBlock(): Promise<SponsorBlockSegment[]>;
192
- /**
193
- * Deletes the sponsorblock for the player. This will remove all sponsorblock segments that have been set for the player.
194
- * @returns {Promise<void>}
195
- */
196
- deleteSponsorBlock(): Promise<void>;
197
- /**
198
- * Sets the track repeat mode.
199
- * When track repeat is enabled, the current track will replay after it ends.
200
- * Disables queueRepeat and dynamicRepeat modes if enabled.
201
- *
202
- * @param repeat - A boolean indicating whether to enable track repeat.
203
- * @returns {this} - The player instance.
204
- * @throws {TypeError} If the repeat parameter is not a boolean.
205
- */
206
- setTrackRepeat(repeat: boolean): this;
207
- /**
208
- * Sets the queue repeat.
209
- * @param repeat Whether to repeat the queue or not
210
- * @returns {this} - The player instance.
211
- * @throws {TypeError} If the repeat parameter is not a boolean
212
- */
213
- setQueueRepeat(repeat: boolean): this;
214
- /**
215
- * Sets the queue to repeat and shuffles the queue after each song.
216
- * @param repeat "true" or "false".
217
- * @param ms After how many milliseconds to trigger dynamic repeat.
218
- * @returns {this} - The player instance.
219
- * @throws {TypeError} If the repeat parameter is not a boolean.
220
- * @throws {RangeError} If the queue size is less than or equal to 1.
221
- */
222
- setDynamicRepeat(repeat: boolean, ms: number): Promise<this>;
223
- /**
224
- * Restarts the currently playing track from the beginning.
225
- * If there is no track playing, it will play the next track in the queue.
226
- * @returns {Promise<Player>} The current instance of the Player class for method chaining.
227
- */
228
- restart(): Promise<Player>;
229
- /**
230
- * Stops the player and optionally removes tracks from the queue.
231
- * @param {number} [amount] The amount of tracks to remove from the queue. If not provided, removes the current track if it exists.
232
- * @returns {Promise<this>} - The player instance.
233
- * @throws {RangeError} If the amount is greater than the queue length.
234
- */
235
- stop(amount?: number): Promise<this>;
236
- /**
237
- * Skips the current track.
238
- * @returns {this} - The player instance.
239
- * @throws {Error} If there are no tracks in the queue.
240
- * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
241
- */
242
- pause(pause: boolean): Promise<this>;
243
- /**
244
- * Skips to the previous track in the queue.
245
- * @returns {this} - The player instance.
246
- * @throws {Error} If there are no previous tracks in the queue.
247
- * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
248
- */
249
- previous(addBackToQueue?: boolean): Promise<this>;
250
- /**
251
- * Seeks to a given position in the currently playing track.
252
- * @param position - The position in milliseconds to seek to.
253
- * @returns {this} - The player instance.
254
- * @throws {Error} If the position is invalid.
255
- * @emits {PlayerStateUpdate} - With {@link PlayerStateEventTypes.TrackChange} as the change type.
256
- */
257
- seek(position: number): Promise<this>;
258
- /**
259
- * Returns the current repeat state of the player.
260
- * @param player The player to get the repeat state from.
261
- * @returns The repeat state of the player, or null if it is not repeating.
262
- */
263
- private getRepeatState;
264
- /**
265
- * Automatically moves the player to a usable node.
266
- * @returns {Promise<Player | void>} - The player instance or void if not moved.
267
- */
268
- autoMoveNode(): Promise<Player | void>;
269
- /**
270
- * Moves the player to another node.
271
- * @param {string} identifier - The identifier of the node to move to.
272
- * @returns {Promise<Player>} - The player instance after being moved.
273
- */
274
- moveNode(identifier: string): Promise<Player>;
275
- /**
276
- * Retrieves the data associated with the player.
277
- * @returns {Record<string, unknown>} - The data associated with the player.
278
- */
279
- getData(): Record<string, unknown>;
280
- /**
281
- * Retrieves the dynamic loop interval of the player.
282
- * @returns {NodeJS.Timeout | null} - The dynamic loop interval of the player.
283
- */
284
- getDynamicLoopIntervalPublic(): NodeJS.Timeout | null;
285
- /**
286
- * Retrieves the data associated with the player.
287
- * @returns {Record<string, unknown>} - The data associated with the player.
288
- */
289
- getSerializableData(): Record<string, unknown>;
290
- /**
291
- * Retrieves the current lyrics for the playing track.
292
- * @param skipTrackSource - Indicates whether to skip the track source when fetching lyrics.
293
- * @returns {Promise<Lyrics>} - The lyrics of the current track.
294
- */
295
- getCurrentLyrics(skipTrackSource?: boolean): Promise<Lyrics>;
296
- /**
297
- * Sets up the voice receiver for the player.
298
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is set up.
299
- * @throws {Error} - If the node is not a NodeLink.
300
- */
301
- setupVoiceReceiver(): Promise<void>;
302
- /**
303
- * Removes the voice receiver for the player.
304
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is removed.
305
- * @throws {Error} - If the node is not a NodeLink.
306
- */
307
- removeVoiceReceiver(): Promise<void>;
308
- /**
309
- * Closes the voice receiver for the player.
310
- * @param {number} code - The code to close the voice receiver with.
311
- * @param {string} reason - The reason to close the voice receiver with.
312
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is closed.
313
- */
314
- private closeVoiceReceiver;
315
- /**
316
- * Reconnects the voice receiver for the player.
317
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is reconnected.
318
- */
319
- private reconnectVoiceReceiver;
320
- /**
321
- * Disconnects the voice receiver for the player.
322
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is disconnected.
323
- */
324
- private disconnectVoiceReceiver;
325
- /**
326
- * Opens the voice receiver for the player.
327
- * @returns {Promise<void>} - A promise that resolves when the voice receiver is opened.
328
- */
329
- private openVoiceReceiver;
330
- /**
331
- * Handles a voice receiver message.
332
- * @param {string} payload - The payload to handle.
333
- * @returns {Promise<void>} - A promise that resolves when the voice receiver message is handled.
334
- */
335
- private onVoiceReceiverMessage;
336
- /**
337
- * Handles a voice receiver error.
338
- * @param {Error} error - The error to handle.
339
- * @returns {Promise<void>} - A promise that resolves when the voice receiver error is handled.
340
- */
341
- private onVoiceReceiverError;
342
- /**
343
- * Updates the voice state for the player.
344
- * @returns {Promise<void>} - A promise that resolves when the voice state is updated.
345
- */
346
- updateVoice(): Promise<void>;
347
- }
@@ -1,23 +0,0 @@
1
- import { Manager } from "./Manager";
2
- /**
3
- * Base abstract class for all plugins.
4
- * Users must extend this and implement load and unload methods.
5
- */
6
- export declare abstract class Plugin {
7
- readonly name: string;
8
- /**
9
- * @param name The name of the plugin
10
- */
11
- constructor(name: string);
12
- /**
13
- * Load the plugin.
14
- * @param manager The MagmaStream Manager instance
15
- */
16
- abstract load(manager: Manager): void;
17
- /**
18
- * Unload the plugin.
19
- * Called on shutdown to gracefully cleanup resources or detach listeners.
20
- * @param manager The MagmaStream Manager instance
21
- */
22
- abstract unload(manager: Manager): void;
23
- }
@@ -1,95 +0,0 @@
1
- import { Node } from "./Node";
2
- import { Manager } from "./Manager";
3
- import { LavalinkSession, LavaPlayer, RestPlayOptions } from "./Types";
4
- /** Handles the requests sent to the Lavalink REST API. */
5
- export declare class Rest {
6
- /** The Node that this Rest instance is connected to. */
7
- private node;
8
- /** The password for the Node. */
9
- private readonly password;
10
- /** The URL of the Node. */
11
- private readonly url;
12
- /** The Manager instance. */
13
- manager: Manager;
14
- /** Whether the node is a NodeLink. */
15
- isNodeLink: boolean;
16
- constructor(node: Node, manager: Manager);
17
- /**
18
- * Gets the session ID.
19
- * @returns {string} Returns the session ID.
20
- */
21
- private get sessionId();
22
- /**
23
- * Sets the session ID.
24
- * This method is used to set the session ID after a resume operation is done.
25
- * @param {string} sessionId The session ID to set.
26
- * @returns {string} Returns the set session ID.
27
- */
28
- setSessionId(sessionId: string): string;
29
- /**
30
- * Retrieves the player that is currently running on the node.
31
- * @param {string} guildId The guild ID of the player to retrieve.
32
- * @returns {Promise<LavaPlayer>} Returns the player.
33
- */
34
- getPlayer(guildId: string): Promise<LavaPlayer>;
35
- /**
36
- * Sends a PATCH request to update player related data.
37
- * @param {RestPlayOptions} options The options to update the player with.
38
- * @returns {Promise<LavaPlayer>} Returns the updated player.
39
- */
40
- updatePlayer(options: RestPlayOptions): Promise<LavaPlayer>;
41
- /**
42
- * Sends a DELETE request to the server to destroy the player.
43
- * @param {string} guildId The guild ID of the player to destroy.
44
- * @returns {Promise<void>} Returns void (204 No Content).
45
- */
46
- destroyPlayer(guildId: string): Promise<void>;
47
- /**
48
- * Updates the session status for resuming.
49
- * @param {boolean} resuming - Indicates whether the session should be set to resuming.
50
- * @param {number} timeout - The timeout duration for the session resume.
51
- * @returns {Promise<LavalinkSession>} The updated session.
52
- */
53
- updateSession(resuming: boolean, timeout: number): Promise<LavalinkSession>;
54
- /**
55
- * Sends a request to the specified endpoint and returns the response data.
56
- * @param {string} method The HTTP method to use for the request.
57
- * @param {string} endpoint The endpoint to send the request to.
58
- * @param {unknown} [body] The data to send in the request body.
59
- * @returns {Promise<unknown>} The response data of the request.
60
- */
61
- private request;
62
- /**
63
- * Sends a GET request to the specified endpoint and returns the response data.
64
- * @param {string} endpoint The endpoint to send the GET request to.
65
- * @returns {Promise<T>} The response data of the GET request.
66
- */
67
- get<T>(endpoint: string): Promise<T>;
68
- /**
69
- * Sends a PATCH request to the specified endpoint and returns the response data.
70
- * @param {string} endpoint The endpoint to send the PATCH request to.
71
- * @param {unknown} body The data to send in the request body.
72
- * @returns {Promise<T>} The response data of the PATCH request.
73
- */
74
- patch<T>(endpoint: string, body: unknown): Promise<T>;
75
- /**
76
- * Sends a POST request to the specified endpoint and returns the response data.
77
- * @param {string} endpoint The endpoint to send the POST request to.
78
- * @param {unknown} body The data to send in the request body.
79
- * @returns {Promise<T>} The response data of the POST request.
80
- */
81
- post<T>(endpoint: string, body: unknown): Promise<T>;
82
- /**
83
- * Sends a PUT request to the specified endpoint and returns the response data.
84
- * @param {string} endpoint The endpoint to send the PUT request to.
85
- * @param {unknown} body The data to send in the request body.
86
- * @returns {Promise<T>} The response data of the PUT request.
87
- */
88
- put<T>(endpoint: string, body: unknown): Promise<T>;
89
- /**
90
- * Sends a DELETE request to the specified endpoint.
91
- * @param {string} endpoint - The endpoint to send the DELETE request to.
92
- * @returns {Promise<void>} Void.
93
- */
94
- delete(endpoint: string): Promise<void>;
95
- }