Handle case where no insurance info is on the wiki

This commit is contained in:
Luke Robles 2023-04-28 14:40:23 -07:00
parent f68270acb5
commit 42b9dcea5f

View File

@ -11,6 +11,7 @@ async def get_ship(ship_name):
wiki_ship_name = "_".join(elem.capitalize() for elem in ship_name.split())
# print(wiki_ship_name)
# print("%s%s" % (wiki_url, wiki_ship_name))
headers = {
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0"
@ -80,30 +81,39 @@ async def get_ship(ship_name):
.find("div", {"class": "infobox-data__value"})
.text
)
expedited_claim_time = (
soup.find("div", {"class": "data-expeditetime infobox-data infobox-col4"})
.find("div", {"class": "infobox-data__value"})
.text
)
expedited_fee = (
soup.find("div", {"class": "data-expeditecost infobox-data infobox-col2"})
.find("div", {"class": "infobox-data__value"})
.text
)
embed.add_field(name="**Insurance claim time**", value=claim_time, inline=True)
try:
expedited_claim_time = (
soup.find(
"div", {"class": "data-expeditetime infobox-data infobox-col4"}
)
.find("div", {"class": "infobox-data__value"})
.text
)
embed.add_field(
name="**Expedite claim time**", value=expedited_claim_time, inline=True
)
except Exception:
pass
try:
expedited_fee = (
soup.find(
"div", {"class": "data-expeditecost infobox-data infobox-col2"}
)
.find("div", {"class": "infobox-data__value"})
.text
)
embed.add_field(name="**Expedite Fee**", value=expedited_fee, inline=True)
except Exception:
pass
embed.add_field(
name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False
)
except Exception:
except Exception as e:
embed = discord.Embed(description="", color=discord.Color.red(), type="rich")
embed.add_field(
name="**Could not find that ship**",