mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
Upgrades the bot from fluxerjs 2.2 to 3.0 and restructures everything into a layered architecture (~28K lines): Dependencies: - @fluxerjs/core, util, voice: ^2.2.0 -> ^3.0.0 (typed events, PartialMessage payloads, camelCase API) - @fluxerjs/sharding ^3.0.0 added — built-in sharding mode (shard.mjs, one process per shard) - @discordjs/opus dropped — opusscript + prism-media cover encoding Architecture: - commands: every command split into submodules (player, lastfm, settings, debug) with a shared CommandBuilder/Loader/Handler core - ui: embeds, paginators, help command, permission checks - voice: gateway event routing, rejoin/247 boot recovery, state resolver - music: player split into Queue/Search/Playback/Display mixins, stream pipeline + WebM/Opus muxer (no FFmpeg needed) - dashboard: Redis pub/sub, RPC handlers, serializers - db: MySQL manager + per-guild settings - services: LastFm manager split into focused mixins - utils: sharding, 24/7 helpers, API client Runtime fixes over v2: - Redis v5 reconnect: capped numeric backoff (0.5s ramp to 15s), never exhausts, auto-recovers when the server comes back - Redis main/subscriber clients connect in parallel; clean shutdown - Logger storm guard: identical error/warn lines deduped in a 60s window - self-deaf fix on voice join - config example uses redis://127.0.0.1 (avoids IPv6 ENETUNREACH) Housekeeping: dead code removed (Tuna.mjs + follow-redirects dep), .gitignore added (config.json, .env, node_modules, runtime state).
69 lines
2.7 KiB
JavaScript
69 lines
2.7 KiB
JavaScript
/**
|
|
* @module commands/seek
|
|
* @description Seek to a specific position in the currently playing track.
|
|
*/
|
|
|
|
import { CommandBuilder } from "../src/commands/index.mjs";
|
|
import { EmbedBuilder } from "@fluxerjs/core";
|
|
import { getGlobalColor } from "../src/ui/index.mjs";
|
|
import { Utils } from "../src/utils/Utils.mjs";
|
|
import { ERROR_COLOR } from "../src/utils/UI.mjs";
|
|
|
|
/** @type {CommandBuilder} @description Command definition for the seek command. */
|
|
export const command = new CommandBuilder()
|
|
.setName("seek")
|
|
.setDescription("Seek to a specific position in the current track.", "commands.seek")
|
|
.setCategory("music")
|
|
.addTextOption(o =>
|
|
o.setName("position")
|
|
.setDescription("Position to seek to (e.g. 1:30, 90, or 1:30:00 for hours)")
|
|
.setRequired(true)
|
|
);
|
|
|
|
/**
|
|
* @async
|
|
* Run handler for the seek command.
|
|
* Parses a duration string and seeks the player to that position.
|
|
* @param {object} msg - The command message wrapper.
|
|
* @param {object} data - Parsed command data containing the position option.
|
|
* @returns {Promise<void>}
|
|
*/
|
|
export async function run(msg, data) {
|
|
const positionInput = data.get("position")?.value;
|
|
|
|
const p = await this.getPlayer(msg, true, true, false);
|
|
if (!p) return;
|
|
|
|
if (!p.queue?.getCurrent()) {
|
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.nothingPlaying"))] });
|
|
}
|
|
|
|
if (p._paused) {
|
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.paused"))] });
|
|
}
|
|
|
|
let seekMs = Utils.parseDuration(positionInput);
|
|
if (!seekMs || seekMs < 0) {
|
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.invalidFormat"))] });
|
|
}
|
|
|
|
const trackDuration = p._getTrackDurationMs(p.queue.getCurrent());
|
|
|
|
if (trackDuration > 0 && seekMs >= trackDuration) {
|
|
const maxStr = Utils.prettifyMS(trackDuration);
|
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.exceedsDuration", { duration: maxStr }))] });
|
|
}
|
|
|
|
try {
|
|
const result = await p.seekToPosition(seekMs);
|
|
if (result) {
|
|
const seekStr = Utils.prettifyMS(seekMs);
|
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(getGlobalColor()).setDescription(this.t(msg, "responses.seek.seeked", { position: seekStr }))] });
|
|
} else {
|
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.notSupported"))] });
|
|
}
|
|
} catch (err) {
|
|
return msg.reply({ embeds: [new EmbedBuilder().setColor(ERROR_COLOR).setDescription(this.t(msg, "responses.seek.failed", { error: err.message }))] });
|
|
}
|
|
}
|