feat(ticket): add transfer, priority, lock/unlock, stats, message recording
All checks were successful
ci / ci (push) Successful in 44s
All checks were successful
ci / ci (push) Successful in 44s
- TransferButton: transfer ticket to another staff member - PriorityButton: set ticket priority (low/normal/high/urgent) - LockButton: lock/unlock ticket (toggle channel permissions) - StatsButton: show ticket info (category, user, claimed, priority, messages) - on_message listener: records all messages for transcript - TicketData: added locked, priority fields
This commit is contained in:
parent
4d1e265848
commit
e46c04fe98
3 changed files with 269 additions and 2 deletions
|
|
@ -8,7 +8,17 @@ from discord.ext import commands
|
|||
|
||||
from tickets import storage
|
||||
from tickets.data import TicketCategory
|
||||
from tickets.ui import AddMemberButton, ClaimButton, CloseButton, PanelCreateButton
|
||||
from tickets.ui import (
|
||||
AddMemberButton,
|
||||
ClaimButton,
|
||||
CloseButton,
|
||||
LockButton,
|
||||
PanelCreateButton,
|
||||
PriorityButton,
|
||||
StatsButton,
|
||||
TransferButton,
|
||||
_is_staff,
|
||||
)
|
||||
|
||||
logger = logging.getLogger("vision")
|
||||
|
||||
|
|
@ -134,7 +144,8 @@ class TicketManagementView(discord.ui.LayoutView):
|
|||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
container = discord.ui.Container()
|
||||
container.add_item(discord.ui.ActionRow(ClaimButton(), AddMemberButton(), CloseButton()))
|
||||
container.add_item(discord.ui.ActionRow(ClaimButton(), AddMemberButton(), TransferButton()))
|
||||
container.add_item(discord.ui.ActionRow(PriorityButton(), LockButton(), StatsButton(), CloseButton()))
|
||||
self.add_item(container)
|
||||
|
||||
|
||||
|
|
@ -150,6 +161,37 @@ class TicketSystem(commands.Cog):
|
|||
async def on_ready(self):
|
||||
logger.info("TicketSystem cog charge")
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_message(self, message: discord.Message):
|
||||
if message.author.bot:
|
||||
return
|
||||
if not message.guild:
|
||||
return
|
||||
|
||||
ticket = storage.get_ticket(message.channel.id)
|
||||
if not ticket:
|
||||
return
|
||||
|
||||
config = storage.get_config(message.guild.id)
|
||||
member = message.guild.get_member(message.author.id)
|
||||
if not member:
|
||||
return
|
||||
|
||||
is_staff = _is_staff(member, config)
|
||||
|
||||
from tickets.data import TicketMessage
|
||||
|
||||
msg = TicketMessage(
|
||||
author_id=message.author.id,
|
||||
author_name=str(message.author),
|
||||
content=message.content,
|
||||
timestamp=message.created_at.isoformat(),
|
||||
attachments=[a.url for a in message.attachments],
|
||||
is_staff=is_staff,
|
||||
)
|
||||
ticket.messages.append(msg)
|
||||
storage.save_ticket(ticket)
|
||||
|
||||
@ticket.command(name="setup", description="Envoyer le panneau de tickets")
|
||||
@app_commands.describe(channel="Canal pour le panneau")
|
||||
@app_commands.checks.has_permissions(manage_guild=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue