diff --git a/README.md b/README.md index d3759f0..4741c3d 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Built for game-server hosting support (Indifferent Broccoli), with game detectio --- ## Features - +########### ### Email → Discord - Polls Gmail about every **30 seconds** for new mail. diff --git a/handlers/commands.js b/handlers/commands.js index e2de7f8..719e819 100644 --- a/handlers/commands.js +++ b/handlers/commands.js @@ -149,13 +149,17 @@ async function runEscalation(interaction, ticket, nextTier, reason) { }); if (!isDiscordTicket && ticket.gmailThreadId) { - const emailBody = CONFIG.ESCALATION_MESSAGE.replace(/\{support_name\}/g, CONFIG.SUPPORT_NAME) + (reason ? `\n\nReason: ${reason}` : ''); - await sendTicketNotificationEmail( - ticket, - `Ticket escalated to ${nextTier === 1 ? 'tier 2' : 'tier 3'}`, - emailBody, - interaction.member?.displayName || interaction.user.username - ); + try { + const emailBody = CONFIG.ESCALATION_MESSAGE.replace(/\{support_name\}/g, CONFIG.SUPPORT_NAME) + (reason ? `\n\nReason: ${reason}` : ''); + await sendTicketNotificationEmail( + ticket, + `Ticket escalated to ${nextTier === 1 ? 'tier 2' : 'tier 3'}`, + emailBody, + interaction.member?.displayName || interaction.user.username + ); + } catch (emailErr) { + console.error('Escalation email failed (non-fatal):', emailErr.message); + } } if (nextTier === 2 && ticket.welcomeMessageId) { @@ -1204,4 +1208,4 @@ async function handleAutocomplete(interaction) { } } -module.exports = { handleCommand, handleContextMenu, handleAutocomplete, runEscalation, runDeescalation }; +module.exports = { handleCommand, handleContextMenu, handleAutocomplete, runEscalation, runDeescalation }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 7fb4285..359381c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,8 @@ "express": "^5.2.1", "googleapis": "^171.4.0", "mongodb": "^7.1.0", - "mongoose": "^6.12.0" + "mongoose": "^6.12.0", + "p-queue": "^6.6.2" } }, "node_modules/@aws-crypto/sha256-browser": { @@ -2464,6 +2465,11 @@ "node": ">= 0.6" } }, + "node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==" + }, "node_modules/express": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", @@ -3366,6 +3372,40 @@ "wrappy": "1" } }, + "node_modules/p-finally": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", + "integrity": "sha512-LICb2p9CB7FS+0eR1oqWnHhp0FljGLZCWBE9aix0Uye9W8LTQPwMTYVGWQWIw9RdQiDg4+epXQODwIYJtSJaow==", + "engines": { + "node": ">=4" + } + }, + "node_modules/p-queue": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/p-queue/-/p-queue-6.6.2.tgz", + "integrity": "sha512-RwFpb72c/BhQLEXIZ5K2e+AhgNVmIejGlTgiB9MzZ0e93GRvqZ7uSi0dvRF7/XIXDeNkra2fNHBxTyPDGySpjQ==", + "dependencies": { + "eventemitter3": "^4.0.4", + "p-timeout": "^3.2.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-timeout": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/p-timeout/-/p-timeout-3.2.0.tgz", + "integrity": "sha512-rhIwUycgwwKcP9yTOOFK/AKsAopjjCakVqLHePO3CC6Mir1Z99xT+R63jZxAT5lFZLa2inS5h+ZS2GvR99/FBg==", + "dependencies": { + "p-finally": "^1.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",