Fix save()

This commit is contained in:
Nexus 2024-04-19 16:34:50 +01:00 committed by GitHub
parent adeb3108b1
commit a36110ed32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -754,11 +754,12 @@ class OtherCog(commands.Cog):
response = None
for url in self.urls:
try:
response = await client.get(url)
response: httpx.Response = await client.get(url)
response.raise_for_status()
except (httpx.HTTPError, ConnectionError) as e:
continue
f.write(await response.read())
async for chunk in response.aiter_bytes():
f.write(chunk)
else:
raise discord.HTTPException(response, "failed to download any of %s" % ", ".join(self.urls))