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="-------", value="", inline=False)
|
||||
dimensions = ["Length", "Width", "Height"]
|
||||
for dimension in dimensions:
|
||||
try:
|
||||
length = (
|
||||
value = (
|
||||
soup.find(
|
||||
"div", {"class": "template-dimensions-label"}, string="Length"
|
||||
"div", {"class": "template-dimensions-label"}, string=dimension
|
||||
)
|
||||
.findNext("div", {"class": "template-dimensions-data"})
|
||||
.text
|
||||
)
|
||||
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)
|
||||
value = "N/A"
|
||||
embed.add_field(name=f"**{dimension}**", value=value, inline=True)
|
||||
|
||||
embed.add_field(
|
||||
name="**Link**", value="%s%s" % (wiki_url, wiki_ship_name), inline=False
|
||||
|
Loading…
x
Reference in New Issue
Block a user