lavalink-client 1.1.24 → 1.1.25
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/cjs/structures/LavalinkManager.d.ts +4 -3
- package/dist/cjs/structures/LavalinkManager.js +12 -5
- package/dist/cjs/structures/Node.js +2 -2
- package/dist/cjs/structures/Player.d.ts +1 -1
- package/dist/cjs/structures/Player.js +6 -3
- package/dist/esm/structures/LavalinkManager.d.ts +4 -3
- package/dist/esm/structures/LavalinkManager.js +12 -5
- package/dist/esm/structures/Node.js +2 -2
- package/dist/esm/structures/Player.d.ts +1 -1
- package/dist/esm/structures/Player.js +6 -3
- package/dist/types/structures/LavalinkManager.d.ts +4 -3
- package/dist/types/structures/Player.d.ts +1 -1
- package/package.json +1 -1
|
@@ -64,7 +64,7 @@ export interface ManagerOptions {
|
|
|
64
64
|
playerDestroy?: {
|
|
65
65
|
/** To show the debug reason at all times. */
|
|
66
66
|
debugLog?: boolean;
|
|
67
|
-
/** If you get 'Error: Use Player#destroy(
|
|
67
|
+
/** If you get 'Error: Use Player#destroy("reason") not LavalinkManager#deletePlayer() to stop the Player' put it on true */
|
|
68
68
|
dontThrowError?: boolean;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
@@ -102,7 +102,7 @@ interface LavalinkManagerEvents {
|
|
|
102
102
|
"playerCreate": (player: Player) => void;
|
|
103
103
|
/**
|
|
104
104
|
* Emitted when a Player is moved within the channel.
|
|
105
|
-
* @event Manager
|
|
105
|
+
* @event Manager#playerMove
|
|
106
106
|
*/
|
|
107
107
|
"playerMove": (player: Player, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
|
|
108
108
|
/**
|
|
@@ -141,7 +141,8 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
141
141
|
constructor(options: ManagerOptions);
|
|
142
142
|
createPlayer(options: PlayerOptions): Player;
|
|
143
143
|
getPlayer(guildId: string): Player;
|
|
144
|
-
|
|
144
|
+
destroyPlayer(guildId: string, destroyReason?: string): Promise<Player>;
|
|
145
|
+
deletePlayer(guildId: string): boolean;
|
|
145
146
|
get useable(): boolean;
|
|
146
147
|
/**
|
|
147
148
|
* Initiates the Manager.
|
|
@@ -101,15 +101,22 @@ class LavalinkManager extends events_1.EventEmitter {
|
|
|
101
101
|
getPlayer(guildId) {
|
|
102
102
|
return this.players.get(guildId);
|
|
103
103
|
}
|
|
104
|
-
|
|
104
|
+
destroyPlayer(guildId, destroyReason) {
|
|
105
105
|
const oldPlayer = this.getPlayer(guildId);
|
|
106
106
|
if (!oldPlayer)
|
|
107
107
|
return;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
return oldPlayer.destroy(destroyReason);
|
|
109
|
+
}
|
|
110
|
+
deletePlayer(guildId) {
|
|
111
|
+
const oldPlayer = this.getPlayer(guildId);
|
|
112
|
+
if (!oldPlayer)
|
|
113
|
+
return;
|
|
114
|
+
// oldPlayer.connected is operational. you could also do oldPlayer.voice?.token
|
|
115
|
+
if (oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
116
|
+
if (!this.options?.debugOptions?.playerDestroy?.dontThrowError)
|
|
117
|
+
throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${JSON.stringify(oldPlayer.toJSON?.())}`);
|
|
111
118
|
else
|
|
112
|
-
console.error("Use Player#destroy(
|
|
119
|
+
console.error("Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player", oldPlayer.toJSON?.());
|
|
113
120
|
}
|
|
114
121
|
return this.players.delete(guildId);
|
|
115
122
|
}
|
|
@@ -87,7 +87,7 @@ class LavalinkNode {
|
|
|
87
87
|
modify?.(options);
|
|
88
88
|
const url = new URL(`${this.poolAddress}${options.path}`);
|
|
89
89
|
url.searchParams.append("trace", "true");
|
|
90
|
-
options.path = url.
|
|
90
|
+
options.path = url.pathname + url.search;
|
|
91
91
|
const request = await this.rest.request(options);
|
|
92
92
|
this.calls++;
|
|
93
93
|
if (options.method === "DELETE")
|
|
@@ -171,7 +171,7 @@ class LavalinkNode {
|
|
|
171
171
|
if (data.noReplace) {
|
|
172
172
|
const url = new URL(`${this.poolAddress}${r.path}`);
|
|
173
173
|
url.searchParams.append("noReplace", data.noReplace?.toString() || "false");
|
|
174
|
-
r.path = url.
|
|
174
|
+
r.path = url.pathname + url.search;
|
|
175
175
|
}
|
|
176
176
|
});
|
|
177
177
|
return this.syncPlayerData({}, res), res;
|
|
@@ -192,7 +192,7 @@ export declare class Player {
|
|
|
192
192
|
/**
|
|
193
193
|
* Destroy the player and disconnect from the voice channel
|
|
194
194
|
*/
|
|
195
|
-
destroy(reason?: string): Promise<this>;
|
|
195
|
+
destroy(reason?: string, disconnect?: boolean): Promise<this>;
|
|
196
196
|
/**
|
|
197
197
|
* Move the player on a different Audio-Node
|
|
198
198
|
* @param newNode New Node / New Node Id
|
|
@@ -345,7 +345,7 @@ class Player {
|
|
|
345
345
|
/**
|
|
346
346
|
* Destroy the player and disconnect from the voice channel
|
|
347
347
|
*/
|
|
348
|
-
async destroy(reason) {
|
|
348
|
+
async destroy(reason, disconnect = true) {
|
|
349
349
|
if (this.LavalinkManager.options.debugOptions.playerDestroy.debugLog)
|
|
350
350
|
console.log(`Lavalink-Client-Debug | PlayerDestroy [::] destroy Function, [guildId ${this.guildId}] - Destroy-Reason: ${String(reason)}`);
|
|
351
351
|
if (this.get("internal_destroystatus") === true) {
|
|
@@ -355,11 +355,14 @@ class Player {
|
|
|
355
355
|
}
|
|
356
356
|
this.set("internal_destroystatus", true);
|
|
357
357
|
// disconnect player and set VoiceChannel to Null
|
|
358
|
-
|
|
358
|
+
if (disconnect)
|
|
359
|
+
await this.disconnect(true);
|
|
360
|
+
else
|
|
361
|
+
this.set("internal_destroywithoutdisconnect", true);
|
|
359
362
|
// Destroy the queue
|
|
360
363
|
await this.queue.utils.destroy();
|
|
361
364
|
// delete the player from cache
|
|
362
|
-
this.LavalinkManager.deletePlayer(this.guildId
|
|
365
|
+
this.LavalinkManager.deletePlayer(this.guildId);
|
|
363
366
|
// destroy the player on lavalink side
|
|
364
367
|
await this.node.destroyPlayer(this.guildId);
|
|
365
368
|
if (this.LavalinkManager.options.debugOptions.playerDestroy.debugLog)
|
|
@@ -64,7 +64,7 @@ export interface ManagerOptions {
|
|
|
64
64
|
playerDestroy?: {
|
|
65
65
|
/** To show the debug reason at all times. */
|
|
66
66
|
debugLog?: boolean;
|
|
67
|
-
/** If you get 'Error: Use Player#destroy(
|
|
67
|
+
/** If you get 'Error: Use Player#destroy("reason") not LavalinkManager#deletePlayer() to stop the Player' put it on true */
|
|
68
68
|
dontThrowError?: boolean;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
@@ -102,7 +102,7 @@ interface LavalinkManagerEvents {
|
|
|
102
102
|
"playerCreate": (player: Player) => void;
|
|
103
103
|
/**
|
|
104
104
|
* Emitted when a Player is moved within the channel.
|
|
105
|
-
* @event Manager
|
|
105
|
+
* @event Manager#playerMove
|
|
106
106
|
*/
|
|
107
107
|
"playerMove": (player: Player, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
|
|
108
108
|
/**
|
|
@@ -141,7 +141,8 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
141
141
|
constructor(options: ManagerOptions);
|
|
142
142
|
createPlayer(options: PlayerOptions): Player;
|
|
143
143
|
getPlayer(guildId: string): Player;
|
|
144
|
-
|
|
144
|
+
destroyPlayer(guildId: string, destroyReason?: string): Promise<Player>;
|
|
145
|
+
deletePlayer(guildId: string): boolean;
|
|
145
146
|
get useable(): boolean;
|
|
146
147
|
/**
|
|
147
148
|
* Initiates the Manager.
|
|
@@ -98,15 +98,22 @@ export class LavalinkManager extends EventEmitter {
|
|
|
98
98
|
getPlayer(guildId) {
|
|
99
99
|
return this.players.get(guildId);
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
destroyPlayer(guildId, destroyReason) {
|
|
102
102
|
const oldPlayer = this.getPlayer(guildId);
|
|
103
103
|
if (!oldPlayer)
|
|
104
104
|
return;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
return oldPlayer.destroy(destroyReason);
|
|
106
|
+
}
|
|
107
|
+
deletePlayer(guildId) {
|
|
108
|
+
const oldPlayer = this.getPlayer(guildId);
|
|
109
|
+
if (!oldPlayer)
|
|
110
|
+
return;
|
|
111
|
+
// oldPlayer.connected is operational. you could also do oldPlayer.voice?.token
|
|
112
|
+
if (oldPlayer.voiceChannelId === "string" && oldPlayer.connected && !oldPlayer.get("internal_destroywithoutdisconnect")) {
|
|
113
|
+
if (!this.options?.debugOptions?.playerDestroy?.dontThrowError)
|
|
114
|
+
throw new Error(`Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player ${JSON.stringify(oldPlayer.toJSON?.())}`);
|
|
108
115
|
else
|
|
109
|
-
console.error("Use Player#destroy(
|
|
116
|
+
console.error("Use Player#destroy() not LavalinkManager#deletePlayer() to stop the Player", oldPlayer.toJSON?.());
|
|
110
117
|
}
|
|
111
118
|
return this.players.delete(guildId);
|
|
112
119
|
}
|
|
@@ -83,7 +83,7 @@ export class LavalinkNode {
|
|
|
83
83
|
modify?.(options);
|
|
84
84
|
const url = new URL(`${this.poolAddress}${options.path}`);
|
|
85
85
|
url.searchParams.append("trace", "true");
|
|
86
|
-
options.path = url.
|
|
86
|
+
options.path = url.pathname + url.search;
|
|
87
87
|
const request = await this.rest.request(options);
|
|
88
88
|
this.calls++;
|
|
89
89
|
if (options.method === "DELETE")
|
|
@@ -167,7 +167,7 @@ export class LavalinkNode {
|
|
|
167
167
|
if (data.noReplace) {
|
|
168
168
|
const url = new URL(`${this.poolAddress}${r.path}`);
|
|
169
169
|
url.searchParams.append("noReplace", data.noReplace?.toString() || "false");
|
|
170
|
-
r.path = url.
|
|
170
|
+
r.path = url.pathname + url.search;
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
return this.syncPlayerData({}, res), res;
|
|
@@ -192,7 +192,7 @@ export declare class Player {
|
|
|
192
192
|
/**
|
|
193
193
|
* Destroy the player and disconnect from the voice channel
|
|
194
194
|
*/
|
|
195
|
-
destroy(reason?: string): Promise<this>;
|
|
195
|
+
destroy(reason?: string, disconnect?: boolean): Promise<this>;
|
|
196
196
|
/**
|
|
197
197
|
* Move the player on a different Audio-Node
|
|
198
198
|
* @param newNode New Node / New Node Id
|
|
@@ -342,7 +342,7 @@ export class Player {
|
|
|
342
342
|
/**
|
|
343
343
|
* Destroy the player and disconnect from the voice channel
|
|
344
344
|
*/
|
|
345
|
-
async destroy(reason) {
|
|
345
|
+
async destroy(reason, disconnect = true) {
|
|
346
346
|
if (this.LavalinkManager.options.debugOptions.playerDestroy.debugLog)
|
|
347
347
|
console.log(`Lavalink-Client-Debug | PlayerDestroy [::] destroy Function, [guildId ${this.guildId}] - Destroy-Reason: ${String(reason)}`);
|
|
348
348
|
if (this.get("internal_destroystatus") === true) {
|
|
@@ -352,11 +352,14 @@ export class Player {
|
|
|
352
352
|
}
|
|
353
353
|
this.set("internal_destroystatus", true);
|
|
354
354
|
// disconnect player and set VoiceChannel to Null
|
|
355
|
-
|
|
355
|
+
if (disconnect)
|
|
356
|
+
await this.disconnect(true);
|
|
357
|
+
else
|
|
358
|
+
this.set("internal_destroywithoutdisconnect", true);
|
|
356
359
|
// Destroy the queue
|
|
357
360
|
await this.queue.utils.destroy();
|
|
358
361
|
// delete the player from cache
|
|
359
|
-
this.LavalinkManager.deletePlayer(this.guildId
|
|
362
|
+
this.LavalinkManager.deletePlayer(this.guildId);
|
|
360
363
|
// destroy the player on lavalink side
|
|
361
364
|
await this.node.destroyPlayer(this.guildId);
|
|
362
365
|
if (this.LavalinkManager.options.debugOptions.playerDestroy.debugLog)
|
|
@@ -64,7 +64,7 @@ export interface ManagerOptions {
|
|
|
64
64
|
playerDestroy?: {
|
|
65
65
|
/** To show the debug reason at all times. */
|
|
66
66
|
debugLog?: boolean;
|
|
67
|
-
/** If you get 'Error: Use Player#destroy(
|
|
67
|
+
/** If you get 'Error: Use Player#destroy("reason") not LavalinkManager#deletePlayer() to stop the Player' put it on true */
|
|
68
68
|
dontThrowError?: boolean;
|
|
69
69
|
};
|
|
70
70
|
};
|
|
@@ -102,7 +102,7 @@ interface LavalinkManagerEvents {
|
|
|
102
102
|
"playerCreate": (player: Player) => void;
|
|
103
103
|
/**
|
|
104
104
|
* Emitted when a Player is moved within the channel.
|
|
105
|
-
* @event Manager
|
|
105
|
+
* @event Manager#playerMove
|
|
106
106
|
*/
|
|
107
107
|
"playerMove": (player: Player, oldVoiceChannelId: string, newVoiceChannelId: string) => void;
|
|
108
108
|
/**
|
|
@@ -141,7 +141,8 @@ export declare class LavalinkManager extends EventEmitter {
|
|
|
141
141
|
constructor(options: ManagerOptions);
|
|
142
142
|
createPlayer(options: PlayerOptions): Player;
|
|
143
143
|
getPlayer(guildId: string): Player;
|
|
144
|
-
|
|
144
|
+
destroyPlayer(guildId: string, destroyReason?: string): Promise<Player>;
|
|
145
|
+
deletePlayer(guildId: string): boolean;
|
|
145
146
|
get useable(): boolean;
|
|
146
147
|
/**
|
|
147
148
|
* Initiates the Manager.
|
|
@@ -192,7 +192,7 @@ export declare class Player {
|
|
|
192
192
|
/**
|
|
193
193
|
* Destroy the player and disconnect from the voice channel
|
|
194
194
|
*/
|
|
195
|
-
destroy(reason?: string): Promise<this>;
|
|
195
|
+
destroy(reason?: string, disconnect?: boolean): Promise<this>;
|
|
196
196
|
/**
|
|
197
197
|
* Move the player on a different Audio-Node
|
|
198
198
|
* @param newNode New Node / New Node Id
|
package/package.json
CHANGED