Fix errors by just returning N/A

This commit is contained in:
Luke Robles 2023-05-07 13:09:35 -07:00
parent e4faa7ca14
commit af12a21687

View File

@ -90,37 +90,55 @@ async def get_ship(ship_name):
# embed.add_field(name="**Description**", value=ship["description"], inline=False)
embed.add_field(name="-------", value="", inline=False)
stowage_capacity = (
soup.find("tr", {"class": "data-stowagespace infobox-data infobox-col2"})
.findChildren("td")[0]
.text
)
try:
stowage_capacity = (
soup.find(
"tr", {"class": "data-stowagespace infobox-data infobox-col2"}
)
.findChildren("td")[0]
.text
)
except Exception:
stowage_capacity = "N/A"
embed.add_field(
name="**Stowage Capacity**", value=stowage_capacity, inline=True
)
cargo_capacity = (
soup.find("tr", {"class": "data-cargocapacity infobox-data infobox-col4"})
.findChildren("td")[0]
.text
)
try:
cargo_capacity = (
soup.find(
"tr", {"class": "data-cargocapacity infobox-data infobox-col4"}
)
.findChildren("td")[0]
.text
)
except Exception:
cargo_capacity = "N/A"
embed.add_field(name="**Cargo Capacity**", value=cargo_capacity, inline=True)
crew_size = (
soup.find("tr", {"class": "data-crew infobox-data infobox-col4"})
.findChildren("td")[0]
.text
)
try:
crew_size = (
soup.find("tr", {"class": "data-crew infobox-data infobox-col4"})
.findChildren("td")[0]
.text
)
except Exception:
crew_size = "N/A"
embed.add_field(name="**Crew Size**", value=crew_size, inline=True)
embed.add_field(name="-------", value="", inline=False)
claim_time = (
soup.find("div", {"class": "data-claimtime infobox-data infobox-col4"})
.find("div", {"class": "infobox-data__value"})
.text
)
try:
claim_time = (
soup.find("div", {"class": "data-claimtime infobox-data infobox-col4"})
.find("div", {"class": "infobox-data__value"})
.text
)
except Exception:
claim_time = "N/A"
embed.add_field(name="**Insurance claim time**", value=claim_time, inline=True)
try:
@ -131,24 +149,24 @@ async def get_ship(ship_name):
.find("div", {"class": "infobox-data__value"})
.text
)
embed.add_field(
name="**Expedite claim time**", value=expedited_claim_time, inline=True
)
except Exception as e:
print(e)
except Exception:
expedited_claim_time = "N/A"
embed.add_field(
name="**Expedite claim time**", value=expedited_claim_time, inline=True
)
try:
expedited_fee = (
expedite_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 as e:
print(e)
pass
except Exception:
expedite_fee = "N/A"
embed.add_field(name="**Expedite Fee**", value=expedite_fee, inline=True)
embed.add_field(
name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False
@ -164,7 +182,6 @@ async def get_ship(ship_name):
% ship_name,
inline=True,
)
print(e)
return embed
return embed