feat(issues): added configuration
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 4s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 4s
This commit is contained in:
parent
65e2c1d93c
commit
f649d92808
1 changed files with 46 additions and 1 deletions
|
@ -10,9 +10,18 @@ class Issues(commands.Cog):
|
||||||
self.config = Config.get_conf(self, identifier=4285273314713, force_registration=True)
|
self.config = Config.get_conf(self, identifier=4285273314713, force_registration=True)
|
||||||
self.config.register_global(
|
self.config.register_global(
|
||||||
request_channel = None,
|
request_channel = None,
|
||||||
gitea_url = None
|
gitea_repository_url = None,
|
||||||
|
gitea_token = None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def issuesconfig(self, ctx: commands.Context, channel: discord.TextChannel = None):
|
||||||
|
if channel:
|
||||||
|
await self.config.request_channel.set(channel)
|
||||||
|
await ctx.send(content=f"Channel set to {channel.mention}.\nRun this command again without a channel argument to configure the other settings.")
|
||||||
|
else:
|
||||||
|
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 issuestest(self, interaction: discord.Interaction):
|
async def issuestest(self, interaction: discord.Interaction):
|
||||||
color = await self.bot.get_embed_color(None)
|
color = await self.bot.get_embed_color(None)
|
||||||
|
@ -102,3 +111,39 @@ class Issues(commands.Cog):
|
||||||
username = f"{interaction.user.name}#{interaction.user.discriminator}"
|
username = f"{interaction.user.name}#{interaction.user.discriminator}"
|
||||||
embed.set_footer(text=f"Submitted by {username} ({interaction.user.id})", icon_url=interaction.user.display_avatar.url)
|
embed.set_footer(text=f"Submitted by {username} ({interaction.user.id})", icon_url=interaction.user.display_avatar.url)
|
||||||
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 IssueConfigurationButton(discord.ui.View):
|
||||||
|
def __init__(self, config, ctx):
|
||||||
|
super().__init__()
|
||||||
|
self.config = config
|
||||||
|
self.ctx = ctx
|
||||||
|
|
||||||
|
@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):
|
||||||
|
await interaction.response.send_modal(Issues.IssuesConfigurationModal(self.config, self.ctx))
|
||||||
|
|
||||||
|
class IssuesConfigurationModal(discord.ui.Modal, title="Modifying configuration..."):
|
||||||
|
def __init__(self, config, ctx):
|
||||||
|
super().__init__()
|
||||||
|
self.config = config
|
||||||
|
self.ctx = ctx
|
||||||
|
|
||||||
|
gitea_repository_url = discord.ui.TextInput(
|
||||||
|
label="Gitea Repository URL",
|
||||||
|
placeholder="https://try.gitea.io/owner/repository",
|
||||||
|
style=discord.TextStyle.short,
|
||||||
|
max_length=200
|
||||||
|
)
|
||||||
|
gitea_token = discord.ui.TextInput(
|
||||||
|
label="Gitea User Access Token",
|
||||||
|
placeholder="Generate one from your user settings page.",
|
||||||
|
style=discord.TextStyle.short,
|
||||||
|
max_length=200
|
||||||
|
)
|
||||||
|
|
||||||
|
async def on_submit(self, interaction: discord.Interaction):
|
||||||
|
if self.gitea_token.value is not None:
|
||||||
|
await self.config.gitea_token.set(self.gitea_token.value)
|
||||||
|
if self.gitea_repository_url.value is not None:
|
||||||
|
await self.config.gitea_repository_url.set(self.gitea_repository_url.value)
|
||||||
|
await interaction.response.send_message(content="Configuration changed!")
|
||||||
|
|
Loading…
Reference in a new issue