feat: added error handling for download command

This commit is contained in:
Seaswimmer 2023-08-01 17:31:21 -04:00
parent 201ec72808
commit efbc07dd17
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -114,7 +114,11 @@ class MusicDownloader(commands.Cog):
await asyncio.sleep(0.5) await asyncio.sleep(0.5)
if os.path.isfile(full_filename): if os.path.isfile(full_filename):
with open(full_filename, 'rb') as file: with open(full_filename, 'rb') as file:
try:
complete_message = await ctx.send(content="YouTube Downloader completed!\nDownloaded file:", file=discord.File(file, ytdlp_output[0])) complete_message = await ctx.send(content="YouTube Downloader completed!\nDownloaded file:", file=discord.File(file, ytdlp_output[0]))
except ValueError:
complete_message = await ctx.send(content="YouTube Downloader completed, but the audio file was too large to upload.")
return
file.close() file.close()
if delete is True or await self.bot.is_owner(ctx.author) is False: if delete is True or await self.bot.is_owner(ctx.author) is False:
if ytdlp_output[1] is False: if ytdlp_output[1] is False: