add a slight error message

This commit is contained in:
Nexus 2023-03-16 23:28:24 +00:00
parent 44710e4c8c
commit 2f970d4297

View file

@ -866,7 +866,10 @@ class OtherCog(commands.Cog):
await interaction.response.defer() await interaction.response.defer()
_msg = await interaction.followup.send("Converting text to MP3...") _msg = await interaction.followup.send("Converting text to MP3...")
text_pre = self.children[0].value text_pre = self.children[0].value
_io = await _bot.loop.run_in_executor(None, _convert, text_pre) try:
_io = await _bot.loop.run_in_executor(None, _convert, text_pre)
except (Exception, IOError) as e:
return await _msg.edit(content="failed. " + str(e))
fn = "" fn = ""
_words = text_pre.split() _words = text_pre.split()
while len(fn) < 28: while len(fn) < 28:
@ -877,6 +880,8 @@ class OtherCog(commands.Cog):
if len(fn) + len(word) + 1 > 28: if len(fn) + len(word) + 1 > 28:
continue continue
fn += word + "-" fn += word + "-"
fn = fn[:-1]
fn = fn[:28]
await _msg.edit( await _msg.edit(
content="Here's your MP3!", content="Here's your MP3!",
file=discord.File(_io, filename=fn + ".mp3") file=discord.File(_io, filename=fn + ".mp3")