mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
fix(player, ui, voice): resolve seek 0 validation, help paginator reset, and voice retry backoff (#22)
This commit is contained in:
1 parent
04aece8af3
commit
08e5d363fc
4 files changed
+35
-30
No files matched your search
@@ -143,6 +143,7 @@ export async function run(msg, data) {
|
||||
await clearReactions();
|
||||
|
||||
if (e.emoji_id === CANCEL_EMOJI) {
|
||||
p.searches.delete(msg.authorId);
|
||||
rawMsg.edit({
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.cancelled"), null, this.t(msg, "responses.search.resultsTitle", { provider: name }))]
|
||||
}).catch(() => {});
|
||||
@@ -167,6 +168,7 @@ export async function run(msg, data) {
|
||||
const SESSION_MS = this.config?.timers?.searchSessionTimeout ?? 30_000;
|
||||
const timer = setTimeout(() => {
|
||||
unobserve();
|
||||
p.searches.delete(msg.authorId);
|
||||
clearReactions().catch(() => {});
|
||||
rawMsg.edit({
|
||||
embeds: [makeEmbed(this.t(msg, "responses.search.timedOut"), this.t(msg, "responses.search.sessionClosed"), this.t(msg, "responses.search.resultsTitle", { provider: name }))]
|
||||
|
||||
+4
-2
@@ -48,8 +48,10 @@ export async function run(msg, data) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.live"))] });
|
||||
}
|
||||
|
||||
let seekMs = Utils.parseDuration(positionInput);
|
||||
if (!seekMs || seekMs < 0) {
|
||||
const trimmed = String(positionInput ?? "").trim();
|
||||
const isZero = /^0+(:0+)?(:0+)?$/.test(trimmed);
|
||||
const seekMs = isZero ? 0 : Utils.parseDuration(trimmed);
|
||||
if (seekMs === null || isNaN(seekMs) || seekMs < 0 || (!isZero && seekMs === 0)) {
|
||||
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
||||
}
|
||||
|
||||
|
||||
+21
-24
@@ -222,25 +222,7 @@ export class RichPaginator {
|
||||
const next = this._next;
|
||||
const buildEmbed = this._buildEmbed.bind(this);
|
||||
|
||||
const unobserve = wrapped.onReaction(allReactions, async (e) => {
|
||||
const emoji = e.emoji_id;
|
||||
|
||||
if (emoji === prev || emoji === next) {
|
||||
const tab = tabs[state.tab];
|
||||
const totalPages = Math.max(1, tab.pages.length);
|
||||
if (totalPages <= 1) return;
|
||||
state.page = emoji === prev
|
||||
? (state.page - 1 + totalPages) % totalPages
|
||||
: (state.page + 1) % totalPages;
|
||||
} else {
|
||||
const idx = tabEmojis.indexOf(emoji);
|
||||
if (idx === -1 || idx === state.tab) return;
|
||||
state.tab = idx;
|
||||
state.page = 0;
|
||||
}
|
||||
|
||||
rawMsg.edit({ embeds: [buildEmbed(state.tab, state.page)] }).catch(() => {});
|
||||
});
|
||||
let unobserve = () => {};
|
||||
|
||||
/** @private Clear all reactions on the paginator message. */
|
||||
const clearReactions = async () => {
|
||||
@@ -279,11 +261,26 @@ export class RichPaginator {
|
||||
timer = setTimeout(closeSession, this._timeout);
|
||||
};
|
||||
|
||||
const origHandler = wrapped.handler.observedReactions.get(rawMsg.id);
|
||||
if (origHandler) {
|
||||
const origCb = origHandler.cb;
|
||||
origHandler.cb = (e, m) => { resetTimer(); origCb(e, m); };
|
||||
}
|
||||
unobserve = wrapped.onReaction(allReactions, async (e) => {
|
||||
resetTimer();
|
||||
const emoji = e.emoji_id;
|
||||
|
||||
if (emoji === prev || emoji === next) {
|
||||
const tab = tabs[state.tab];
|
||||
const totalPages = Math.max(1, tab.pages.length);
|
||||
if (totalPages <= 1) return;
|
||||
state.page = emoji === prev
|
||||
? (state.page - 1 + totalPages) % totalPages
|
||||
: (state.page + 1) % totalPages;
|
||||
} else {
|
||||
const idx = tabEmojis.indexOf(emoji);
|
||||
if (idx === -1 || idx === state.tab) return;
|
||||
state.tab = idx;
|
||||
state.page = 0;
|
||||
}
|
||||
|
||||
rawMsg.edit({ embeds: [buildEmbed(state.tab, state.page)] }).catch(() => {});
|
||||
});
|
||||
|
||||
return rawMsg;
|
||||
}
|
||||
|
||||
@@ -41,15 +41,19 @@ const RejoinManager = {
|
||||
return player;
|
||||
} catch (err) {
|
||||
const errMsg = err?.message ?? String(err);
|
||||
const isTrackTimeout = errMsg.includes("track publication timed out")
|
||||
const isTransientError = errMsg.includes("track publication timed out")
|
||||
|| errMsg.includes("Voice connection timeout")
|
||||
|| errMsg.includes("LiveKit connection timeout")
|
||||
|| errMsg.includes("lavalink player create failed")
|
||||
|| errMsg.includes("Failed to create audio player")
|
||||
|| errMsg.includes("internal error");
|
||||
|| errMsg.includes("internal error")
|
||||
|| errMsg.includes("ETIMEDOUT")
|
||||
|| errMsg.includes("ECONNRESET");
|
||||
|
||||
if (isTrackTimeout && attempt < maxRetries) {
|
||||
if (isTransientError && attempt < maxRetries) {
|
||||
const backoffMs = baseDelay * Math.pow(2, attempt - 1);
|
||||
logger.warn(
|
||||
`[${context}] Track publication failed for channel ${channelId} (attempt ${attempt}/${maxRetries}) — ` +
|
||||
`[${context}] Voice connection/track failed for channel ${channelId} (attempt ${attempt}/${maxRetries}) — ` +
|
||||
`retrying in ${backoffMs / 1000}s: ${errMsg}`
|
||||
);
|
||||
await new Promise(resolve => setTimeout(resolve, backoffMs));
|
||||
|
||||
Reference in new issue
Block a user