removing apex
All checks were successful
Build and push / changes (push) Successful in 4s
Build and push / Lint-Python (push) Successful in 3s
Build and push / Build-and-Push-Docker (push) Successful in 3m0s
Build and push / sync-argocd-app (push) Successful in 2s
Build and push / post-status-to-discord (push) Successful in 2s

This commit is contained in:
Luke R 2025-02-26 15:32:50 -08:00
parent 928b1cad07
commit a0c4ba4b0a
4 changed files with 1 additions and 105 deletions

View File

@ -1,89 +0,0 @@
import discord
import os
import requests
def get_player(player):
url = "https://public-api.tracker.gg/v2/apex/standard/profile/origin/" + player
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)",
"accept": "application/json",
"TRN-Api-Key": os.getenv("tracker_network_token"),
}
response = requests.get(url, headers=headers).json()["data"]
# Build the embed
embed = discord.Embed(description="-------", color=discord.Color.red(), type="rich")
embed.set_thumbnail(url=response["platformInfo"]["avatarUrl"])
embed.set_author(
name="Apex stats for %s" % response["platformInfo"]["platformUserId"],
icon_url=response["segments"][0]["stats"]["peakRankScore"]["metadata"][
"iconUrl"
],
)
embed.add_field(
name="**Current Rank**",
value=response["segments"][0]["stats"]["peakRankScore"]["displayName"],
inline=True,
)
embed.add_field(name="Account Wide stats", value="-----", inline=False)
stats_we_care_about = ["wins", "level", "kills", "damage", "headshots", "revives"]
for stat in stats_we_care_about:
embed.add_field(
name="**%s**" % response["segments"][0]["stats"][stat]["displayName"],
value=response["segments"][0]["stats"][stat]["displayValue"],
inline=True,
)
all_legends = response["segments"][1:]
# Calculate their most effective legends
embed.add_field(name="Bests", value="-----", inline=False)
embed.add_field(
name="**Legend with most kills**",
value="%s: %s"
% (
find_best(all_legends, key="kills")["metadata"]["name"],
find_best(all_legends, key="kills")["stats"]["kills"]["displayValue"],
),
)
embed.add_field(
name="**Legend with most wins**",
value="%s: %s"
% (
find_best(all_legends, key="wins")["metadata"]["name"],
find_best(all_legends, key="wins")["stats"]["wins"]["displayValue"],
),
)
embed.add_field(
name="**Legend with most damage**",
value="%s: %s"
% (
find_best(all_legends, key="damage")["metadata"]["name"],
find_best(all_legends, key="damage")["stats"]["damage"]["displayValue"],
),
)
embed.add_field(
name="**Legend with most revives**",
value="%s: %s"
% (
find_best(all_legends, key="revives")["metadata"]["name"],
find_best(all_legends, key="revives")["stats"]["revives"]["displayValue"],
),
)
return embed
def find_best(blob, key):
"""
find_best(blob, key)
blob should be the list within the request you want to find the best of,
must be one of [weapopns, vehicles, classes, gamemodes, maps, gadgets], eg. response["weapons"],
and the key to use to make that distinction, for example, for weapons, you could use kills
"""
return max(blob, key=lambda x: x["stats"][key]["value"] if key in x else 0)

View File

@ -3,6 +3,7 @@ from discord.ext import commands
import core_utils import core_utils
import discord import discord
import os import os
import random
import requests import requests
import requests_cache import requests_cache

View File

@ -203,7 +203,6 @@ class Cheeky(commands.Cog):
required=True, required=True,
), ),
): ):
if template not in sorted( if template not in sorted(
list( list(
map( map(

View File

@ -9,21 +9,6 @@ class Games(commands.Cog):
def __init__(self, bot): def __init__(self, bot):
self.bot: commands.Bot = bot self.bot: commands.Bot = bot
@commands.slash_command(
guild_ids=None,
name="apex",
description="Query the game's API for data about a player",
)
async def apex(self, ctx: commands.Context, player):
import apex_legends
try:
await ctx.defer()
embed = apex_legends.get_player(player)
await ctx.send_followup(embed=embed)
except Exception as e:
await ctx.send(e)
async def get_ffxiv_worlds(ctx: discord.AutocompleteContext): async def get_ffxiv_worlds(ctx: discord.AutocompleteContext):
url = "https://na.finalfantasyxiv.com/lodestone/worldstatus/" url = "https://na.finalfantasyxiv.com/lodestone/worldstatus/"