modified: bot.py

This commit is contained in:
SimolZimol
2026-01-09 17:10:00 +01:00
parent 52eea52def
commit 2edd8726a2

46
bot.py
View File

@@ -129,15 +129,15 @@ async def setup(
@bot.tree.command(name="ticket", description="Create a new project update ticket")
@app_commands.describe(
message_id="The Discord message ID to reference",
message_id="Optional: Discord message ID to reference",
project_name="The project name from devanturas.net/versions",
title="Brief title for this update"
)
async def create_ticket(
interaction: discord.Interaction,
message_id: str,
project_name: str,
title: str
title: str,
message_id: str = None
):
guild_id = interaction.guild.id if interaction.guild else None
settings = load_server_settings(guild_id)
@@ -148,41 +148,41 @@ async def create_ticket(
)
return
active_channel = bot.get_channel(settings["active_channel_id"])
if not active_channel:
await interaction.response.send_message(
"❌ Active channel not found! Please reconfigure with `/setup`.",
ephemeral=True
)
return
# Create ticket ID
ticket_id = f"TICKET-{ticket_counter:04d}"
global ticket_counter
ticket_counter += 1
# Create embed for the ticket
referenced_message_content = None
referenced_message_author = None
if message_id:
try:
ref_message = await active_channel.fetch_message(int(message_id))
referenced_message_content = ref_message.content
referenced_message_author = ref_message.author.mention
except Exception:
referenced_message_content = None
referenced_message_author = None
embed = discord.Embed(
title=f"🎫 {ticket_id}: {title}",
description=f"**Project Update Request**",
color=discord.Color.blue(),
timestamp=datetime.utcnow()
)
embed.add_field(name="📋 Project", value=project_name, inline=True)
embed.add_field(name="📊 Status", value=TicketStatus.PENDING, inline=True)
embed.add_field(name="👤 Created By", value=interaction.user.mention, inline=True)
embed.add_field(name="🔗 Message ID", value=f"`{message_id}`", inline=False)
if message_id:
embed.add_field(name="🔗 Message ID", value=f"`{message_id}`", inline=False)
if referenced_message_content:
embed.add_field(name="💬 Request Message", value=referenced_message_content, inline=False)
if referenced_message_author:
embed.add_field(name="🙋 Request By", value=referenced_message_author, inline=True)
embed.add_field(
name="🌐 Project Links",
value=f"[All Projects](https://devanturas.net/versions) | [Project Page](https://devanturas.net/projects/{project_name})",
inline=False
)
embed.set_footer(text=f"Ticket ID: {ticket_id}")
# Send to active channel
ticket_message = await active_channel.send(embed=embed)
# Store ticket data
ticket = {
"message_id": ticket_message.id,
"channel_id": active_channel.id,
@@ -191,11 +191,11 @@ async def create_ticket(
"status": TicketStatus.PENDING,
"creator": interaction.user.id,
"created_at": datetime.utcnow().isoformat(),
"reference_message_id": message_id
"reference_message_id": message_id,
"referenced_message_content": referenced_message_content,
"referenced_message_author": referenced_message_author
}
save_ticket(ticket_id, ticket)
# Confirm to user
await interaction.response.send_message(
f"✅ Ticket created successfully!\n"
f"**Ticket ID:** `{ticket_id}`\n"