modified: bot.py

This commit is contained in:
SimolZimol
2026-01-09 23:35:04 +01:00
parent e87dc61dec
commit 30259fa102

46
bot.py
View File

@@ -76,6 +76,19 @@ def init_db():
# Tables might already be utf8mb4 or might not exist yet # Tables might already be utf8mb4 or might not exist yet
print(f"Table conversion info: {e}") print(f"Table conversion info: {e}")
# Add new columns if they don't exist
try:
cursor.execute('ALTER TABLE tickets ADD COLUMN original_text TEXT')
print("Added original_text column")
except Exception as e:
print(f"original_text column info: {e}")
try:
cursor.execute('ALTER TABLE tickets ADD COLUMN download_link VARCHAR(512)')
print("Added download_link column")
except Exception as e:
print(f"download_link column info: {e}")
conn.commit() conn.commit()
cursor.close() cursor.close()
conn.close() conn.close()
@@ -285,7 +298,7 @@ async def create_ticket(
# Create embed for the ticket with improved design # Create embed for the ticket with improved design
embed = discord.Embed( embed = discord.Embed(
title=f"🎫 {title}", title=f"{title}",
description=f"**Project:** {project_name}\n**Ticket ID:** `{ticket_id}`", description=f"**Project:** {project_name}\n**Ticket ID:** `{ticket_id}`",
color=0x5865F2, # Discord Blurple color=0x5865F2, # Discord Blurple
timestamp=datetime.utcnow() timestamp=datetime.utcnow()
@@ -294,25 +307,24 @@ async def create_ticket(
# Add original request if available # Add original request if available
if original_text and original_author: if original_text and original_author:
embed.add_field( embed.add_field(
name="💬 Original Request", name="Original Request",
value=f"> {original_text}\n\n{original_author.mention}", value=f"> {original_text}\n\n{original_author.mention}",
inline=False inline=False
) )
# Status and creator info # Status and creator info
embed.add_field(name="📊 Status", value=TicketStatus.PENDING, 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="Created By", value=interaction.user.mention, inline=True)
embed.add_field(name="📅 Created", value=f"<t:{int(datetime.utcnow().timestamp())}:R>", inline=True) embed.add_field(name="Created", value=f"<t:{int(datetime.utcnow().timestamp())}:R>", inline=True)
# Project links # Project links
embed.add_field( embed.add_field(
name="🌐 Links", name="Links",
value=f"[📦 All Projects](https://devanturas.net/projects) • [📋 {project_name}](https://devanturas.net/projects/{project_name})", value=f"[All Projects](https://devanturas.net/projects) • [{project_name}](https://devanturas.net/projects/{project_name})",
inline=False inline=False
) )
embed.set_footer(text=f"Update Ticket System • {ticket_id}", icon_url="https://cdn.discordapp.com/emojis/1234567890.png") embed.set_footer(text=f"Update Ticket System • {ticket_id}")
embed.set_thumbnail(url="https://devanturas.net/assets/logo.png")
# Send to active channel # Send to active channel
ticket_message = await active_channel.send(embed=embed) ticket_message = await active_channel.send(embed=embed)
@@ -405,8 +417,8 @@ async def update_status(
# Update the status field # Update the status field
for i, field in enumerate(embed.fields): for i, field in enumerate(embed.fields):
if field.name == "📊 Status": if "Status" in field.name:
embed.set_field_at(i, name="📊 Status", value=new_status_text, inline=True) embed.set_field_at(i, name="Status", value=new_status_text, inline=True)
break break
# Change color based on status # Change color based on status
@@ -424,14 +436,14 @@ async def update_status(
# Update or add download link field # Update or add download link field
download_field_exists = False download_field_exists = False
for i, field in enumerate(embed.fields): for i, field in enumerate(embed.fields):
if "Download" in field.name or "🔗" in field.name: if "Download" in field.name:
embed.set_field_at(i, name="🔗 Download", value=f"[Download Update]({download_link})", inline=False) embed.set_field_at(i, name="Download", value=f"[Download Update]({download_link})", inline=False)
download_field_exists = True download_field_exists = True
break break
if not download_field_exists: if not download_field_exists:
embed.add_field( embed.add_field(
name="🔗 Download", name="Download",
value=f"[Download Update]({download_link})", value=f"[Download Update]({download_link})",
inline=False inline=False
) )
@@ -443,15 +455,15 @@ async def update_status(
# Check if update history field exists # Check if update history field exists
history_exists = False history_exists = False
for i, field in enumerate(embed.fields): for i, field in enumerate(embed.fields):
if "Update History" in field.name or "📝" in field.name: if "Update History" in field.name:
current_history = field.value current_history = field.value
embed.set_field_at(i, name="📝 Update History", value=f"{current_history}\n{update_text}", inline=False) embed.set_field_at(i, name="Update History", value=f"{current_history}\n{update_text}", inline=False)
history_exists = True history_exists = True
break break
if not history_exists: if not history_exists:
embed.add_field( embed.add_field(
name="📝 Update History", name="Update History",
value=update_text, value=update_text,
inline=False inline=False
) )