Handle case where no insurance info is on the wiki
This commit is contained in:
parent
f68270acb5
commit
42b9dcea5f
@ -11,6 +11,7 @@ async def get_ship(ship_name):
|
|||||||
wiki_ship_name = "_".join(elem.capitalize() for elem in ship_name.split())
|
wiki_ship_name = "_".join(elem.capitalize() for elem in ship_name.split())
|
||||||
|
|
||||||
# print(wiki_ship_name)
|
# print(wiki_ship_name)
|
||||||
|
# print("%s%s" % (wiki_url, wiki_ship_name))
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/112.0"
|
"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"})
|
.find("div", {"class": "infobox-data__value"})
|
||||||
.text
|
.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)
|
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(
|
embed.add_field(
|
||||||
name="**Expedite claim time**", value=expedited_claim_time, inline=True
|
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)
|
embed.add_field(name="**Expedite Fee**", value=expedited_fee, inline=True)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False
|
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 = discord.Embed(description="❌", color=discord.Color.red(), type="rich")
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name="**Could not find that ship**",
|
name="**Could not find that ship**",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user