Reduce copy pasted code for getting the ship dimensions
This commit is contained in:
parent
81b71e4bce
commit
9d4e682cf9
@ -413,42 +413,19 @@ async def get_ship(ship_name):
|
|||||||
embed.add_field(name="**Expedite Fee**", value=expedite_fee, inline=True)
|
embed.add_field(name="**Expedite Fee**", value=expedite_fee, inline=True)
|
||||||
|
|
||||||
embed.add_field(name="-------", value="", inline=False)
|
embed.add_field(name="-------", value="", inline=False)
|
||||||
try:
|
dimensions = ["Length", "Width", "Height"]
|
||||||
length = (
|
for dimension in dimensions:
|
||||||
soup.find(
|
try:
|
||||||
"div", {"class": "template-dimensions-label"}, string="Length"
|
value = (
|
||||||
|
soup.find(
|
||||||
|
"div", {"class": "template-dimensions-label"}, string=dimension
|
||||||
|
)
|
||||||
|
.findNext("div", {"class": "template-dimensions-data"})
|
||||||
|
.text
|
||||||
)
|
)
|
||||||
.findNext("div", {"class": "template-dimensions-data"})
|
except Exception:
|
||||||
.text
|
value = "N/A"
|
||||||
)
|
embed.add_field(name=f"**{dimension}**", value=value, inline=True)
|
||||||
except Exception:
|
|
||||||
length = "N/A"
|
|
||||||
|
|
||||||
embed.add_field(name="**Length**", value=length, inline=True)
|
|
||||||
|
|
||||||
try:
|
|
||||||
width = (
|
|
||||||
soup.find("div", {"class": "template-dimensions-label"}, string="Width")
|
|
||||||
.findNext("div", {"class": "template-dimensions-data"})
|
|
||||||
.text
|
|
||||||
)
|
|
||||||
except Exception:
|
|
||||||
width = "N/A"
|
|
||||||
|
|
||||||
embed.add_field(name="**Width**", value=width, inline=True)
|
|
||||||
|
|
||||||
try:
|
|
||||||
height = (
|
|
||||||
soup.find(
|
|
||||||
"div", {"class": "template-dimensions-label"}, string="Height"
|
|
||||||
)
|
|
||||||
.findNext("div", {"class": "template-dimensions-data"})
|
|
||||||
.text
|
|
||||||
)
|
|
||||||
except Exception:
|
|
||||||
height = "N/A"
|
|
||||||
|
|
||||||
embed.add_field(name="**Height**", value=height, inline=True)
|
|
||||||
|
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user