feat(issues): added more logic to IssuesModal
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 5s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 5s
This commit is contained in:
parent
09757c1e87
commit
032f695277
1 changed files with 86 additions and 42 deletions
|
@ -44,60 +44,104 @@ class Issues(commands.Cog):
|
||||||
|
|
||||||
@discord.ui.button(label="Bot Bug", style=discord.ButtonStyle.danger, row=0)
|
@discord.ui.button(label="Bot Bug", style=discord.ButtonStyle.danger, row=0)
|
||||||
async def issue_button_bot_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
|
async def issue_button_bot_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
await interaction.response.send_modal(Issues.BotBugModal())
|
await interaction.response.send_modal(Issues.IssuesModal(button_id="bug"))
|
||||||
|
|
||||||
@discord.ui.button(label="Cog Bug", style=discord.ButtonStyle.danger, row=1)
|
@discord.ui.button(label="Cog Bug", style=discord.ButtonStyle.danger, row=1)
|
||||||
async def issue_button_cog_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
|
async def issue_button_cog_bug(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
await interaction.response.send_modal(Issues.BotBugModal())
|
await interaction.response.send_modal(Issues.IssuesModal(button_id="bug"))
|
||||||
|
|
||||||
@discord.ui.button(label="Bot Suggestion", style=discord.ButtonStyle.blurple, row=0)
|
@discord.ui.button(label="Bot Suggestion", style=discord.ButtonStyle.blurple, row=0)
|
||||||
async def issue_button_bot_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
|
async def issue_button_bot_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
await interaction.response.send_modal(Issues.BotBugModal())
|
await interaction.response.send_modal(Issues.IssuesModal(button_id="bot_suggestion"))
|
||||||
|
|
||||||
@discord.ui.button(label="Cog Suggestion", style=discord.ButtonStyle.blurple, row=1)
|
@discord.ui.button(label="Cog Suggestion", style=discord.ButtonStyle.blurple, row=1)
|
||||||
async def issue_button_cog_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
|
async def issue_button_cog_suggestion(self, interaction: discord.Interaction, button: discord.ui.Button):
|
||||||
await interaction.response.send_modal(Issues.BotBugModal())
|
await interaction.response.send_modal(Issues.IssuesModal(button_id="cog_suggestion"))
|
||||||
|
|
||||||
class BotBugModal(discord.ui.Modal, title="Creating issue..."):
|
class IssuesModal(discord.ui.Modal, title="Creating issue..."):
|
||||||
def __init__(self):
|
def __init__(self, button_id):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.button_id = button_id
|
||||||
|
self.input_list = []
|
||||||
|
|
||||||
bug_description = discord.ui.TextInput(
|
if self.button_id == "cog_suggestion":
|
||||||
|
self.cog_name = discord.ui.TextInput(
|
||||||
|
label="What cog is your feature request for?",
|
||||||
|
placeholder="If unsure, input 'GalaxyCogs'",
|
||||||
|
style=discord.TextStyle.short,
|
||||||
|
max_length=100
|
||||||
|
)
|
||||||
|
self.input_list.append(self.cog_name)
|
||||||
|
if self.button_id == "cog_suggestion" or self.button_id == "bot_suggestion":
|
||||||
|
self.feature_request_description = discord.ui.TextInput(
|
||||||
|
label="Is your feature request related to a problem?",
|
||||||
|
placeholder="A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
self.solution = discord.ui.TextInput(
|
||||||
|
label="Solution",
|
||||||
|
placeholder="Provide a clear and concise description of the solution you'd like.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
self.alternatives = discord.ui.TextInput(
|
||||||
|
label="Alternatives",
|
||||||
|
placeholder="Describe alternatives you've considered.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
self.input_list.append(self.feature_request_description)
|
||||||
|
self.input_list.append(self.solution)
|
||||||
|
self.input_list.append(self.alternatives)
|
||||||
|
if self.button_id == "bot":
|
||||||
|
self.bug_description = discord.ui.TextInput(
|
||||||
label="Describe the bug",
|
label="Describe the bug",
|
||||||
placeholder="A clear and concise description of what the bug is.",
|
placeholder="A clear and concise description of what the bug is.",
|
||||||
style=discord.TextStyle.paragraph,
|
style=discord.TextStyle.paragraph,
|
||||||
max_length=2048
|
max_length=2048
|
||||||
)
|
)
|
||||||
reproduction_steps = discord.ui.TextInput(
|
self.reproduction_steps = discord.ui.TextInput(
|
||||||
label="To Reproduce",
|
label="To Reproduce",
|
||||||
placeholder="What caused the bug?",
|
placeholder="What caused the bug?",
|
||||||
style=discord.TextStyle.paragraph,
|
style=discord.TextStyle.paragraph,
|
||||||
required=True,
|
required=True,
|
||||||
max_length=2048
|
max_length=2048
|
||||||
)
|
)
|
||||||
expected_behavior = discord.ui.TextInput(
|
self.expected_behavior = discord.ui.TextInput(
|
||||||
label="Expected Behavior",
|
label="Expected Behavior",
|
||||||
placeholder="A clear and concise description of what you expected to happen.",
|
placeholder="A clear and concise description of what you expected to happen.",
|
||||||
style=discord.TextStyle.paragraph,
|
style=discord.TextStyle.paragraph,
|
||||||
required=True,
|
required=True,
|
||||||
max_length=2048
|
max_length=2048
|
||||||
)
|
)
|
||||||
additional_context = discord.ui.TextInput(
|
self.input_list.append(self.bug_description)
|
||||||
|
self.input_list.append(self.reproduction_steps)
|
||||||
|
self.input_list.append(self.expected_behavior)
|
||||||
|
self.additional_context = discord.ui.TextInput(
|
||||||
label="Additional Context",
|
label="Additional Context",
|
||||||
placeholder="Add any other context about the problem here.",
|
placeholder=f"Add any other context about the {'problem' if self.button_id == 'bug' else 'feature request'} here.",
|
||||||
style=discord.TextStyle.paragraph,
|
style=discord.TextStyle.paragraph,
|
||||||
required=False,
|
required=False,
|
||||||
max_length=2048
|
max_length=2048
|
||||||
)
|
)
|
||||||
screenshots = discord.ui.TextInput(
|
self.screenshots = discord.ui.TextInput(
|
||||||
label="Screenshots",
|
label="Screenshots",
|
||||||
placeholder="Add screenshots to help explain your problem. Seperate each screenshot with a newline.",
|
placeholder=f"Add screenshots to help explain your {'problem' if self.button_id == 'bug' else 'feature request'}. Seperate each screenshot with a newline.",
|
||||||
style=discord.TextStyle.paragraph,
|
style=discord.TextStyle.paragraph,
|
||||||
required=False,
|
required=False,
|
||||||
max_length=2048
|
max_length=2048
|
||||||
)
|
)
|
||||||
|
self.input_list.append(self.additional_context)
|
||||||
|
self.input_list.append(self.screenshots)
|
||||||
|
|
||||||
async def on_submit(self, interaction: discord.Interaction):
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
embed = discord.Embed(title="Issue Request", color=await Issues.bot.get_embed_color(None))
|
embed = discord.Embed(title="Issue Request", color=await Issues.bot.get_embed_color(None))
|
||||||
fields = [self.bug_description, self.reproduction_steps, self.expected_behavior, self.additional_context, self.screenshots]
|
for item in self.input_list:
|
||||||
await Issues.send_to_target(self, self.target, interaction, self.message, self.secondary_message)
|
title = item.label
|
||||||
|
value = item.value
|
||||||
|
if value is not None:
|
||||||
|
embed.add_field(title, value)
|
||||||
|
await interaction.response.send_message(embed=embed)
|
||||||
|
|
Loading…
Reference in a new issue