p-queue
This commit is contained in:
@@ -12,11 +12,12 @@ const {
|
||||
} = require('discord.js');
|
||||
const { mongoose } = require('../db-connection');
|
||||
const { CONFIG, TICKET_TAGS } = require('../config');
|
||||
const { getPriorityEmoji, replaceVariables, escapeRegex } = require('../utils');
|
||||
const { getPriorityEmoji, getPriorityColor, replaceVariables, escapeRegex } = require('../utils');
|
||||
const { canRename, makeTicketName, pickTicketCategoryId, createDiscordTicketAsThread, checkTicketCreationRateLimit } = require('../services/tickets');
|
||||
const { sendTicketNotificationEmail } = require('../services/gmail');
|
||||
const { getTicketActionRow } = require('../utils/ticketComponents');
|
||||
const { getEmailRouting } = require('../services/guildSettings');
|
||||
const { enqueueRename, enqueueMove } = require('../services/channelQueue');
|
||||
const { trackInteraction, trackError, getAnalyticsSummary } = require('./analytics');
|
||||
const { handleAccountInfoCommand } = require('./accountinfo');
|
||||
const { handleSetupCommand } = require('./setup');
|
||||
@@ -80,7 +81,7 @@ async function runEscalation(interaction, ticket, nextTier, reason) {
|
||||
interaction.guild
|
||||
);
|
||||
try {
|
||||
await interaction.channel.setName(newName);
|
||||
await enqueueRename(interaction.channel, newName);
|
||||
} catch (e) {
|
||||
console.error('Rename error (escalate):', e);
|
||||
}
|
||||
@@ -93,7 +94,7 @@ async function runEscalation(interaction, ticket, nextTier, reason) {
|
||||
}
|
||||
|
||||
if (!interaction.channel.isThread() && categoryId) {
|
||||
await interaction.channel.setParent(categoryId, { lockPermissions: true });
|
||||
await enqueueMove(interaction.channel, categoryId);
|
||||
}
|
||||
|
||||
const pendingEmbed = new EmbedBuilder()
|
||||
@@ -117,8 +118,10 @@ async function runEscalation(interaction, ticket, nextTier, reason) {
|
||||
.replace(/\{support_name\}/g, CONFIG.SUPPORT_NAME)
|
||||
+ (reason ? `\n\n**Reason:** ${reason}` : '');
|
||||
const escalatedEmbed = new EmbedBuilder()
|
||||
.setTitle(`🚨 Escalated to ${nextTier === 1 ? 'Tier 2' : 'Tier 3'} Support`)
|
||||
.setDescription(escalationBody)
|
||||
.setColor(CONFIG.EMBED_COLOR_INFO);
|
||||
.setColor(CONFIG.EMBED_COLOR_ESCALATED)
|
||||
.setFooter({ text: `Escalated by ${interaction.member?.displayName || interaction.user.username}` });
|
||||
const updatedTicketForRow = { ...ticket, escalationTier: nextTier, escalated: true };
|
||||
const escalationRow = getTicketActionRow(updatedTicketForRow);
|
||||
await interaction.channel.send({
|
||||
@@ -193,7 +196,7 @@ async function runDeescalation(interaction, ticket) {
|
||||
interaction.guild
|
||||
);
|
||||
try {
|
||||
await interaction.channel.setName(newName);
|
||||
await enqueueRename(interaction.channel, newName);
|
||||
} catch (e) {
|
||||
console.error('Rename error (deescalate):', e);
|
||||
}
|
||||
@@ -206,12 +209,16 @@ async function runDeescalation(interaction, ticket) {
|
||||
}
|
||||
|
||||
if (!interaction.channel.isThread() && categoryId) {
|
||||
await interaction.channel.setParent(categoryId, { lockPermissions: true });
|
||||
await enqueueMove(interaction.channel, categoryId);
|
||||
}
|
||||
|
||||
const tierLabel = newTier === 0 ? 'normal' : newTier === 1 ? 'tier 2' : 'tier 3';
|
||||
const deescalateEmbed = new EmbedBuilder()
|
||||
.setColor(0x00BFFF)
|
||||
.setTitle(`✅ De-escalated to ${tierLabel} Support`)
|
||||
.setFooter({ text: interaction.member?.displayName || interaction.user.username });
|
||||
await interaction.reply({
|
||||
content: `Ticket de‑escalated to **${tierLabel}** support.`,
|
||||
embeds: [deescalateEmbed],
|
||||
ephemeral: true
|
||||
});
|
||||
|
||||
@@ -737,7 +744,16 @@ async function handleCommand(interaction) {
|
||||
{ $set: { priority: level } }
|
||||
);
|
||||
|
||||
await interaction.reply(channelMessage);
|
||||
const priorityTitle =
|
||||
newIdx === oldIdx
|
||||
? 'Priority Set'
|
||||
: `Priority ${newIdx > oldIdx ? 'Upgraded' : 'Downgraded'} → ${levelLabel}`;
|
||||
const priorityEmbed = new EmbedBuilder()
|
||||
.setTitle(priorityTitle)
|
||||
.setDescription(channelMessage)
|
||||
.setColor(getPriorityColor(level))
|
||||
.setFooter({ text: interaction.member?.displayName || interaction.user.username });
|
||||
await interaction.reply({ embeds: [priorityEmbed] });
|
||||
|
||||
if (level === 'high' && ticket.gmailThreadId && !ticket.gmailThreadId.startsWith('discord-')) {
|
||||
await sendTicketNotificationEmail(
|
||||
@@ -1139,11 +1155,4 @@ async function handleAutocomplete(interaction) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
handleCommand,
|
||||
handleContextMenu,
|
||||
handleAutocomplete,
|
||||
runEscalation,
|
||||
runDeescalation,
|
||||
hasStaffRole
|
||||
};
|
||||
module.exports = { handleCommand, handleContextMenu, handleAutocomplete, runEscalation, runDeescalation };
|
||||
|
||||
Reference in New Issue
Block a user