diff --git a/commandes/bug_report.py b/commandes/bug_report.py index 05e1fcb..13292a8 100644 --- a/commandes/bug_report.py +++ b/commandes/bug_report.py @@ -35,16 +35,7 @@ def save_report(issue_iid, user_id): class BugReportModal(disnake.ui.Modal): - def __init__(self, priority_choice): - if priority_choice is None: - self.priority_choice = type( - "PriorityChoice", - (), - {"name": "Normal", "value": "Normal"}, - )() - else: - self.priority_choice = priority_choice - + def __init__(self): super().__init__( title="Signaler un Bug", components=[ @@ -62,7 +53,7 @@ class BugReportModal(disnake.ui.Modal): custom_id="bug_description", required=True, max_length=1000, - ) + ), ] ) @@ -73,8 +64,8 @@ class BugReportModal(disnake.ui.Modal): if not bug_title: bug_title = "Sans titre" - priority_name = getattr(self.priority_choice, "name", None) or "Normal" - priority_value = getattr(self.priority_choice, "value", None) or "Normal" + priority_name = "Normale" + priority_value = "Normal" description_value = interaction.text_values.get("bug_description") or "" @@ -444,100 +435,19 @@ class BugReport(commands.Cog): name="signaler_bug", description="Signaler un bug aux développeurs", ) - async def signaler_bug( - self, - interaction: disnake.ApplicationCommandInteraction, - titre: str = commands.Param(description="Titre/Courte description du bug"), - description: str = commands.Param(description="Description détaillée (copy-paste accepté !)"), - priority: str = commands.Param( - description="Priorité du bug", - choices={"Basse": "Low", "Normale": "Normal", "Haute": "High", "Urgente": "Urgent"}, - ), - ): - """Signale un bug directement avec arguments - copy-paste supporté.""" - from collections import namedtuple - - Choice = namedtuple('Choice', ['name', 'value']) - mapping = {"Basse": "Low", "Normale": "Normal", "Haute": "High", "Urgente": "Urgent"} - reverse = {v: k for k, v in mapping.items()} - - p_name = reverse.get(priority, "Normal") - choice = Choice(name=p_name, value=priority) - - await interaction.response.send_message("Envoi de votre rapport de bug à GitLab...", ephemeral=True) - - bug_title = titre.strip() if titre else "Sans titre" - priority_name = choice.name - description_value = description - - description_text = f"**Rapporté par:** {interaction.user} ({interaction.user.id})\n" - description_text += f"**Priorité:** {priority_name}\n\n" - description_text += f"**Description:**\n{description_value}" - - labels = ["bug", "manual-report", f"Priority::{choice.value}"] - - result = await gitlab_client.create_issue( - title=f"[MANUAL] {bug_title}", - description=description_text, - labels=labels, - ) - - if result: - issue_iid = result.get("iid") - save_report(issue_iid, interaction.user.id) - await interaction.edit_original_response( - content=( - "✅ Votre bug a été signalé avec succès ! " - "Nous avons bien été averti et le bug sera réglé dans la prochaine mise à jour. " - f"[Voir l'issue]({result.get('web_url')})" - ) - ) - else: - await interaction.edit_original_response( - content="❌ Une erreur est survenue lors de l'envoi du rapport à GitLab. Veuillez contacter un administrateur." - ) + async def signifier_bug(self, interaction: disnake.ApplicationCommandInteraction): + """Ouvre un formulaire pour signaler un bug.""" + modal = BugReportModal(None) + await interaction.response.send_modal(modal) @commands.slash_command( name="suggerer_fonctionnalite", description="Proposer une nouvelle fonctionnalité pour le bot", ) - async def suggerer_fonctionnalite( - self, - interaction: disnake.ApplicationCommandInteraction, - titre: str = commands.Param(description="Titre de la suggestion"), - description: str = commands.Param(description="Détails de la fonctionnalité (copy-paste accepté !)"), - ): - """Suggère une fonctionnalité directement avec arguments - copy-paste supporté.""" - await interaction.response.send_message("Envoi de votre suggestion à GitLab...", ephemeral=True) - - suggestion_title = titre.strip() if titre else "Sans titre" - description_value = description - - description_text = f"**Sugéré par:** {interaction.user} ({interaction.user.id})\n\n" - description_text += f"**Description:**\n{description_value}" - - labels = ["enhancement", "manual-suggestion"] - - result = await gitlab_client.create_issue( - title=f"[SUGGESTION] {suggestion_title}", - description=description_text, - labels=labels, - ) - - if result: - issue_iid = result.get("iid") - save_report(issue_iid, interaction.user.id) - await interaction.edit_original_response( - content=( - "✅ Votre suggestion a été envoyée avec succès ! " - "Merci de contribuer à l'amélioration du bot. " - f"[Voir l'issue]({result.get('web_url')})" - ) - ) - else: - await interaction.edit_original_response( - content="❌ Une erreur est survenue lors de l'envoi de la suggestion à GitLab." - ) + async def suggerer_fonctionnalite(self, interaction: disnake.ApplicationCommandInteraction): + """Ouvre un formulaire pour suggérer une fonctionnalité.""" + modal = FeatureSuggestionModal() + await interaction.response.send_modal(modal) def setup(bot):