mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -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 skippedLink = current ? (current.spotifyUrl || current.url || "") : "";
|
||||||
|
|
||||||
const err = p.skip();
|
const err = p.skip();
|
||||||
if (err) {
|
if (!p.connection || !current) {
|
||||||
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(err);
|
const embed = new EmbedBuilder().setColor(getGlobalColor()).setDescription(err);
|
||||||
return message.reply({ embeds: [embed] });
|
return message.reply({ embeds: [embed] });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,32 @@ export class Remix {
|
|||||||
const presenceContents = config.presenceContents ?? [];
|
const presenceContents = config.presenceContents ?? [];
|
||||||
const presenceInterval = config.presenceInterval ?? 30_000;
|
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 ?? {};
|
const timers = config.timers ?? {};
|
||||||
this.T = {
|
this.T = {
|
||||||
aloneCheckInterval: timers.aloneCheckInterval ?? 60_000,
|
aloneCheckInterval: timers.aloneCheckInterval ?? 60_000,
|
||||||
@@ -295,6 +321,19 @@ export class Remix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.gatewayHandler.onReady();
|
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) {
|
} catch (e) {
|
||||||
logger.error("[Ready] Fatal error in Ready handler:", e);
|
logger.error("[Ready] Fatal error in Ready handler:", e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -512,6 +512,12 @@ export class CommandHandler extends EventEmitter {
|
|||||||
return;
|
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;
|
const userId = msg.message?.author?.id ?? msg.author?.id;
|
||||||
if (userId && !this.owners.includes(userId)) {
|
if (userId && !this.owners.includes(userId)) {
|
||||||
const now = Date.now();
|
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 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());
|
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();
|
const streamStartedAt = Date.now();
|
||||||
|
|
||||||
await new Promise((resolve) => {
|
let safetyTimer;
|
||||||
const safetyTimer = setTimeout(() => {
|
let onFinish, onError;
|
||||||
|
|
||||||
|
const playbackSettled = new Promise((resolve) => {
|
||||||
|
safetyTimer = setTimeout(() => {
|
||||||
logger.warn(`[Player] Stream safety timeout hit (${Math.round(safetyMs / 1000)}s) — advancing queue`);
|
logger.warn(`[Player] Stream safety timeout hit (${Math.round(safetyMs / 1000)}s) — advancing queue`);
|
||||||
cleanup();
|
cleanup();
|
||||||
resolve();
|
resolve();
|
||||||
}, safetyMs);
|
}, safetyMs);
|
||||||
|
|
||||||
const onFinish = () => {
|
onFinish = () => {
|
||||||
clearTimeout(safetyTimer);
|
clearTimeout(safetyTimer);
|
||||||
cleanup();
|
cleanup();
|
||||||
resolve();
|
resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onError = (e) => {
|
onError = (e) => {
|
||||||
clearTimeout(safetyTimer);
|
clearTimeout(safetyTimer);
|
||||||
cleanup();
|
cleanup();
|
||||||
if (isIgnorableMediaStateError(e)) {
|
if (isIgnorableMediaStateError(e)) {
|
||||||
@@ -961,6 +964,19 @@ export default class Player extends EventEmitter {
|
|||||||
this._mediaPlayer.once("finish", onFinish);
|
this._mediaPlayer.once("finish", onFinish);
|
||||||
this._mediaPlayer.once("error", onError);
|
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) {
|
} catch (e) {
|
||||||
if (audioStream && !audioStream.destroyed) {
|
if (audioStream && !audioStream.destroyed) {
|
||||||
try { audioStream.destroy(); } catch (e2) { logger.warn("[Player] Error destroying stream:", e2?.message); }
|
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._clearTrackEndTimer();
|
||||||
this._activeTrackOpt = null;
|
this._activeTrackOpt = null;
|
||||||
|
|
||||||
if (this._mediaPlayer) {
|
await this._stopMediaPlayer();
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
const channelId = this._channelId;
|
const channelId = this._channelId;
|
||||||
if (this._revoice && channelId && typeof this._revoice.markIntentionalDisconnect === "function") {
|
if (this._revoice && channelId && typeof this._revoice.markIntentionalDisconnect === "function") {
|
||||||
@@ -1405,7 +1416,6 @@ export default class Player extends EventEmitter {
|
|||||||
|
|
||||||
const connToDestroy = this.connection;
|
const connToDestroy = this.connection;
|
||||||
this.connection = null;
|
this.connection = null;
|
||||||
this._mediaPlayer = null;
|
|
||||||
if (this._revoice && this._channelId) {
|
if (this._revoice && this._channelId) {
|
||||||
try { this._revoice.markIntentionalDisconnect(this._channelId); } catch(e) { logger.warn("[Player] Mark intentional disconnect on destroy:", e?.message); }
|
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 {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (this._moonlink?.manager) {
|
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];
|
const track = result?.tracks?.[0];
|
||||||
if (track?.encoded) {
|
if (track?.encoded) {
|
||||||
const nlBase = `http://${this._nl.host}:${this._nl.port}`;
|
const nlBase = `http://${this._nl.host}:${this._nl.port}`;
|
||||||
|
|||||||
@@ -101,13 +101,17 @@ function installLiveKitLogFilter() {
|
|||||||
const origLog = console.log;
|
const origLog = console.log;
|
||||||
const origInfo = console.info;
|
const origInfo = console.info;
|
||||||
|
|
||||||
const filtered = function (...args) {
|
const filteredLog = function (...args) {
|
||||||
if (isLiveKitLogMessage(...args)) return;
|
if (isLiveKitLogMessage(...args)) return;
|
||||||
return origLog.apply(console, args);
|
return origLog.apply(console, args);
|
||||||
};
|
};
|
||||||
|
const filteredInfo = function (...args) {
|
||||||
|
if (isLiveKitLogMessage(...args)) return;
|
||||||
|
return origInfo.apply(console, args);
|
||||||
|
};
|
||||||
|
|
||||||
console.log = filtered;
|
console.log = filteredLog;
|
||||||
console.info = filtered;
|
console.info = filteredInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user