Fix: système de ticket & arriver-départ

This commit is contained in:
Mathis 2026-05-31 12:07:24 +02:00
parent d9afa32828
commit a169449390
9 changed files with 61 additions and 69 deletions

View file

@ -185,7 +185,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"catv2_{cat.id}_{int(disnake.utils.time_snowflake(disnake.utils.utcnow()) / 1000)}"
)
)
)
@ -200,8 +200,13 @@ class TicketPanelView(disnake.ui.View):
import traceback
traceback.print_exc()
# Fallback: texte simple avec view legacy
cat_list = "\n".join(f"{cat.emoji} **{cat.name}** — {cat.description or 'Aucune description'}" for cat in self.config.categories[:5])
if not interaction.response.is_done():
if interaction.response.is_done():
await interaction.followup.send(
f"**🎫 Créer un Ticket**\n\nSélectionnez une catégorie ci-dessous:",
view=CategorySelectionView(self.bot, self.config),
ephemeral=True
)
else:
await interaction.response.send_message(
f"**🎫 Créer un Ticket**\n\nSélectionnez une catégorie ci-dessous:",
view=CategorySelectionView(self.bot, self.config),
@ -2239,11 +2244,15 @@ class CategoryManagerView(disnake.ui.View):
async def callback(self, interaction: disnake.ModalInteraction):
import uuid
cat_id = str(uuid.uuid4())[:8]
name_val = interaction.text_values.get("add_cat_name", "Nouvelle Catégorie")
desc_val = interaction.text_values.get("add_cat_desc", "")
emoji_val = interaction.text_values.get("add_cat_emoji", "🎫")
category = TicketCategory(
id=cat_id,
name=self.name.value,
description=self.description.value or "",
emoji=self.emoji.value or "🎫"
name=name_val,
description=desc_val,
emoji=emoji_val
)
self.config.categories.append(category)
self.storage.save_config(interaction.guild_id, self.config)
@ -2847,10 +2856,10 @@ class TicketCommands(commands.Cog):
if not custom_id:
return
# Accept both ticket_* / cat_* / close_* custom_ids
# Accept both ticket_* / catv2_* / close_* custom_ids
if not (
str(custom_id).startswith("ticket_")
or str(custom_id).startswith("cat_")
or str(custom_id).startswith("catv2_")
or str(custom_id) in {"close_confirm", "close_cancel", "delay_cancel"}
):
return
@ -2875,20 +2884,10 @@ class TicketCommands(commands.Cog):
try:
# Routage manuel
if custom_id == "ticket_create":
view = TicketPanelView(self.bot, config, self.storage)
await view._create_callback(inter)
elif custom_id == "ticket_my_tickets":
view = TicketPanelView(self.bot, config, self.storage)
await view._my_tickets_callback(inter)
elif custom_id == "ticket_analytics":
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 = catv2_{cat.id}_{snowflake}
if custom_id.startswith("catv2_"):
try:
# format: cat_<catid>_<suffix>
# format: catv2_<catid>_<suffix>
parts = custom_id.split("_")
if len(parts) >= 3:
cat_id = "_".join(parts[1:-1])
@ -2904,7 +2903,7 @@ class TicketCommands(commands.Cog):
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)
kuby_logger.error(f"[TicketSystem] catv2_ routing error: {e}", exc_info=True)
if not inter.response.is_done():
await inter.response.send_message(f"Erreur interne: {e}", ephemeral=True)