-
Notifications
You must be signed in to change notification settings - Fork 1
Find Issues command #3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is something like?
.
.
from hata import Client, ClientWrapper, Message
.
.
.
@ALL.interactions(is_global=True, wait_for_acknowledgement=True)
async def ref_issue(client: Client, message: Message, query: ("str", "Topic to search"), repo: ("str", "Repo to search.")): # type: ignore # noqa: F722
"""Provides specific metric(s) for the voxel51/fiftyone repository."""
if repo is not None and repo not in VOXEL51_REPOS:
abort("Must be Voxel51 repo.")
elif repo is None:
repo = "voxel51/fiftyone" # default
try:
GITHUB.get_repo(repo)
issues = repo.search_issues(f'{query} in:title,body')
if issues.totalCount == 0:
return await client.message_create(message.channel, "No relevant issues found.")
issue_links = "\n".join(f"{issue.title}: {issue.html_url}" for issue in issues[:5])
await client.message_create(message.channel, f"Top relevant issues:\n{issue_links}")
except GithubException as e:
logging.error(f"GitHub API error: {e}")
await client.message_create(message.channel, "An error occurred while searching for issues. Please try again later.")|
Since I think that this will work as a slash command I added a line for fetching the GitHub organization to limit the ones that are listed. I choose to return the |
|
I appreciate the patience here, I've been doing a lot of this from mobile and finally had the opportunity to pull this onto a local machine. Updated with type hints, docstrings, imports, and formatting (assumed line line of 100, Added the I did notice that on my Windows machine, |
|
Great, thanks for the contribution. I will merge which will trigger a deployment. |
|
@Burhan-Q issue with loading this plugin: |
|
🤔 hm, guess the docstring needs shortening. Hadn't considered there would be a limit there. |
Rationale
Brief exchange with SteveO on the docs repo made me think this could be a good addition.
Changes
Adds Discord
/ref_issuecommand, that allows users to search for 5 relevant issues. Includes two argumentsrepoandqueryto allow specifying the repo to search and the keywords in title/topic of Issues to find.Testing
😆 unfortunately not at all. Did my best to mirror what other sections of code were doing and to make sure it had a logical flow. Not sure if the "default" behavior included (try to search
voxel51/fiftyoneif no repo is specified).