magmastream 2.10.6-alpha.1 → 2.10.6-alpha.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.
|
@@ -532,8 +532,7 @@ class Manager extends events_1.EventEmitter {
|
|
|
532
532
|
async restorePlayerFromState(node, nodeId, guildId, state, cleanup) {
|
|
533
533
|
if (!state.guildId || state.node?.options?.identifier !== nodeId)
|
|
534
534
|
return;
|
|
535
|
-
|
|
536
|
-
if (!hasGuild)
|
|
535
|
+
if (state.guildId !== guildId)
|
|
537
536
|
return;
|
|
538
537
|
const lavaPlayer = (await node.rest.get(`/v4/sessions/${state.node.sessionId}/players/${state.guildId}`));
|
|
539
538
|
if (!lavaPlayer)
|
|
@@ -720,6 +719,9 @@ class Manager extends events_1.EventEmitter {
|
|
|
720
719
|
.map(async ({ name: guildId }) => {
|
|
721
720
|
const stateFilePath = Utils_1.PlayerUtils.getPlayerStatePath(guildId);
|
|
722
721
|
try {
|
|
722
|
+
// Guilds outside this client's cache belong to another cluster; skip them before reading any file.
|
|
723
|
+
if (!this.resolveGuild(guildId))
|
|
724
|
+
return;
|
|
723
725
|
await promises_1.default.access(stateFilePath);
|
|
724
726
|
const state = JSON.parse(await promises_1.default.readFile(stateFilePath, "utf-8"));
|
|
725
727
|
await this.restorePlayerFromState(node, nodeId, guildId, state, async () => {
|
|
@@ -742,15 +744,15 @@ class Manager extends events_1.EventEmitter {
|
|
|
742
744
|
const keys = await this.redis.keys(`${Utils_1.PlayerUtils.getRedisKey()}playerstore:*`);
|
|
743
745
|
await Promise.all(keys.map(async (key) => {
|
|
744
746
|
try {
|
|
747
|
+
const guildId = key.split(":").pop();
|
|
748
|
+
if (!guildId || !this.resolveGuild(guildId))
|
|
749
|
+
return;
|
|
745
750
|
const data = await this.redis.get(key);
|
|
746
751
|
if (!data)
|
|
747
752
|
return;
|
|
748
753
|
const state = JSON.parse(data);
|
|
749
754
|
if (!state || typeof state !== "object")
|
|
750
755
|
return;
|
|
751
|
-
const guildId = key.split(":").pop();
|
|
752
|
-
if (!guildId)
|
|
753
|
-
return;
|
|
754
756
|
await this.restorePlayerFromState(node, nodeId, guildId, state, async () => {
|
|
755
757
|
await this.redis.del(key);
|
|
756
758
|
this.emit(Enums_1.ManagerEventTypes.Debug, `[MANAGER] Deleted Redis state: ${key}`);
|
package/dist/structures/Node.js
CHANGED
|
@@ -534,6 +534,7 @@ class Node {
|
|
|
534
534
|
if (!player || player.node.options.identifier !== this.options.identifier)
|
|
535
535
|
return;
|
|
536
536
|
player.position = payload.state.position ?? 0;
|
|
537
|
+
player.ping = payload.state.ping ?? -1;
|
|
537
538
|
this.manager.emit(Enums_1.ManagerEventTypes.PlayerUpdate, player, payload);
|
|
538
539
|
}
|
|
539
540
|
/**
|
|
@@ -18,6 +18,8 @@ export declare class Player {
|
|
|
18
18
|
dynamicRepeat: boolean;
|
|
19
19
|
/** The time the player is in the track. */
|
|
20
20
|
position: number;
|
|
21
|
+
/** Last node-reported Discord voice ping in milliseconds; -1 when unavailable. */
|
|
22
|
+
ping: number;
|
|
21
23
|
/** Whether the player is playing. */
|
|
22
24
|
playing: boolean;
|
|
23
25
|
/** Whether the player is paused. */
|
|
@@ -84,6 +86,8 @@ export declare class Player {
|
|
|
84
86
|
* @returns {T} - The data associated with the key, cast to the specified type.
|
|
85
87
|
*/
|
|
86
88
|
get<T>(key: string): T;
|
|
89
|
+
/** Returns the last node-reported Discord voice ping in milliseconds, or -1 when unavailable. */
|
|
90
|
+
getPing(): number;
|
|
87
91
|
/**
|
|
88
92
|
* Same as Manager#search() but a shortcut on the player itself.
|
|
89
93
|
* @param query
|
|
@@ -26,6 +26,8 @@ class Player {
|
|
|
26
26
|
dynamicRepeat = false;
|
|
27
27
|
/** The time the player is in the track. */
|
|
28
28
|
position = 0;
|
|
29
|
+
/** Last node-reported Discord voice ping in milliseconds; -1 when unavailable. */
|
|
30
|
+
ping = -1;
|
|
29
31
|
/** Whether the player is playing. */
|
|
30
32
|
playing = false;
|
|
31
33
|
/** Whether the player is paused. */
|
|
@@ -162,6 +164,10 @@ class Player {
|
|
|
162
164
|
// Access the data object using the key and cast it to the specified type T.
|
|
163
165
|
return this.data[key];
|
|
164
166
|
}
|
|
167
|
+
/** Returns the last node-reported Discord voice ping in milliseconds, or -1 when unavailable. */
|
|
168
|
+
getPing() {
|
|
169
|
+
return this.ping;
|
|
170
|
+
}
|
|
165
171
|
/**
|
|
166
172
|
* Same as Manager#search() but a shortcut on the player itself.
|
|
167
173
|
* @param query
|