From e364f354b007a9deeefacfab8bd35c03069d9402 Mon Sep 17 00:00:00 2001 From: LE BERRE Mickael Date: Mon, 18 May 2026 11:56:28 +0200 Subject: [PATCH] fix: mystats username lookup and multi-word name support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Résolution du nom via find_user_by_name avant get_user_all_pbs (l'ancien code passait le nom en guise de discord_id → aucun résultat) - Affichage du nom de la cible dans le titre de l'embed - * pour capturer les noms avec espaces Co-Authored-By: Claude Sonnet 4.6 --- cogs/mystats.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cogs/mystats.py b/cogs/mystats.py index 86b985f..2992238 100644 --- a/cogs/mystats.py +++ b/cogs/mystats.py @@ -12,21 +12,33 @@ class MyStats(commands.Cog): self.bot = bot @commands.command(name="mystats") - async def mystats(self, ctx, target_user: str = None): + async def mystats(self, ctx, *, target_user: str = None): """Affiche tous les PB d'un utilisateur avec les nouvelles difficultés""" if ctx.channel.id != AUTHORIZED_CHANNEL_ID: return try: - username = target_user if target_user else ctx.author.id - user_data = db_manager.get_user_all_pbs(username) + 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 **{ctx.author.display_name}**.") + await ctx.send(f"❌ No data found for **{display_name}**.") return embed = discord.Embed( - title=f"📊 {ctx.author.display_name}'s Complete Stats", + title=f"📊 {display_name}'s Complete Stats", color=0x00bfff )