feat(issues): added modals for all the distinct issue types
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
Some checks reported warnings
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
parent
9e95da3c9e
commit
633295c446
1 changed files with 136 additions and 2 deletions
138
issues/modals.py
138
issues/modals.py
|
@ -2,9 +2,11 @@ import aiohttp
|
||||||
import discord
|
import discord
|
||||||
from redbot.core import Config
|
from redbot.core import Config
|
||||||
|
|
||||||
|
#
|
||||||
# Misc. functions
|
# Misc. functions
|
||||||
|
#
|
||||||
|
|
||||||
def construct_embed(interaction: discord.Interaction, fields: list, color: str):
|
def construct_embed(interaction: discord.Interaction, fields: list[discord.Embed.fields], color: str):
|
||||||
embed = discord.Embed(title="Issue Request", color=color)
|
embed = discord.Embed(title="Issue Request", color=color)
|
||||||
for item in fields:
|
for item in fields:
|
||||||
title = item.label
|
title = item.label
|
||||||
|
@ -38,7 +40,9 @@ def construct_embed(interaction: discord.Interaction, fields: list, color: str):
|
||||||
)
|
)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
#
|
||||||
# Modals for the core '/issues' command.
|
# Modals for the core '/issues' command.
|
||||||
|
#
|
||||||
|
|
||||||
class BotBugModal(discord.ui.Modal, title="Creating issue..."):
|
class BotBugModal(discord.ui.Modal, title="Creating issue..."):
|
||||||
def __init__(self, color, cog_instance, original_interaction):
|
def __init__(self, color, cog_instance, original_interaction):
|
||||||
|
@ -51,6 +55,7 @@ class BotBugModal(discord.ui.Modal, title="Creating issue..."):
|
||||||
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,
|
||||||
|
required=True,
|
||||||
max_length=2048
|
max_length=2048
|
||||||
)
|
)
|
||||||
reproduction_steps = discord.ui.TextInput(
|
reproduction_steps = discord.ui.TextInput(
|
||||||
|
@ -81,7 +86,135 @@ class BotBugModal(discord.ui.Modal, title="Creating issue..."):
|
||||||
embed.set_author(name="Bot Bug Report")
|
embed.set_author(name="Bot Bug Report")
|
||||||
await self.cog_instance.submit_issue_request(interaction=interaction, original_interaction=self.original_interaction, embed=embed)
|
await self.cog_instance.submit_issue_request(interaction=interaction, original_interaction=self.original_interaction, embed=embed)
|
||||||
|
|
||||||
|
class CogBugModal(discord.ui.Modal, title="Creating issue..."):
|
||||||
|
def __init__(self, color, cog_instance, original_interaction):
|
||||||
|
super().__init__()
|
||||||
|
self.color = color
|
||||||
|
self.cog_instance = cog_instance
|
||||||
|
self.original_interaction = original_interaction
|
||||||
|
|
||||||
|
cog_name = discord.ui.TextInput(
|
||||||
|
label="What cog is causing this error?",
|
||||||
|
placeholder="If unsure, put \"GalaxyCogs\".",
|
||||||
|
style=discord.TextStyle.short,
|
||||||
|
required=True,
|
||||||
|
max_length=50
|
||||||
|
)
|
||||||
|
bug_description = discord.ui.TextInput(
|
||||||
|
label="Describe the bug",
|
||||||
|
placeholder="A clear and concise description of what the bug is.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
reproduction_steps = discord.ui.TextInput(
|
||||||
|
label="To Reproduce",
|
||||||
|
placeholder="What caused the bug?",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
expected_behavior = discord.ui.TextInput(
|
||||||
|
label="Expected Behavior",
|
||||||
|
placeholder="A clear and concise description of what you expected to happen.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
additional_context = discord.ui.TextInput(
|
||||||
|
label="Additional Context",
|
||||||
|
placeholder="Add any other context about the problem here.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=False,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
|
fields = [self.cog_name, self.bug_description, self.reproduction_steps, self.expected_behavior, self.additional_context]
|
||||||
|
embed = construct_embed(interaction, fields, self.color)
|
||||||
|
embed.set_author(name="Cog Bug Report")
|
||||||
|
await self.cog_instance.submit_issue_request(interaction=interaction, original_interaction=self.original_interaction, embed=embed)
|
||||||
|
|
||||||
|
class BotSuggestionModal(discord.ui.Modal, title="Creating issue..."):
|
||||||
|
def __init__(self, color, cog_instance, original_interaction):
|
||||||
|
super().__init__()
|
||||||
|
self.color = color
|
||||||
|
self.cog_instance = cog_instance
|
||||||
|
self.original_interaction = original_interaction
|
||||||
|
|
||||||
|
suggestion_description = discord.ui.TextInput(
|
||||||
|
label="Describe your suggestion.",
|
||||||
|
placeholder="A clear and concise description of what your suggestion is.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
alternatives = discord.ui.TextInput(
|
||||||
|
label="Describe alternatives you've considered.",
|
||||||
|
placeholder="A clear and concise description of any alternative solutions or features you've cnosidered.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
additional_context = discord.ui.TextInput(
|
||||||
|
label="Additional Context",
|
||||||
|
placeholder="Add any other context about your suggestion here.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=False,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
|
fields = [self.suggestion_description, self.alternatives, self.additional_context]
|
||||||
|
embed = construct_embed(interaction, fields, self.color)
|
||||||
|
embed.set_author(name="Cog Suggestion")
|
||||||
|
await self.cog_instance.submit_issue_request(interaction=interaction, original_interaction=self.original_interaction, embed=embed)
|
||||||
|
|
||||||
|
class CogSuggestionModal(discord.ui.Modal, title="Creating issue..."):
|
||||||
|
def __init__(self, color, cog_instance, original_interaction):
|
||||||
|
super().__init__()
|
||||||
|
self.color = color
|
||||||
|
self.cog_instance = cog_instance
|
||||||
|
self.original_interaction = original_interaction
|
||||||
|
|
||||||
|
cog_name = discord.ui.TextInput(
|
||||||
|
label="What cog is your suggestion for?",
|
||||||
|
placeholder="If unsure, put \"GalaxyCogs\".",
|
||||||
|
style=discord.TextStyle.short,
|
||||||
|
required=True,
|
||||||
|
max_length=50
|
||||||
|
)
|
||||||
|
suggestion_description = discord.ui.TextInput(
|
||||||
|
label="Describe your suggestion.",
|
||||||
|
placeholder="A clear and concise description of what your suggestion is.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
alternatives = discord.ui.TextInput(
|
||||||
|
label="Describe alternatives you've considered.",
|
||||||
|
placeholder="A clear and concise description of any alternative solutions or features you've cnosidered.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=True,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
additional_context = discord.ui.TextInput(
|
||||||
|
label="Additional Context",
|
||||||
|
placeholder="Add any other context about your suggestion here.",
|
||||||
|
style=discord.TextStyle.paragraph,
|
||||||
|
required=False,
|
||||||
|
max_length=2048
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
|
fields = [self.cog_name, self.suggestion_description, self.alternatives, self.additional_context]
|
||||||
|
embed = construct_embed(interaction, fields, self.color)
|
||||||
|
embed.set_author(name="Cog Suggestion")
|
||||||
|
await self.cog_instance.submit_issue_request(interaction=interaction, original_interaction=self.original_interaction, embed=embed)
|
||||||
|
|
||||||
|
#
|
||||||
# Response modal
|
# Response modal
|
||||||
|
#
|
||||||
|
|
||||||
class IssueResponseModal(discord.ui.Modal, title="Sending response message..."):
|
class IssueResponseModal(discord.ui.Modal, title="Sending response message..."):
|
||||||
def __init__(self, channel, message_id, user, approved):
|
def __init__(self, channel, message_id, user, approved):
|
||||||
|
@ -176,8 +309,9 @@ class IssueResponseModal(discord.ui.Modal, title="Sending response message..."):
|
||||||
await message.edit(embed=embed, view=None)
|
await message.edit(embed=embed, view=None)
|
||||||
await self.user.send(embed=embed)
|
await self.user.send(embed=embed)
|
||||||
|
|
||||||
|
#
|
||||||
# Configuration modal
|
# Configuration modal
|
||||||
|
#
|
||||||
|
|
||||||
class IssuesConfigurationModal(discord.ui.Modal, title="Modifying configuration..."):
|
class IssuesConfigurationModal(discord.ui.Modal, title="Modifying configuration..."):
|
||||||
def __init__(self, config, ctx):
|
def __init__(self, config, ctx):
|
||||||
|
|
Loading…
Reference in a new issue