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()
|
data = await data.json()
|
||||||
else:
|
else:
|
||||||
data = None
|
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 = []
|
fields = []
|
||||||
if data["shipping_available"]:
|
fields.append(Field(data["short-name"], data["time-title"]))
|
||||||
fields.append(Field(data["short-name"], data["time-title"]))
|
for service in data["shipping_services_available"][1:]:
|
||||||
for service in data["shipping_services_available"][1:]:
|
service_data = await self._session.get(
|
||||||
service_data = await self._session.get(
|
self.api_url + dest + "/" + service["url"]
|
||||||
self.api_url + dest + "/" + service["url"]
|
)
|
||||||
)
|
if service_data.status > 400:
|
||||||
if service_data.status > 400:
|
continue
|
||||||
continue
|
service_data = await service_data.json()
|
||||||
service_data = await service_data.json()
|
fields.append(
|
||||||
fields.append(
|
Field(
|
||||||
Field(
|
service_data["short-name"],
|
||||||
service_data["short-name"],
|
service_data["time-title"],
|
||||||
service_data["time-title"],
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
country = "-".join(
|
country = "-".join(
|
||||||
x for x in data["country"].split(" ") if x != "the"
|
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",
|
icon_url="https://dev.zevaryx.com/db_logo.png",
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
else:
|
elif not data["is_valid"]:
|
||||||
embed = build_embed(
|
embed = build_embed(
|
||||||
title="Check Shipping Times",
|
title="Check Shipping Times",
|
||||||
description="Country not found.\nYou can [view all shipping "
|
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",
|
icon_url="https://dev.zevaryx.com/db_logo.png",
|
||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
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):
|
def setup(bot):
|
||||||
|
|
Loading…
Add table
Reference in a new issue