mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
test
This commit is contained in:
1 parent
3ea4ac660e
commit
9366bbe95a
2 files changed
+35
-3
No files matched your search
+15
-3
@@ -186,9 +186,13 @@ 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 just the user ID
|
||||
// (matching Stoat format where data = userId string)
|
||||
emit(eventType, member.user.id);
|
||||
// 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);
|
||||
// Also send global user update
|
||||
this.dashboard.userUpdate({
|
||||
type: eventType,
|
||||
@@ -209,6 +213,14 @@ 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);
|
||||
// Also broadcast on global channel for full state update
|
||||
this.dashboard.playerUpdate({ type: "startplay" }, player);
|
||||
});
|
||||
|
||||
@@ -184,6 +184,26 @@ export class Dashboard {
|
||||
return { message: "Adding to queue" };
|
||||
}
|
||||
|
||||
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);
|
||||
if (!player) return { error: "Player not found" };
|
||||
const authErr = this._authorizePlayerControl(user, player);
|
||||
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 };
|
||||
}
|
||||
}
|
||||
|
||||
case "testConnection": {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user