manual commit 2026-04-10T19:45:00Z
This commit is contained in:
@@ -6,6 +6,7 @@ const { Client, GatewayIntentBits, Partials } = require('discord.js');
|
||||
const express = require('express');
|
||||
const { connectMongoDB } = require('./db-connection');
|
||||
const { CONFIG } = require('./config');
|
||||
const { mongoose } = require('./db-connection');
|
||||
|
||||
// Handlers
|
||||
const { handleButton, handleTicketModal } = require('./handlers/buttons');
|
||||
|
||||
@@ -574,15 +574,17 @@ async function registerCommands() {
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
|
||||
new SlashCommandBuilder()
|
||||
.setName('signature')
|
||||
.setDescription('Set your personal email signature (valediction, display name, tagline)')
|
||||
.setContexts([InteractionContextType.Guild])
|
||||
.setIntegrationTypes([ApplicationIntegrationType.GuildInstall])
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
|
||||
),
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ManageMessages)
|
||||
];
|
||||
|
||||
const contextMenuCommands = [
|
||||
const contextMenuCommands = [
|
||||
new ContextMenuCommandBuilder()
|
||||
.setName('Create Ticket From Message')
|
||||
.setType(ApplicationCommandType.Message)
|
||||
|
||||
@@ -157,54 +157,10 @@ async function sendTicketClosedEmail(ticket, discordDisplayName) {
|
||||
}
|
||||
}
|
||||
|
||||
// StaffSignature model is registered in models.js; re-import here for use in this file
|
||||
const { mongoose } = require('../db-connection');
|
||||
const StaffSignature = mongoose.model('StaffSignature');
|
||||
|
||||
/**
|
||||
* Get formatted signature blocks (text and HTML) for a staff member
|
||||
* @param {string} userId - Discord user ID
|
||||
* @returns {Promise<{text: string, html: string}>} Signature blocks
|
||||
*/
|
||||
async function getStaffSignatureBlocks(userId) {
|
||||
try {
|
||||
const signature = await StaffSignature.findOne({ userId }).lean();
|
||||
|
||||
if (!signature) {
|
||||
return {
|
||||
text: '',
|
||||
html: ''
|
||||
};
|
||||
}
|
||||
|
||||
const valediction = signature.valediction || '';
|
||||
const displayName = signature.displayName || '';
|
||||
const tagline = signature.tagline || '';
|
||||
|
||||
const textSignature = [
|
||||
valediction,
|
||||
displayName,
|
||||
tagline
|
||||
].filter(Boolean).join('\n');
|
||||
|
||||
const htmlSignature = [
|
||||
valediction ? `<p style="margin: 0;">${escapeHtml(valediction)}</p>` : '',
|
||||
displayName ? `<p style="margin: 0; font-weight: bold;">${escapeHtml(displayName)}</p>` : '',
|
||||
tagline ? `<div style="color: #666; font-size: 12px;">${escapeHtml(tagline)}</div>` : ''
|
||||
].filter(Boolean).join('\n');
|
||||
|
||||
return {
|
||||
text: textSignature,
|
||||
html: htmlSignature
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('Error fetching staff signature:', err);
|
||||
return {
|
||||
text: '',
|
||||
html: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a notification email in the ticket thread (e.g. escalation, high-priority).
|
||||
* @param {Object} ticket - Ticket with gmailThreadId, senderEmail, subject
|
||||
|
||||
Reference in New Issue
Block a user