Country exists, no shipping

This commit is contained in:
Zeva Rose 2021-06-27 15:21:04 -06:00
parent e2c91071b2
commit 5879b5f833

View file

@ -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):