Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ TOKEN=your_bot_token
// DEFAULT IS OPENAI
OPENAI_API_KEY=<token>
GEMINI_API_KEY=<token>
GITHUB_ACCESS_TOKEN=<token>
```

### Running the Bot
Expand Down
2 changes: 1 addition & 1 deletion cogs/faq.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



with open("model.toml", "rb") as f:
with open("config.toml", "rb") as f:
model_config = tomli.load(f)


Expand Down
22 changes: 22 additions & 0 deletions cogs/issue_slash.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from discord.ext import commands
import discord
from discord import app_commands


from view.modal.issue_modal import IssueModal

class Issue(commands.Cog):

def __init__(self, bot):
self.bot = bot
self.index = 0

@app_commands.command(name="issue", description="issue report")
async def announce(self, interaction: discord.Interaction):
""" /issue """
modal = IssueModal()
await interaction.response.send_modal(modal)


async def setup(bot):
await bot.add_cog(Issue(bot))
5 changes: 4 additions & 1 deletion model.toml → config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ Instructions for handling unmatched queries:



MODERATOR_ID=796423055136129025
MODERATOR_ID=796423055136129025
REPO_OWNER ="BasedHardware"
REPO_NAME ="omi"
ISSUE_CHN="1053524659200610385"
2 changes: 1 addition & 1 deletion core/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

logger = logging.getLogger(__name__)

with open("model.toml", "rb") as f:
with open("config.toml", "rb") as f:
model_config = tomli.load(f)


Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ rich==14.1.0
pynacl==1.6.0
openai==2.0.0
google-genai==1.39.1
tomli==2.2.1
tomli==2.2.1
pygithub==2.8.1
132 changes: 132 additions & 0 deletions view/modal/issue_modal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import discord
import asyncio
from github import Github, Auth
import tomli
from dotenv import load_dotenv
import logging
import os


load_dotenv()
Gtoken = os.getenv('GITHUB_ACCESS_TOKEN')
if not Gtoken:
logging.error("GITHUB ACCESS TOKEN NOT FOUND IN .ENV FILE.")
exit()

with open("config.toml", "rb") as f:
config = tomli.load(f)

GITHUB_ACCESS_TOKEN=Gtoken

REPO_OWNER = config["REPO_OWNER"]
REPO_NAME = config["REPO_NAME"]



class IssueModal(discord.ui.Modal, title="Omi Issue Report"):
IssueTitle = discord.ui.TextInput(
label="Issue Title",
style=discord.TextStyle.short,
required=True,
max_length=100,
)

IssueDes = discord.ui.TextInput(
label="Issue Description",
style=discord.TextStyle.long,
required=True,
max_length=300,
)

async def on_submit(self, interaction: discord.Interaction):

# Defer the response immediately to avoid timeout
await interaction.response.defer(ephemeral=True)

# Initialize with new auth method
auth = Auth.Token(GITHUB_ACCESS_TOKEN)
g = Github(auth=auth)

# Get the repository
repo = g.get_repo(f"{REPO_OWNER}/{REPO_NAME}")


# Create an issue
issue = repo.create_issue(
title=self.IssueTitle.value,
body=f"## Description\n\n{self.IssueDes.value}\n\n## Reported by\nDiscord User: {interaction.user.name} (ID: {interaction.user.id})"
)


issue_chn = discord.utils.get(
interaction.guild.channels, id=1053524659200610385)

# Embed
embed = discord.Embed(
title=f"🐛 {self.IssueTitle.value}",
description=f"**Issue #{issue.number}** has been created on GitHub",
color=discord.Colour(0x238636), # GitHub green color
url=issue.html_url
)

embed.add_field(
name="📝 Description",
value=self.IssueDes.value[:200] + "..." if len(self.IssueDes.value) > 200 else self.IssueDes.value,
inline=False
)

embed.add_field(
name="🔢 Issue Number",
value=f"#{issue.number}",
inline=True
)

embed.add_field(
name="🔗 GitHub Link",
value=f"[View on GitHub]({issue.html_url})",
inline=True
)

embed.set_author(
name=f"Reported by {interaction.user.name}",
icon_url=interaction.user.display_avatar.url if interaction.user.display_avatar else None
)

embed.set_footer(
text=f"You'll be contacted in a thread if the dev team needs more info",
icon_url="https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png"
)

# Send the embed with user mention
message = await issue_chn.send(
content=f"{interaction.user.mention} Your issue has been created! You'll be notified in a thread if the dev team needs any additional information.",
embed=embed
)

# Create a thread for follow-up questions
thread = await message.create_thread(
name=f"Issue #{issue.number}: {self.IssueTitle.value[:50]}",
auto_archive_duration=1440 # 24 hours
)

await thread.send(f"Hey {interaction.user.mention}, this thread is for any follow-up questions from the dev team about your issue.")


# Use followup since we deferred the response
await interaction.followup.send(
"**Issue created successfully!**", ephemeral=True
)


async def on_error(
self, interaction: discord.Interaction, error: Exception
) -> None:
# Check if interaction is already responded to
if interaction.response.is_done():
await interaction.followup.send(
"Oops! Something went wrong.", ephemeral=True
)
else:
await interaction.response.send_message(
"Oops! Something went wrong.", ephemeral=True
)