mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
dashboard tests
This commit is contained in:
1 parent
9366bbe95a
commit
37c29ca6cd
3 files changed
+44
-30
No files matched your search
+6
-15
@@ -186,13 +186,9 @@ export class PlayerManager {
|
||||
if (stateChannelId !== channelId) continue;
|
||||
const member = guild.members?.get?.(state.userId ?? state.user_id);
|
||||
if (!member?.user || member.user?.bot) continue;
|
||||
// Send per-player channel "join"/"leave" event with the full user
|
||||
// object — matching Stoat format where data = Dashboard.convertUser(user).
|
||||
// The backend Player.setupEvents does:
|
||||
// join: this.users.push(data) — works with objects
|
||||
// leave: findIndex(u => u === data.id) — needs data.id
|
||||
const convertedUser = Dashboard.convertUser(member.user);
|
||||
emit(eventType, convertedUser);
|
||||
// Send per-player channel "join"/"leave" event with just the user ID
|
||||
// (matching Stoat format where data = userId string)
|
||||
emit(eventType, member.user.id);
|
||||
// Also send global user update
|
||||
this.dashboard.userUpdate({
|
||||
type: eventType,
|
||||
@@ -213,14 +209,9 @@ export class PlayerManager {
|
||||
player.on("startplay", (song) => {
|
||||
// Send the serialised video to the per-player channel
|
||||
emit("startplay", Dashboard.convertVideo(song ?? player.queue?.current));
|
||||
// The backend Player expects "streamStartPlay" with a timestamp so it
|
||||
// can compute elapsed time for the dashboard progress bar.
|
||||
// Player.mjs sets startedPlaying = Date.now() just before emitting
|
||||
// "startplay", so we use the same value (or fall back to Date.now()).
|
||||
const startedAt = player.startedPlaying instanceof Date
|
||||
? player.startedPlaying.getTime()
|
||||
: Number(player.startedPlaying) || Date.now();
|
||||
emit("streamStartPlay", startedAt);
|
||||
// Emit streamStartPlay with current timestamp so the backend can
|
||||
// calculate elapsed time accurately (matches Stoat behaviour)
|
||||
emit("streamStartPlay", Date.now());
|
||||
// Also broadcast on global channel for full state update
|
||||
this.dashboard.playerUpdate({ type: "startplay" }, player);
|
||||
});
|
||||
|
||||
@@ -184,30 +184,23 @@ export class Dashboard {
|
||||
return { message: "Adding to queue" };
|
||||
}
|
||||
|
||||
case "testConnection": {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
case "leave": {
|
||||
if (!user) return { error: "Invalid user" };
|
||||
const channelId = params.data.channel;
|
||||
if (!channelId) return { error: "Missing channel ID" };
|
||||
const player = this._getPlayerById(channelId);
|
||||
const player = this._getPlayerById(params.data.channel);
|
||||
if (!player) return { error: "Player not found" };
|
||||
const authErr = this._authorizePlayerControl(user, player);
|
||||
const authErr = await this._authorizeUserInGuild(user, player._guildId);
|
||||
if (authErr) return { error: authErr };
|
||||
try {
|
||||
await player.leave();
|
||||
player.destroy();
|
||||
const activeChannelId = player._channelId ?? channelId;
|
||||
this.remix.players.playerMap.delete(activeChannelId);
|
||||
return { message: "Left channel" };
|
||||
} catch (e) {
|
||||
logger.dashboard("[Dashboard] Leave error:", e.message);
|
||||
return { error: "Failed to leave channel: " + e.message };
|
||||
return { error: "Failed to leave: " + e.message };
|
||||
}
|
||||
}
|
||||
|
||||
case "testConnection": {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
default:
|
||||
return { error: "Unknown function: " + (params.func ?? "(none)") };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user