feat(tickets): open tickets from a panel button in any channel
CI / quality (push) Has been cancelled
CI / quality (push) Has been cancelled
Members had to know `/ticket create` and its category list to reach support, so the entry point is now a panel: `/ticket setup` publishes it in the current channel, the button opens a menu of the categories the member is allowed to open, and the choice creates the ticket. The panel channel and message are stored in `ticket_panels`, so a reinstall replaces the previous message instead of leaving the server two entry points, and the panel survives a restart.
This commit is contained in:
9 files changed
+492
-29
No files matched your search
@@ -69,3 +69,38 @@ export function countOpenTickets(guildId) {
|
||||
.get(guildId);
|
||||
return row.count;
|
||||
}
|
||||
|
||||
// --- Ticket panels (`/ticket setup`) ----------------------------------------
|
||||
|
||||
export function setTicketPanel({ guildId, channelId, messageId, createdBy = null }) {
|
||||
getDatabase()
|
||||
.prepare(
|
||||
`INSERT INTO ticket_panels (guild_id, channel_id, message_id, created_by)
|
||||
VALUES (?, ?, ?, ?)
|
||||
ON CONFLICT (guild_id, channel_id) DO UPDATE SET
|
||||
message_id = excluded.message_id,
|
||||
created_by = excluded.created_by,
|
||||
updated_at = datetime('now')`,
|
||||
)
|
||||
.run(guildId, channelId, messageId, createdBy);
|
||||
}
|
||||
|
||||
export function getTicketPanel({ guildId, channelId }) {
|
||||
return (
|
||||
getDatabase()
|
||||
.prepare('SELECT * FROM ticket_panels WHERE guild_id = ? AND channel_id = ?')
|
||||
.get(guildId, channelId) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
export function listTicketPanels({ guildId }) {
|
||||
return getDatabase()
|
||||
.prepare('SELECT * FROM ticket_panels WHERE guild_id = ? ORDER BY updated_at DESC')
|
||||
.all(guildId);
|
||||
}
|
||||
|
||||
export function deleteTicketPanel({ guildId, channelId }) {
|
||||
return getDatabase()
|
||||
.prepare('DELETE FROM ticket_panels WHERE guild_id = ? AND channel_id = ?')
|
||||
.run(guildId, channelId).changes;
|
||||
}
|
||||
Reference in new issue
Block a user