Merge missing changes, better error handling
This commit is contained in:
parent
88a2049a53
commit
c747369667
@ -36,14 +36,16 @@ class LoveCalculator(Cog):
|
|||||||
async with session.get(url) as response:
|
async with session.get(url) as response:
|
||||||
assert response.status == 200
|
assert response.status == 200
|
||||||
resp = await response.text()
|
resp = await response.text()
|
||||||
|
|
||||||
log.debug(f"{resp=}")
|
log.debug(f"{resp=}")
|
||||||
soup_object = BeautifulSoup(resp, "html.parser")
|
soup_object = BeautifulSoup(resp, "html.parser")
|
||||||
try:
|
|
||||||
description = (
|
description = soup_object.find("div", class_="result__score").get_text()
|
||||||
soup_object.find("div", class_="result__score").get_text().strip()
|
|
||||||
)
|
if description is None:
|
||||||
except:
|
|
||||||
description = "Dr. Love is busy right now"
|
description = "Dr. Love is busy right now"
|
||||||
|
else:
|
||||||
|
description = description.strip()
|
||||||
|
|
||||||
result_image = soup_object.find("img", class_="result__image").get("src")
|
result_image = soup_object.find("img", class_="result__image").get("src")
|
||||||
|
|
||||||
@ -61,6 +63,11 @@ class LoveCalculator(Cog):
|
|||||||
except:
|
except:
|
||||||
title = "Dr. Love has left a note for you."
|
title = "Dr. Love has left a note for you."
|
||||||
|
|
||||||
em = discord.Embed(title=title, description=result_text, color=discord.Color.red(), url=f"https://www.lovecalculator.com/{result_image}")
|
em = discord.Embed(
|
||||||
|
title=title,
|
||||||
|
description=result_text,
|
||||||
|
color=discord.Color.red(),
|
||||||
|
url=f"https://www.lovecalculator.com/{result_image}",
|
||||||
|
)
|
||||||
|
|
||||||
await ctx.send(embed=em)
|
await ctx.send(embed=em)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user