dashboard works

This commit is contained in:
NoLogicAlan committed 2026-05-08 01:15:30 +03:00
1 parent f8e5275422
commit 28891e2f90
3 files changed
+68 -12

No files matched your search

+2 -1
View File
@@ -239,13 +239,14 @@ export class Remix {
const ALONE_CHECK_INTERVAL = this.T.aloneCheckInterval; const ALONE_CHECK_INTERVAL = this.T.aloneCheckInterval;
setInterval(() => { setInterval(() => {
for (const [mapKey, player] of this.players.playerMap) { for (const [mapKey, player] of this.players.playerMap) {
let channelId = mapKey;
try { try {
const guildId = player._guildId; const guildId = player._guildId;
if (!guildId) continue; if (!guildId) continue;
if (player._isJoining || player._isRecovering) continue; if (player._isJoining || player._isRecovering) continue;
const channelId = player._channelId ?? mapKey; channelId = player._channelId ?? mapKey;
const cleanChanId = String(channelId).replace(/\D/g, ""); const cleanChanId = String(channelId).replace(/\D/g, "");
if (!cleanChanId) continue; if (!cleanChanId) continue;
+17 -3
View File
@@ -765,10 +765,19 @@ export class PlayerManager {
this.playerMap.set(cleanChannelId, player); this.playerMap.set(cleanChannelId, player);
(async () => { (async () => {
const statusMsg = await message.reply(mkEmbed(this._t(message, "responses.join.joining"))); let statusMsg = null;
try {
statusMsg = await message.reply(mkEmbed(this._t(message, "responses.join.joining")));
} catch (_) {
// reply() may fail or return a non-standard object (e.g. dashboard fakeMsg)
}
const canEdit = typeof statusMsg?.edit === "function";
try { try {
await player.join(cid); await player.join(cid);
await statusMsg.edit(mkEmbed(this._t(message, "responses.join.joined", { channel: cid }))); if (canEdit) {
await statusMsg.edit(mkEmbed(this._t(message, "responses.join.joined", { channel: cid }))).catch(() => {});
}
const guildId = cleanId(channel.guildId ?? getMessageGuildId(message)); const guildId = cleanId(channel.guildId ?? getMessageGuildId(message));
if (guildId) { if (guildId) {
@@ -792,7 +801,12 @@ export class PlayerManager {
} else { } else {
errorMsg = this._t(message, "responses.join.joinFailed", { error: err.message }); errorMsg = this._t(message, "responses.join.joinFailed", { error: err.message });
} }
await statusMsg.edit(mkEmbed(errorMsg)).catch(() => {}); if (canEdit) {
await statusMsg.edit(mkEmbed(errorMsg)).catch(() => {});
} else {
// Can't edit the status message — send a new reply instead
try { await message.reply(mkEmbed(errorMsg)); } catch (_) {}
}
this.playerMap.delete(cleanChannelId); this.playerMap.delete(cleanChannelId);
player.destroy(); player.destroy();
} }
+49 -8
View File
@@ -84,7 +84,20 @@ export class Dashboard {
if (member) { if (member) {
server.channels = server.channels.filter(c => { server.channels = server.channels.filter(c => {
const ch = guild.channels.get(c.id); const ch = guild.channels.get(c.id);
return ch ? ch.permissionsFor(member)?.has("ViewChannel") : false; if (!ch) return false;
// @fluxerjs/core GuildChannel objects do NOT expose a
// permissionsFor() method like discord.js does. If the method
// exists, use it; otherwise the user is already verified as a
// guild member so showing all channels is safe.
if (typeof ch.permissionsFor === "function") {
try {
const perms = ch.permissionsFor(member);
return perms ? perms.has("ViewChannel") : false;
} catch (_) {
return true; // permission check failed — show channel anyway
}
}
return true;
}); });
} }
return server; return server;
@@ -146,10 +159,12 @@ export class Dashboard {
if (authErr) return { error: authErr }; if (authErr) return { error: authErr };
if (this.remix.players.playerMap.has(voiceChannel.id)) return { message: "Already Connected" }; if (this.remix.players.playerMap.has(voiceChannel.id)) return { message: "Already Connected" };
// Build a minimal fake message that satisfies PlayerManager.initPlayer(). // Build a minimal fake message that satisfies PlayerManager.initPlayer().
// The reply() returns a mock with edit() so initPlayer's statusMsg.edit
// calls don't crash (Fluxer doesn't expose message edit from dashboards).
const fakeMsg = { const fakeMsg = {
channel: { channel: textChannel, guildId: voiceChannel.guildId }, channel: { channel: textChannel, guildId: voiceChannel.guildId },
message: { guildId: voiceChannel.guildId }, message: { guildId: voiceChannel.guildId },
reply: async () => ({ catch: () => {} }), reply: async () => ({ edit: async () => {}, catch: () => {} }),
}; };
this.remix.players.initPlayer(fakeMsg, voiceChannel.id); this.remix.players.initPlayer(fakeMsg, voiceChannel.id);
return { message: "Joining" }; return { message: "Joining" };
@@ -307,13 +322,29 @@ export class Dashboard {
* @param {import("@fluxerjs/core").User} user * @param {import("@fluxerjs/core").User} user
*/ */
static convertUser(user) { static convertUser(user) {
// Build avatar URL — @fluxerjs/core may expose displayAvatarURL() or
// may just have a raw hash in user.avatar. Handle both cases.
let avatarUrl = null;
try {
if (typeof user.displayAvatarURL === "function") {
avatarUrl = user.displayAvatarURL();
}
} catch (_) { /* not available */ }
if (!avatarUrl && user.avatar) {
const hash = String(typeof user.avatar === "object" ? (user.avatar.hash ?? user.avatar) : user.avatar);
if (hash && hash !== "[object Object]") {
const ext = hash.startsWith("a_") ? ".gif" : ".webp";
avatarUrl = `https://cdn.fluxer.app/avatars/${user.id}/${hash}${ext}?size=128`;
}
}
if (!avatarUrl && typeof user.defaultAvatarURL === "string") {
avatarUrl = user.defaultAvatarURL;
}
return { return {
id: user.id, id: user.id,
username: user.username, username: user.username,
displayName: user.displayName ?? user.globalName ?? user.username, displayName: user.displayName ?? user.globalName ?? user.username,
avatar: { avatar: { url: avatarUrl },
url: user.displayAvatarURL() ?? user.defaultAvatarURL,
},
}; };
} }
@@ -345,7 +376,17 @@ export class Dashboard {
* @param {import("@fluxerjs/core").GuildChannel} channel * @param {import("@fluxerjs/core").GuildChannel} channel
*/ */
static convertChannel(channel) { static convertChannel(channel) {
const isVoice = channel.isVoiceBased?.() ?? false; // Same voice-detection logic as convertServerForList — @fluxerjs/core may
// not expose isVoiceBased(), so fall back to the type field.
let isVoice = false;
if (typeof channel.isVoiceBased === "function") {
isVoice = channel.isVoiceBased();
} else if (channel.isVoiceBased === true) {
isVoice = true;
} else {
const t = channel.type;
isVoice = t === 2 || t === 13 || t === "GUILD_VOICE" || t === "GUILD_STAGE_VOICE";
}
let voiceParticipants = []; let voiceParticipants = [];
if (isVoice) { if (isVoice) {
const guild = channel?.guild ?? channel?.client?.guilds?.get(channel?.guildId); const guild = channel?.guild ?? channel?.client?.guilds?.get(channel?.guildId);
@@ -383,12 +424,12 @@ export class Dashboard {
* @param {import("@fluxerjs/core").Guild} guild * @param {import("@fluxerjs/core").Guild} guild
* @returns {string|null} * @returns {string|null}
*/ */
static guildIconURL(guild) { static guildIconURL(guild, size = 128) {
if (!guild?.icon) return null; if (!guild?.icon) return null;
// guild.icon may be "hash" or "a_hash" (animated prefix) // guild.icon may be "hash" or "a_hash" (animated prefix)
const hash = String(guild.icon); const hash = String(guild.icon);
const ext = hash.startsWith("a_") ? ".gif" : ".webp"; const ext = hash.startsWith("a_") ? ".gif" : ".webp";
return `https://cdn.fluxer.app/icons/${guild.id}/${hash}${ext}`; return `https://cdn.fluxer.app/icons/${guild.id}/${hash}${ext}?size=${size}`;
} }
/** /**