From 5dc286e364fd84196aef5a5fd517afe4bbbdf051 Mon Sep 17 00:00:00 2001 From: NoLogicAlan Date: Tue, 27 Oct 2026 03:11:37 +0300 Subject: [PATCH] feat(docs): update README with playback history and instant replay features refactor(commands): remove unused imports from various command files refactor(src): clean up imports in multiple source files for better organization (#21) --- README.md | 6 +++++- commands/autoplay.mjs | 1 - commands/eval.mjs | 9 ++++++++- commands/leave.mjs | 2 +- commands/list.mjs | 2 +- commands/search.mjs | 2 +- commands/settings/setters.mjs | 6 +++--- src/dashboard/Dashboard.mjs | 5 ----- src/db/DatabaseManager.mjs | 4 +--- src/db/Settings.mjs | 2 +- src/music/PlayerManager.mjs | 2 +- src/music/audio/FluxerAudioBridge.mjs | 11 ++++------- src/music/player/PlaybackMixin.mjs | 3 --- src/music/player/Player.mjs | 3 +-- src/services/TrackOptionsManager.mjs | 3 +-- src/services/lastfm/LastFmManager.mjs | 2 +- src/utils/Utils.mjs | 3 +-- src/voice/VoiceStateCache.mjs | 1 - src/voice/gateway/GatewayHandler.mjs | 4 ++-- 19 files changed, 32 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 93f9869..f4d04d6 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,8 @@ A few things worth knowing: - **Radio stations** — built-in support for custom radio streams with keyword-based search - **Last.fm integration** — account linking, scrobbling, now-playing, play loved/top/recent/albums, whoknows, crowns, compare, leaderboards, and profiles - **Autoplay** — automatically play similar tracks when the queue ends (powered by Last.fm) +- **Playback history & undo** — circular playback history buffer (up to 20 tracks) allowing listeners to step backwards in the queue (`%previous`, `%prev`, `%undo`) without lost tracks +- **Instant song replay** — restart the currently playing track from 0:00 with zero stream lag (`%replay`, `%restart`) - **Seek** — jump to a specific position in the current track - **Track options** — set custom start/end times per track, great for album compilations and hidden tracks - **Queue move** — reorder tracks by moving them to a different position @@ -164,6 +166,8 @@ Below is the complete list of Remix's commands. The default prefix is `%`. | `pause` | Pause the current playback | `%pause` | | | `resume` | Resume the paused playback | `%resume` | | | `skip` | Skip the currently playing song | `%skip` | `s` | +| `previous` | Play the previous track from recent playback history | `%previous` / `%prev` | `prev`, `back`, `undo` | +| `replay` | Restart the current song from the beginning (0:00) | `%replay` | `restart` | | `np` | Show the currently playing song | `%np` | `current`, `nowplaying` | | `list` | View the upcoming queue | `%list` | `queue`, `q` | | `loop` | Toggle loop mode (song or queue) | `%loop queue` | | @@ -261,7 +265,7 @@ docker/ | `bot` | remix-bot | `${WEB_PORT:-8080}` → 80 | The Remix bot (+ optional dashboard backend) | | `mysql` | remix-mysql | — | Settings, Last.fm users, and track options storage | | `redis` | remix-redis | — | Dashboard RPC pub/sub (optional) | -| `nodelink` | remix-nodelink | `${NODELINK_PORT:-3000}` | Lavalink-compatible audio node | +| `nodelink` | remix-nodelink | `${NODELINK_PORT:-3000}` | Lavalink-compatible audio node (`ghcr.io/performanc/nodelink:latest`) | #### Useful Docker commands diff --git a/commands/autoplay.mjs b/commands/autoplay.mjs index 9738d98..c6a29ab 100644 --- a/commands/autoplay.mjs +++ b/commands/autoplay.mjs @@ -5,7 +5,6 @@ import { CommandBuilder } from "../src/commands/index.mjs"; import { EmbedBuilder } from "@fluxerjs/core"; -import { getGlobalColor } from "../src/ui/index.mjs"; import { logger } from "../src/core/Logger.mjs"; /** @type {CommandBuilder} @description Command definition for the autoplay command. */ diff --git a/commands/eval.mjs b/commands/eval.mjs index 744f8e7..04cf215 100644 --- a/commands/eval.mjs +++ b/commands/eval.mjs @@ -9,6 +9,7 @@ import { getGlobalColor } from "../src/ui/index.mjs"; import { logger } from "../src/core/Logger.mjs"; import { inspect } from "node:util"; import { ERROR_COLOR, EMOJI_REMOVE_TIMEOUT } from "../src/utils/UI.mjs"; +import { collectSecrets, redactSecrets } from "../src/utils/Redact.mjs"; /** @private @type {string[]} Property name substrings that indicate sensitive/secret data. */ const RESTRICTED = [ @@ -92,7 +93,7 @@ function removeSensitive(obj, level = 0, visited = new WeakSet()) { * @param {*} value - The raw eval result. * @returns {Promise} The sanitized output string. */ -async function clean(value) { +async function clean(value, config = null) { if (value instanceof Promise) value = await value; if (typeof value === "object" && value !== null) { @@ -108,6 +109,12 @@ async function clean(value) { output = `[Inspection Error]: ${err.message}`; } + /* Mask all configured secret values */ + if (config) { + const secrets = collectSecrets(config); + output = redactSecrets(output, secrets); + } + return output .replace(/`/g, "`\u200b") .replace(/@/g, "@\u200b") || "undefined"; diff --git a/commands/leave.mjs b/commands/leave.mjs index 0def027..7ff3250 100644 --- a/commands/leave.mjs +++ b/commands/leave.mjs @@ -6,7 +6,7 @@ import { CommandBuilder } from "../src/commands/index.mjs"; import { EmbedBuilder } from "@fluxerjs/core"; import { logger } from "../src/core/Logger.mjs"; -import { getGlobalColor, cleanId } from "../src/ui/index.mjs"; +import { cleanId } from "../src/ui/index.mjs"; /** @type {CommandBuilder} @description Command definition for the leave/stop command. */ export const command = new CommandBuilder() diff --git a/commands/list.mjs b/commands/list.mjs index 720474f..aa8b87e 100644 --- a/commands/list.mjs +++ b/commands/list.mjs @@ -4,7 +4,7 @@ */ import { CommandBuilder } from "../src/commands/index.mjs"; -import { QueuePaginator, getGlobalColor } from "../src/ui/index.mjs"; +import { QueuePaginator } from "../src/ui/index.mjs"; import { EmbedBuilder } from "@fluxerjs/core"; const PAGE_SIZE = 10; diff --git a/commands/search.mjs b/commands/search.mjs index 360e31c..4313b61 100644 --- a/commands/search.mjs +++ b/commands/search.mjs @@ -4,7 +4,7 @@ */ import { CommandBuilder } from "../src/commands/index.mjs"; -import { Message, getGlobalColor } from "../src/ui/index.mjs"; +import { Message } from "../src/ui/index.mjs"; import { EmbedBuilder } from "@fluxerjs/core"; import { PROVIDER_CHOICES, PROVIDER_NAMES, parseInlineProvider } from "../src/music/providers.mjs"; import { NUMBER_EMOJIS, CANCEL_EMOJI } from "../src/utils/UI.mjs"; diff --git a/commands/settings/setters.mjs b/commands/settings/setters.mjs index baa17a3..878cad6 100644 --- a/commands/settings/setters.mjs +++ b/commands/settings/setters.mjs @@ -10,12 +10,12 @@ import { cleanId, getMessageGuildId, getGlobalColor } from "../../src/ui/index.m import { EmbedBuilder } from "@fluxerjs/core"; import runnables from "../../settings/runnables.mjs"; import { - parseBool, displayValue, getGuildName, embed, tWrap, prettifySettingLabel, - BOOL_SETTINGS, VALID_LOCALES, VOLUME_MIN, VOLUME_MAX, PREFIX_MAX, SHORTCUTS, + parseBool, displayValue, embed, tWrap, prettifySettingLabel, + BOOL_SETTINGS, VALID_LOCALES, VOLUME_MIN, VOLUME_MAX, PREFIX_MAX, VOTE_SKIP_THRESHOLD_MIN, VOTE_SKIP_THRESHOLD_MAX, } from "./utils.mjs"; import { - get247Channels, save247Channels, build247Panel, disable247, handle247Toggle, + save247Channels, disable247, handle247Toggle, } from "./channels247.mjs"; /** diff --git a/src/dashboard/Dashboard.mjs b/src/dashboard/Dashboard.mjs index e401900..06e91c6 100644 --- a/src/dashboard/Dashboard.mjs +++ b/src/dashboard/Dashboard.mjs @@ -11,14 +11,9 @@ * conversion helpers in Serializers.mjs — both are attached at the bottom of this file. */ -import { CommandBuilder, CommandHandler, Option } from "../commands/index.mjs"; -import { PermissionFlags } from "@fluxerjs/core"; -import Player from "../music/player/index.mjs"; -import { Utils, cleanId } from "../utils/Utils.mjs"; import { DatabaseManager } from "../db/DatabaseManager.mjs"; import { RedisHandler } from "./RedisHandler.mjs"; import { logger } from "../core/Logger.mjs"; -import { iterateVoiceStates } from "../voice/VoiceStateResolver.mjs"; import { applyMixins } from "../utils/mixins.mjs"; import RpcHandlersMixin from "./RpcHandlersMixin.mjs"; import Serializers from "./Serializers.mjs"; diff --git a/src/db/DatabaseManager.mjs b/src/db/DatabaseManager.mjs index 5b1fe44..e877e28 100644 --- a/src/db/DatabaseManager.mjs +++ b/src/db/DatabaseManager.mjs @@ -5,9 +5,7 @@ */ import { compare, genSalt, hash } from "bcryptjs"; -import { createPool } from "mysql2/promise"; -import { logger } from "../core/Logger.mjs"; -import { MYSQL_POOL_DEFAULTS, attachMysqlPoolGuard } from "./MysqlGuard.mjs"; +import { attachMysqlPoolGuard } from "./MysqlGuard.mjs"; import { getSharedPromisePool } from "./PoolManager.mjs"; /** diff --git a/src/db/Settings.mjs b/src/db/Settings.mjs index f4676f1..c9c0e06 100644 --- a/src/db/Settings.mjs +++ b/src/db/Settings.mjs @@ -8,7 +8,7 @@ import fs from "node:fs"; import mysql from "mysql2"; import { EventEmitter } from "node:events"; -import { MYSQL_POOL_DEFAULTS, attachMysqlPoolGuard } from "./MysqlGuard.mjs"; +import { attachMysqlPoolGuard } from "./MysqlGuard.mjs"; import { getSharedMysqlPool } from "./PoolManager.mjs"; import { logger } from "../core/Logger.mjs"; diff --git a/src/music/PlayerManager.mjs b/src/music/PlayerManager.mjs index 3b20b81..5eab397 100644 --- a/src/music/PlayerManager.mjs +++ b/src/music/PlayerManager.mjs @@ -12,7 +12,7 @@ */ import Player from "./player/index.mjs"; -import { Utils, cleanId } from "../utils/Utils.mjs"; +import { cleanId } from "../utils/Utils.mjs"; import { logger } from "../core/Logger.mjs"; import { getMessageGuildId } from "../ui/index.mjs"; import { applyMixins } from "../utils/mixins.mjs"; diff --git a/src/music/audio/FluxerAudioBridge.mjs b/src/music/audio/FluxerAudioBridge.mjs index 451403f..346f28a 100644 --- a/src/music/audio/FluxerAudioBridge.mjs +++ b/src/music/audio/FluxerAudioBridge.mjs @@ -163,16 +163,13 @@ export class FluxerAudioBridge extends EventEmitter { // this point get the explicit error below instead of fetching their // source page. if (!trackInfo.encoded && trackInfo.url && trackInfo.url.startsWith("http")) { - logger.player("[AudioBridge] Route 3: Fetching directly: " + trackInfo.url.substring(0, 80) + "..."); - const response = await fetch(trackInfo.url, { + logger.player("[AudioBridge] Route 3: Fetching directly via SafeHttp: " + trackInfo.url.substring(0, 80) + "..."); + const { openPublicStream } = await import("./SafeHttp.mjs"); + const { stream, req } = await openPublicStream(trackInfo.url, { headers: { "User-Agent": "Mozilla/5.0 (compatible; Bot/1.0)" }, - redirect: "follow", }); - if (!response.ok) { - throw new Error("HTTP " + response.status + " for " + trackInfo.url); - } - const stream = Readable.fromWeb(response.body); this._sourceStream = stream; + this._sourceReq = req || null; const routed = await this._routeByMagic(stream); if (routed.kind === "webm") { diff --git a/src/music/player/PlaybackMixin.mjs b/src/music/player/PlaybackMixin.mjs index e74f20b..003872f 100644 --- a/src/music/player/PlaybackMixin.mjs +++ b/src/music/player/PlaybackMixin.mjs @@ -9,13 +9,10 @@ */ import { EmbedBuilder } from "@fluxerjs/core"; -import { getGlobalColor } from "../../ui/index.mjs"; import { ERROR_COLOR } from "../../utils/UI.mjs"; import { Utils, cleanId } from "../../utils/Utils.mjs"; import { logger } from "../../core/Logger.mjs"; -import meta from "../probe.mjs"; import { getBilibiliStreamUrl } from "../bilibili/index.mjs"; -import { isLoadstreamEnabled } from "../audio/AudioSettings.mjs"; /** * @type {object} diff --git a/src/music/player/Player.mjs b/src/music/player/Player.mjs index 319d898..e60cba1 100644 --- a/src/music/player/Player.mjs +++ b/src/music/player/Player.mjs @@ -11,8 +11,7 @@ import { getVoiceManager } from "@fluxerjs/voice"; import { EventEmitter } from "node:events"; import http from "node:http"; import https from "node:https"; -import { EmbedBuilder, PermissionFlags } from "@fluxerjs/core"; -import { getGlobalColor } from "../../ui/index.mjs"; +import { PermissionFlags } from "@fluxerjs/core"; import { Utils, cleanId } from "../../utils/Utils.mjs"; import { logger } from "../../core/Logger.mjs"; import { get247ChannelMode, detachPlayerFromManager } from "../../utils/Helpers247.mjs"; diff --git a/src/services/TrackOptionsManager.mjs b/src/services/TrackOptionsManager.mjs index ed40a2c..22086e4 100644 --- a/src/services/TrackOptionsManager.mjs +++ b/src/services/TrackOptionsManager.mjs @@ -1,7 +1,6 @@ /** @module src/services/TrackOptionsManager @description Per-user track options (start/end timestamps) stored in MySQL. Provides caching, matching, and CRUD for track segments. */ -import mysql from "mysql2"; import { logger } from "../core/Logger.mjs"; -import { MYSQL_POOL_DEFAULTS, attachMysqlPoolGuard } from "../db/MysqlGuard.mjs"; +import { attachMysqlPoolGuard } from "../db/MysqlGuard.mjs"; import { getSharedMysqlPool } from "../db/PoolManager.mjs"; const DEFAULT_ALIAS = "default"; diff --git a/src/services/lastfm/LastFmManager.mjs b/src/services/lastfm/LastFmManager.mjs index b3dfbca..93482d5 100644 --- a/src/services/lastfm/LastFmManager.mjs +++ b/src/services/lastfm/LastFmManager.mjs @@ -14,7 +14,7 @@ import { logger } from "../../core/Logger.mjs"; import { normalizeTrackText } from "./constants.mjs"; import { applyMixins } from "../../utils/mixins.mjs"; import { parseLastFmUrl, isLastFmUrl } from "./urlUtils.mjs"; -import { MYSQL_POOL_DEFAULTS, attachMysqlPoolGuard } from "../../db/MysqlGuard.mjs"; +import { attachMysqlPoolGuard } from "../../db/MysqlGuard.mjs"; import { getSharedPromisePool } from "../../db/PoolManager.mjs"; import UserStoreMixin from "./UserStoreMixin.mjs"; import ScrobblingMixin from "./ScrobblingMixin.mjs"; diff --git a/src/utils/Utils.mjs b/src/utils/Utils.mjs index 63c2190..7e1de22 100644 --- a/src/utils/Utils.mjs +++ b/src/utils/Utils.mjs @@ -1,7 +1,6 @@ /** @module src/utils/Utils @description General-purpose utility functions for formatting, validation, string manipulation, and ID cleaning. */ -import { escapeMarkdown as _escapeMarkdown, truncate as _truncate } from "@fluxerjs/util"; -import { logger } from "../core/Logger.mjs"; +import { escapeMarkdown as _escapeMarkdown } from "@fluxerjs/util"; /** * Strip all non-digit characters from a value to extract a Snowflake/numeric ID. diff --git a/src/voice/VoiceStateCache.mjs b/src/voice/VoiceStateCache.mjs index 2a35235..f268ba4 100644 --- a/src/voice/VoiceStateCache.mjs +++ b/src/voice/VoiceStateCache.mjs @@ -1,6 +1,5 @@ /** @module src/voice/VoiceStateCache */ -import { logger } from "../core/Logger.mjs"; import { cleanId } from "../utils/Utils.mjs"; /** diff --git a/src/voice/gateway/GatewayHandler.mjs b/src/voice/gateway/GatewayHandler.mjs index 7f66c77..1b312f0 100644 --- a/src/voice/gateway/GatewayHandler.mjs +++ b/src/voice/gateway/GatewayHandler.mjs @@ -10,10 +10,10 @@ import { Events, GatewayOpcodes } from "@fluxerjs/core"; import { logger, _wsErrorCooldown } from "../../core/Logger.mjs"; import { ServerSettings } from "../../db/Settings.mjs"; -import { get247ChannelMode, remove247ChannelMode } from "../../utils/Helpers247.mjs"; +import { get247ChannelMode } from "../../utils/Helpers247.mjs"; import { cleanId } from "../../utils/Utils.mjs"; import * as ShardingUtils from "../../utils/ShardingUtils.mjs"; -import { iterateVoiceStates, hasHumansInChannel, getChannelsWithHumans, resolveIsBotUser } from "../VoiceStateResolver.mjs"; +import { iterateVoiceStates, resolveIsBotUser } from "../VoiceStateResolver.mjs"; import { applyMixins } from "../../utils/mixins.mjs"; import VoiceStateRouting from "./VoiceStateRouting.mjs"; import GuildSync from "./GuildSync.mjs";