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
+34
-29
No files matched your search
@@ -143,6 +143,7 @@ export async function run(msg, data) {
|
|||||||
await clearReactions();
|
await clearReactions();
|
||||||
|
|
||||||
if (e.emoji_id === CANCEL_EMOJI) {
|
if (e.emoji_id === CANCEL_EMOJI) {
|
||||||
|
p.searches.delete(msg.authorId);
|
||||||
rawMsg.edit({
|
rawMsg.edit({
|
||||||
embeds: [makeEmbed(this.t(msg, "responses.search.cancelled"), null, this.t(msg, "responses.search.resultsTitle", { provider: name }))]
|
embeds: [makeEmbed(this.t(msg, "responses.search.cancelled"), null, this.t(msg, "responses.search.resultsTitle", { provider: name }))]
|
||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
@@ -167,6 +168,7 @@ export async function run(msg, data) {
|
|||||||
const SESSION_MS = this.config?.timers?.searchSessionTimeout ?? 30_000;
|
const SESSION_MS = this.config?.timers?.searchSessionTimeout ?? 30_000;
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
unobserve();
|
unobserve();
|
||||||
|
p.searches.delete(msg.authorId);
|
||||||
clearReactions().catch(() => {});
|
clearReactions().catch(() => {});
|
||||||
rawMsg.edit({
|
rawMsg.edit({
|
||||||
embeds: [makeEmbed(this.t(msg, "responses.search.timedOut"), this.t(msg, "responses.search.sessionClosed"), this.t(msg, "responses.search.resultsTitle", { provider: name }))]
|
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"))] });
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.live"))] });
|
||||||
}
|
}
|
||||||
|
|
||||||
let seekMs = Utils.parseDuration(positionInput);
|
const trimmed = String(positionInput ?? "").trim();
|
||||||
if (!seekMs || seekMs < 0) {
|
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"))] });
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-23
@@ -222,25 +222,7 @@ export class RichPaginator {
|
|||||||
const next = this._next;
|
const next = this._next;
|
||||||
const buildEmbed = this._buildEmbed.bind(this);
|
const buildEmbed = this._buildEmbed.bind(this);
|
||||||
|
|
||||||
const unobserve = wrapped.onReaction(allReactions, async (e) => {
|
let unobserve = () => {};
|
||||||
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(() => {});
|
|
||||||
});
|
|
||||||
|
|
||||||
/** @private Clear all reactions on the paginator message. */
|
/** @private Clear all reactions on the paginator message. */
|
||||||
const clearReactions = async () => {
|
const clearReactions = async () => {
|
||||||
@@ -279,12 +261,27 @@ export class RichPaginator {
|
|||||||
timer = setTimeout(closeSession, this._timeout);
|
timer = setTimeout(closeSession, this._timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
const origHandler = wrapped.handler.observedReactions.get(rawMsg.id);
|
unobserve = wrapped.onReaction(allReactions, async (e) => {
|
||||||
if (origHandler) {
|
resetTimer();
|
||||||
const origCb = origHandler.cb;
|
const emoji = e.emoji_id;
|
||||||
origHandler.cb = (e, m) => { resetTimer(); origCb(e, m); };
|
|
||||||
|
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;
|
return rawMsg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,15 +41,19 @@ const RejoinManager = {
|
|||||||
return player;
|
return player;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const errMsg = err?.message ?? String(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("lavalink player create failed")
|
||||||
|| errMsg.includes("Failed to create audio player")
|
|| 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);
|
const backoffMs = baseDelay * Math.pow(2, attempt - 1);
|
||||||
logger.warn(
|
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}`
|
`retrying in ${backoffMs / 1000}s: ${errMsg}`
|
||||||
);
|
);
|
||||||
await new Promise(resolve => setTimeout(resolve, backoffMs));
|
await new Promise(resolve => setTimeout(resolve, backoffMs));
|
||||||
|
|||||||
Reference in new issue
Block a user