From 0749706e8809d1f3d26f7c69e0baeb2b5a2d3f23 Mon Sep 17 00:00:00 2001 From: imnotverygood <68748172+imnotverygood@users.noreply.github.com> Date: Fri, 24 Jul 2020 18:30:52 +0100 Subject: [PATCH] Add BytesIO seek to fix empty file error (#104) * Add BytesIO seek to fix empty file error "ValueError: embedded null byte" error on the discord attachment due to the data being read from the end. * Fix incorrect indent * Add discord back to File call --- tts/tts.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tts/tts.py b/tts/tts.py index 02f8b8e..ef2a223 100644 --- a/tts/tts.py +++ b/tts/tts.py @@ -30,4 +30,5 @@ class TTS(Cog): mp3_fp = io.BytesIO() tts = gTTS(text, "en") tts.write_to_fp(mp3_fp) - await ctx.send(file=discord.File(mp3_fp.getvalue(), "text.mp3")) + mp3_fp.seek(0) + await ctx.send(file=discord.File(mp3_fp, "text.mp3"))