Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions tux/cogs/admin/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ async def create_issue(self, ctx: commands.Context[Tux], title: str, body: str)
"""

try:
created_issue = await self.github.create_issue(title, body)
issue_body = body + "\n\nAuthor: " + str(ctx.author)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider using a more structured approach for adding author information

Instead of appending the author information directly to the body, consider using GitHub's API to set it as a custom field or label if possible. Alternatively, you could add a structured metadata section at the end of the body, which would be easier to parse programmatically if needed.

Suggested change
issue_body = body + "\n\nAuthor: " + str(ctx.author)
metadata = {
"Author": str(ctx.author),
"Created-By": "Discord Bot"
}
metadata_str = "\n".join(f"{k}: {v}" for k, v in metadata.items())
issue_body = f"{body}\n\n---\n{metadata_str}"

created_issue = await self.github.create_issue(title, issue_body)

embed = EmbedCreator.create_success_embed(
title="Issue Created",
Expand All @@ -492,7 +493,7 @@ async def create_issue(self, ctx: commands.Context[Tux], title: str, body: str)
)
embed.add_field(name="Issue Number", value=created_issue.number, inline=False)
embed.add_field(name="Title", value=title, inline=False)
embed.add_field(name="Body", value=body, inline=False)
embed.add_field(name="Body", value=issue_body, inline=False)

except Exception as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Add error logging for better debugging and monitoring

Before sending the error message to the user, consider adding proper error logging. This will help with debugging and monitoring the application's behavior.

Suggested change
except Exception as e:
except Exception as e:
logging.error(f"Error creating issue: {e}", exc_info=True)

await ctx.send(f"Error creating issue: {e}", delete_after=30, ephemeral=True)
Expand Down