1
0
Fork 0
mirror of synced 2024-05-20 20:42:27 +12:00

Catch an invalid response in some cases

This commit is contained in:
Phxntxm 2017-03-24 15:37:23 -05:00
parent a5d8e849aa
commit 30df3be94a

View file

@ -273,11 +273,11 @@ class Core:
result = await utils.request('http://random.dog', attr='text')
try:
soup = bs(result, 'html.parser')
except TypeError:
filename = soup.img.get('src')
except (TypeError, AttributeError):
await ctx.send("I couldn't connect! Sorry no dogs right now ;w;")
return
filename = soup.img.get('src')
image = await utils.download_image("http://random.dog/{}".format(filename))
await ctx.send(file=image, filename=filename)