mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
hotfix /testing
This commit is contained in:
1 parent
b7252fccaf
commit
dbe1c46dc5
5 files changed
+53
-16
No files matched your search
@@ -188,7 +188,7 @@ export class Remix {
|
||||
commands.owners = config.owners ?? [];
|
||||
|
||||
this.moonlink = null;
|
||||
const moonlinkInitialised = false;
|
||||
let moonlinkInitialised = false;
|
||||
|
||||
this.voiceCache = new VoiceStateCache({ maxUsers: 50_000, maxBots: 10_000 });
|
||||
|
||||
|
||||
@@ -231,12 +231,6 @@ export class LastFmManager {
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
`);
|
||||
|
||||
try {
|
||||
await pool.execute("ALTER TABLE \`lastfm_users\` ADD COLUMN \`scrobble_count\` BIGINT NOT NULL DEFAULT 0 AFTER \`scrobble\`");
|
||||
} catch (e) {
|
||||
logger.warn("[LastFm] Migration warning:", e?.message);
|
||||
}
|
||||
|
||||
await pool.execute(`
|
||||
CREATE TABLE IF NOT EXISTS \`lastfm_stats\` (
|
||||
\`id\` TINYINT(1) NOT NULL PRIMARY KEY DEFAULT 1,
|
||||
@@ -298,7 +292,7 @@ export class LastFmManager {
|
||||
[...f.params, String(userId), ...f.params]
|
||||
);
|
||||
} catch (e) {
|
||||
logger.warn("[LastFm] Migration warning:", e?.message);
|
||||
logger.warn("[LastFm] Stats update warning:", e?.message);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
@@ -572,14 +572,19 @@ export class MessageHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Join a voice channel using the documented VoiceManager.join() API.
|
||||
* Reference: https://fluxer.js.org/v/latest/guides/voice
|
||||
*
|
||||
* @param {string} channelId
|
||||
* @returns {Promise<import("@fluxerjs/voice").VoiceConnectionLike>}
|
||||
*/
|
||||
async joinChannel(channelId) {
|
||||
const { joinVoiceChannel } = await import("@fluxerjs/voice");
|
||||
const { getVoiceManager } = await import("@fluxerjs/voice");
|
||||
const channel = await this.client.channels.fetch(channelId);
|
||||
if (!channel || !("guildId" in channel)) throw new Error("Cannot join a non-guild voice channel.");
|
||||
return joinVoiceChannel(this.client, channel);
|
||||
const vm = getVoiceManager(this.client);
|
||||
if (!vm) throw new Error("VoiceManager not available.");
|
||||
return vm.join(channel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -17,11 +17,14 @@
|
||||
* that occurs when a Fluxer bot token is sent to an incompatible API.
|
||||
*/
|
||||
|
||||
import { MediaPlayer } from "revoice.js";
|
||||
import { createRequire } from "node:module";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const { MediaPlayer } = require("revoice.js");
|
||||
|
||||
import { ConnectionState, LKRoomEvent } from "./constants/FluxerRevoice.mjs";
|
||||
import { getVoiceManager } from "@fluxerjs/voice";
|
||||
import { Utils } from "./Utils.mjs";
|
||||
import { Utils, cleanId } from "./Utils.mjs";
|
||||
import { EventEmitter } from "node:events";
|
||||
import meta from "./probe.mjs";
|
||||
import { Worker } from "node:worker_threads";
|
||||
|
||||
@@ -20,10 +20,12 @@
|
||||
* 3. Gateway sends VOICE_SERVER_UPDATE with { endpoint, token }
|
||||
* 4. The endpoint/token are LiveKit credentials
|
||||
*
|
||||
* This adapter wraps @fluxerjs/voice's `joinVoiceChannel()` and returns
|
||||
* This adapter wraps @fluxerjs/voice's VoiceManager.join() and returns
|
||||
* a `FluxerVoiceConnection` that is API-compatible with revoice.js's
|
||||
* `VoiceConnection`, so Player.mjs and MediaPlayer work unchanged.
|
||||
*
|
||||
* Reference: https://fluxer.js.org/v/latest/guides/voice
|
||||
*
|
||||
* IMPORTANT: @livekit/rtc-node (Node.js SDK) does NOT have `room.state`.
|
||||
* ✅ room.isConnected — boolean getter (true when connected)
|
||||
* ✅ room.connectionState — ConnectionState enum getter
|
||||
@@ -32,7 +34,7 @@
|
||||
*/
|
||||
|
||||
import { EventEmitter } from "node:events";
|
||||
import { joinVoiceChannel, getVoiceManager } from "@fluxerjs/voice";
|
||||
import { getVoiceManager } from "@fluxerjs/voice";
|
||||
|
||||
export const ConnectionState = Object.freeze({
|
||||
CONN_DISCONNECTED: 0,
|
||||
@@ -288,7 +290,7 @@ export class FluxerRevoice extends EventEmitter {
|
||||
* Send a channel-specific leave signal to the Fluxer gateway so it
|
||||
* knows the bot is no longer in the given channel. Without this, the
|
||||
* gateway may think the bot is still connected and won't send a fresh
|
||||
* VOICE_SERVER_UPDATE on the next joinVoiceChannel() call, causing the
|
||||
* VOICE_SERVER_UPDATE on the next VoiceManager.join() call, causing the
|
||||
* rejoin to hang or fail.
|
||||
*
|
||||
* IMPORTANT: Only uses channel-specific leave (vm.leaveChannel).
|
||||
@@ -445,9 +447,14 @@ export class FluxerRevoice extends EventEmitter {
|
||||
|
||||
const channelGuildId = guildId ?? channel?.guildId ?? channel?.guild?.id ?? null;
|
||||
|
||||
const vm = getVoiceManager(this.client);
|
||||
if (!vm) {
|
||||
throw new Error(`Fluxer voice join failed for ${channelId}: VoiceManager not available — call getVoiceManager(client) before login`);
|
||||
}
|
||||
|
||||
let nativeConnection;
|
||||
try {
|
||||
nativeConnection = await joinVoiceChannel(this.client, channel);
|
||||
nativeConnection = await vm.join(channel);
|
||||
} catch (e) {
|
||||
throw new Error(`Fluxer voice join failed for ${channelId}: ${e.message}`);
|
||||
}
|
||||
@@ -551,6 +558,7 @@ export class FluxerRevoice extends EventEmitter {
|
||||
});
|
||||
|
||||
room.on(LKRoomEvent.Disconnected, (reason) => {
|
||||
if (conn._destroyed) return;
|
||||
const isIntentional = this._intentionalDisconnects.has(String(channelId));
|
||||
const reasonLabel = isIntentional ? "intentional" : (reason ?? "unexpected");
|
||||
logger.player(`[FluxerRevoice] Room disconnected: ${reasonLabel}`);
|
||||
@@ -594,6 +602,33 @@ export class FluxerRevoice extends EventEmitter {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Handle the VoiceManager's serverLeave event, which fires when
|
||||
* the Fluxer/LiveKit server terminates the session server-side.
|
||||
* Without this handler the bot never learns the session is dead,
|
||||
* leading to "validate request timed out" on the next join attempt.
|
||||
*
|
||||
* Reference: https://fluxer.js.org/v/latest/guides/voice
|
||||
* "If using LiveKit, the server may emit serverLeave.
|
||||
* Listen and reconnect if needed."
|
||||
*/
|
||||
if (nativeConnection && typeof nativeConnection.on === "function") {
|
||||
nativeConnection.on("serverLeave", () => {
|
||||
if (conn._destroyed) return;
|
||||
logger.player(`[FluxerRevoice] serverLeave received for channel ${channelId} — cleaning up`);
|
||||
conn._connected = false;
|
||||
conn._destroyed = true;
|
||||
this.connections.delete(channelId);
|
||||
this._leaveGateway(channelId, channelGuildId);
|
||||
if (room) {
|
||||
try { room.disconnect().catch(() => {}); } catch (_) { /** already gone */ }
|
||||
}
|
||||
if (conn.listenerCount("disconnect") > 0) {
|
||||
conn.emit("disconnect");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.connections.set(channelId, conn);
|
||||
|
||||
if (_leaveIfEmpty) {
|
||||
|
||||
Reference in new issue
Block a user