feat(issues): finished api integration with gitea
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
cfd5f7b19c
commit
4f90076c37
1 changed files with 31 additions and 5 deletions
|
@ -193,6 +193,7 @@ class Issues(commands.Cog):
|
||||||
self.message_id = message_id
|
self.message_id = message_id
|
||||||
self.user = user
|
self.user = user
|
||||||
self.approved = approved
|
self.approved = approved
|
||||||
|
self.config = Config.get_conf(None, cog_name='Issues', identifier=4285273314713)
|
||||||
|
|
||||||
response = discord.ui.TextInput(
|
response = discord.ui.TextInput(
|
||||||
label="Response",
|
label="Response",
|
||||||
|
@ -210,15 +211,40 @@ class Issues(commands.Cog):
|
||||||
if self.approved:
|
if self.approved:
|
||||||
embed.color = 1226519
|
embed.color = 1226519
|
||||||
embed.title = "Issue Request Approved"
|
embed.title = "Issue Request Approved"
|
||||||
await interaction.response.send_message(content="Issue request accepted.", ephemeral=True)
|
status = "accepted"
|
||||||
else:
|
else:
|
||||||
embed.color = 15671552
|
embed.color = 15671552
|
||||||
embed.title = "Issue Request Denied"
|
embed.title = "Issue Request Denied"
|
||||||
await interaction.response.send_message(content="Issue request denied.", ephemeral=True)
|
status = "denied"
|
||||||
|
await interaction.response.send_message(content=f"Issue request {status}.")
|
||||||
if self.response.value is not None:
|
if self.response.value is not None:
|
||||||
embed.add_field(name=f"Response from {interaction.user.name}", value=self.response.value, inline=False)
|
embed.add_field(name=f"Response from {interaction.user.name}", value=self.response.value, inline=False)
|
||||||
for field in embed.fields:
|
if self.approved:
|
||||||
field_names.append(field.name)
|
for field in embed.fields:
|
||||||
field_values.append(field.value)
|
field_names.append(f"**{field.name}**")
|
||||||
|
field_values.append(field.value)
|
||||||
|
if embed.footer.text == "Bot Bug Report":
|
||||||
|
issue_title = f"[BOT BUG] Automatically generated issue"
|
||||||
|
elif embed.footer.text == "Bot Suggestion":
|
||||||
|
issue_title = f"[BOT SUGGESTION] Automatically generated issue"
|
||||||
|
elif embed.footer.text == "Cog Bug Report" or embed.footer.text == "Cog Suggestion":
|
||||||
|
issue_title = f"[{field_values[0]}] Automatically generated issue"
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Bearer {await self.config.gitea_token()}",
|
||||||
|
"Accept": "application/json"
|
||||||
|
}
|
||||||
|
url = await self.config.gitea_repository_url()
|
||||||
|
issue_body = "\n".join([f"{name}\n{value}" for name, value in zip(field_names, field_values)])
|
||||||
|
issue_data = {
|
||||||
|
"title": issue_title,
|
||||||
|
"body": issue_body
|
||||||
|
}
|
||||||
|
async def create_issue():
|
||||||
|
async with aiohttp.ClientSession(headers=headers) as session:
|
||||||
|
async with session.post(url, json=issue_data) as response:
|
||||||
|
return await response.json(), response.status
|
||||||
|
response_json, status_code = await create_issue()
|
||||||
|
if status_code == 201:
|
||||||
|
await interaction.response.send_message(content=f"Issue request {status}.\n[Issue successfully created.]({response_json.get('html_url')})", ephemeral=True)
|
||||||
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)
|
||||||
|
|
Loading…
Reference in a new issue