All checks were successful
Deploy Bot on NAS / deploy (push) Successful in 29s
discord.py's built-in !help command exposes cog docstrings directly to Discord members — leaving them in French made the output partially French. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
98 lines
4.3 KiB
Python
98 lines
4.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
import discord
|
|
from discord.ext import commands
|
|
from config import AUTHORIZED_CHANNEL_ID, BOSS_CONFIG
|
|
from utils.helpers import format_damage_display, format_date_only
|
|
from utils.pb_handler import db_manager # Make sure db_manager is initialized correctly
|
|
|
|
class MyStats(commands.Cog):
|
|
"""Cog for displaying all PBs for a user"""
|
|
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
|
|
@commands.command(name="mystats")
|
|
async def mystats(self, ctx, *, target_user: str = None):
|
|
"""Shows all PBs for a user across all difficulties"""
|
|
if ctx.channel.id != AUTHORIZED_CHANNEL_ID:
|
|
return
|
|
|
|
try:
|
|
if target_user:
|
|
matches = db_manager.find_user_by_name(target_user)
|
|
if not matches:
|
|
await ctx.send(f"❌ No data found for **{target_user}**.")
|
|
return
|
|
if len(matches) > 1:
|
|
await ctx.send(f"⚠️ Multiple users found for **{target_user}**. Please be more specific.")
|
|
return
|
|
user_id, display_name = matches[0]
|
|
else:
|
|
user_id = ctx.author.id
|
|
display_name = ctx.author.display_name
|
|
|
|
user_data = db_manager.get_user_all_pbs(user_id)
|
|
|
|
if not user_data:
|
|
await ctx.send(f"❌ No data found for **{display_name}**.")
|
|
return
|
|
|
|
embed = discord.Embed(
|
|
title=f"📊 {display_name}'s Complete Stats",
|
|
color=0x00bfff
|
|
)
|
|
|
|
# Hydra - all difficulties
|
|
hydra_stats = []
|
|
for difficulty in BOSS_CONFIG['hydra']['difficulties']:
|
|
pb_key = f'pb_hydra_{difficulty}'
|
|
date_key = f'pb_hydra_{difficulty}_date'
|
|
|
|
if pb_key in user_data and user_data[pb_key] > 0:
|
|
pb_value = user_data[pb_key]
|
|
pb_date = user_data.get(date_key)
|
|
date_text = f" • {format_date_only(pb_date)}" if pb_date else ""
|
|
hydra_stats.append(f"**{difficulty.title()}:** {format_damage_display(pb_value)}{date_text}")
|
|
|
|
hydra_text = "\n".join(hydra_stats) if hydra_stats else "No records"
|
|
embed.add_field(name="⚔️ Hydra PBs", value=hydra_text, inline=False)
|
|
|
|
# Chimera - all difficulties
|
|
chimera_stats = []
|
|
for difficulty in BOSS_CONFIG['chimera']['difficulties']:
|
|
pb_key = f'pb_chimera_{difficulty}'
|
|
date_key = f'pb_chimera_{difficulty}_date'
|
|
|
|
if pb_key in user_data and user_data[pb_key] > 0:
|
|
pb_value = user_data[pb_key]
|
|
pb_date = user_data.get(date_key)
|
|
date_text = f" • {format_date_only(pb_date)}" if pb_date else ""
|
|
display_name = "Ultra Nightmare" if difficulty == "ultra" else difficulty.title()
|
|
chimera_stats.append(f"**{display_name}:** {format_damage_display(pb_value)}{date_text}")
|
|
|
|
chimera_text = "\n".join(chimera_stats) if chimera_stats else "No records"
|
|
embed.add_field(name="🛡️ Chimera PBs", value=chimera_text, inline=False)
|
|
|
|
# CvC
|
|
cvc_pb = user_data.get('pb_cvc', 0)
|
|
cvc_date = user_data.get('pb_cvc_date')
|
|
cvc_text = f"**{format_damage_display(cvc_pb)} damage**" if cvc_pb > 0 else "No record"
|
|
if cvc_pb > 0 and cvc_date:
|
|
formatted_date = format_date_only(cvc_date)
|
|
if formatted_date:
|
|
cvc_text += f" • {formatted_date}"
|
|
embed.add_field(name="🗡️ CvC PB", value=cvc_text, inline=False)
|
|
|
|
# Combined total
|
|
total_damage = sum(user_data.get(f'pb_hydra_{d}', 0) for d in BOSS_CONFIG['hydra']['difficulties'])
|
|
total_damage += sum(user_data.get(f'pb_chimera_{d}', 0) for d in BOSS_CONFIG['chimera']['difficulties'])
|
|
total_damage += user_data.get('pb_cvc', 0)
|
|
embed.add_field(name="💯 Total Combined Damage", value=f"**{format_damage_display(total_damage)}**", inline=False)
|
|
|
|
await ctx.send(embed=embed)
|
|
|
|
except Exception as e:
|
|
await ctx.send(f"❌ Error: {e}")
|
|
|
|
async def setup(bot):
|
|
await bot.add_cog(MyStats(bot))
|