Compare commits

..

2 commits

Author SHA1 Message Date
LE BERRE Mickael
e364f354b0 fix: mystats username lookup and multi-word name support
All checks were successful
Deploy Bot on NAS / deploy (push) Successful in 25s
- 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 <noreply@anthropic.com>
2026-05-18 11:56:28 +02:00
LE BERRE Mickael
314483e4f5 fix: support multi-word usernames in pb lookup commands
Sans le *, discord.py tronquait les noms avec espaces au premier mot.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 11:52:04 +02:00
4 changed files with 20 additions and 8 deletions

View file

@ -12,21 +12,33 @@ class MyStats(commands.Cog):
self.bot = bot self.bot = bot
@commands.command(name="mystats") @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""" """Affiche tous les PB d'un utilisateur avec les nouvelles difficultés"""
if ctx.channel.id != AUTHORIZED_CHANNEL_ID: if ctx.channel.id != AUTHORIZED_CHANNEL_ID:
return return
try: try:
username = target_user if target_user else ctx.author.id if target_user:
user_data = db_manager.get_user_all_pbs(username) 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: 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 return
embed = discord.Embed( embed = discord.Embed(
title=f"📊 {ctx.author.display_name}'s Complete Stats", title=f"📊 {display_name}'s Complete Stats",
color=0x00bfff color=0x00bfff
) )

View file

@ -10,7 +10,7 @@ class Pbchimera(commands.Cog):
self.bot = bot self.bot = bot
@commands.command(name="pbchimera") @commands.command(name="pbchimera")
async def pbchimera(self, ctx, arg1: str = None, arg2: str = None): async def pbchimera(self, ctx, arg1: str = None, *, arg2: str = None):
"""Commande !pbchimera avec gestion des difficultés""" """Commande !pbchimera avec gestion des difficultés"""
await handle_pb_command(ctx, 'chimera', arg1, arg2) await handle_pb_command(ctx, 'chimera', arg1, arg2)

View file

@ -10,7 +10,7 @@ class Pbcvc(commands.Cog):
self.bot = bot self.bot = bot
@commands.command(name="pbcvc") @commands.command(name="pbcvc")
async def pbcvc(self, ctx, target_user: str = None): async def pbcvc(self, ctx, *, target_user: str = None):
"""Commande !pbcvc""" """Commande !pbcvc"""
await handle_pb_command(ctx, 'cvc', target_user) await handle_pb_command(ctx, 'cvc', target_user)

View file

@ -10,7 +10,7 @@ class Pbhydra(commands.Cog):
self.bot = bot self.bot = bot
@commands.command(name="pbhydra") @commands.command(name="pbhydra")
async def pbhydra(self, ctx, arg1: str = None, arg2: str = None): async def pbhydra(self, ctx, arg1: str = None, *, arg2: str = None):
"""Commande !pbhydra avec gestion des difficultés""" """Commande !pbhydra avec gestion des difficultés"""
await handle_pb_command(ctx, 'hydra', arg1, arg2) await handle_pb_command(ctx, 'hydra', arg1, arg2)