Implement ticket panel synchronization and configuration updates
- Added `panelChannelId` and `panelMessageId` fields to the `TicketConfig` model for managing ticket panel settings. - Introduced `syncTicketPanel` function to handle posting and updating the ticket panel in Discord channels via BullMQ. - Enhanced error handling for ticket panel synchronization, including specific error messages for missing categories and posting failures. - Updated WebUI components to support panel channel selection and improved error messaging for synchronization issues. - Added localization entries for new error messages related to ticket panel synchronization in both English and German. - Refactored ticket category management to trigger panel synchronization upon category creation, update, or deletion.
This commit is contained in:
@@ -7,8 +7,6 @@ import { ticketCommandData } from './command-definitions.js';
|
||||
import {
|
||||
addUserToTicket,
|
||||
assertTicketStaff,
|
||||
buildPanelComponents,
|
||||
buildPanelEmbed,
|
||||
claimTicket,
|
||||
closeTicket,
|
||||
createCategoryWithRole,
|
||||
@@ -17,7 +15,9 @@ import {
|
||||
removeUserFromTicket,
|
||||
renameTicket,
|
||||
setTicketPriority,
|
||||
syncTicketPanel,
|
||||
TicketError,
|
||||
TicketPanelError,
|
||||
upsertCategoryByName
|
||||
} from './service.js';
|
||||
|
||||
@@ -67,10 +67,26 @@ const ticketCommand: SlashCommand = {
|
||||
return;
|
||||
}
|
||||
|
||||
const embed = buildPanelEmbed(locale, name, description);
|
||||
const components = buildPanelComponents(categories);
|
||||
await channel.send({ embeds: [embed], components });
|
||||
await interaction.reply({ content: t(locale, 'ticket.panel.created'), ephemeral: true });
|
||||
try {
|
||||
await syncTicketPanel(context, interaction.guildId!, {
|
||||
channelId: channel.id,
|
||||
title: name,
|
||||
description
|
||||
});
|
||||
await interaction.reply({ content: t(locale, 'ticket.panel.created'), ephemeral: true });
|
||||
} catch (error) {
|
||||
if (error instanceof TicketPanelError) {
|
||||
const key =
|
||||
error.code === 'no_categories'
|
||||
? 'ticket.error.no_categories'
|
||||
: error.code === 'not_configured'
|
||||
? 'ticket.error.invalid_channel'
|
||||
: 'ticket.error.missing_permission';
|
||||
await interaction.reply({ content: t(locale, key), ephemeral: true });
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user