fix: /config/set now syncs all runtime-relevant globals
Previously only 4 of 5+ settings were synced to globals when set via the generic /config/set endpoint. Added: - memory.use_cheshire_cat -> globals.USE_CHESHIRE_CAT - runtime.mood.dm_mood -> globals.DM_MOOD + DM_MOOD_DESCRIPTION - Uses same _GLOBALS_SYNC mapping pattern as restore_runtime_settings
This commit is contained in:
30
bot/api.py
30
bot/api.py
@@ -2978,15 +2978,27 @@ async def set_config_value(request: Request):
|
||||
from config_manager import config_manager
|
||||
config_manager.set(key_path, value, persist=persist)
|
||||
|
||||
# Update globals if needed
|
||||
if key_path == "discord.language_mode":
|
||||
globals.LANGUAGE_MODE = value
|
||||
elif key_path == "autonomous.debug_mode":
|
||||
globals.AUTONOMOUS_DEBUG = value
|
||||
elif key_path == "voice.debug_mode":
|
||||
globals.VOICE_DEBUG_MODE = value
|
||||
elif key_path == "gpu.prefer_amd":
|
||||
globals.PREFER_AMD_GPU = value
|
||||
# ── Sync globals for every runtime-relevant key path ──
|
||||
_GLOBALS_SYNC = {
|
||||
"discord.language_mode": ("LANGUAGE_MODE", str),
|
||||
"autonomous.debug_mode": ("AUTONOMOUS_DEBUG", bool),
|
||||
"voice.debug_mode": ("VOICE_DEBUG_MODE", bool),
|
||||
"memory.use_cheshire_cat": ("USE_CHESHIRE_CAT", bool),
|
||||
"gpu.prefer_amd": ("PREFER_AMD_GPU", bool),
|
||||
}
|
||||
|
||||
if key_path in _GLOBALS_SYNC:
|
||||
attr, converter = _GLOBALS_SYNC[key_path]
|
||||
setattr(globals, attr, converter(value))
|
||||
elif key_path == "runtime.mood.dm_mood":
|
||||
# DM mood needs description loaded alongside
|
||||
if isinstance(value, str) and value in getattr(globals, "AVAILABLE_MOODS", []):
|
||||
globals.DM_MOOD = value
|
||||
try:
|
||||
from utils.moods import load_mood_description
|
||||
globals.DM_MOOD_DESCRIPTION = load_mood_description(value)
|
||||
except Exception:
|
||||
globals.DM_MOOD_DESCRIPTION = f"I'm feeling {value} today."
|
||||
|
||||
return {
|
||||
"success": True,
|
||||
|
||||
Reference in New Issue
Block a user