diff --git a/.gitignore b/.gitignore index 57868ea..196f560 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target .direnv result -.env \ No newline at end of file +.env +*.mp3 \ No newline at end of file diff --git a/discord-tts-bot/src/main.rs b/discord-tts-bot/src/main.rs index 5f9466d..7776c52 100644 --- a/discord-tts-bot/src/main.rs +++ b/discord-tts-bot/src/main.rs @@ -47,8 +47,16 @@ async fn event_handler( new_message.react(&ctx.http, '💤').await?; } else { println!("{}: {}", new_message.author.name, new_message.content); - new_message.react(&ctx.http, '✅').await?; - NARRATOR.speak(&format!("{} says {}", new_message.author.name, RE.replace_all(&new_message.content[PREFIX.len()..], "$1"))).unwrap(); + match NARRATOR.speak(&format!("{} says {}", new_message.author.name, RE.replace_all(&new_message.content[PREFIX.len()..], "$1"))) { + Ok(_) => { + new_message.react(&ctx.http, '✅').await?; + }, + Err(err) => { + println!("{err}"); + new_message.react(&ctx.http, '❌').await?; + new_message.reply(&ctx.http, "TTS failed, message might be too long").await?; + }, + } } } }