Adding boss spawn command as well as making a generic function to query the tarkov api
All checks were successful
Build and push / changes (push) Successful in 4s
Build and push / Lint-Python (push) Successful in 6s
Build and push / Build-and-Push-Docker (push) Successful in 1m18s
Build and push / sync-argocd-app (push) Successful in 4s

This commit is contained in:
Luke R 2024-11-02 10:24:51 -07:00
parent 4d75803e27
commit 9d97cecd75
2 changed files with 68 additions and 4 deletions

View File

@ -27,7 +27,6 @@ class Tarkov(commands.Cog):
)
async def trader_resets(self, ctx: commands.Context):
await ctx.defer()
# Define the target date and time
embed = discord.Embed(
description="-------", color=discord.Color.blue(), type="rich"
)
@ -47,9 +46,7 @@ class Tarkov(commands.Cog):
"""
headers = {"Content-Type": "application/json"}
response = requests.post(
"https://api.tarkov.dev/graphql", headers=headers, json={"query": query}
).json()["data"]["traders"]
response = tarkov.query_tarkov_api(query)["traders"]
# Loop through the dataset
for entry in response:
@ -150,6 +147,66 @@ class Tarkov(commands.Cog):
await ctx.defer()
await ctx.send_followup(embed=embed)
@tarkov.command(
guild_ids=core_utils.my_guilds,
name="bosses",
description="Boss spawn chances per map",
)
async def boss_spawns(self, ctx: commands.Context):
await ctx.defer()
embed = discord.Embed(
description="-------", color=discord.Color.blue(), type="rich"
)
embed.set_author(name="Boss Spawn chances by map")
embed.set_thumbnail(
url="https://cdna.artstation.com/p/assets/covers/images/057/149/064/smaller_square/jakub-mrowczynski-jakub-mrowczynski-tagilla-thumbnail-001.jpg?1670943952"
)
query = """
{
maps(lang: en, gameMode: pve) {
name
bosses{
spawnChance
boss{
id
}
}
}
}
"""
dont_care = [
"pmcBEAR",
"infectedCivil",
"assault",
"infectedLaborant",
"pmcUSEC",
"infectedAssault",
"infectedPmc",
"ExUsec",
]
headers = {"Content-Type": "application/json"}
response = tarkov.query_tarkov_api(query)["maps"]
# Wasteful, but make a new dict to hold the info we care about
levels = {}
for level in response:
levels[level["name"]] = {
boss["boss"]["id"]: boss["spawnChance"]
for boss in level["bosses"]
if boss["boss"]["id"] not in dont_care
}
for key, value in levels.items():
embed.add_field(
name=key,
value="\n".join(f"{k}: `{v}`" for k, v in value.items()),
inline=False,
)
await ctx.send_followup(embed=embed)
def setup(bot):
bot.add_cog(Tarkov(bot))

View File

@ -21,3 +21,10 @@ def allowed_level_roll():
[str(random.randint(1, 4)), "Any level"]
)
return message
def query_tarkov_api(query):
headers = {"Content-Type": "application/json"}
return requests.post(
"https://api.tarkov.dev/graphql", headers=headers, json={"query": query}
).json()["data"]