fix: convert effect values to proper types when loading from preferences
JSON stores numbers as strings, so pitch and speed were being returned as strings from get_user_effects(), causing format string errors like: 'Unknown format code d for object of type str' Now get_user_effects() explicitly converts: - pitch to int - speed to float This fixes the format string errors when logging or displaying effects.
This commit is contained in:
@@ -195,12 +195,15 @@ class VoiceManager:
|
||||
|
||||
# Effects management methods
|
||||
|
||||
def get_user_effects(self, user_id: int) -> dict[str, Any]:
|
||||
def get_user_effects(self, user_id: int) -> dict[str, int | float]:
|
||||
"""Get the audio effects for a user. Returns defaults if not set."""
|
||||
effects = self._user_effects.get(user_id, {})
|
||||
# Convert to proper types (JSON stores them as strings)
|
||||
pitch = effects.get("pitch", AudioEffects.PITCH_DEFAULT)
|
||||
speed = effects.get("speed", AudioEffects.SPEED_DEFAULT)
|
||||
return {
|
||||
"pitch": effects.get("pitch", AudioEffects.PITCH_DEFAULT),
|
||||
"speed": effects.get("speed", AudioEffects.SPEED_DEFAULT),
|
||||
"pitch": int(pitch) if pitch is not None else AudioEffects.PITCH_DEFAULT,
|
||||
"speed": float(speed) if speed is not None else AudioEffects.SPEED_DEFAULT,
|
||||
}
|
||||
|
||||
def set_user_effect(self, user_id: int, effect_name: str, value: Any) -> tuple[bool, str]:
|
||||
|
||||
Reference in New Issue
Block a user