mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
hotfix
This commit is contained in:
1 parent
8a8925653c
commit
3a72e46775
12 files changed
+72
-28
No files matched your search
@@ -42,6 +42,12 @@ export async function run(msg, data) {
|
|||||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.paused"))] });
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.paused"))] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const current = p.queue.getCurrent();
|
||||||
|
|
||||||
|
if (current?.type === "radio" || current?.isLive || p._getTrackDurationMs(current) === 0) {
|
||||||
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.live"))] });
|
||||||
|
}
|
||||||
|
|
||||||
let seekMs = Utils.parseDuration(positionInput);
|
let seekMs = Utils.parseDuration(positionInput);
|
||||||
if (!seekMs || seekMs < 0) {
|
if (!seekMs || seekMs < 0) {
|
||||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ const BotVoiceMixin = {
|
|||||||
|
|
||||||
await player.playNext();
|
await player.playNext();
|
||||||
|
|
||||||
if (current && pos > 0) {
|
if (current && pos > 0 && dur > 0) {
|
||||||
await new Promise((r) => setTimeout(r, 800)); // let the bridge settle
|
await new Promise((r) => setTimeout(r, 800)); // let the bridge settle
|
||||||
try { await player.seekToPosition(pos); } catch (_) {}
|
try { await player.seekToPosition(pos); } catch (_) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,24 +4,6 @@
|
|||||||
* survive bot reboots/crashes. One row per (bot_id, guild_id) holding a JSON
|
* survive bot reboots/crashes. One row per (bot_id, guild_id) holding a JSON
|
||||||
* snapshot of the player: voice channel, text channel, queue tracks, current
|
* snapshot of the player: voice channel, text channel, queue tracks, current
|
||||||
* track, resume position, volume and loop modes.
|
* track, resume position, volume and loop modes.
|
||||||
*
|
|
||||||
* WHY MySQL AND NOT REDIS/FILES:
|
|
||||||
* - The bot already owns a MySQL pool (RemoteSettingsManager) that is flushed
|
|
||||||
* on graceful shutdown; snapshots ride the same healthy connection and are
|
|
||||||
* durable across restarts of ANY component.
|
|
||||||
* - The project's Redis handle (dashboard RedisHandler) is a pub/sub cache
|
|
||||||
* whose client is closed on shutdown — it is the wrong place for state
|
|
||||||
* that must outlive a reboot.
|
|
||||||
* - Local JSON files were audited and removed from the hot path years ago
|
|
||||||
* (storage/stats.json has no writer left); adding file writes would make
|
|
||||||
* the bot slower, not faster.
|
|
||||||
*
|
|
||||||
* Write pattern:
|
|
||||||
* - Full snapshot: debounced 3s per player, triggered by queue/playback
|
|
||||||
* events (see Player.mjs).
|
|
||||||
* - Position heartbeat: single cheap UPDATE of the position_ms column every
|
|
||||||
* 15s while a track is playing, so resume-after-crash lands within ~15s
|
|
||||||
* of where the song actually was.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { logger } from "../core/Logger.mjs";
|
import { logger } from "../core/Logger.mjs";
|
||||||
|
|||||||
@@ -79,6 +79,12 @@ const DisplayMixin = {
|
|||||||
? `${vid.title} - ${vid.url}`
|
? `${vid.title} - ${vid.url}`
|
||||||
: `[${vid.title}](${vid.url})`;
|
: `[${vid.title}](${vid.url})`;
|
||||||
}
|
}
|
||||||
|
if (vid.isLive || vid.type === "livestream") {
|
||||||
|
const link = vid.url || "";
|
||||||
|
return code
|
||||||
|
? `${vid.title} (LIVE) - ${link}`
|
||||||
|
: `🔴 [${vid.title}](${link}) — **LIVE**`;
|
||||||
|
}
|
||||||
const elapsed = this.getCurrentElapsedDuration();
|
const elapsed = this.getCurrentElapsedDuration();
|
||||||
const total = this.getDuration(vid.duration);
|
const total = this.getDuration(vid.duration);
|
||||||
const link = vid.spotifyUrl || vid.url || "";
|
const link = vid.spotifyUrl || vid.url || "";
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ const PlaybackMixin = {
|
|||||||
this._lastPlayedTrack = this.queue.getCurrent() ?? songData;
|
this._lastPlayedTrack = this.queue.getCurrent() ?? songData;
|
||||||
this.queue.current = null;
|
this.queue.current = null;
|
||||||
this.emit("stopplay");
|
this.emit("stopplay");
|
||||||
if (!this._is247Enabled()) {
|
this._scheduleRadioReconnect(songData);
|
||||||
this._startInactivityTimer();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +171,7 @@ const PlaybackMixin = {
|
|||||||
this._pausedAt = null;
|
this._pausedAt = null;
|
||||||
this._queueEndedSent = false;
|
this._queueEndedSent = false;
|
||||||
this._consecutiveErrors = 0;
|
this._consecutiveErrors = 0;
|
||||||
|
this._radioReconnects = 0;
|
||||||
|
|
||||||
if (songData.type !== "radio" || !this._radioAnnounced) {
|
if (songData.type !== "radio" || !this._radioAnnounced) {
|
||||||
this.announceSong(songData);
|
this.announceSong(songData);
|
||||||
@@ -362,6 +361,31 @@ const PlaybackMixin = {
|
|||||||
this._skipping = false;
|
this._skipping = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private Re-arm the same radio station after its stream drops. Live
|
||||||
|
* streams end on network hiccups, not on purpose — retry twice (3s apart)
|
||||||
|
* before giving the channel back to the inactivity timer. A user-queued
|
||||||
|
* song or an intentional leave during the wait window cancels it.
|
||||||
|
* @this {import('./Player.mjs').Player}
|
||||||
|
* @param {object} track - The radio track object that ended.
|
||||||
|
*/
|
||||||
|
_scheduleRadioReconnect(track) {
|
||||||
|
const maxRetries = 2;
|
||||||
|
if ((this._radioReconnects ?? 0) >= maxRetries || !track?.url) {
|
||||||
|
this._radioReconnects = 0;
|
||||||
|
if (!this._is247Enabled()) this._startInactivityTimer();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this._radioReconnects = (this._radioReconnects ?? 0) + 1;
|
||||||
|
logger.player(`[Player] Radio stream ended — reconnecting (${this._radioReconnects}/${maxRetries}) in 3s: ${track.title}`);
|
||||||
|
setTimeout(() => {
|
||||||
|
if (this._destroyed || this.leaving || !this._voiceConn) return;
|
||||||
|
if (this.queue.getCurrent() || !this.queue.isEmpty()) return;
|
||||||
|
this.queue.add(track);
|
||||||
|
this.playNext().catch(e => logger.error("[Player] Radio reconnect playNext error:", e.message));
|
||||||
|
}, 3_000).unref?.();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private Clear the track-end timer.
|
* @private Clear the track-end timer.
|
||||||
* @this {import('./Player.mjs').Player}
|
* @this {import('./Player.mjs').Player}
|
||||||
|
|||||||
@@ -148,6 +148,7 @@ const SearchMixin = {
|
|||||||
videoId: info.identifier ?? "",
|
videoId: info.identifier ?? "",
|
||||||
encoded: track.encoded ?? info.encoded ?? "",
|
encoded: track.encoded ?? info.encoded ?? "",
|
||||||
sourceName: info.sourceName ?? "unknown",
|
sourceName: info.sourceName ?? "unknown",
|
||||||
|
isLive: info.isLive === true,
|
||||||
title: Utils.cleanTitle(info.title ?? "Unknown"),
|
title: Utils.cleanTitle(info.title ?? "Unknown"),
|
||||||
url: trackUri,
|
url: trackUri,
|
||||||
thumbnail: info.artworkUrl ?? null,
|
thumbnail: info.artworkUrl ?? null,
|
||||||
@@ -292,14 +293,24 @@ const SearchMixin = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lcTracks.length === 0) {
|
if (lcTracks.length === 0) {
|
||||||
if (!isUrl && source !== "ytmsearch") {
|
if (!isUrl) {
|
||||||
events.emit("message", "No results from primary source, trying YouTube Music...");
|
const FALLBACKS = [
|
||||||
const fallback = await this._lavalink.search(searchQuery, { source: "ytmsearch" });
|
{ source: "ytmsearch", label: "YouTube Music" },
|
||||||
if (fallback?.tracks?.length > 0) {
|
{ source: "ytsearch", label: "YouTube" },
|
||||||
const video = this._lcTrackToVideo(fallback.tracks[0], trackMeta);
|
{ source: "scsearch", label: "SoundCloud" },
|
||||||
|
].filter(f => f.source !== source);
|
||||||
|
|
||||||
|
for (const fb of FALLBACKS) {
|
||||||
|
events.emit("message", "No results yet — trying **" + fb.label + "**...");
|
||||||
|
let fbResult = null;
|
||||||
|
try {
|
||||||
|
fbResult = await this._lavalink.search(searchQuery, { source: fb.source });
|
||||||
|
} catch (_) { fbResult = null; }
|
||||||
|
if (fbResult?.tracks?.length > 0) {
|
||||||
|
const video = this._lcTrackToVideo(fbResult.tracks[0], trackMeta);
|
||||||
if (video) {
|
if (video) {
|
||||||
this.addToQueue(video, top);
|
this.addToQueue(video, top);
|
||||||
events.emit("message", "Successfully added [" + video.title + "](" + video.url + ") to the queue.");
|
events.emit("message", "Successfully added [" + video.title + "](" + video.url + ") to the queue. *(found on " + fb.label + ")*");
|
||||||
if (!this.queue.getCurrent()) {
|
if (!this.queue.getCurrent()) {
|
||||||
this.playNext().catch(e => logger.error("[Player] playNext error:", e.message));
|
this.playNext().catch(e => logger.error("[Player] playNext error:", e.message));
|
||||||
}
|
}
|
||||||
@@ -307,6 +318,12 @@ const SearchMixin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const lavasrcHost = /(?:open\.spotify\.com|spotify\.link|music\.apple\.com|tidal\.com|deezer\.com|deezer\.page\.link|music\.youtube\.com\/playlist)/i;
|
||||||
|
try { if (lavasrcHost.test(new URL(query.trim()).hostname)) {
|
||||||
|
events.emit("message", "⚠️ This link needs the **LavaSrc plugin** on the audio node, which isn't available. Try the song/playlist **name** instead — e.g. `%play <name>`.");
|
||||||
|
} } catch (_) {}
|
||||||
|
}
|
||||||
events.emit("message", "**No results found for '" + query + "'.**");
|
events.emit("message", "**No results found for '" + query + "'.**");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -328,6 +345,9 @@ const SearchMixin = {
|
|||||||
if (video) {
|
if (video) {
|
||||||
this.addToQueue(video, top);
|
this.addToQueue(video, top);
|
||||||
events.emit("message", "Successfully added [" + video.title + "](" + video.url + ") to the queue.");
|
events.emit("message", "Successfully added [" + video.title + "](" + video.url + ") to the queue.");
|
||||||
|
if (playlistQuery) {
|
||||||
|
events.emit("message", "⚠️ Couldn't load the full playlist — added just this video.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
events.emit("message", "**Failed to parse track data.**");
|
events.emit("message", "**Failed to parse track data.**");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -775,6 +775,7 @@
|
|||||||
"seek": {
|
"seek": {
|
||||||
"nothingPlaying": "❌ لا يوجد شيء يعمل حالياً!",
|
"nothingPlaying": "❌ لا يوجد شيء يعمل حالياً!",
|
||||||
"paused": "❌ لا يمكن الانتقال أثناء الإيقاف المؤقت. استأنف أولاً.",
|
"paused": "❌ لا يمكن الانتقال أثناء الإيقاف المؤقت. استأنف أولاً.",
|
||||||
|
"live": "❌ هذا بث مباشر أو راديو — لا يمكن الانتقال إلى موضع محدد.",
|
||||||
"invalidFormat": "❌ تنسيق موضع غير صالح. استخدم `mm:ss` أو `hh:mm:ss` أو ثوانٍ (مثلاً `1:30`، `90`).",
|
"invalidFormat": "❌ تنسيق موضع غير صالح. استخدم `mm:ss` أو `hh:mm:ss` أو ثوانٍ (مثلاً `1:30`، `90`).",
|
||||||
"exceedsDuration": "❌ موضع الانتقال يتجاوز مدة المقطع (**{{duration}}**).",
|
"exceedsDuration": "❌ موضع الانتقال يتجاوز مدة المقطع (**{{duration}}**).",
|
||||||
"seeked": "⏩ تم الانتقال إلى **{{position}}**",
|
"seeked": "⏩ تم الانتقال إلى **{{position}}**",
|
||||||
|
|||||||
@@ -775,6 +775,7 @@
|
|||||||
"seek": {
|
"seek": {
|
||||||
"nothingPlaying": "❌ هیچ شتێک پەخش ناکرێت لە ئێستادا!",
|
"nothingPlaying": "❌ هیچ شتێک پەخش ناکرێت لە ئێستادا!",
|
||||||
"paused": "❌ ناتوانرێت لە کاتی وەستاودا بگەڕێیتەوە. سەرەتا بەردەوامبکە.",
|
"paused": "❌ ناتوانرێت لە کاتی وەستاودا بگەڕێیتەوە. سەرەتا بەردەوامبکە.",
|
||||||
|
"live": "❌ ئەمە پەخشێکی ڕاستەوخۆ یان ڕادیۆیە — ناتوانرێت بگوازرێتەوە بۆ شوێنێکی دیاریکراو.",
|
||||||
"invalidFormat": "❅ شێوازی شوێنی نادروست. `mm:ss`، `hh:mm:ss`، یان چرکە بەکاربهێنە (بۆ نموونە `1:30`، `90`).",
|
"invalidFormat": "❅ شێوازی شوێنی نادروست. `mm:ss`، `hh:mm:ss`، یان چرکە بەکاربهێنە (بۆ نموونە `1:30`، `90`).",
|
||||||
"exceedsDuration": "❌ شوێنی گەڕانەوە لە ماوەی تراکەکە زیاترە (**{{duration}}**).",
|
"exceedsDuration": "❌ شوێنی گەڕانەوە لە ماوەی تراکەکە زیاترە (**{{duration}}**).",
|
||||||
"seeked": "⏩ گەڕایەوە بۆ **{{position}}**",
|
"seeked": "⏩ گەڕایەوە بۆ **{{position}}**",
|
||||||
|
|||||||
@@ -775,6 +775,7 @@
|
|||||||
"seek": {
|
"seek": {
|
||||||
"nothingPlaying": "❌ Es wird gerade nichts abgespielt!",
|
"nothingPlaying": "❌ Es wird gerade nichts abgespielt!",
|
||||||
"paused": "❌ Kann nicht springen während pausiert. Zuerst fortsetzen.",
|
"paused": "❌ Kann nicht springen während pausiert. Zuerst fortsetzen.",
|
||||||
|
"live": "❌ Das ist ein Livestream oder Radio — Spulen wird hier nicht unterstützt.",
|
||||||
"invalidFormat": "❌ Ungültiges Positionsformat. Nutze `mm:ss`, `hh:mm:ss` oder Sekunden (z.B. `1:30`, `90`).",
|
"invalidFormat": "❌ Ungültiges Positionsformat. Nutze `mm:ss`, `hh:mm:ss` oder Sekunden (z.B. `1:30`, `90`).",
|
||||||
"exceedsDuration": "❌ Sprungposition überschreitet Track-Dauer (**{{duration}}**).",
|
"exceedsDuration": "❌ Sprungposition überschreitet Track-Dauer (**{{duration}}**).",
|
||||||
"seeked": "⏩ Gesprungen zu **{{position}}**",
|
"seeked": "⏩ Gesprungen zu **{{position}}**",
|
||||||
|
|||||||
@@ -776,6 +776,7 @@
|
|||||||
"seek": {
|
"seek": {
|
||||||
"nothingPlaying": "❌ There's nothing playing at the moment!",
|
"nothingPlaying": "❌ There's nothing playing at the moment!",
|
||||||
"paused": "❌ Can't seek while paused. Resume first.",
|
"paused": "❌ Can't seek while paused. Resume first.",
|
||||||
|
"live": "❌ This is a live stream or radio — you can't seek in it.",
|
||||||
"invalidFormat": "❌ Invalid position format. Use `mm:ss`, `hh:mm:ss`, or seconds (e.g. `1:30`, `90`).",
|
"invalidFormat": "❌ Invalid position format. Use `mm:ss`, `hh:mm:ss`, or seconds (e.g. `1:30`, `90`).",
|
||||||
"exceedsDuration": "❌ Seek position exceeds track duration (**{{duration}}**).",
|
"exceedsDuration": "❌ Seek position exceeds track duration (**{{duration}}**).",
|
||||||
"seeked": "⏩ Seeked to **{{position}}**",
|
"seeked": "⏩ Seeked to **{{position}}**",
|
||||||
|
|||||||
@@ -775,6 +775,7 @@
|
|||||||
"seek": {
|
"seek": {
|
||||||
"nothingPlaying": "❌ Não está tocando nada no momento!",
|
"nothingPlaying": "❌ Não está tocando nada no momento!",
|
||||||
"paused": "❌ Não é possível buscar enquanto pausado. Retome primeiro.",
|
"paused": "❌ Não é possível buscar enquanto pausado. Retome primeiro.",
|
||||||
|
"live": "❌ Isto é uma transmissão ao vivo ou rádio — não é possível buscar uma posição.",
|
||||||
"invalidFormat": "❌ Formato de posição inválido. Use `mm:ss`, `hh:mm:ss`, ou segundos (ex: `1:30`, `90`).",
|
"invalidFormat": "❌ Formato de posição inválido. Use `mm:ss`, `hh:mm:ss`, ou segundos (ex: `1:30`, `90`).",
|
||||||
"exceedsDuration": "❌ Posição de busca excede a duração da faixa (**{{duration}}**).",
|
"exceedsDuration": "❌ Posição de busca excede a duração da faixa (**{{duration}}**).",
|
||||||
"seeked": "⏩ Pulou para **{{position}}**",
|
"seeked": "⏩ Pulou para **{{position}}**",
|
||||||
|
|||||||
@@ -738,6 +738,7 @@
|
|||||||
"seek": {
|
"seek": {
|
||||||
"nothingPlaying": "❌ Şu anda çalan bir şey yok!",
|
"nothingPlaying": "❌ Şu anda çalan bir şey yok!",
|
||||||
"paused": "❌ Duraklatılmışken konuma gidilemez. Önce devam ettirin.",
|
"paused": "❌ Duraklatılmışken konuma gidilemez. Önce devam ettirin.",
|
||||||
|
"live": "❌ Bu canlı bir yayın veya radyo — belirli bir konuma geçilemez.",
|
||||||
"invalidFormat": "❌ Geçersiz konum biçimi. `dd:ss`, `sa:dd:ss` veya saniye kullanın (örn. `1:30`, `90`).",
|
"invalidFormat": "❌ Geçersiz konum biçimi. `dd:ss`, `sa:dd:ss` veya saniye kullanın (örn. `1:30`, `90`).",
|
||||||
"exceedsDuration": "❌ Konum parça süresini aşıyor (**{{duration}}**).",
|
"exceedsDuration": "❌ Konum parça süresini aşıyor (**{{duration}}**).",
|
||||||
"seeked": "⏩ **{{position}}** konumuna gidildi",
|
"seeked": "⏩ **{{position}}** konumuna gidildi",
|
||||||
|
|||||||
Reference in new issue
Block a user