mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
testing
This commit is contained in:
1 parent
50ac37de13
commit
841042ec4d
5 files changed
+75
-21
No files matched your search
+1
-1
@@ -27,7 +27,7 @@ export async function run(message) {
|
||||
const skippedLink = current ? (current.spotifyUrl || current.url || "") : "";
|
||||
|
||||
const err = p.skip();
|
||||
if (err) {
|
||||
if (!p.connection || !current) {
|
||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(err);
|
||||
return message.reply({ embeds: [embed] });
|
||||
}
|
||||
|
||||
@@ -89,6 +89,32 @@ export class Remix {
|
||||
const presenceContents = config.presenceContents ?? [];
|
||||
const presenceInterval = config.presenceInterval ?? 30_000;
|
||||
|
||||
const buildRuntimePresence = (entry) => {
|
||||
const isObj = typeof entry === "object" && entry !== null;
|
||||
const customStatus = {};
|
||||
if (isObj) {
|
||||
if (entry.text) customStatus.text = entry.text;
|
||||
if (entry.emoji_name) customStatus.emojiName = entry.emoji_name;
|
||||
if (entry.emoji_id) customStatus.emojiId = entry.emoji_id;
|
||||
} else {
|
||||
customStatus.text = String(entry);
|
||||
}
|
||||
|
||||
const update = { status: "online", afk: false, customStatus };
|
||||
|
||||
if (isObj && entry.activity) {
|
||||
update.activities = [{
|
||||
name: entry.activity.name ?? "music",
|
||||
type: entry.activity.type ?? 0,
|
||||
url: entry.activity.url ?? undefined,
|
||||
}];
|
||||
}
|
||||
|
||||
return update;
|
||||
};
|
||||
let presenceRotationIndex = presenceContents.length > 1 ? 1 : 0;
|
||||
let presenceRotationStarted = false;
|
||||
|
||||
const timers = config.timers ?? {};
|
||||
this.T = {
|
||||
aloneCheckInterval: timers.aloneCheckInterval ?? 60_000,
|
||||
@@ -295,6 +321,19 @@ export class Remix {
|
||||
}
|
||||
|
||||
this.gatewayHandler.onReady();
|
||||
|
||||
if (!presenceRotationStarted && presenceContents.length > 1) {
|
||||
presenceRotationStarted = true;
|
||||
setInterval(() => {
|
||||
try {
|
||||
const entry = presenceContents[presenceRotationIndex % presenceContents.length];
|
||||
client.user?.setPresence(buildRuntimePresence(entry));
|
||||
presenceRotationIndex = (presenceRotationIndex + 1) % presenceContents.length;
|
||||
} catch (e) {
|
||||
logger.warn("[Presence] Rotation update failed:", e?.message);
|
||||
}
|
||||
}, presenceInterval).unref?.();
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error("[Ready] Fatal error in Ready handler:", e);
|
||||
}
|
||||
|
||||
@@ -512,6 +512,12 @@ export class CommandHandler extends EventEmitter {
|
||||
return;
|
||||
}
|
||||
|
||||
const guildId = msg.channel?.channel?.guildId ?? msg.message?.guildId;
|
||||
const prefix = this.getPrefix(guildId);
|
||||
const ping = `<@${this.client.user?.id}>`;
|
||||
const pingBang = `<@!${this.client.user?.id}>`;
|
||||
if (!(msg.content.startsWith(prefix) || msg.content.startsWith(ping) || msg.content.startsWith(pingBang))) return;
|
||||
|
||||
const userId = msg.message?.author?.id ?? msg.author?.id;
|
||||
if (userId && !this.owners.includes(userId)) {
|
||||
const now = Date.now();
|
||||
@@ -525,11 +531,6 @@ export class CommandHandler extends EventEmitter {
|
||||
}
|
||||
}
|
||||
}
|
||||
const guildId = msg.channel?.channel?.guildId ?? msg.message?.guildId;
|
||||
const prefix = this.getPrefix(guildId);
|
||||
const ping = `<@${this.client.user?.id}>`;
|
||||
const pingBang = `<@!${this.client.user?.id}>`;
|
||||
if (!(msg.content.startsWith(prefix) || msg.content.startsWith(ping) || msg.content.startsWith(pingBang))) return;
|
||||
|
||||
const len = msg.content.startsWith(prefix) ? prefix.length : (msg.content.startsWith(pingBang) ? pingBang.length : ping.length);
|
||||
const args = msg.content.slice(len).replace(/\u00A0/gi, " ").trim().split(" ").map(e => e.trim());
|
||||
|
||||
+22
-12
@@ -924,20 +924,23 @@ export default class Player extends EventEmitter {
|
||||
|
||||
const streamStartedAt = Date.now();
|
||||
|
||||
await new Promise((resolve) => {
|
||||
const safetyTimer = setTimeout(() => {
|
||||
let safetyTimer;
|
||||
let onFinish, onError;
|
||||
|
||||
const playbackSettled = new Promise((resolve) => {
|
||||
safetyTimer = setTimeout(() => {
|
||||
logger.warn(`[Player] Stream safety timeout hit (${Math.round(safetyMs / 1000)}s) — advancing queue`);
|
||||
cleanup();
|
||||
resolve();
|
||||
}, safetyMs);
|
||||
|
||||
const onFinish = () => {
|
||||
onFinish = () => {
|
||||
clearTimeout(safetyTimer);
|
||||
cleanup();
|
||||
resolve();
|
||||
};
|
||||
|
||||
const onError = (e) => {
|
||||
onError = (e) => {
|
||||
clearTimeout(safetyTimer);
|
||||
cleanup();
|
||||
if (isIgnorableMediaStateError(e)) {
|
||||
@@ -961,6 +964,19 @@ export default class Player extends EventEmitter {
|
||||
this._mediaPlayer.once("finish", onFinish);
|
||||
this._mediaPlayer.once("error", onError);
|
||||
});
|
||||
|
||||
// Race the buffered-HTTP-stream error watcher against normal playback
|
||||
// completion so a real network/stream failure (e.g. connection reset
|
||||
// mid-download) is reported and advances the queue with an error
|
||||
// message, instead of becoming an orphaned unhandled rejection while
|
||||
// playback hangs waiting on events that will never fire.
|
||||
try {
|
||||
await Promise.race([streamError, playbackSettled]);
|
||||
} finally {
|
||||
clearTimeout(safetyTimer);
|
||||
this._mediaPlayer?.off("finish", onFinish);
|
||||
this._mediaPlayer?.off("error", onError);
|
||||
}
|
||||
} catch (e) {
|
||||
if (audioStream && !audioStream.destroyed) {
|
||||
try { audioStream.destroy(); } catch (e2) { logger.warn("[Player] Error destroying stream:", e2?.message); }
|
||||
@@ -1330,12 +1346,7 @@ export default class Player extends EventEmitter {
|
||||
this._clearTrackEndTimer();
|
||||
this._activeTrackOpt = null;
|
||||
|
||||
if (this._mediaPlayer) {
|
||||
if (typeof this._mediaPlayer.destroy === "function") {
|
||||
try { this._mediaPlayer.destroy(); } catch(e) { logger.warn("[Player] MediaPlayer destroy error on leave:", e?.message); }
|
||||
}
|
||||
this._mediaPlayer = null;
|
||||
}
|
||||
await this._stopMediaPlayer();
|
||||
|
||||
const channelId = this._channelId;
|
||||
if (this._revoice && channelId && typeof this._revoice.markIntentionalDisconnect === "function") {
|
||||
@@ -1405,7 +1416,6 @@ export default class Player extends EventEmitter {
|
||||
|
||||
const connToDestroy = this.connection;
|
||||
this.connection = null;
|
||||
this._mediaPlayer = null;
|
||||
if (this._revoice && this._channelId) {
|
||||
try { this._revoice.markIntentionalDisconnect(this._channelId); } catch(e) { logger.warn("[Player] Mark intentional disconnect on destroy:", e?.message); }
|
||||
}
|
||||
@@ -2290,7 +2300,7 @@ export default class Player extends EventEmitter {
|
||||
} else {
|
||||
try {
|
||||
if (this._moonlink?.manager) {
|
||||
const result = await this._moonlink.search(`ytsearch:${songData.title}`);
|
||||
const result = await this._moonlink.search(songData.title, "youtube");
|
||||
const track = result?.tracks?.[0];
|
||||
if (track?.encoded) {
|
||||
const nlBase = `http://${this._nl.host}:${this._nl.port}`;
|
||||
|
||||
@@ -101,13 +101,17 @@ function installLiveKitLogFilter() {
|
||||
const origLog = console.log;
|
||||
const origInfo = console.info;
|
||||
|
||||
const filtered = function (...args) {
|
||||
const filteredLog = function (...args) {
|
||||
if (isLiveKitLogMessage(...args)) return;
|
||||
return origLog.apply(console, args);
|
||||
};
|
||||
const filteredInfo = function (...args) {
|
||||
if (isLiveKitLogMessage(...args)) return;
|
||||
return origInfo.apply(console, args);
|
||||
};
|
||||
|
||||
console.log = filtered;
|
||||
console.info = filtered;
|
||||
console.log = filteredLog;
|
||||
console.info = filteredInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user