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

11
TODO.md
View file

@ -1,11 +0,0 @@
# TODO - Kuby
- [x] Identifier le cog qui démarre le serveur aiohttp sur 127.0.0.1:5001 (bug_report.py)
- [x] Remplacer lasync hook `cog_load` par un démarrage différé via `__init__` + `bot.loop.create_task` (disnake 2.12.0)
- [x] Renommer la logique serveur en `_start_webhook_server`
- [x] Attendre `await bot.wait_until_ready()` avant douvrir le port
- [x] Conserver le retry bind port 5001 (OSError errno 98)
- [ ] Redémarrer le bot
- [ ] Vérifier dans les logs: "Internal Bot Webhook Server started on 127.0.0.1:5001"

View file

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