60 lines
2.0 KiB
Python
Executable File
60 lines
2.0 KiB
Python
Executable File
import requests, json, pprint, discord
|
|
|
|
|
|
def get_player(player):
|
|
player = player.lower()
|
|
url = (
|
|
"https://api.gametools.network/bf2042/stats/?raw=false&format_values=true&name="
|
|
+ player
|
|
+ "&platform=pc&skip_battlelog=false"
|
|
)
|
|
headers = {
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64)",
|
|
"accept": "application/json",
|
|
}
|
|
response = requests.get(url, headers=headers).json()
|
|
|
|
# Build the embed
|
|
embed = discord.Embed(
|
|
description="-------", color=discord.Color.teal(), type="rich"
|
|
)
|
|
embed.set_thumbnail(url=response["avatar"])
|
|
embed.set_author(name="Battlefield 2042 stats for %s" % response["userName"])
|
|
# embed.add_field(
|
|
# name="**Rank**", value="%s, %s" % (rank_number, rank_title), inline=False
|
|
# )
|
|
|
|
gameplay_stats = {
|
|
"bestClass": "Best Class",
|
|
"mvp": "Times you were an MVP",
|
|
"matchesPlayed": "Total games played",
|
|
"kills": "Total Kills",
|
|
"deaths": "Total Deaths",
|
|
"killDeath": "KDR",
|
|
"wins": "All Time Wins",
|
|
"loses": "All Time Loses",
|
|
"winPercent": "Win/loss percentage",
|
|
"accuracy": "Accuracy percentage",
|
|
"killsPerMinute": "Kills per Minute",
|
|
"damagePerMinute": "Damage per Minute",
|
|
"killsPerMatch": "Avg kills per game",
|
|
"damagePerMatch": "Avg damage per game",
|
|
"headShots": "Total Head shots",
|
|
"headshots": "Kills via Head Shot as a Percentage",
|
|
"timePlayed": "Total time played",
|
|
"revives": "Total # of revives",
|
|
"heals": "Total amount healed",
|
|
"resupplies": "Total # of ammo resupplies",
|
|
"repairs": "Total vehicle damage repaired",
|
|
"squadmateRevive": "Squad mate revives",
|
|
"vehiclesDestroyed": "Total vehicles destroyed",
|
|
}
|
|
|
|
for stat, readable in gameplay_stats.items():
|
|
embed.add_field(
|
|
name="**%s**" % readable,
|
|
value=response[stat],
|
|
inline=True,
|
|
)
|
|
return embed
|