Skip to content

Commit

Permalink
move converting to discord files into try-catch
Browse files Browse the repository at this point in the history
this should result in less errors causing a infinite load error
  • Loading branch information
kytpbs committed Aug 6, 2024
1 parent 76352c0 commit c4b4909
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/download_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ async def download_video_command(interaction: discord.Interaction, url: str, is_

try:
attachments = downloader.download_video_from_link(url)
file_paths = [attachment.path for attachment in attachments]
discord_files = convert_paths_to_discord_files(file_paths)
except Exception as e:
await interaction.followup.send("Bir şey ters gitti... lütfen tekrar deneyin", ephemeral=True)
raise e # re-raise the exception so we can see what went wrong
file_paths = [attachment.path for attachment in attachments]
if len(attachments) == 0:
await interaction.followup.send("Bir şeyler ters gitti, lütfen tekrar deneyin", ephemeral=True)
return
content = " + ".join(filter(None, [attachment.caption for attachment in attachments])) or "Video Downloaded"
await interaction.followup.send(content, files=convert_paths_to_discord_files(file_paths))
await interaction.followup.send(content, files=discord_files, ephemeral=is_ephemeral)

0 comments on commit c4b4909

Please sign in to comment.