no comment still working on it

This commit is contained in:
NoLogicAlan committed 2026-08-28 23:51:20 +03:00
1 parent cea0014e18
commit e11fca151c
87 files changed
+5710 -10182

No files matched your search

+32 -31
View File
@@ -1,37 +1,38 @@
# WIP Web Dashboard for Remix
# Settings System
Control Remix through a web interface and set server settings and similar.
Per-guild settings for Remix, backed by MySQL.
Installation instructions will follow soon:tm:
## How it works
## Setup
- Defaults live in `storage/defaults.json`. Every guild starts from this template.
- `src/Settings.mjs` contains the implementation:
- `SettingsManager` — defines the setting keys, their defaults and descriptions.
- `ServerSettings` — per-guild view; `get`/`set`/`reset` operate in memory and persist with an 80 ms debounced write.
- `RemoteSettingsManager` — loads every guild row from the MySQL `settings` table (`id` primary key + `data` JSON column) and writes individual keys back with `JSON_SET`.
- The `settings` table is the only table you need to create manually:
1. Create a mysql server with the following table:
```MySQL
CREATE TABLE `ksiTokens` (
`user` varchar(26) NOT NULL,
`id` varchar(50) NOT NULL,
`token` varchar(70) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
`createdAt` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
CREATE TABLE `logins` (
`user` text NOT NULL,
`id` varchar(50) NOT NULL,
`token` varchar(70) NOT NULL,
`verified` tinyint(1) NOT NULL,
`createdAt` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
```sql
CREATE TABLE `settings` (
`id` varchar(70) NOT NULL,
`data` json NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
```
2. Fill out the connection details in `config.json` in the remix root directory (See `config.example.json`)
3. SSL setup:
- Create a certificate. For example [using Let's Encrypt](https://letsencrypt.org/de/getting-started/)
- Find the path to your private key and certificate pem files. Certbot uses `/etc/letsencrypt/live/remix.fairuse.org/privkey.pem` for the private key and `/etc/letsencrypt/live/remix.fairuse.org/fullchain.pem` for the certificate file. Fill in the paths in the config file
- set `useSSL` in `config.json` to `true`
- Make sure to configure the ports correctly. HTTPS connects to port `443` so make sure to set `webPort` accordingly.
Credits for Website design:
- NoLogicAlan
- ophx
- ShadowLp174
- Fantic
## Files
| File | Purpose |
| :--- | :--- |
| `Settings.mjs` | Re-export of `src/Settings.mjs` classes |
| `migrate.mjs` | One-shot tool that clones every guild row from one settings table/bot ID to another (`npm run migrate`) |
| `runnables.mjs` | Validators applied when a setting changes (e.g. `prefix` must be ≤ 5 chars with no whitespace, `pfp` only accepts `default`) |
## Managing settings in a server
Use the `%settings` command (requires Manage Server):
- `%settings get` — view all settings for this server
- `%settings set <key> <value>` — change a setting
- `%settings reset <key>` — reset a setting to its default
- `%settings help` — explain a specific key
Shortcut commands `prefix` / `pfx` and `247` map to the corresponding settings keys.
+2 -7
View File
@@ -1,10 +1,5 @@
/**
* @file Settings.mjs — Dashboard Settings — server-side settings manager for the web dashboard
* @module settings.Settings
*/
/**
* Re-exports from src/Settings.mjs for backward compatibility.
* The canonical definitions now live in src/Settings.mjs.
* @module settings/Settings
* @description Re-exports the core Settings classes from `src/Settings.mjs`.
*/
export { SettingsManager, ServerSettings, RemoteSettingsManager } from "../src/Settings.mjs";
+4 -2
View File
@@ -1,6 +1,8 @@
/**
* @file migrate.mjs — Migration script — migrates settings and 24/7 channel data between Redis and SQLite backends
* @module settings.migrate
* @module settings/migrate
* @description One-shot migration script that copies all server settings from one
* RemoteSettingsManager instance to another (e.g. between databases or bot IDs).
* Reads `config.json` for MySQL credentials and runs once on the "ready" event.
*/
import { RemoteSettingsManager } from "../src/Settings.mjs";
+28 -29
View File
@@ -1,44 +1,43 @@
/**
* @file runnables.mjs — Runnable validators — server-side validation functions for settings values (prefix, volume, 24/7 mode, etc.)
* @module settings.runnables
* @module settings/runnables
* @description Validation runnables for settings values.
* Each function is called with (value, context) and returns an error string or null.
*/
/**
* Validate a prefix setting value.
* @param {*} value - The value to validate.
* @param {object} ctx - Command context (unused but provided by the settings system).
* @returns {string|null} Error message if invalid, or null if valid.
*/
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;
prefix(value) {
if (!value || typeof value !== 'string') return 'Prefix must be a non-empty string.';
if (value.length > 5) return 'Prefix must be 5 characters or fewer.';
if (/\s/.test(value)) return 'Prefix must not contain whitespace.';
return null;
},
/**
* 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
* Validate a pfp (profile picture) setting value.
* Only 'default' is accepted on Fluxer.
* @param {*} value - The value to validate.
* @returns {string|null} Error message if invalid, or null if valid.
*/
pfp(value, _data) {
if (value !== "default") {
return "Profile picture customisation is not supported on Fluxer.";
pfp(value) {
if (value !== 'default') {
return 'Profile picture customisation is not supported on Fluxer.';
}
return true;
return null;
},
/**
* 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
* Validate stay_247 setting. Always valid — the 24/7 system manages
* this value internally via the toggle command.
* @param {*} value - The value (ignored).
* @returns {string|null} Always null (no error).
*/
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.";
stay_247(value) {
return null;
},
};