Skip to content

Commit

Permalink
Don't crash on timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
joinemm committed Nov 30, 2023
1 parent 8bd879c commit dd4c321
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions modules/media_embedders.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,11 @@ async def download_media(
"Content-Length"
) or response.headers.get("x-full-image-content-length")
if content_length and int(content_length) < max_filesize:
buffer = io.BytesIO(await response.read())
return discord.File(fp=buffer, filename=filename, spoiler=spoiler)
try:
buffer = io.BytesIO(await response.read())
return discord.File(fp=buffer, filename=filename, spoiler=spoiler)
except asyncio.TimeoutError:
pass
try:
# try to stream until we hit our limit
buffer = b""
Expand Down

0 comments on commit dd4c321

Please sign in to comment.