diff --git a/gateway/run.py b/gateway/run.py index 4ac739a7458..5ce3fd5521c 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -7254,10 +7254,13 @@ class GatewayRunner: if getattr(event, "channel_context", None): message_text = f"{event.channel_context}\n\n[New message]\n{message_text}" + # Declare at outer scope so the audio-file-paths handling block below + # remains safe when ``event.media_urls`` is empty (no inner block runs). + audio_file_paths: list[str] = [] + if event.media_urls: image_paths = [] audio_paths = [] - audio_file_paths: list[str] = [] # audio file attachments — not for STT for i, path in enumerate(event.media_urls): mtype = event.media_types[i] if i < len(event.media_types) else "" if mtype.startswith("image/") or event.message_type == MessageType.PHOTO: