From 9233d19a49bbdc27c21c8b73b88afef5eb9c8fd6 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Tue, 7 Nov 2023 23:47:26 -0800 Subject: [PATCH 1/2] Better error handling --- discord-tts-bot/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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?; + }, + } } } } From 502517cfcbbfcb7dc9b5bf077fc4884cb081c729 Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Tue, 7 Nov 2023 23:47:50 -0800 Subject: [PATCH 2/2] Ignore .mp3 files --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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