Saving player data to json file
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from discord.ext import commands
|
||||
from services.torn_api import fetch_enemy_members
|
||||
from services.ffscouter import fetch_batch_stats
|
||||
from services.torn_api import update_enemy_faction, update_friendly_faction
|
||||
|
||||
|
||||
class HitCommands(commands.Cog):
|
||||
def __init__(self, bot, enrolled_attackers, enemy_queue):
|
||||
@@ -26,29 +26,19 @@ class HitCommands(commands.Cog):
|
||||
self.enrolled_attackers.remove(user_id)
|
||||
await ctx.send(f"{ctx.author.mention} has been removed from the rotation.")
|
||||
|
||||
|
||||
@commands.command()
|
||||
async def stats(self, ctx):
|
||||
members = await fetch_enemy_members()
|
||||
if not members:
|
||||
await ctx.send("No active members found.")
|
||||
return
|
||||
async def update_enemy(self, ctx):
|
||||
success = await update_enemy_faction()
|
||||
if success:
|
||||
await ctx.send("Enemy faction data updated with estimated stats!")
|
||||
else:
|
||||
await ctx.send("Failed to update enemy faction data.")
|
||||
|
||||
ids = [m["id"] for m in members if m.get("status", {}).get("state") in ("Okay", "Idle")]
|
||||
ff_map = await fetch_batch_stats(ids)
|
||||
|
||||
lines = []
|
||||
for m in members:
|
||||
pid = str(m["id"])
|
||||
est = ff_map.get(pid, {}).get("bs_estimate_human", "?")
|
||||
if m.get("status", {}).get("state") not in ("Okay", "Idle"):
|
||||
continue
|
||||
lines.append(f"**{m['name']}** (ID:{pid}) | Lv {m['level']} | Estimated BS: {est}")
|
||||
|
||||
chunk = ""
|
||||
for line in lines:
|
||||
if len(chunk) + len(line) > 1900:
|
||||
await ctx.send(chunk)
|
||||
chunk = ""
|
||||
chunk += line + "\n"
|
||||
if chunk:
|
||||
await ctx.send(chunk)
|
||||
@commands.command()
|
||||
async def update_friendly(self, ctx):
|
||||
success = await update_friendly_faction()
|
||||
if success:
|
||||
await ctx.send("Friendly faction data updated with estimated stats!")
|
||||
else:
|
||||
await ctx.send("Failed to update friendly faction data.")
|
||||
Reference in New Issue
Block a user