Fix: mise à jour des catégories dans le panel /ticket

This commit is contained in:
Lowei 2026-05-23 10:58:21 +02:00
parent 3534363f98
commit 19fa423210
2 changed files with 33 additions and 21 deletions

View file

@ -182,7 +182,7 @@ class TicketPanelView(disnake.ui.View):
accessory=disnake.ui.Button(
label=cat.name,
style=disnake.ButtonStyle.primary,
custom_id=f"cat_{cat.id}_{int(disnake.utils.time_snowflake(disnake.utils.utcnow()) / 1000)}"
custom_id=f"cat|{cat.id}|{int(disnake.utils.time_snowflake(disnake.utils.utcnow()) / 1000)}"
)
)
)
@ -3138,17 +3138,17 @@ class TicketCommands(commands.Cog):
view = TicketPanelView(self.bot, config, self.storage)
await view._analytics_callback(inter)
# ✅ BUGFIX: Sélection de catégorie en V2 => custom_id = cat_{cat.id}_{snowflake}
elif custom_id.startswith("cat_"):
# ✅ BUGFIX: Sélection de catégorie en V2 => custom_id = cat|<catid>|<suffix>
elif str(custom_id).startswith("cat|"):
try:
# format: cat_<catid>_<suffix>
parts = custom_id.split("_")
if len(parts) >= 3:
cat_id = "_".join(parts[1:-1])
else:
cat_id = parts[1] if len(parts) > 1 else None
# format: cat|<catid>|<suffix>
parts = str(custom_id).split("|")
if len(parts) < 3:
await inter.response.send_message("Catégorie non trouvée.", ephemeral=True)
return
category = next((c for c in config.categories if c.id == cat_id), None)
cat_id = parts[1]
category = next((c for c in config.categories if str(c.id) == str(cat_id)), None)
if not category:
await inter.response.send_message("Catégorie non trouvée.", ephemeral=True)
return
@ -3158,6 +3158,29 @@ class TicketCommands(commands.Cog):
modal = RecruitmentQuestionsModal(self.bot, config, category)
else:
modal = TicketPriorityModal(self.bot, config, category)
await inter.response.send_modal(modal)
except Exception as e:
kuby_logger.error(f"[TicketSystem] cat| routing error: {e}", exc_info=True)
if not inter.response.is_done():
await inter.response.send_message(f"Erreur interne: {e}", ephemeral=True)
# backward compatibility (legacy cat_<id>_<suffix>)
elif custom_id.startswith("cat_"):
try:
parts = str(custom_id).split("_")
cat_id = "_".join(parts[1:-1]) if len(parts) >= 3 else (parts[1] if len(parts) > 1 else None)
category = next((c for c in config.categories if str(c.id) == str(cat_id)), None)
if not category:
await inter.response.send_message("Catégorie non trouvée.", ephemeral=True)
return
if category.is_recruitment and category.questions:
modal = RecruitmentQuestionsModal(self.bot, config, category)
else:
modal = TicketPriorityModal(self.bot, config, category)
await inter.response.send_modal(modal)
except Exception as e:
kuby_logger.error(f"[TicketSystem] cat_ routing error: {e}", exc_info=True)