From 7b740803620f4b7375644c8f37fb624f3028ef04 Mon Sep 17 00:00:00 2001 From: churl Date: Thu, 20 Jan 2022 23:12:31 +0100 Subject: [PATCH] stop connecting on invalid file --- bot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bot.py b/bot.py index b94b78e..f3da9c4 100644 --- a/bot.py +++ b/bot.py @@ -223,8 +223,13 @@ class HeidiClient(discord.Client): soundfile = message.content.split(" ")[-1] + try: + audio_source = discord.FFmpegPCMAudio("/sounds/" + soundfile + ".mp3") # only works from docker + except AttributeError: + print("Error: Invalid soundfile!") + return + voice_client = await voice_channel.connect() - audio_source = discord.FFmpegPCMAudio("/sounds/" + soundfile + ".mp3") # only works from docker voice_client.play(audio_source) while voice_client.is_playing():