From 292043102d7266b3a0665aed3c55c9d3b945754c Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 4 Nov 2026 01:30:44 +0100 Subject: tts: attach the generated WAV without a temp file --- src/commands/tts.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/commands/tts.rs') diff --git a/src/commands/tts.rs b/src/commands/tts.rs index f45d2e8..28e4443 100644 --- a/src/commands/tts.rs +++ b/src/commands/tts.rs @@ -30,21 +30,13 @@ pub async fn tts( match output { OutputMode::File => { let wav = crate::tts::encode_wav(&audio_data, 48000, 2); - - tokio::fs::create_dir_all(crate::config::TEMP_PATH) - .await - .ok(); - let path = format!( - "{}/tts_{}.wav", - crate::config::TEMP_PATH, - uuid::Uuid::new_v4(), - ); - tokio::fs::write(&path, &wav).await?; + // Attach the bytes directly: no temp file to leak and no panic if + // an external cleaner removes it between write and attach. if let Err(e) = ctx .send( poise::CreateReply::default() .content(lang::L_TTS_SAVED) - .attachment(serenity::CreateAttachment::path(&path).await.unwrap()), + .attachment(serenity::CreateAttachment::bytes(wav, "tts.wav")), ) .await { -- cgit v1.2.3