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.
- package/dist/index.d.ts +3912 -20
- package/package.json +4 -4
- package/dist/config/blockedWords.d.ts +0 -1
- package/dist/statestorage/JsonQueue.d.ts +0 -173
- package/dist/statestorage/MemoryQueue.d.ts +0 -154
- package/dist/statestorage/RedisQueue.d.ts +0 -178
- package/dist/structures/Enums.d.ts +0 -313
- package/dist/structures/Filters.d.ts +0 -352
- package/dist/structures/MagmastreamError.d.ts +0 -14
- package/dist/structures/Manager.d.ts +0 -259
- package/dist/structures/Node.d.ts +0 -390
- package/dist/structures/Player.d.ts +0 -347
- package/dist/structures/Plugin.d.ts +0 -23
- package/dist/structures/Rest.d.ts +0 -95
- package/dist/structures/Types.d.ts +0 -1359
- package/dist/structures/Utils.d.ts +0 -169
- package/dist/utils/filtersEqualizers.d.ts +0 -16
- package/dist/utils/managerCheck.d.ts +0 -7
- package/dist/utils/nodeCheck.d.ts +0 -7
- package/dist/utils/playerCheck.d.ts +0 -7
- package/dist/wrappers/cloudstorm.d.ts +0 -27
- package/dist/wrappers/discord.js.d.ts +0 -14
- package/dist/wrappers/discordeno.d.ts +0 -18
- package/dist/wrappers/eris.d.ts +0 -14
- package/dist/wrappers/oceanic.d.ts +0 -14
- package/dist/wrappers/seyfert.d.ts +0 -36
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { Collection } from "@discordjs/collection";
|
|
2
|
-
import { GatewayVoiceStateUpdate } from "discord-api-types/v10";
|
|
3
|
-
import { EventEmitter } from "events";
|
|
4
|
-
import { Node } from "./Node";
|
|
5
|
-
import { Player } from "./Player";
|
|
6
|
-
import { Redis as RedisClient } from "ioredis";
|
|
7
|
-
import { AnyGuild, AnyUser, DiscordVoiceState, ManagerEvents, ManagerInitOptions, ManagerOptions, NodeOptions, PlayerOptions, SearchQuery, SearchResult, StandaloneManagerOptions, TrackData, VoicePacket, VoiceServer } from "./Types";
|
|
8
|
-
/**
|
|
9
|
-
* The main hub for interacting with Lavalink and using Magmastream.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Manager extends EventEmitter {
|
|
12
|
-
/** The map of players. */
|
|
13
|
-
readonly players: Collection<string, Player>;
|
|
14
|
-
/** The map of nodes. */
|
|
15
|
-
readonly nodes: Collection<string, Node>;
|
|
16
|
-
/** The options that were set. */
|
|
17
|
-
readonly options: ManagerOptions;
|
|
18
|
-
initiated: boolean;
|
|
19
|
-
redis?: RedisClient;
|
|
20
|
-
private _send;
|
|
21
|
-
private _getUser?;
|
|
22
|
-
private _getGuild?;
|
|
23
|
-
private loadedPlugins;
|
|
24
|
-
/**
|
|
25
|
-
* Initiates the Manager class.
|
|
26
|
-
* @param options
|
|
27
|
-
* @param options.enabledPlugins - An array of enabledPlugins to load.
|
|
28
|
-
* @param options.nodes - An array of node options to create nodes from.
|
|
29
|
-
* @param options.playNextOnEnd - Whether to automatically play the first track in the queue when the player is created.
|
|
30
|
-
* @param options.autoPlaySearchPlatforms - The search platform autoplay will use. Fallback to Youtube if not found.
|
|
31
|
-
* @param options.enablePriorityMode - Whether to use the priority when selecting a node to play on.
|
|
32
|
-
* @param options.clientName - The name of the client to send to Lavalink.
|
|
33
|
-
* @param options.defaultSearchPlatform - The default search platform to use when searching for tracks.
|
|
34
|
-
* @param options.useNode - The strategy to use when selecting a node to play on.
|
|
35
|
-
* @param options.trackPartial - The partial track search results to use when searching for tracks. This partials will always be presented on each track.
|
|
36
|
-
* @param options.eventBatchDuration - The duration to wait before processing the collected player state events.
|
|
37
|
-
* @param options.eventBatchInterval - The interval to wait before processing the collected player state events.
|
|
38
|
-
*/
|
|
39
|
-
constructor(options: StandaloneManagerOptions);
|
|
40
|
-
constructor(options: ManagerOptions, isWrapper: true);
|
|
41
|
-
/**
|
|
42
|
-
* Initiates the Manager.
|
|
43
|
-
* @param clientId - The Discord client ID (only required when not using any of the magmastream wrappers).
|
|
44
|
-
* @param clusterId - The cluster ID which runs the current process (required).
|
|
45
|
-
* @returns The manager instance.
|
|
46
|
-
*/
|
|
47
|
-
init(options?: ManagerInitOptions): Promise<this>;
|
|
48
|
-
/**
|
|
49
|
-
* Searches the enabled sources based off the URL or the `source` property.
|
|
50
|
-
* @param query
|
|
51
|
-
* @param requester
|
|
52
|
-
* @returns The search result.
|
|
53
|
-
*/
|
|
54
|
-
search<T = unknown>(query: string | SearchQuery, requester?: T): Promise<SearchResult>;
|
|
55
|
-
/**
|
|
56
|
-
* Returns a player or undefined if it does not exist.
|
|
57
|
-
* @param guildId The guild ID of the player to retrieve.
|
|
58
|
-
* @returns The player if it exists, undefined otherwise.
|
|
59
|
-
*/
|
|
60
|
-
getPlayer(guildId: string): Player | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* Creates a player or returns one if it already exists.
|
|
63
|
-
* @param options The options to create the player with.
|
|
64
|
-
* @returns The created player.
|
|
65
|
-
*/
|
|
66
|
-
create(options: PlayerOptions): Player;
|
|
67
|
-
/**
|
|
68
|
-
* Destroys a player.
|
|
69
|
-
* @param guildId The guild ID of the player to destroy.
|
|
70
|
-
* @returns A promise that resolves when the player has been destroyed.
|
|
71
|
-
*/
|
|
72
|
-
destroy(guildId: string): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Creates a new node or returns an existing one if it already exists.
|
|
75
|
-
* @param options - The options to create the node with.
|
|
76
|
-
* @returns The created node.
|
|
77
|
-
*/
|
|
78
|
-
createNode(options: NodeOptions): Node;
|
|
79
|
-
/**
|
|
80
|
-
* Destroys a node if it exists. Emits a debug event if the node is found and destroyed.
|
|
81
|
-
* @param identifier - The identifier of the node to destroy.
|
|
82
|
-
* @returns {void}
|
|
83
|
-
* @emits {debug} - Emits a debug message indicating the node is being destroyed.
|
|
84
|
-
*/
|
|
85
|
-
destroyNode(identifier: string): Promise<void>;
|
|
86
|
-
/**
|
|
87
|
-
* Attaches an event listener to the manager.
|
|
88
|
-
* @param event The event to listen for.
|
|
89
|
-
* @param listener The function to call when the event is emitted.
|
|
90
|
-
* @returns The manager instance for chaining.
|
|
91
|
-
*/
|
|
92
|
-
on<T extends keyof ManagerEvents>(event: T, listener: (...args: ManagerEvents[T]) => void): this;
|
|
93
|
-
/**
|
|
94
|
-
* Updates the voice state of a player based on the provided data.
|
|
95
|
-
* @param data - The data containing voice state information, which can be a VoicePacket, VoiceServer, or VoiceState.
|
|
96
|
-
* @returns A promise that resolves when the voice state update is handled.
|
|
97
|
-
* @emits {debug} - Emits a debug message indicating the voice state is being updated.
|
|
98
|
-
*/
|
|
99
|
-
updateVoiceState(data: VoicePacket | VoiceServer | DiscordVoiceState): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
* Decodes an array of base64 encoded tracks and returns an array of TrackData.
|
|
102
|
-
* Emits a debug event with the tracks being decoded.
|
|
103
|
-
* @param tracks - An array of base64 encoded track strings.
|
|
104
|
-
* @returns A promise that resolves to an array of TrackData objects.
|
|
105
|
-
* @throws Will throw an error if no nodes are available or if the API request fails.
|
|
106
|
-
*/
|
|
107
|
-
decodeTracks(tracks: string[]): Promise<TrackData[]>;
|
|
108
|
-
/**
|
|
109
|
-
* Decodes a base64 encoded track and returns a TrackData.
|
|
110
|
-
* @param track - The base64 encoded track string.
|
|
111
|
-
* @returns A promise that resolves to a TrackData object.
|
|
112
|
-
* @throws Will throw an error if no nodes are available or if the API request fails.
|
|
113
|
-
*/
|
|
114
|
-
decodeTrack(track: string): Promise<TrackData>;
|
|
115
|
-
/**
|
|
116
|
-
* Saves player states.
|
|
117
|
-
* @param {string} guildId - The guild ID of the player to save
|
|
118
|
-
*/
|
|
119
|
-
savePlayerState(guildId: string): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* Sleeps for a specified amount of time.
|
|
122
|
-
* @param ms The amount of time to sleep in milliseconds.
|
|
123
|
-
* @returns A promise that resolves after the specified amount of time.
|
|
124
|
-
*/
|
|
125
|
-
private sleep;
|
|
126
|
-
private restorePlayerFromState;
|
|
127
|
-
private restoreQueue;
|
|
128
|
-
private restorePreviousQueue;
|
|
129
|
-
private restoreRepeatState;
|
|
130
|
-
private restorePlayerData;
|
|
131
|
-
private restoreFilters;
|
|
132
|
-
/**
|
|
133
|
-
* Loads player states from the JSON file.
|
|
134
|
-
* @param nodeId The ID of the node to load player states from.
|
|
135
|
-
* @returns A promise that resolves when the player states have been loaded.
|
|
136
|
-
*/
|
|
137
|
-
loadPlayerStates(nodeId: string): Promise<void>;
|
|
138
|
-
/**
|
|
139
|
-
* Returns the node to use based on the configured `useNode` and `enablePriorityMode` options.
|
|
140
|
-
* If `enablePriorityMode` is true, the node is chosen based on priority, otherwise it is chosen based on the `useNode` option.
|
|
141
|
-
* If `useNode` is "leastLoad", the node with the lowest load is chosen, if it is "leastPlayers", the node with the fewest players is chosen.
|
|
142
|
-
* If `enablePriorityMode` is false and `useNode` is not set, the node with the lowest load is chosen.
|
|
143
|
-
* @returns {Node} The node to use.
|
|
144
|
-
*/
|
|
145
|
-
get useableNode(): Node;
|
|
146
|
-
/**
|
|
147
|
-
* Handles the shutdown of the process by saving all active players' states.
|
|
148
|
-
* This function is called when the process is about to exit.
|
|
149
|
-
* It iterates through all players and calls {@link savePlayerState} to save their states.
|
|
150
|
-
* After saving, it exits the process.
|
|
151
|
-
* @param stopProcess - A function to stop the process.
|
|
152
|
-
*/
|
|
153
|
-
handleShutdown(stopProcess?: () => Promise<void>): Promise<void>;
|
|
154
|
-
/**
|
|
155
|
-
* Parses a YouTube title into a clean title and author.
|
|
156
|
-
* @param title - The original title of the YouTube video.
|
|
157
|
-
* @param originalAuthor - The original author of the YouTube video.
|
|
158
|
-
* @returns An object with the clean title and author.
|
|
159
|
-
*/
|
|
160
|
-
private parseYouTubeTitle;
|
|
161
|
-
/**
|
|
162
|
-
* Balances brackets in a given string by ensuring all opened brackets are closed correctly.
|
|
163
|
-
* @param str - The input string that may contain unbalanced brackets.
|
|
164
|
-
* @returns A new string with balanced brackets.
|
|
165
|
-
*/
|
|
166
|
-
private balanceBrackets;
|
|
167
|
-
/**
|
|
168
|
-
* Escapes a string by replacing special regex characters with their escaped counterparts.
|
|
169
|
-
* @param string - The string to escape.
|
|
170
|
-
* @returns The escaped string.
|
|
171
|
-
*/
|
|
172
|
-
/**
|
|
173
|
-
* Checks if the given data is a voice update.
|
|
174
|
-
* @param data The data to check.
|
|
175
|
-
* @returns Whether the data is a voice update.
|
|
176
|
-
*/
|
|
177
|
-
private isVoiceUpdate;
|
|
178
|
-
/**
|
|
179
|
-
* Determines if the provided update is a valid voice update.
|
|
180
|
-
* A valid update must contain either a token or a session_id.
|
|
181
|
-
*
|
|
182
|
-
* @param update - The voice update data to validate, which can be a VoicePacket, VoiceServer, or VoiceState.
|
|
183
|
-
* @returns {boolean} - True if the update is valid, otherwise false.
|
|
184
|
-
*/
|
|
185
|
-
private isValidUpdate;
|
|
186
|
-
/**
|
|
187
|
-
* Handles a voice server update by updating the player's voice state and sending the voice state to the Lavalink node.
|
|
188
|
-
* @param player The player for which the voice state is being updated.
|
|
189
|
-
* @param update The voice server data received from Discord.
|
|
190
|
-
* @returns A promise that resolves when the voice state update is handled.
|
|
191
|
-
* @emits {debug} - Emits a debug message indicating the voice state is being updated.
|
|
192
|
-
*/
|
|
193
|
-
private handleVoiceServerUpdate;
|
|
194
|
-
/**
|
|
195
|
-
* Handles a voice state update by updating the player's voice channel and session ID if provided, or by disconnecting and destroying the player if the channel ID is null.
|
|
196
|
-
* @param player The player for which the voice state is being updated.
|
|
197
|
-
* @param update The voice state data received from Discord.
|
|
198
|
-
* @emits {playerMove} - Emits a player move event if the channel ID is provided and the player is currently connected to a different voice channel.
|
|
199
|
-
* @emits {playerDisconnect} - Emits a player disconnect event if the channel ID is null.
|
|
200
|
-
*/
|
|
201
|
-
private handleVoiceStateUpdate;
|
|
202
|
-
/**
|
|
203
|
-
* Cleans up an inactive player by removing its state data.
|
|
204
|
-
* This is done to prevent stale state data from accumulating.
|
|
205
|
-
* @param guildId The guild ID of the player to clean up.
|
|
206
|
-
*/
|
|
207
|
-
cleanupInactivePlayer(guildId: string): Promise<void>;
|
|
208
|
-
/**
|
|
209
|
-
* Loads the enabled plugins.
|
|
210
|
-
*/
|
|
211
|
-
private loadPlugins;
|
|
212
|
-
/**
|
|
213
|
-
* Unloads the enabled plugins.
|
|
214
|
-
*/
|
|
215
|
-
private unloadPlugins;
|
|
216
|
-
/**
|
|
217
|
-
* Clears all player states from the file system.
|
|
218
|
-
* This is done to prevent stale state files from accumulating on the file system.
|
|
219
|
-
*/
|
|
220
|
-
private clearAllStoredPlayers;
|
|
221
|
-
/**
|
|
222
|
-
* Returns the nodes that has the least load.
|
|
223
|
-
* The load is calculated by dividing the lavalink load by the number of cores.
|
|
224
|
-
* The result is multiplied by 100 to get a percentage.
|
|
225
|
-
* @returns {Collection<string, Node>}
|
|
226
|
-
*/
|
|
227
|
-
private get leastLoadNode();
|
|
228
|
-
/**
|
|
229
|
-
* Returns the nodes that have the least amount of players.
|
|
230
|
-
* Filters out disconnected nodes and sorts the remaining nodes
|
|
231
|
-
* by the number of players in ascending order.
|
|
232
|
-
* @returns {Collection<string, Node>} A collection of nodes sorted by player count.
|
|
233
|
-
*/
|
|
234
|
-
private get leastPlayersNode();
|
|
235
|
-
/**
|
|
236
|
-
* Returns a node based on priority.
|
|
237
|
-
* The nodes are sorted by priority in descending order, and then a random number
|
|
238
|
-
* between 0 and 1 is generated. The node that has a cumulative weight greater than or equal to the
|
|
239
|
-
* random number is returned.
|
|
240
|
-
* If no node has a cumulative weight greater than or equal to the random number, the node with the
|
|
241
|
-
* lowest load is returned.
|
|
242
|
-
* @returns {Node} The node to use.
|
|
243
|
-
*/
|
|
244
|
-
private get priorityNode();
|
|
245
|
-
protected send(packet: GatewayVoiceStateUpdate): unknown;
|
|
246
|
-
protected getUserFromCache(id: string): AnyUser | undefined;
|
|
247
|
-
protected getGuildFromCache(id: string): AnyGuild | undefined;
|
|
248
|
-
sendPacket(packet: GatewayVoiceStateUpdate): unknown;
|
|
249
|
-
/**
|
|
250
|
-
* Resolves a PortableUser or ID to a real user object.
|
|
251
|
-
* Can be overridden by wrapper managers to return wrapper-specific User classes.
|
|
252
|
-
*/
|
|
253
|
-
resolveUser(user: AnyUser | string): Promise<AnyUser>;
|
|
254
|
-
/**
|
|
255
|
-
* Resolves a Guild ID to a real guild object.
|
|
256
|
-
* Can be overridden by wrapper managers to return wrapper-specific Guild classes.
|
|
257
|
-
*/
|
|
258
|
-
resolveGuild(guildId: string): AnyGuild;
|
|
259
|
-
}
|
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
import { Manager } from "./Manager";
|
|
2
|
-
import { Player } from "./Player";
|
|
3
|
-
import { Rest } from "./Rest";
|
|
4
|
-
import WebSocket from "ws";
|
|
5
|
-
import { LavalinkInfo, Lyrics, NodeLinkGetLyrics, NodeOptions, NodeStats, PlayerEvent, PlayerEvents, Track, TrackEndEvent, TrackExceptionEvent, TrackStartEvent, TrackStuckEvent, WebSocketClosedEvent } from "./Types";
|
|
6
|
-
import { SponsorBlockSegment } from "./Enums";
|
|
7
|
-
export declare class Node {
|
|
8
|
-
manager: Manager;
|
|
9
|
-
options: NodeOptions;
|
|
10
|
-
/** The socket for the node. */
|
|
11
|
-
socket: WebSocket | null;
|
|
12
|
-
/** The stats for the node. */
|
|
13
|
-
stats: NodeStats;
|
|
14
|
-
/** The manager for the node */
|
|
15
|
-
/** The node's session ID. */
|
|
16
|
-
sessionId: string | null;
|
|
17
|
-
/** The REST instance. */
|
|
18
|
-
readonly rest: Rest;
|
|
19
|
-
/** Actual Lavalink information of the node. */
|
|
20
|
-
info: LavalinkInfo | null;
|
|
21
|
-
/** Whether the node is a NodeLink. */
|
|
22
|
-
isNodeLink: boolean;
|
|
23
|
-
private reconnectTimeout?;
|
|
24
|
-
private reconnectAttempts;
|
|
25
|
-
private redisPrefix?;
|
|
26
|
-
private sessionIdsMap;
|
|
27
|
-
/**
|
|
28
|
-
* Creates an instance of Node.
|
|
29
|
-
* @param manager - The manager for the node.
|
|
30
|
-
* @param options - The options for the node.
|
|
31
|
-
*/
|
|
32
|
-
constructor(manager: Manager, options: NodeOptions);
|
|
33
|
-
/**
|
|
34
|
-
* Checks if the Node is currently connected.
|
|
35
|
-
* This method returns true if the Node has an active WebSocket connection, indicating it is ready to receive and process commands.
|
|
36
|
-
*/
|
|
37
|
-
get connected(): boolean;
|
|
38
|
-
/** Returns the full address for this node, including the host and port. */
|
|
39
|
-
get address(): string;
|
|
40
|
-
private getCompositeKey;
|
|
41
|
-
private getRedisSessionIdsKey;
|
|
42
|
-
private getNodeSessionsDir;
|
|
43
|
-
private getNodeSessionPath;
|
|
44
|
-
/**
|
|
45
|
-
* Loads session IDs from the sessionIds.json file if it exists.
|
|
46
|
-
* The session IDs are used to resume sessions for each node.
|
|
47
|
-
*
|
|
48
|
-
* The session IDs are stored in the sessionIds.json file as a composite key
|
|
49
|
-
* of the node identifier and cluster ID. This allows multiple clusters to
|
|
50
|
-
* be used with the same node identifier.
|
|
51
|
-
*/
|
|
52
|
-
loadSessionIds(): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Updates the session ID in the sessionIds.json file.
|
|
55
|
-
*
|
|
56
|
-
* This method is called after the session ID has been updated, and it
|
|
57
|
-
* writes the new session ID to the sessionIds.json file.
|
|
58
|
-
*
|
|
59
|
-
* @remarks
|
|
60
|
-
* The session ID is stored in the sessionIds.json file as a composite key
|
|
61
|
-
* of the node identifier and cluster ID. This allows multiple clusters to
|
|
62
|
-
* be used with the same node identifier.
|
|
63
|
-
*/
|
|
64
|
-
updateSessionId(): Promise<void>;
|
|
65
|
-
private updateSessionIdFile;
|
|
66
|
-
private updateSessionIdRedis;
|
|
67
|
-
/**
|
|
68
|
-
* Connects to the Node.
|
|
69
|
-
*
|
|
70
|
-
* @remarks
|
|
71
|
-
* If the node is already connected, this method will do nothing.
|
|
72
|
-
* If the node has a session ID, it will be sent in the headers of the WebSocket connection.
|
|
73
|
-
* If the node has no session ID but the `enableSessionResumeOption` option is true, it will use the session ID
|
|
74
|
-
* stored in the sessionIds.json file if it exists.
|
|
75
|
-
*/
|
|
76
|
-
connect(): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Destroys the node and cleans up associated resources.
|
|
79
|
-
*
|
|
80
|
-
* This method emits a debug event indicating that the node is being destroyed and attempts
|
|
81
|
-
* to automatically move all players connected to the node to a usable one. It then closes
|
|
82
|
-
* the WebSocket connection, removes all event listeners, and clears the reconnect timeout.
|
|
83
|
-
* Finally, it emits a "nodeDestroy" event and removes the node from the manager.
|
|
84
|
-
*
|
|
85
|
-
* @returns {Promise<void>} A promise that resolves when the node and its resources have been destroyed.
|
|
86
|
-
*/
|
|
87
|
-
destroy(): Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Attempts to reconnect to the node if the connection is lost.
|
|
90
|
-
*
|
|
91
|
-
* This method is called when the WebSocket connection is closed
|
|
92
|
-
* unexpectedly. It will attempt to reconnect to the node after a
|
|
93
|
-
* specified delay, and will continue to do so until the maximum
|
|
94
|
-
* number of retry attempts is reached or the node is manually destroyed.
|
|
95
|
-
* If the maximum number of retry attempts is reached, an error event
|
|
96
|
-
* will be emitted and the node will be destroyed.
|
|
97
|
-
*
|
|
98
|
-
* @returns {Promise<void>} - Resolves when the reconnection attempt is scheduled.
|
|
99
|
-
* @emits {debug} - Emits a debug event indicating the node is attempting to reconnect.
|
|
100
|
-
* @emits {nodeReconnect} - Emits a nodeReconnect event when the node is attempting to reconnect.
|
|
101
|
-
* @emits {nodeError} - Emits an error event if the maximum number of retry attempts is reached.
|
|
102
|
-
* @emits {nodeDestroy} - Emits a nodeDestroy event if the maximum number of retry attempts is reached.
|
|
103
|
-
*/
|
|
104
|
-
private reconnect;
|
|
105
|
-
/**
|
|
106
|
-
* Upgrades the node to a NodeLink.
|
|
107
|
-
*
|
|
108
|
-
* @param request - The incoming message.
|
|
109
|
-
*/
|
|
110
|
-
private upgrade;
|
|
111
|
-
/**
|
|
112
|
-
* Handles the "open" event emitted by the WebSocket connection.
|
|
113
|
-
*
|
|
114
|
-
* This method is called when the WebSocket connection is established.
|
|
115
|
-
* It clears any existing reconnect timeouts, emits a debug event
|
|
116
|
-
* indicating the node is connected, and emits a "nodeConnect" event
|
|
117
|
-
* with the node as the argument.
|
|
118
|
-
*/
|
|
119
|
-
protected open(): void;
|
|
120
|
-
/**
|
|
121
|
-
* Handles the "close" event emitted by the WebSocket connection.
|
|
122
|
-
*
|
|
123
|
-
* This method is called when the WebSocket connection is closed.
|
|
124
|
-
* It emits a "nodeDisconnect" event with the node and the close event as arguments,
|
|
125
|
-
* and a debug event indicating the node is disconnected.
|
|
126
|
-
* It then attempts to move all players connected to that node to a useable one.
|
|
127
|
-
* If the close event was not initiated by the user, it will also attempt to reconnect.
|
|
128
|
-
*
|
|
129
|
-
* @param {number} code The close code of the WebSocket connection.
|
|
130
|
-
* @param {string} reason The reason for the close event.
|
|
131
|
-
* @returns {Promise<void>} A promise that resolves when the disconnection is handled.
|
|
132
|
-
*/
|
|
133
|
-
protected close(code: number, reason: string): Promise<void>;
|
|
134
|
-
/**
|
|
135
|
-
* Handles the "error" event emitted by the WebSocket connection.
|
|
136
|
-
*
|
|
137
|
-
* This method is called when an error occurs on the WebSocket connection.
|
|
138
|
-
* It emits a "nodeError" event with the node and the error as arguments and
|
|
139
|
-
* a debug event indicating the error on the node.
|
|
140
|
-
* @param {Error} error The error that occurred.
|
|
141
|
-
*/
|
|
142
|
-
protected error(error: Error): void;
|
|
143
|
-
/**
|
|
144
|
-
* Handles incoming messages from the Lavalink WebSocket connection.
|
|
145
|
-
* @param {Buffer | string} d The message received from the WebSocket connection.
|
|
146
|
-
* @returns {Promise<void>} A promise that resolves when the message is handled.
|
|
147
|
-
* @emits {debug} - Emits a debug event with the message received from the WebSocket connection.
|
|
148
|
-
* @emits {nodeError} - Emits a nodeError event if an unexpected op is received.
|
|
149
|
-
* @emits {nodeRaw} - Emits a nodeRaw event with the raw message received from the WebSocket connection.
|
|
150
|
-
* @private
|
|
151
|
-
*/
|
|
152
|
-
protected message(d: Buffer | string): Promise<void>;
|
|
153
|
-
/**
|
|
154
|
-
* Handles an event emitted from the Lavalink node.
|
|
155
|
-
* @param {PlayerEvent & PlayerEvents} payload The event emitted from the node.
|
|
156
|
-
* @returns {Promise<void>} A promise that resolves when the event has been handled.
|
|
157
|
-
* @private
|
|
158
|
-
*/
|
|
159
|
-
protected handleEvent(payload: PlayerEvent & PlayerEvents): Promise<void>;
|
|
160
|
-
/**
|
|
161
|
-
* Emitted when a new track starts playing.
|
|
162
|
-
* @param {Player} player The player that started playing the track.
|
|
163
|
-
* @param {Track} track The track that started playing.
|
|
164
|
-
* @param {TrackStartEvent} payload The payload of the event emitted by the node.
|
|
165
|
-
* @private
|
|
166
|
-
*/
|
|
167
|
-
protected trackStart(player: Player, track: Track, payload: TrackStartEvent): void;
|
|
168
|
-
/**
|
|
169
|
-
* Emitted when a track ends playing.
|
|
170
|
-
* @param {Player} player - The player that the track ended on.
|
|
171
|
-
* @param {Track} track - The track that ended.
|
|
172
|
-
* @param {TrackEndEvent} payload - The payload of the event emitted by the node.
|
|
173
|
-
* @private
|
|
174
|
-
*/
|
|
175
|
-
trackEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* Handles autoplay logic for a player.
|
|
178
|
-
* This method is responsible for selecting an appropriate method of autoplay
|
|
179
|
-
* and executing it. If autoplay is not enabled or all attempts have failed,
|
|
180
|
-
* it will return false.
|
|
181
|
-
* @param {Player} player - The player to handle autoplay for.
|
|
182
|
-
* @param {number} attempt - The current attempt number of the autoplay.
|
|
183
|
-
* @returns {Promise<boolean>} A promise that resolves to a boolean indicating if autoplay was successful.
|
|
184
|
-
* @private
|
|
185
|
-
*/
|
|
186
|
-
private handleAutoplay;
|
|
187
|
-
/**
|
|
188
|
-
* Handles the scenario when a track fails to play or load.
|
|
189
|
-
* Shifts the queue to the next track and emits a track end event.
|
|
190
|
-
* If there is no next track, handles the queue end scenario.
|
|
191
|
-
* If autoplay is enabled, plays the next track.
|
|
192
|
-
*
|
|
193
|
-
* @param {Player} player - The player instance associated with the track.
|
|
194
|
-
* @param {Track} track - The track that failed.
|
|
195
|
-
* @param {TrackEndEvent} payload - The event payload containing details about the track end.
|
|
196
|
-
* @returns {Promise<void>} A promise that resolves when the track failure has been processed.
|
|
197
|
-
* @private
|
|
198
|
-
*/
|
|
199
|
-
private handleFailedTrack;
|
|
200
|
-
/**
|
|
201
|
-
* Handles the scenario when a track is repeated.
|
|
202
|
-
* Shifts the queue to the next track and emits a track end event.
|
|
203
|
-
* If there is no next track, handles the queue end scenario.
|
|
204
|
-
* If autoplay is enabled, plays the next track.
|
|
205
|
-
*
|
|
206
|
-
* @param {Player} player - The player instance associated with the track.
|
|
207
|
-
* @param {Track} track - The track that is repeated.
|
|
208
|
-
* @param {TrackEndEvent} payload - The event payload containing details about the track end.
|
|
209
|
-
* @returns {Promise<void>} A promise that resolves when the repeated track has been processed.
|
|
210
|
-
* @private
|
|
211
|
-
*/
|
|
212
|
-
private handleRepeatedTrack;
|
|
213
|
-
/**
|
|
214
|
-
* Plays the next track in the queue.
|
|
215
|
-
* Updates the queue by shifting the current track to the previous track
|
|
216
|
-
* and plays the next track if autoplay is enabled.
|
|
217
|
-
*
|
|
218
|
-
* @param {Player} player - The player associated with the track.
|
|
219
|
-
* @param {Track} track - The track that has ended.
|
|
220
|
-
* @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
|
|
221
|
-
* @returns {void}
|
|
222
|
-
* @private
|
|
223
|
-
*/
|
|
224
|
-
private playNextTrack;
|
|
225
|
-
/**
|
|
226
|
-
* Handles the event when a queue ends.
|
|
227
|
-
* If autoplay is enabled, attempts to play the next track in the queue using the autoplay logic.
|
|
228
|
-
* If all attempts fail, resets the player state and emits the `queueEnd` event.
|
|
229
|
-
* @param {Player} player - The player associated with the track.
|
|
230
|
-
* @param {Track} track - The track that has ended.
|
|
231
|
-
* @param {TrackEndEvent} payload - The event payload containing additional data about the track end event.
|
|
232
|
-
* @returns {Promise<void>} A promise that resolves when the queue end processing is complete.
|
|
233
|
-
*/
|
|
234
|
-
queueEnd(player: Player, track: Track, payload: TrackEndEvent): Promise<void>;
|
|
235
|
-
/**
|
|
236
|
-
* Fetches the lyrics of a track from the Lavalink node.
|
|
237
|
-
*
|
|
238
|
-
* If the node is a NodeLink, it will use the `NodeLinkGetLyrics` method to fetch the lyrics.
|
|
239
|
-
*
|
|
240
|
-
* Requires the `lavalyrics-plugin` to be present in the Lavalink node.
|
|
241
|
-
* Requires the `lavasrc-plugin` or `java-lyrics-plugin` to be present in the Lavalink node.
|
|
242
|
-
*
|
|
243
|
-
* @param {Track} track - The track to fetch the lyrics for.
|
|
244
|
-
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
245
|
-
* @param {string} [language="en"] - The language of the lyrics.
|
|
246
|
-
* @returns {Promise<Lyrics | NodeLinkGetLyrics>} A promise that resolves with the lyrics data.
|
|
247
|
-
*/
|
|
248
|
-
getLyrics(track: Track, skipTrackSource?: boolean, language?: string): Promise<Lyrics | NodeLinkGetLyrics>;
|
|
249
|
-
/**
|
|
250
|
-
* Subscribes to lyrics for a player.
|
|
251
|
-
* @param {string} guildId - The ID of the guild to subscribe to lyrics for.
|
|
252
|
-
* @param {boolean} [skipTrackSource=false] - Whether to skip using the track's source URL.
|
|
253
|
-
* @returns {Promise<unknown>} A promise that resolves when the subscription is complete.
|
|
254
|
-
* @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
|
|
255
|
-
*/
|
|
256
|
-
lyricsSubscribe(guildId: string, skipTrackSource?: boolean): Promise<unknown>;
|
|
257
|
-
/**
|
|
258
|
-
* Unsubscribes from lyrics for a player.
|
|
259
|
-
* @param {string} guildId - The ID of the guild to unsubscribe from lyrics for.
|
|
260
|
-
* @returns {Promise<unknown>} A promise that resolves when the unsubscription is complete.
|
|
261
|
-
* @throws {RangeError} If the node is not connected to the lavalink server or if the java-lyrics-plugin is not available.
|
|
262
|
-
*/
|
|
263
|
-
lyricsUnsubscribe(guildId: string): Promise<unknown>;
|
|
264
|
-
/**
|
|
265
|
-
* Handles the event when a track becomes stuck during playback.
|
|
266
|
-
* Stops the current track and emits a `trackStuck` event.
|
|
267
|
-
*
|
|
268
|
-
* @param {Player} player - The player associated with the track that became stuck.
|
|
269
|
-
* @param {Track} track - The track that became stuck.
|
|
270
|
-
* @param {TrackStuckEvent} payload - The event payload containing additional data about the track stuck event.
|
|
271
|
-
* @returns {void}
|
|
272
|
-
* @protected
|
|
273
|
-
*/
|
|
274
|
-
protected trackStuck(player: Player, track: Track, payload: TrackStuckEvent): Promise<void>;
|
|
275
|
-
/**
|
|
276
|
-
* Handles the event when a track has an error during playback.
|
|
277
|
-
* Stops the current track and emits a `trackError` event.
|
|
278
|
-
*
|
|
279
|
-
* @param {Player} player - The player associated with the track that had an error.
|
|
280
|
-
* @param {Track} track - The track that had an error.
|
|
281
|
-
* @param {TrackExceptionEvent} payload - The event payload containing additional data about the track error event.
|
|
282
|
-
* @returns {void}
|
|
283
|
-
* @protected
|
|
284
|
-
*/
|
|
285
|
-
protected trackError(player: Player, track: Track, payload: TrackExceptionEvent): Promise<void>;
|
|
286
|
-
/**
|
|
287
|
-
* Emitted when the WebSocket connection for a player closes.
|
|
288
|
-
* The payload of the event will contain the close code and reason if provided.
|
|
289
|
-
* @param {Player} player - The player associated with the WebSocket connection.
|
|
290
|
-
* @param {WebSocketClosedEvent} payload - The event payload containing additional data about the WebSocket close event.
|
|
291
|
-
*/
|
|
292
|
-
protected socketClosed(player: Player, payload: WebSocketClosedEvent): void;
|
|
293
|
-
/**
|
|
294
|
-
* Emitted when the segments for a track are loaded.
|
|
295
|
-
* The payload of the event will contain the segments.
|
|
296
|
-
* @param {Player} player - The player associated with the segments.
|
|
297
|
-
* @param {Track} track - The track associated with the segments.
|
|
298
|
-
* @param {SponsorBlockSegmentsLoaded} payload - The event payload containing additional data about the segments loaded event.
|
|
299
|
-
*/
|
|
300
|
-
private sponsorBlockSegmentLoaded;
|
|
301
|
-
/**
|
|
302
|
-
* Emitted when a segment of a track is skipped using the sponsorblock plugin.
|
|
303
|
-
* The payload of the event will contain the skipped segment.
|
|
304
|
-
* @param {Player} player - The player associated with the skipped segment.
|
|
305
|
-
* @param {Track} track - The track associated with the skipped segment.
|
|
306
|
-
* @param {SponsorBlockSegmentSkipped} payload - The event payload containing additional data about the segment skipped event.
|
|
307
|
-
*/
|
|
308
|
-
private sponsorBlockSegmentSkipped;
|
|
309
|
-
/**
|
|
310
|
-
* Emitted when chapters for a track are loaded using the sponsorblock plugin.
|
|
311
|
-
* The payload of the event will contain the chapters.
|
|
312
|
-
* @param {Player} player - The player associated with the chapters.
|
|
313
|
-
* @param {Track} track - The track associated with the chapters.
|
|
314
|
-
* @param {SponsorBlockChaptersLoaded} payload - The event payload containing additional data about the chapters loaded event.
|
|
315
|
-
*/
|
|
316
|
-
private sponsorBlockChaptersLoaded;
|
|
317
|
-
/**
|
|
318
|
-
* Emitted when a chapter of a track is started using the sponsorblock plugin.
|
|
319
|
-
* The payload of the event will contain the started chapter.
|
|
320
|
-
* @param {Player} player - The player associated with the started chapter.
|
|
321
|
-
* @param {Track} track - The track associated with the started chapter.
|
|
322
|
-
* @param {SponsorBlockChapterStarted} payload - The event payload containing additional data about the chapter started event.
|
|
323
|
-
*/
|
|
324
|
-
private sponsorBlockChapterStarted;
|
|
325
|
-
/**
|
|
326
|
-
* Emitted when lyrics for a track are found.
|
|
327
|
-
* The payload of the event will contain the lyrics.
|
|
328
|
-
* @param {Player} player - The player associated with the lyrics.
|
|
329
|
-
* @param {Track} track - The track associated with the lyrics.
|
|
330
|
-
* @param {LyricsFoundEvent} payload - The event payload containing additional data about the lyrics found event.
|
|
331
|
-
*/
|
|
332
|
-
private lyricsFound;
|
|
333
|
-
/**
|
|
334
|
-
* Emitted when lyrics for a track are not found.
|
|
335
|
-
* The payload of the event will contain the track.
|
|
336
|
-
* @param {Player} player - The player associated with the lyrics.
|
|
337
|
-
* @param {Track} track - The track associated with the lyrics.
|
|
338
|
-
* @param {LyricsNotFoundEvent} payload - The event payload containing additional data about the lyrics not found event.
|
|
339
|
-
*/
|
|
340
|
-
private lyricsNotFound;
|
|
341
|
-
/**
|
|
342
|
-
* Emitted when a line of lyrics for a track is received.
|
|
343
|
-
* The payload of the event will contain the lyrics line.
|
|
344
|
-
* @param {Player} player - The player associated with the lyrics line.
|
|
345
|
-
* @param {Track} track - The track associated with the lyrics line.
|
|
346
|
-
* @param {LyricsLineEvent} payload - The event payload containing additional data about the lyrics line event.
|
|
347
|
-
*/
|
|
348
|
-
private lyricsLine;
|
|
349
|
-
/**
|
|
350
|
-
* Fetches Lavalink node information.
|
|
351
|
-
* @returns {Promise<LavalinkInfo>} A promise that resolves to the Lavalink node information.
|
|
352
|
-
*/
|
|
353
|
-
fetchInfo(): Promise<LavalinkInfo>;
|
|
354
|
-
/**
|
|
355
|
-
* Gets the current sponsorblock segments for a player.
|
|
356
|
-
* @param {Player} player - The player to get the sponsorblocks for.
|
|
357
|
-
* @returns {Promise<SponsorBlockSegment[]>} A promise that resolves to the sponsorblock segments.
|
|
358
|
-
* @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
|
|
359
|
-
*/
|
|
360
|
-
getSponsorBlock(player: Player): Promise<SponsorBlockSegment[]>;
|
|
361
|
-
/**
|
|
362
|
-
* Sets the sponsorblock segments for a player.
|
|
363
|
-
* @param {Player} player - The player to set the sponsor blocks for.
|
|
364
|
-
* @param {SponsorBlockSegment[]} segments - The sponsorblock segments to set. Defaults to `[SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]` if not provided.
|
|
365
|
-
* @returns {Promise<void>} The promise is resolved when the operation is complete.
|
|
366
|
-
* @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
|
|
367
|
-
* @throws {RangeError} If no segments are provided.
|
|
368
|
-
* @throws {SyntaxError} If an invalid sponsorblock is provided.
|
|
369
|
-
* @example
|
|
370
|
-
* ```ts
|
|
371
|
-
* // use it on the player via player.setSponsorBlock();
|
|
372
|
-
* player.setSponsorBlock([SponsorBlockSegment.Sponsor, SponsorBlockSegment.SelfPromo]);
|
|
373
|
-
* ```
|
|
374
|
-
*/
|
|
375
|
-
setSponsorBlock(player: Player, segments?: SponsorBlockSegment[]): Promise<void>;
|
|
376
|
-
/**
|
|
377
|
-
* Deletes the sponsorblock segments for a player.
|
|
378
|
-
* @param {Player} player - The player to delete the sponsorblocks for.
|
|
379
|
-
* @returns {Promise<void>} The promise is resolved when the operation is complete.
|
|
380
|
-
* @throws {RangeError} If the sponsorblock-plugin is not available in the Lavalink node.
|
|
381
|
-
*/
|
|
382
|
-
deleteSponsorBlock(player: Player): Promise<void>;
|
|
383
|
-
/**
|
|
384
|
-
* Creates a README.md or README.txt file in the magmastream directory
|
|
385
|
-
* if it doesn't already exist. This file is used to store player data
|
|
386
|
-
* for autoresume and other features.
|
|
387
|
-
* @private
|
|
388
|
-
*/
|
|
389
|
-
private createReadmeFile;
|
|
390
|
-
}
|