refactor(bug_report): utiliser bouton + modal pour le formulaire
Les commandes /signaler_bug et /suggerer_fonctionnalite affichent maintenant un embed avec un bouton qui ouvre le formulaire modal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8da858d1d8
commit
a9f577fc06
1 changed files with 36 additions and 6 deletions
|
|
@ -97,6 +97,16 @@ class BugReportModal(disnake.ui.Modal):
|
|||
)
|
||||
|
||||
|
||||
class BugReportView(disnake.ui.View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
|
||||
@disnake.ui.button(label="🎫 Remplir le formulaire", style=disnake.ButtonStyle.primary, custom_id="open_bug_form")
|
||||
async def open_bug_form(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
|
||||
modal = BugReportModal()
|
||||
await interaction.response.send_modal(modal)
|
||||
|
||||
|
||||
class FeatureSuggestionModal(disnake.ui.Modal):
|
||||
def __init__(self):
|
||||
super().__init__(
|
||||
|
|
@ -126,7 +136,7 @@ class FeatureSuggestionModal(disnake.ui.Modal):
|
|||
suggestion_title = (interaction.text_values.get("suggestion_title") or "").strip() or "Sans titre"
|
||||
description_value = interaction.text_values.get("suggestion_description") or ""
|
||||
|
||||
description_text = f"**Suggéré par:** {interaction.user} ({interaction.user.id})\n\n"
|
||||
description_text = f"**Sugéré par:** {interaction.user} ({interaction.user.id})\n\n"
|
||||
description_text += f"**Description:**\n{description_value}"
|
||||
|
||||
labels = ["enhancement", "manual-suggestion"]
|
||||
|
|
@ -153,6 +163,16 @@ class FeatureSuggestionModal(disnake.ui.Modal):
|
|||
)
|
||||
|
||||
|
||||
class FeatureSuggestionView(disnake.ui.View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
|
||||
@disnake.ui.button(label="🎫 Remplir le formulaire", style=disnake.ButtonStyle.green, custom_id="open_suggestion_form")
|
||||
async def open_suggestion_form(self, button: disnake.ui.Button, interaction: disnake.MessageInteraction):
|
||||
modal = FeatureSuggestionModal()
|
||||
await interaction.response.send_modal(modal)
|
||||
|
||||
|
||||
class BugReport(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
|
@ -266,7 +286,7 @@ class BugReport(commands.Cog):
|
|||
note_obj_attrs = payload.get("object_attributes") or {}
|
||||
kuby_logger.info(
|
||||
f"[GitLab note] system={note_obj_attrs.get('system', False)} "
|
||||
f"note_len={len(str(note_obj_attrs.get('note') or note_obj_attrs.get('body') or payload.get('note') or ''))}"
|
||||
f"note_len={len(str(note_obj_attrs.get('note') or note_obj_attrs.get('body') or payload.get('note') or ''))}"
|
||||
)
|
||||
|
||||
app_info = await self.bot.application_info()
|
||||
|
|
@ -437,8 +457,13 @@ class BugReport(commands.Cog):
|
|||
)
|
||||
async def signifier_bug(self, interaction: disnake.ApplicationCommandInteraction):
|
||||
"""Ouvre un formulaire pour signaler un bug."""
|
||||
modal = BugReportModal(None)
|
||||
await interaction.response.send_modal(modal)
|
||||
embed = disnake.Embed(
|
||||
title="🐛 Signaler un Bug",
|
||||
description="Cliquez sur le bouton ci-dessous pour remplir le formulaire de signalement.",
|
||||
color=disnake.Color.red()
|
||||
)
|
||||
view = BugReportView()
|
||||
await interaction.response.send_message(embed=embed, view=view, ephemeral=True)
|
||||
|
||||
@commands.slash_command(
|
||||
name="suggerer_fonctionnalite",
|
||||
|
|
@ -446,8 +471,13 @@ class BugReport(commands.Cog):
|
|||
)
|
||||
async def suggerer_fonctionnalite(self, interaction: disnake.ApplicationCommandInteraction):
|
||||
"""Ouvre un formulaire pour suggérer une fonctionnalité."""
|
||||
modal = FeatureSuggestionModal()
|
||||
await interaction.response.send_modal(modal)
|
||||
embed = disnake.Embed(
|
||||
title="💡 Suggérer une Fonctionnalité",
|
||||
description="Cliquez sur le bouton ci-dessous pour remplir le formulaire de suggestion.",
|
||||
color=disnake.Color.green()
|
||||
)
|
||||
view = FeatureSuggestionView()
|
||||
await interaction.response.send_message(embed=embed, view=view, ephemeral=True)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue