Adding boss spawn command as well as making a generic function to query the tarkov api
This commit is contained in:
parent
4d75803e27
commit
9d97cecd75
@ -27,7 +27,6 @@ class Tarkov(commands.Cog):
|
|||||||
)
|
)
|
||||||
async def trader_resets(self, ctx: commands.Context):
|
async def trader_resets(self, ctx: commands.Context):
|
||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
# Define the target date and time
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
description="-------", color=discord.Color.blue(), type="rich"
|
description="-------", color=discord.Color.blue(), type="rich"
|
||||||
)
|
)
|
||||||
@ -47,9 +46,7 @@ class Tarkov(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
headers = {"Content-Type": "application/json"}
|
headers = {"Content-Type": "application/json"}
|
||||||
response = requests.post(
|
response = tarkov.query_tarkov_api(query)["traders"]
|
||||||
"https://api.tarkov.dev/graphql", headers=headers, json={"query": query}
|
|
||||||
).json()["data"]["traders"]
|
|
||||||
|
|
||||||
# Loop through the dataset
|
# Loop through the dataset
|
||||||
for entry in response:
|
for entry in response:
|
||||||
@ -150,6 +147,66 @@ class Tarkov(commands.Cog):
|
|||||||
await ctx.defer()
|
await ctx.defer()
|
||||||
await ctx.send_followup(embed=embed)
|
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):
|
def setup(bot):
|
||||||
bot.add_cog(Tarkov(bot))
|
bot.add_cog(Tarkov(bot))
|
||||||
|
@ -21,3 +21,10 @@ def allowed_level_roll():
|
|||||||
[str(random.randint(1, 4)), "Any level"]
|
[str(random.randint(1, 4)), "Any level"]
|
||||||
)
|
)
|
||||||
return message
|
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"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user