fix: resolve bugs in voice, filter, dashboard, and stats handling

- Fix filter command using stale track reference instead of current queue track

- Fix playnext null check before editing status message

- Fix join command using raw channel ID before cleaning it

- Fix GatewayHandler passing wrong isBot flag in voice state cache

- Fix Dashboard shared server filtering (was returning empty, now filters correctly)

- Fix avatar fallback using discriminator (deprecated) → use user ID instead

- Refactor Player.mjs: extract ConnectionState/LKRoomEvent to FluxerRevoice constants

- Refactor Player.mjs: replace local formatMsHelper with Utils.prettifyMS

- Add Logger.guild() method; use it in GatewayHandler instead of logger.info()

- Remove rbl-stats module from modules.json

- Remove unused empty event listeners in PlayerManager

- Remove unused CRITICAL_PERMISSIONS import from GatewayHandler
This commit is contained in:
NoLogicAlan committed 2026-05-25 19:22:20 +03:00
1 parent 58464e6862
commit b581722c46
19 files changed
+45 -92

No files matched your search

+4 -4
View File
@@ -4,7 +4,7 @@ import { logger } from "./constants/Logger.mjs";
import { ServerSettings } from "./Settings.mjs";
import { get247ChannelMode, remove247ChannelMode } from "./constants/Helpers247.mjs";
import { VoiceStateCache } from "./constants/VoiceStateCache.mjs";
import { REQUIRED_BOT_PERMISSIONS, CRITICAL_PERMISSIONS } from "./MessageHandler.mjs";
import { REQUIRED_BOT_PERMISSIONS } from "./MessageHandler.mjs";
/**
* GatewayHandler — manages raw WebSocket gateway events, voice-state tracking,
@@ -126,7 +126,7 @@ export class GatewayHandler {
` All missing: ${missingNames.join(", ")}`
);
} else {
logger.info(
logger.guild(
`[GuildCreate] Server ${guildId} is missing optional permissions: ${result.optionalMissing.join(", ")}`
);
}
@@ -745,12 +745,12 @@ export class GatewayHandler {
if (evictGuildId && evictUserId) {
const currentLoc = remix.voiceCache.getUserLocation(evictGuildId, evictUserId);
if (currentLoc && currentLoc.channelId === evictEntry.channelId) {
remix.voiceCache.updateUser({ guildId: evictGuildId, userId: evictUserId, channelId: null, isBot: false });
remix.voiceCache.updateUser({ guildId: evictGuildId, userId: evictUserId, channelId: null, isBot: evictEntry.isBot ?? false });
}
}
}
}
if (nextKey) this._prevVoiceState.set(nextKey, { channelId, guildId: guildId ?? prev?.guildId });
if (nextKey) this._prevVoiceState.set(nextKey, { channelId, guildId: guildId ?? prev?.guildId, isBot: isBot === true });
} else {
if (prevKey) this._prevVoiceState.delete(prevKey);
}
+6 -25
View File
@@ -15,19 +15,7 @@
import Revoicejs from "revoice.js";
const { MediaPlayer } = Revoicejs;
const ConnectionState = Object.freeze({
CONN_DISCONNECTED: 0,
CONN_CONNECTED: 1,
CONN_RECONNECTING: 2,
});
const LKRoomEvent = Object.freeze({
ConnectionStateChanged: "connectionStateChanged",
Disconnected: "disconnected",
ParticipantConnected: "participantConnected",
ParticipantDisconnected:"participantDisconnected",
});
import { ConnectionState, LKRoomEvent } from "./constants/FluxerRevoice.mjs";
import { getVoiceManager } from "@fluxerjs/voice";
import { Utils } from "./Utils.mjs";
import { EventEmitter } from "node:events";
@@ -46,15 +34,6 @@ function mkEmbed(desc) {
return { embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(desc)] };
}
function formatMsHelper(ms) {
if (ms == null || ms < 0) return "0:00";
const totalSeconds = Math.floor(ms / 1000);
const hours = Math.floor(totalSeconds / 3600);
const minutes = Math.floor((totalSeconds % 3600) / 60);
const seconds = totalSeconds % 60;
if (hours > 0) return `${hours}:${String(minutes).padStart(2, "0")}:${String(seconds).padStart(2, "0")}`;
return `${minutes}:${String(seconds).padStart(2, "0")}`;
}
/** NodeLink default password — centralised so it doesn't need to be hardcoded in two places. */
const NL_DEFAULT_PASSWORD = "youshallnotpass";
@@ -568,8 +547,10 @@ export default class Player extends EventEmitter {
try {
const room = this.connection?.room;
if (room?.isConnected && room.remoteParticipants) {
const botId = this.client?.user?.id;
for (const [, participant] of room.remoteParticipants) {
if (participant?.identity || participant?.sid) {
const pId = participant?.identity || participant?.sid;
if (pId && pId !== botId) {
return true;
}
}
@@ -1893,8 +1874,8 @@ export default class Player extends EventEmitter {
const progressBar = this._createProgressBar(20);
let trackOptLine = "";
if (this._activeTrackOpt) {
const optStart = formatMsHelper(this._activeTrackOpt.startMs);
const optEnd = this._activeTrackOpt.endMs > 0 ? formatMsHelper(this._activeTrackOpt.endMs) : "end";
const optStart = Utils.prettifyMS(this._activeTrackOpt.startMs);
const optEnd = this._activeTrackOpt.endMs > 0 ? Utils.prettifyMS(this._activeTrackOpt.endMs) : "end";
trackOptLine = `\n✂️ Custom: ${optStart} → ${optEnd}`;
}
return {
-5
View File
@@ -356,9 +356,6 @@ export class PlayerManager {
this.dashboard.playerUpdate({ type: "update" }, player);
});
player.on("message", (message) => {
});
player.on("autoleave", () => {
sendUserUpdates("leave");
emitGlobal("close");
@@ -912,8 +909,6 @@ export class PlayerManager {
}
});
player.on("leave", () => {});
player.on("message", (m) => {
let ch = player.textChannel;
const guildId = cleanId(player._guildId ?? ch?.guildId ?? ch?.guild?.id ?? getMessageGuildId({ channel: ch }));
+5 -2
View File
@@ -29,19 +29,22 @@
import { EventEmitter } from "node:events";
import { joinVoiceChannel, getVoiceManager } from "@fluxerjs/voice";
const ConnectionState = Object.freeze({
export const ConnectionState = Object.freeze({
CONN_DISCONNECTED: 0,
CONN_CONNECTED: 1,
CONN_RECONNECTING: 2,
});
const RoomEvent = Object.freeze({
export const LKRoomEvent = Object.freeze({
ConnectionStateChanged: "connectionStateChanged",
Disconnected: "disconnected",
ParticipantConnected: "participantConnected",
ParticipantDisconnected:"participantDisconnected",
});
/** @deprecated Use LKRoomEvent instead — kept for backward compat within this file */
const RoomEvent = LKRoomEvent;
import { logger } from "./Logger.mjs";
{
+4
View File
@@ -47,6 +47,10 @@ export const logger = {
if (_config?.enabled === false) return;
console.warn(`[${ts()}] ${tag}`, ...args);
},
info(tag, ...args) {
if (_config?.enabled === false) return;
console.log(`[${ts()}] ${tag}`, ...args);
},
player(...args) { if (isEnabled("player")) console.log(`[${ts()}]`, ...args); },
inactivity(...args) { if (isEnabled("inactivity")) console.log(`[${ts()}]`, ...args); },
+1 -5
View File
@@ -93,13 +93,9 @@ export class VoiceStateCache {
if (!set) { set = new Set(); channelIdx.set(cKey, set); }
set.add(cleanUser);
locations.delete(uKey);
locations.set(uKey, { channelId: cleanChannel, guildId: cleanGuild, userId: cleanUser });
if (locations.has(uKey)) {
locations.delete(uKey);
locations.set(uKey, { channelId: cleanChannel, guildId: cleanGuild, userId: cleanUser });
}
while (locations.size > maxEntries) {
const evictKey = locations.keys().next().value;
if (evictKey === uKey) {
+4 -4
View File
@@ -8,19 +8,19 @@ class Tuna {
}
get(path, params = {}) {
return new Promise((resolve, rej) => {
var query = "";
let query = "";
for (let key in params) {
query += ((query.length === 0) ? "?" : "&") + key + "=" + encodeURIComponent(params[key]);
}
var options = {
const options = {
method: "GET",
hostname: "tuna-api.voicemod.net",
path: path + query,
headers: { "x-api-key": this.apiKey },
maxRedirects: 20
};
var req = https.request(options, function(res) {
var chunks = [];
const req = https.request(options, function(res) {
const chunks = [];
res.on("data", (chunk) => { chunks.push(chunk); });
res.on("end", () => {
try {
+12 -7
View File
@@ -76,21 +76,26 @@ export class Dashboard {
}
case "allServers": {
let guilds;
try {
const guilds = await this.remix.client.user.fetchGuilds();
return guilds.map(g => Dashboard.convertServer(g));
guilds = await this.remix.client.user.fetchGuilds();
} catch (e) {
const id = Utils.uid();
logger.dashboard("[Dashboard] allServers error:", id, e);
return [];
}
let result = guilds.map(g => Dashboard.convertServer(g));
if (data.accessor) {
try {
const accessorUser = await this.remix.client.users.fetch(data.accessor).catch(() => null);
if (accessorUser) return await this.remix.getSharedServers(accessorUser);
if (accessorUser) {
const shared = await this.remix.getSharedServers(accessorUser);
const sharedIds = new Set(shared.map(s => s.id));
result = result.filter(g => sharedIds.has(g.id));
}
} catch (_) {}
}
return [];
return result;
}
case "commands": {
@@ -434,8 +439,8 @@ export class Dashboard {
} else if (typeof user.avatarURL === "function") {
try { avatarUrl = user.avatarURL() ?? ""; } catch (_) {}
}
if (!avatarUrl && user.discriminator) {
avatarUrl = `https://fluxerusercontent.com/embed/avatars/${parseInt(user.discriminator || "0") % 5}.png`;
if (!avatarUrl) {
avatarUrl = `https://fluxerusercontent.com/embed/avatars/${parseInt(user.id?.slice(-4) ?? "0") % 5}.png`;
}
return {
id: user.id,
@@ -476,7 +481,7 @@ export class Dashboard {
*/
static convertChannel(channel) {
const type = channel.type ?? 0;
const isVoice = channel.isVoice?.() ?? (type === 2) ?? false;
const isVoice = channel.isVoice?.() || type === 2;
const isCategory = type === 4;
const isText = !isVoice && !isCategory && (
type === 0 || type === 5 || type === 13 ||
-12
View File
@@ -544,26 +544,14 @@ const post = (event, payload) => {
};
utils.on("message", (m) => {
if (jobId === "dev") { logger.worker("[Message]", m); return; }
post("message", m);
});
utils.on("error", (m) => {
if (jobId === "dev") { logger.worker("[Error]", m); return; }
post("error", m);
});
(async () => {
if (jobId === "dev") {
try {
const result = await utils.getVideoData("Neoni funeral", "ytm");
logger.worker("[Worker result]", result);
} catch (e) {
logger.error("[Worker error]", e);
}
return;
}
try {
switch (jobId) {
case "generalQuery": {