Country exists, no shipping
This commit is contained in:
parent
e2c91071b2
commit
5879b5f833
1 changed files with 35 additions and 16 deletions
|
@ -66,23 +66,26 @@ class DbrandCog(commands.Cog):
|
|||
data = await data.json()
|
||||
else:
|
||||
data = None
|
||||
if data is not None and data["is_valid"]:
|
||||
if (
|
||||
data is not None
|
||||
and data["is_valid"]
|
||||
and data["shipping_available"]
|
||||
):
|
||||
fields = []
|
||||
if data["shipping_available"]:
|
||||
fields.append(Field(data["short-name"], data["time-title"]))
|
||||
for service in data["shipping_services_available"][1:]:
|
||||
service_data = await self._session.get(
|
||||
self.api_url + dest + "/" + service["url"]
|
||||
)
|
||||
if service_data.status > 400:
|
||||
continue
|
||||
service_data = await service_data.json()
|
||||
fields.append(
|
||||
Field(
|
||||
service_data["short-name"],
|
||||
service_data["time-title"],
|
||||
)
|
||||
fields.append(Field(data["short-name"], data["time-title"]))
|
||||
for service in data["shipping_services_available"][1:]:
|
||||
service_data = await self._session.get(
|
||||
self.api_url + dest + "/" + service["url"]
|
||||
)
|
||||
if service_data.status > 400:
|
||||
continue
|
||||
service_data = await service_data.json()
|
||||
fields.append(
|
||||
Field(
|
||||
service_data["short-name"],
|
||||
service_data["time-title"],
|
||||
)
|
||||
)
|
||||
country = "-".join(
|
||||
x for x in data["country"].split(" ") if x != "the"
|
||||
)
|
||||
|
@ -104,7 +107,7 @@ class DbrandCog(commands.Cog):
|
|||
icon_url="https://dev.zevaryx.com/db_logo.png",
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
else:
|
||||
elif not data["is_valid"]:
|
||||
embed = build_embed(
|
||||
title="Check Shipping Times",
|
||||
description="Country not found.\nYou can [view all shipping "
|
||||
|
@ -119,6 +122,22 @@ class DbrandCog(commands.Cog):
|
|||
icon_url="https://dev.zevaryx.com/db_logo.png",
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
elif not data["shipping_available"]:
|
||||
embed = build_embed(
|
||||
title="Shipping to {}".format(data["country"]),
|
||||
description="No shipping available.\nTime to move to a country"
|
||||
+ "that has shipping available.\nYou can [find a new country "
|
||||
+ "to live in here](https://dbrand.com/shipping)",
|
||||
fields=[],
|
||||
url="https://dbrand.com/shipping",
|
||||
color="#FFBB00",
|
||||
)
|
||||
embed.set_thumbnail(url="https://dev.zevaryx.com/db_logo.png")
|
||||
embed.set_footer(
|
||||
text="dbrand.com",
|
||||
icon_url="https://dev.zevaryx.com/db_logo.png",
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
Loading…
Add table
Reference in a new issue