Compare commits

..

No commits in common. "633295c4468cce41e195f70e7feeff4a45c79f1e" and "978f5e857d0a0d0fe54c9e316a459e19f61da553" have entirely different histories.

2 changed files with 12 additions and 146 deletions

View file

@ -1,6 +1,7 @@
import discord import discord
from redbot.core import Config, app_commands, commands, checks from redbot.core import Config, app_commands, commands, checks
import modals from .modals import BotBugModal, IssuesConfigurationModal, IssueResponseModal
class Issues(commands.Cog): class Issues(commands.Cog):
"""This cog allows you to create Gitea issues through a Discord modal. """This cog allows you to create Gitea issues through a Discord modal.
@ -27,8 +28,7 @@ class Issues(commands.Cog):
await ctx.channel.send(content="Click the button below to configure the cog.", view=self.IssueConfigurationButton(self.config, ctx)) await ctx.channel.send(content="Click the button below to configure the cog.", view=self.IssueConfigurationButton(self.config, ctx))
@app_commands.command() @app_commands.command()
async def issues(self, interaction: discord.Interaction): async def issuestest(self, interaction: discord.Interaction):
"""Found a bug or have a suggestion for the Galaxy bot? Use this command."""
color = await self.bot.get_embed_color(None) color = await self.bot.get_embed_color(None)
await interaction.response.send_message(content="Hello world!", view=self.IssueButtons(color, self, interaction), ephemeral=True) await interaction.response.send_message(content="Hello world!", view=self.IssueButtons(color, self, interaction), ephemeral=True)
@ -55,19 +55,19 @@ 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(modals.BotBugModal(self.color, self.cog_instance, self.original_interaction)) await interaction.response.send_modal(BotBugModal(self.color, self.cog_instance, self.original_interaction))
@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(modals.CogBugModal(self.color, self.cog_instance, self.original_interaction)) await interaction.response.send_modal(BotBugModal(self.color, self.cog_instance, self.original_interaction))
@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(modals.BotSuggestionModal(self.color, self.cog_instance, self.original_interaction)) await interaction.response.send_modal(BotBugModal(self.color, self.cog_instance, self.original_interaction))
@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(modals.CogSuggestionModal(self.color, self.cog_instance, self.original_interaction)) await interaction.response.send_modal(BotBugModal(self.color, self.cog_instance, self.original_interaction))
class IssueConfigurationButton(discord.ui.View): class IssueConfigurationButton(discord.ui.View):
def __init__(self, config, ctx): def __init__(self, config, ctx):
@ -77,7 +77,7 @@ class Issues(commands.Cog):
@discord.ui.button(label="Change Configuration", style=discord.ButtonStyle.blurple, row=0) @discord.ui.button(label="Change Configuration", style=discord.ButtonStyle.blurple, row=0)
async def issue_configuration_button(self, interaction: discord.Interaction, button: discord.ui.Button): async def issue_configuration_button(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.IssuesConfigurationModal(self.config, self.ctx)) await interaction.response.send_modal(IssuesConfigurationModal(self.config, self.ctx))
class IssueResponseButtons(discord.ui.View): class IssueResponseButtons(discord.ui.View):
def __init__(self, channel, message_id, user): def __init__(self, channel, message_id, user):
@ -88,8 +88,8 @@ class Issues(commands.Cog):
@discord.ui.button(label="Approve", style=discord.ButtonStyle.green) @discord.ui.button(label="Approve", style=discord.ButtonStyle.green)
async def issue_response_button_approve(self, interaction: discord.Interaction, button: discord.ui.Button): async def issue_response_button_approve(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, True)) await interaction.response.send_modal(IssueResponseModal(self.channel, self.message_id, self.user, True))
@discord.ui.button(label="Deny", style=discord.ButtonStyle.danger) @discord.ui.button(label="Deny", style=discord.ButtonStyle.danger)
async def issue_response_button_deny(self, interaction: discord.Interaction, button: discord.ui.Button): async def issue_response_button_deny(self, interaction: discord.Interaction, button: discord.ui.Button):
await interaction.response.send_modal(modals.IssueResponseModal(self.channel, self.message_id, self.user, False)) await interaction.response.send_modal(IssueResponseModal(self.channel, self.message_id, self.user, False))

View file

@ -2,11 +2,9 @@ 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[discord.Embed.fields], color: str): def construct_embed(interaction: discord.Interaction, fields: list, 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
@ -40,9 +38,7 @@ def construct_embed(interaction: discord.Interaction, fields: list[discord.Embed
) )
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):
@ -55,7 +51,6 @@ 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(
@ -86,135 +81,7 @@ 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):
@ -309,9 +176,8 @@ 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):