mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-24 06:01:44 -05:00
refactor: centralize shared utilities, fix voice intent, and improve error visibility
- extract `cleanId()` to `Utils.mjs` and remove 97+ inline `String(x).replace(/\D/g, "")` duplicates
- add `VoiceStateResolver.mjs` with `iterateVoiceStates`, `hasHumansInChannel`, `getChannelsWithHumans` — eliminates 12+ duplicated voice-state-iteration blocks across `Player`, `PlayerManager`, `GatewayHandler`, `Dashboard`
- add `UI.mjs` for shared color, emoji, and timeout constants
- move `parseInlineProvider` to `providers.mjs`, `getMessageGuildId` to `MessageHandler.mjs`
- fix `VoiceStateCache.removeGuild` and `TrackOptionsManager` cache deletion mutating Maps during iteration
- fix `checkVoiceChannels` now async returning `{channelId, alreadyInVoice, hasHumans}` — all callers updated
- fix `FluxerRevoice` global `console.log` monkey-patch replaced with scoped `withSuppressedLiveKitLogs(fn)`
- fix `Player._get247Mode()` settings resolution chain
- fix `runnables.mjs` validators were no-ops
- promote `Player` magic numbers to named static constants
- replace all silent `catch (_) {}` with `logger.warn()` throughout
- remove unused deps: `express`, `genius-lyrics`, `ws`
- add `@file` JSDoc headers to all modules
This commit is contained in:
1 parent
0d3035b093
commit
092268281a
67 files changed
+2520
-2179
No files matched your search
+35
-5
@@ -1,14 +1,44 @@
|
||||
/**
|
||||
* @file runnables.mjs — Runnable validators — server-side validation functions for settings values (prefix, volume, 24/7 mode, etc.)
|
||||
* @module settings.runnables
|
||||
*/
|
||||
|
||||
export default {
|
||||
prefix: function(value, data) {
|
||||
/**
|
||||
* Validate a prefix setting value.
|
||||
* @param {string} value - The proposed prefix
|
||||
* @param {object} _data - Additional context (reserved for future use)
|
||||
* @returns {true|string} True if valid, error message string if invalid
|
||||
*/
|
||||
prefix(value, _data) {
|
||||
if (!value || typeof value !== "string") return "Prefix must be a non-empty string.";
|
||||
if (value.length > 10) return "Prefix must be 10 characters or fewer.";
|
||||
if (/\s/.test(value)) return "Prefix must not contain whitespace.";
|
||||
return true;
|
||||
},
|
||||
|
||||
pfp: function(value, data) {
|
||||
/**
|
||||
* Validate a profile picture setting value.
|
||||
* @param {string} value - The proposed pfp value
|
||||
* @param {object} _data - Additional context (reserved for future use)
|
||||
* @returns {true|string} True if valid, error message string if invalid
|
||||
*/
|
||||
pfp(value, _data) {
|
||||
if (value !== "default") {
|
||||
return "Profile picture customisation is not supported on Fluxer.";
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
stay_247: function(value, data) {
|
||||
return false;
|
||||
/**
|
||||
* Validate the 24/7 stay mode setting.
|
||||
* @param {string|boolean} value - The proposed stay_247 value
|
||||
* @param {object} _data - Additional context (reserved for future use)
|
||||
* @returns {true|string} True if valid, error message string if invalid
|
||||
*/
|
||||
stay_247(value, _data) {
|
||||
if (value === true || value === false || value === "true" || value === "false") return true;
|
||||
if (typeof value === "string" && value.length > 0) return true;
|
||||
return "Invalid value for 24/7 mode.";
|
||||
},
|
||||
};
|
||||
};
|
||||
Reference in new issue
Block a user