dashboard works

This commit is contained in:
NoLogicAlan committed 2026-05-08 03:00:20 +03:00
1 parent 777c610b55
commit 009ec31dd8
5 files changed
+129 -35

No files matched your search

+23 -11
View File
@@ -64,6 +64,12 @@ export class GatewayHandler {
return { key: directKey, value: this._prevVoiceState.get(directKey) };
}
// Only do fuzzy search if guildId is null (e.g. from a gateway event
// that doesn't include guild context). When guildId IS provided, we
// must NOT match entries from other guilds — that causes false
// "cross-guild re-key" warnings during multi-guild recovery.
if (guildId) return { key: null, value: null };
const cleanUserId = String(userId ?? "").replace(/\D/g, "");
if (!cleanUserId) return { key: null, value: null };
@@ -507,9 +513,9 @@ export class GatewayHandler {
try { await client.users.fetch(userId).catch(() => {}); } catch (_) {}
}
if (userObj) {
// Send user update on the global :users channel
const details = {
event: "voiceStateUpdate",
userId,
type: channelId ? "join" : "leave",
guildId: resolvedGuildId,
channelId: channelId ?? null,
oldChannelId: oldChannelId ?? null,
@@ -517,19 +523,25 @@ export class GatewayHandler {
remix.dashboard.updateUser(details, userObj);
}
// Send per-player channel events for join/leave
const refChannel = channelId ?? oldChannelId;
const cleanId = refChannel ? String(refChannel).replace(/\D/g, "") : null;
const cleanId_ref = refChannel ? String(refChannel).replace(/\D/g, "") : null;
if (cleanId) {
const player = remix.players.playerMap.get(cleanId);
if (cleanId_ref) {
const player = remix.players.playerMap.get(cleanId_ref);
if (player) {
// Send "join" or "leave" on the per-player channel
// (matching Stoat format: { type, data } where data = userId)
const eventType = channelId ? "join" : "leave";
remix.dashboard.updatePlayer({
guildId: player._guildId,
channelId: player._channelId,
playing: player.playing ?? false,
paused: player.paused ?? false,
queueLength: player.queue?.length ?? 0,
});
type: eventType,
data: userId,
}, player);
// Also update the global players channel with current player state
remix.dashboard.playerUpdate({
type: eventType,
}, player);
}
}
} catch (_) {}