Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
b723942
Add automatic settings migration for missing defaults
THEMPGUYActions Oct 19, 2026
449a7f3
Add configurable ticket channel prefix
THEMPGUYActions Oct 19, 2026
88fb3b3
Use configured prefix for ticket channel names
THEMPGUYActions Oct 19, 2026
4b44f57
Add additive settings migration helper
THEMPGUYActions Oct 19, 2026
74305e0
Test additive settings migration
THEMPGUYActions Oct 19, 2026
81c8b05
Document ticket channel prefix and config migration
THEMPGUYActions Oct 19, 2026
a30ceda
Add configurable priority ordering helpers
THEMPGUYActions Oct 19, 2026
6e78a9f
Test configurable priority ordering
THEMPGUYActions Oct 19, 2026
52abdb7
Add persistent editable queue status embed
THEMPGUYActions Oct 19, 2026
cc2bd0a
Migrate new defaults into existing category and priority entries
THEMPGUYActions Oct 19, 2026
77ffcec
Add priority-based ticket channel ordering
THEMPGUYActions Oct 19, 2026
1b0de59
Use configured priorities for queue order and persist queue display m…
THEMPGUYActions Oct 19, 2026
6dcf9f8
Add per-category prefix and queue embed settings
THEMPGUYActions Oct 19, 2026
57f3dba
Validate category prefixes and queue display configuration
THEMPGUYActions Oct 19, 2026
37df09b
Use configured priority order when rank values are omitted
THEMPGUYActions Oct 19, 2026
b3fb4b8
Coordinate ticket ordering and queue display updates
THEMPGUYActions Oct 19, 2026
989f216
Apply category prefixes and synchronize queue on creation and claims
THEMPGUYActions Oct 19, 2026
f4f4407
Apply priority updates, category transitions, and lifecycle synchroni…
THEMPGUYActions Oct 19, 2026
15d44b6
Apply category prefix and resynchronize queue on reopen
THEMPGUYActions Oct 19, 2026
52eb30d
Refresh sorted tickets and queue embed on startup and schedule
THEMPGUYActions Oct 19, 2026
48ddd7e
Fix queue-display.js template literals
THEMPGUYActions Oct 19, 2026
1146227
Fix ticket-presentation.js template literals
THEMPGUYActions Oct 19, 2026
4d5a8f4
Test migration of new settings into existing categories
THEMPGUYActions Oct 19, 2026
278d1b1
Test priority-based Discord channel ordering
THEMPGUYActions Oct 19, 2026
c75b773
Use configured priority order in queue commands
THEMPGUYActions Oct 19, 2026
5db87b1
Document category prefixes, priority ordering, and queue embed
THEMPGUYActions Oct 19, 2026
7aa085b
Persist ticket opening embed message IDs
THEMPGUYActions Oct 19, 2026
9c2a0da
Update ticket priority embeds by persisted message ID
THEMPGUYActions Oct 19, 2026
9e4bedb
Order priority command choices from highest to lowest
THEMPGUYActions Oct 19, 2026
69842bf
Show priority label and reorder confirmation to staff
THEMPGUYActions Oct 19, 2026
6a57082
Export and harden queue embed formatting
THEMPGUYActions Oct 19, 2026
022c7cb
Fix queue embed newline separators
THEMPGUYActions Oct 19, 2026
d063826
Test persistent queue embed creation and editing
THEMPGUYActions Oct 19, 2026
3d43d2e
Test database priority ordering and strict claims
THEMPGUYActions Oct 19, 2026
e90f5ef
Add robust ticket channel prefix and name builder
THEMPGUYActions Oct 19, 2026
eda438f
Use tested safe channel-name builder for category prefixes
THEMPGUYActions Oct 19, 2026
f0a451d
Test global and category channel prefix naming
THEMPGUYActions Oct 19, 2026
ba1764f
Ensure removed priorities always sort below configured levels
THEMPGUYActions Oct 19, 2026
5b91c6a
Keep active tickets above closed tickets when sorting channels
THEMPGUYActions Oct 19, 2026
fbb44a7
Pass guild context for auto-claim queue refresh
THEMPGUYActions Oct 19, 2026
0afac62
Fix auto-claim status and immediately refresh queue state
THEMPGUYActions Oct 19, 2026
4b9e057
Make queue refresh resilient to announcement send failures
THEMPGUYActions Oct 19, 2026
b1e7d3d
Keep priorities absent from config at the bottom of the queue
THEMPGUYActions Oct 19, 2026
dbb1ff3
Validate priority configuration and IDs
THEMPGUYActions Oct 19, 2026
11edc24
Test active channels sorting above closed tickets
THEMPGUYActions Oct 19, 2026
4f40b33
Keep ticket fallback consistent with existing channel names
THEMPGUYActions Oct 19, 2026
c40ee10
Serialize queue panel refreshes and recover deleted messages
THEMPGUYActions Oct 19, 2026
c55ccef
Test concurrent queue refresh and deleted-message recovery
THEMPGUYActions Oct 19, 2026
e626267
Return the persisted ticket after priority embed migration
THEMPGUYActions Oct 19, 2026
80dc534
Clarify queue display setup and category prefix examples
THEMPGUYActions Oct 19, 2026
ddcc530
Avoid recursive missing-channel queue processing and refresh the display
THEMPGUYActions Oct 19, 2026
daa24f4
Serialize concurrent priority-based channel reordering
THEMPGUYActions Oct 19, 2026
bf79490
Test concurrent channel priority changes
THEMPGUYActions Oct 19, 2026
0b216ce
Report queue panel refresh failures accurately
THEMPGUYActions Oct 19, 2026
94a898e
Expose priority presentation synchronization result
THEMPGUYActions Oct 19, 2026
a7aa552
Report priority presentation failures in the command response
THEMPGUYActions Oct 19, 2026
3c2ffd7
Test automatic claims correctly remove tickets from queue status
THEMPGUYActions Oct 19, 2026
4755411
Document priority sorting scope across Discord categories
THEMPGUYActions Oct 19, 2026
9b851e2
Refresh priority queue immediately after ticket state changes
THEMPGUYActions Oct 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ DISCORD_CLIENT_ID=your_application_id

On first start, `config/settings.json` is created automatically from `config/settings.example.json`. Open it and set your role IDs, channel IDs, and ticket category parent channel IDs before inviting the bot to your server.

On later starts, missing settings are automatically added from the sample config without overwriting existing custom values.

Deploy slash commands:

```sh
Expand Down Expand Up @@ -76,9 +78,14 @@ Once online, run `/ticket-panel` in the channel where users should open tickets.
| `permissions.adminRoleIds` | Roles with full admin access |
| `channels.ticketLogsId` | Channel where ticket events are logged |
| `ticketing.categories` | The ticket categories shown in the panel |
| `ticketing.channelPrefix` | Prefix for new and reopened ticket channels (default: `ticket-`; for example, `support-`) |
| `ticketing.categories[].channelPrefix` | Optional per-category prefix such as `general-`; an empty value inherits `ticketing.channelPrefix` |
| `ticketing.maxOpenPerUser` | Max open tickets per user (`0` = unlimited) |
| `ticketing.creationCooldownSeconds` | Minimum seconds between ticket opens |
| `ticketing.queue.enabled` | Turn the persistent queue on or off |
| `ticketing.queue.strictOrder` | Only allow claiming the highest-ranked waiting ticket |
| `ticketing.queue.display` | Optional priority-ordered queue embed, automatically created/edited in `channelId` and refreshed on the configured interval; its message ID is persisted in SQLite so restarts edit the same message |
| `priorityLevels[].rank` | Numeric priority weight; higher ranks sort before lower ranks, with oldest tickets first within the same rank |
| `ticketing.queue.staffCapacity` | Max active claims per staff member (`0` = no cap) |
| `ticketing.workingHours` | Restrict ticket opening to a time schedule |
| `ticketing.inactivityMonitor` | Alert staff on stale tickets |
Expand All @@ -87,7 +94,7 @@ Once online, run `/ticket-panel` in the channel where users should open tickets.
| `features.suggestions` | Enable the suggestion workflow |
| `features.reviews` | Let users rate their support experience |

Category IDs must be letters, digits, underscores, or hyphens (max 40 chars). Each category can have a `parentCategoryId`, `supportRoleIds`, `requiredRoleIds`, and up to three `questions`.
Category IDs must be letters, digits, underscores, or hyphens (max 40 chars). Each category can have a `parentCategoryId`, `supportRoleIds`, `requiredRoleIds`, and up to three `questions`. Each category can also set `channelPrefix` to override the global prefix; for example, set `channelPrefix` to `general-` to create channels such as `general-12-someone`. To enable the optional queue embed, set `ticketing.queue.enabled` and `ticketing.queue.display.enabled` to `true`, choose `type: "embed"`, and set a text `channelId`. The bot creates the message on first use, stores its message ID in SQLite, then edits that same message after restarts and at `refreshIntervalSeconds`. Higher `priorityLevels[].rank` values appear first; tickets with equal priority stay FIFO, and closed ticket channels are placed below active tickets. Discord channel positions are sorted within each parent category, because channels under separate Discord categories cannot be globally interleaved.

## Commands

Expand Down
14 changes: 13 additions & 1 deletion config/settings.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
"defaultColor": "#6D5AE6"
},
"ticketing": {
"channelPrefix": "ticket-",
"maxOpenPerUser": 3,
"creationCooldownSeconds": 20,
"queue": {
"enabled": false,
"strictOrder": true,
"staffCapacity": 3
"staffCapacity": 3,
"display": {
"enabled": false,
"type": "embed",
"channelId": "",
"refreshIntervalSeconds": 60,
"maxTickets": 15,
"title": "Support Queue"
}
},
"claims": {
"lockOwnerAfterClaim": false,
Expand Down Expand Up @@ -47,6 +56,7 @@
"categories": [
{
"id": "general",
"channelPrefix": "",
"name": "General Support",
"description": "Questions and general help",
"emoji": "🎫",
Expand All @@ -60,6 +70,7 @@
},
{
"id": "technical",
"channelPrefix": "",
"name": "Technical Support",
"description": "Report a technical problem",
"emoji": "🛠️",
Expand All @@ -74,6 +85,7 @@
},
{
"id": "billing",
"channelPrefix": "",
"name": "Billing and Purchases",
"description": "Questions about purchases or payments",
"emoji": "🧾",
Expand Down
23 changes: 22 additions & 1 deletion src/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { config, validateRuntimeConfig } from './config.js';
import { Database } from './db/database.js';
import { handleInteraction } from './handlers/interactions.js';
import { markActivity, runInactivityMonitor } from './services/tickets.js';
import { syncTicketPresentation, syncQueueDisplaysForClient } from './services/ticket-presentation.js';

validateRuntimeConfig();
const db = new Database(config.databasePath);
Expand All @@ -16,6 +17,23 @@ client.config = config;
client.once(Events.ClientReady, (readyClient) => {
console.log(`[ready] ${readyClient.user.tag} online · shard ${readyClient.shard?.ids?.join(',') ?? 'single'} · db=${config.databasePath}`);
console.log(`[ready] Queue ${config.ticketing.queue?.enabled ? 'enabled' : 'disabled'} · ${config.ticketing.categories.length} ticket categories loaded.`);
syncQueueDisplaysForClient(client, db, config).catch((error) => {
console.error('[ticket-presentation] Startup synchronization failed:', error);
});

const queueDisplay = config.ticketing.queue?.display;
if (queueDisplay?.enabled) {
const intervalMs = Math.max(15, Number(queueDisplay.refreshIntervalSeconds ?? 60)) * 1000;
const timer = setInterval(() => {
for (const guild of client.guilds.cache.values()) {
syncTicketPresentation({ guild, db, config, sortChannels: false }).catch((error) => {
console.error(`[queue-display] Refresh failed for guild ${guild.id}:`, error);
});
}
}, intervalMs);
timer.unref();
}

if (config.ticketing.inactivityMonitor?.enabled) {
const intervalMs = Math.max(1, Number(config.ticketing.inactivityMonitor.checkIntervalMinutes ?? 5)) * 60_000;
const timer = setInterval(() => runInactivityMonitor(client).catch((error) => console.error('[inactivity]', error)), intervalMs);
Expand All @@ -32,7 +50,7 @@ client.on(Events.MessageCreate, async (message) => {
if (!message.guild || message.author.bot) return;
try {
const ticket = db.getTicketByChannel(message.channel.id);
if (ticket) await markActivity({ ticket, author: message.member ?? message.author, db, config });
if (ticket) await markActivity({ ticket, author: message.member ?? message.author, db, config, guild: message.guild });
} catch (error) {
console.error('[messageCreate] Could not update ticket activity:', error);
}
Expand All @@ -43,6 +61,9 @@ client.on(Events.ChannelDelete, (channel) => {
const ticket = db.getTicketByChannel(channel.id);
if (ticket && ['open', 'queued'].includes(ticket.status)) {
db.updateTicket(ticket.id, { status: 'closed', closed_at: Date.now(), close_reason: 'Ticket channel was deleted outside the bot.' });
syncTicketPresentation({ guild: channel.guild, db, config }).catch((error) => {
console.error('[ticket-presentation] Failed after an external channel deletion:', error);
});
}
} catch (error) {
console.error('[channelDelete] Could not reconcile deleted ticket:', error);
Expand Down
3 changes: 2 additions & 1 deletion src/commands/definitions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { SlashCommandBuilder } from 'discord.js';
import { getPriorityRank } from '../utils/priority.js';

export function buildCommands(config) {
const categoryChoices = config.ticketing.categories.slice(0, 25).map((item) => ({ name: item.name, value: item.id }));
const priorities = config.priorityLevels.slice(0, 25).map((item) => ({ name: `${item.emoji ?? ''} ${item.label}`.trim(), value: item.id }));
const priorities = [...config.priorityLevels].sort((a, b) => getPriorityRank(b.id, config.priorityLevels) - getPriorityRank(a.id, config.priorityLevels)).slice(0, 25).map((item) => ({ name: `${item.emoji ?? ''} ${item.label}`.trim(), value: item.id }));
const commands = [
new SlashCommandBuilder().setName('ping').setDescription('Check the bot response time.'),
new SlashCommandBuilder().setName('help').setDescription('Show the support bot command guide.'),
Expand Down
50 changes: 50 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dotenv/config';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { addMissingDefaults } from './utils/settings-migration.js';

const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const configPath = path.resolve(root, process.env.TICKETS_CONFIG || './config/settings.json');
Expand All @@ -20,6 +21,37 @@ try {
throw new Error(`Unable to read JSON settings at ${configPath}: ${error.message}`);
}

const sampleSettings = JSON.parse(fs.readFileSync(examplePath, 'utf8'));
if (addMissingDefaults(settings, sampleSettings)) {
fs.writeFileSync(configPath, `${JSON.stringify(settings, null, 2)}\n`, 'utf8');
console.info(`[config] Migrated ${path.relative(root, configPath)} with missing defaults.`);
}

if (typeof settings?.ticketing?.channelPrefix !== 'string') {
throw new Error('settings.ticketing.channelPrefix must be a string.');
}

const queueDisplay = settings?.ticketing?.queue?.display;
if (queueDisplay?.enabled) {
if (!settings.ticketing.queue?.enabled) {
throw new Error('ticketing.queue.display.enabled requires ticketing.queue.enabled to be true.');
}
if (!/^\d{17,20}$/.test(String(queueDisplay.channelId ?? ''))) {
throw new Error('ticketing.queue.display.channelId must be a valid Discord channel ID when the queue display is enabled.');
}
if ((queueDisplay.type ?? 'embed') !== 'embed') {
throw new Error('ticketing.queue.display.type currently supports only "embed".');
}
const refreshSeconds = Number(queueDisplay.refreshIntervalSeconds ?? 60);
if (!Number.isFinite(refreshSeconds) || refreshSeconds < 15 || refreshSeconds > 86400) {
throw new Error('ticketing.queue.display.refreshIntervalSeconds must be between 15 and 86400.');
}
const maxTickets = Number(queueDisplay.maxTickets ?? 15);
if (!Number.isInteger(maxTickets) || maxTickets < 1 || maxTickets > 25) {
throw new Error('ticketing.queue.display.maxTickets must be an integer between 1 and 25.');
}
}

const categories = settings?.ticketing?.categories;
if (!Array.isArray(categories) || categories.length < 1) {
throw new Error('settings.ticketing.categories must contain at least one category.');
Expand All @@ -28,13 +60,31 @@ if (categories.length > 25) throw new Error('Discord select menus support at mos
if (!Array.isArray(settings.priorityLevels) || settings.priorityLevels.length < 1 || settings.priorityLevels.length > 25) {
throw new Error('settings.priorityLevels must contain between 1 and 25 priority levels.');
}

const priorityIds = new Set();
for (const level of settings.priorityLevels) {
if (!level?.id || typeof level.id !== 'string' || !/^[a-z0-9_-]{1,40}$/i.test(level.id)) {
throw new Error('Every priority level needs a unique id (letters, digits, _ and - only; max 40 characters).');
}
if (priorityIds.has(level.id)) throw new Error(`Duplicate priority level id: ${level.id}`);
priorityIds.add(level.id);
if (level.rank !== undefined && (typeof level.rank !== 'number' || !Number.isFinite(level.rank))) {
throw new Error(`Priority level ${level.id} rank must be a finite number when provided.`);
}
if (level.label !== undefined && (typeof level.label !== 'string' || !level.label.trim())) {
throw new Error(`Priority level ${level.id} label must be a non-empty string.`);
}
}
const categoryIds = new Set();
for (const category of categories) {
if (!category?.id || !/^[a-z0-9_-]{1,40}$/i.test(category.id)) {
throw new Error('Every ticket category needs a unique id (letters, digits, _ and - only; max 40 characters).');
}
if (categoryIds.has(category.id)) throw new Error(`Duplicate ticket category id: ${category.id}`);
categoryIds.add(category.id);
if (category.channelPrefix !== undefined && typeof category.channelPrefix !== 'string') {
throw new Error(`Category ${category.id} channelPrefix must be a string.`);
}
if (!Array.isArray(category.questions)) category.questions = [];
if (category.questions.length > 3) category.questions = category.questions.slice(0, 3);
for (const question of category.questions) {
Expand Down
49 changes: 41 additions & 8 deletions src/db/database.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import path from 'node:path';
import Sqlite from 'better-sqlite3';
import { sortTicketsByPriority } from '../utils/priority.js';

const now = () => Date.now();
const asJson = (value, fallback = []) => {
Expand Down Expand Up @@ -37,7 +38,8 @@ export class Database {
close_reason TEXT,
last_activity_at INTEGER NOT NULL,
inactivity_alerted_at INTEGER,
transcript_path TEXT
transcript_path TEXT,
opening_message_id TEXT
);
CREATE INDEX IF NOT EXISTS idx_tickets_owner_status ON tickets(guild_id, owner_id, status);
CREATE INDEX IF NOT EXISTS idx_tickets_queue ON tickets(guild_id, status, priority, created_at);
Expand Down Expand Up @@ -107,6 +109,13 @@ export class Database {
created_at INTEGER NOT NULL
);

CREATE TABLE IF NOT EXISTS queue_status_messages (
guild_id TEXT PRIMARY KEY,
channel_id TEXT NOT NULL,
message_id TEXT NOT NULL,
updated_at INTEGER NOT NULL
);

CREATE TABLE IF NOT EXISTS invoices (
id INTEGER PRIMARY KEY AUTOINCREMENT,
guild_id TEXT NOT NULL,
Expand All @@ -131,6 +140,9 @@ export class Database {
if (!ticketColumns.has('transcript_path')) {
this.sqlite.exec('ALTER TABLE tickets ADD COLUMN transcript_path TEXT');
}
if (!ticketColumns.has('opening_message_id')) {
this.sqlite.exec('ALTER TABLE tickets ADD COLUMN opening_message_id TEXT');
}
}

createTicket(data) {
Expand All @@ -145,6 +157,11 @@ export class Database {
return ticket;
}

ticketsForGuild(guildId) {
return this.sqlite.prepare('SELECT * FROM tickets WHERE guild_id=? ORDER BY created_at ASC, id ASC')
.all(guildId).map((row) => this.hydrateTicket(row));
}

getTicketById(id) {
const row = this.sqlite.prepare('SELECT * FROM tickets WHERE id = ?').get(Number(id));
return this.hydrateTicket(row);
Expand All @@ -165,7 +182,7 @@ export class Database {
}

updateTicket(id, patch) {
const allowed = new Set(['status','priority','tags_json','intake_json','claimed_by','first_response_at','closed_at','closed_by','close_reason','last_activity_at','inactivity_alerted_at','transcript_path']);
const allowed = new Set(['status','priority','tags_json','intake_json','claimed_by','first_response_at','closed_at','closed_by','close_reason','last_activity_at','inactivity_alerted_at','transcript_path','opening_message_id']);
const entries = Object.entries(patch).filter(([key]) => allowed.has(key));
if (!entries.length) return this.getTicketById(id);
const sql = entries.map(([key]) => `${key}=@${key}`).join(', ');
Expand All @@ -174,7 +191,7 @@ export class Database {
return this.getTicketById(id);
}

claimTicketAtomically({ ticketId, staffId, guildId, capacity = 0, strictOrder = false, allowQueueJump = false }) {
claimTicketAtomically({ ticketId, staffId, guildId, capacity = 0, strictOrder = false, allowQueueJump = false, priorityLevels = [] }) {
const transaction = this.sqlite.transaction(() => {
const ticket = this.sqlite.prepare('SELECT * FROM tickets WHERE id=? AND guild_id=?').get(Number(ticketId), guildId);
if (!ticket) return { ok: false, reason: 'missing' };
Expand All @@ -188,8 +205,9 @@ export class Database {
}

if (strictOrder && !allowQueueJump) {
const first = this.sqlite.prepare(`SELECT id FROM tickets WHERE guild_id=? AND status='queued' AND claimed_by IS NULL
ORDER BY CASE priority WHEN 'urgent' THEN 4 WHEN 'high' THEN 3 WHEN 'normal' THEN 2 ELSE 1 END DESC, created_at ASC LIMIT 1`).get(guildId);
const waiting = this.sqlite.prepare("SELECT * FROM tickets WHERE guild_id=? AND status='queued' AND claimed_by IS NULL")
.all(guildId).map((row) => this.hydrateTicket(row));
const first = sortTicketsByPriority(waiting, priorityLevels)[0];
if (first && Number(first.id) !== Number(ticketId)) return { ok: false, reason: 'order', nextTicketId: Number(first.id) };
}

Expand Down Expand Up @@ -268,10 +286,25 @@ export class Database {
.all(staleBefore, ...guildIds).map((row) => this.hydrateTicket(row));
}

queueList(guildId) {
return this.sqlite.prepare(`SELECT * FROM tickets WHERE guild_id=? AND status='queued' AND claimed_by IS NULL
ORDER BY CASE priority WHEN 'urgent' THEN 4 WHEN 'high' THEN 3 WHEN 'normal' THEN 2 ELSE 1 END DESC, created_at ASC`)
queueList(guildId, priorityLevels = []) {
const rows = this.sqlite.prepare("SELECT * FROM tickets WHERE guild_id=? AND status='queued' AND claimed_by IS NULL")
.all(guildId).map((row) => this.hydrateTicket(row));
return sortTicketsByPriority(rows, priorityLevels);
}

getQueueStatusMessage(guildId) {
return this.sqlite.prepare('SELECT guild_id, channel_id, message_id, updated_at FROM queue_status_messages WHERE guild_id=?')
.get(guildId) ?? null;
}

saveQueueStatusMessage(guildId, channelId, messageId) {
const stamp = now();
this.sqlite.prepare(`INSERT INTO queue_status_messages(guild_id, channel_id, message_id, updated_at)
VALUES(?,?,?,?)
ON CONFLICT(guild_id) DO UPDATE SET
channel_id=excluded.channel_id, message_id=excluded.message_id, updated_at=excluded.updated_at`)
.run(guildId, channelId, messageId, stamp);
return this.getQueueStatusMessage(guildId);
}

reserveCreationCooldown(guildId, userId, cooldownMs) {
Expand Down
8 changes: 6 additions & 2 deletions src/handlers/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { renderTranscript } from '../services/transcripts.js';
import { canManageTicket, isAdmin, isStaff, requireStaff, categoryForTicket } from '../services/permissions.js';
import { formatDuration, parseMoneyToMinorUnits, truncate } from '../utils/text.js';
import { calculate } from '../utils/calculator.js';
import { formatPriority } from '../utils/priority.js';

const ephemeral = { ephemeral: true };
const errorText = (error) => error instanceof Error ? error.message : 'An unexpected error occurred.';
Expand Down Expand Up @@ -137,8 +138,11 @@ async function handleSlashCommand(interaction) {
}
if (name === 'ticket-priority') {
const priority = interaction.options.getString('level', true);
await setPriority({ ticket, channel, member, priority, db, config });
return sendReply(interaction, `Ticket #${ticket.id} priority is now **${priority}**.`);
const result = await setPriority({ ticket, channel, member, priority, db, config });
const presentation = result.presentationSynced
? 'Ticket channel order and the configured queue display are up to date.'
: 'The priority was saved, but one or more views could not refresh. Check the bot logs and its Manage Channels / message permissions.';
return sendReply(interaction, `Ticket #${ticket.id} priority is now **${formatPriority(priority, config.priorityLevels)}**. ${presentation}`);
}
if (name === 'ticket-category') {
const categoryId = interaction.options.getString('category', true);
Expand Down
Loading
Loading