from discord.ext import commands from services.torn_api import fetch_enemy_members from services.ffscouter import fetch_batch_stats class HitCommands(commands.Cog): def __init__(self, bot, enrolled_attackers, enemy_queue): self.bot = bot self.enrolled_attackers = enrolled_attackers self.enemy_queue = enemy_queue @commands.command() async def enroll(self, ctx): user_id = ctx.author.id if user_id in self.enrolled_attackers: await ctx.send("You are already enrolled.") return self.enrolled_attackers.append(user_id) await ctx.send(f"{ctx.author.mention} has been enrolled in the hit rotation!") @commands.command() async def drop(self, ctx): user_id = ctx.author.id if user_id not in self.enrolled_attackers: await ctx.send("You are not enrolled.") return 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 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)