feat(bug_report): convertir les commandes en formulaires modaux
Les commandes /signaler_bug et /suggerer_fonctionnalite ouvrent maintenant un formulaire modal au lieu d'afficher des options slash. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
fac7ed1e6b
commit
8da858d1d8
1 changed files with 12 additions and 102 deletions
|
|
@ -35,16 +35,7 @@ def save_report(issue_iid, user_id):
|
||||||
|
|
||||||
|
|
||||||
class BugReportModal(disnake.ui.Modal):
|
class BugReportModal(disnake.ui.Modal):
|
||||||
def __init__(self, priority_choice):
|
def __init__(self):
|
||||||
if priority_choice is None:
|
|
||||||
self.priority_choice = type(
|
|
||||||
"PriorityChoice",
|
|
||||||
(),
|
|
||||||
{"name": "Normal", "value": "Normal"},
|
|
||||||
)()
|
|
||||||
else:
|
|
||||||
self.priority_choice = priority_choice
|
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
title="Signaler un Bug",
|
title="Signaler un Bug",
|
||||||
components=[
|
components=[
|
||||||
|
|
@ -62,7 +53,7 @@ class BugReportModal(disnake.ui.Modal):
|
||||||
custom_id="bug_description",
|
custom_id="bug_description",
|
||||||
required=True,
|
required=True,
|
||||||
max_length=1000,
|
max_length=1000,
|
||||||
)
|
),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -73,8 +64,8 @@ class BugReportModal(disnake.ui.Modal):
|
||||||
if not bug_title:
|
if not bug_title:
|
||||||
bug_title = "Sans titre"
|
bug_title = "Sans titre"
|
||||||
|
|
||||||
priority_name = getattr(self.priority_choice, "name", None) or "Normal"
|
priority_name = "Normale"
|
||||||
priority_value = getattr(self.priority_choice, "value", None) or "Normal"
|
priority_value = "Normal"
|
||||||
|
|
||||||
description_value = interaction.text_values.get("bug_description") or ""
|
description_value = interaction.text_values.get("bug_description") or ""
|
||||||
|
|
||||||
|
|
@ -444,100 +435,19 @@ class BugReport(commands.Cog):
|
||||||
name="signaler_bug",
|
name="signaler_bug",
|
||||||
description="Signaler un bug aux développeurs",
|
description="Signaler un bug aux développeurs",
|
||||||
)
|
)
|
||||||
async def signaler_bug(
|
async def signifier_bug(self, interaction: disnake.ApplicationCommandInteraction):
|
||||||
self,
|
"""Ouvre un formulaire pour signaler un bug."""
|
||||||
interaction: disnake.ApplicationCommandInteraction,
|
modal = BugReportModal(None)
|
||||||
titre: str = commands.Param(description="Titre/Courte description du bug"),
|
await interaction.response.send_modal(modal)
|
||||||
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."
|
|
||||||
)
|
|
||||||
|
|
||||||
@commands.slash_command(
|
@commands.slash_command(
|
||||||
name="suggerer_fonctionnalite",
|
name="suggerer_fonctionnalite",
|
||||||
description="Proposer une nouvelle fonctionnalité pour le bot",
|
description="Proposer une nouvelle fonctionnalité pour le bot",
|
||||||
)
|
)
|
||||||
async def suggerer_fonctionnalite(
|
async def suggerer_fonctionnalite(self, interaction: disnake.ApplicationCommandInteraction):
|
||||||
self,
|
"""Ouvre un formulaire pour suggérer une fonctionnalité."""
|
||||||
interaction: disnake.ApplicationCommandInteraction,
|
modal = FeatureSuggestionModal()
|
||||||
titre: str = commands.Param(description="Titre de la suggestion"),
|
await interaction.response.send_modal(modal)
|
||||||
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."
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def setup(bot):
|
def setup(bot):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue