Adding /drugs
This commit is contained in:
parent
eed0b60346
commit
f3a3d426ee
@ -21,6 +21,47 @@ class StarCitizen(commands.Cog):
|
||||
async def post_medpen_guide(self, ctx: commands.Context):
|
||||
await ctx.respond("https://i.redd.it/lfswlf5c13t71.png")
|
||||
|
||||
@commands.slash_command(
|
||||
guild_ids=None,
|
||||
name="drugs",
|
||||
description="Returns a list of all the drugs in game sorted by their price",
|
||||
)
|
||||
async def post_drugs(self, ctx: commands.Context):
|
||||
headers = {"api_key": os.getenv("uexcorp_key")}
|
||||
|
||||
response = requests.get(
|
||||
"https://portal.uexcorp.space/api/commodities/", headers=headers
|
||||
)
|
||||
|
||||
all_commodities = [x for x in response.json()["data"]]
|
||||
all_drugs = {
|
||||
item["name"]: item["trade_price_sell"]
|
||||
for item in all_commodities
|
||||
if item["kind"] == "Drug"
|
||||
}
|
||||
sorted_dict = dict(sorted(all_drugs.items(), key=lambda item: item[1]))
|
||||
|
||||
embed = discord.Embed(
|
||||
description="-------", color=discord.Color.orange(), type="rich"
|
||||
)
|
||||
|
||||
embed.set_thumbnail(
|
||||
url="https://i.ebayimg.com/images/g/IvQAAOSwjyhaOTZN/s-l1200.webp"
|
||||
)
|
||||
embed.set_author(name="Ranking of drugs by sell price")
|
||||
|
||||
# embed.add_field(name="Details", value=details.text, inline=True)
|
||||
|
||||
for k, v in sorted_dict.items():
|
||||
embed.add_field(
|
||||
name=k,
|
||||
value="${:20,}".format(v),
|
||||
inline=False,
|
||||
)
|
||||
|
||||
await ctx.defer()
|
||||
await ctx.send_followup(embed=embed)
|
||||
|
||||
async def get_all_ships(ctx: discord.AutocompleteContext):
|
||||
"""
|
||||
returns a list of all ships in the game, which can then be passed to the /ship command for auto complete
|
||||
|
Loading…
x
Reference in New Issue
Block a user