mirror of
https://github.com/remix-bot/fluxer.git
synced 2026-11-23 21:52:45 -05:00
- 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
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
/**
|
|
* @file runnables.mjs — Runnable validators — server-side validation functions for settings values (prefix, volume, 24/7 mode, etc.)
|
|
* @module settings.runnables
|
|
*/
|
|
|
|
export default {
|
|
/**
|
|
* 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;
|
|
},
|
|
|
|
/**
|
|
* 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;
|
|
},
|
|
|
|
/**
|
|
* 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.";
|
|
},
|
|
};
|