From 224f37b3743927a0a726c9f75b6976507a902dca Mon Sep 17 00:00:00 2001 From: UltraLionFr Date: Wed, 27 Aug 2025 19:01:26 +0200 Subject: [PATCH] feat: Ajout serveur transcript --- .env.example | 4 +++- events/clients/transcript-server.js | 11 ++++++----- handlers/ticketCloser.js | 8 ++++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index 950cb8f..7867fcb 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,5 @@ BOT_START_MESSAGE=QuantumCraft Studios - Bot lancΓ© DISCORD_TOKEN=votre_token_ici -CLIENT_ID=votre_id_client_ici \ No newline at end of file +CLIENT_ID=votre_id_client_ici +TRANSCRIPT_DOMAIN=http://localhost +TRANSCRIPT_PORT=5417 \ No newline at end of file diff --git a/events/clients/transcript-server.js b/events/clients/transcript-server.js index ad5b788..30fd428 100644 --- a/events/clients/transcript-server.js +++ b/events/clients/transcript-server.js @@ -1,6 +1,7 @@ const fs = require('fs'); const path = require('path'); const express = require('express'); +const { config } = require('../../handlers/configLoader'); module.exports = { name: 'clientReady', @@ -12,9 +13,7 @@ module.exports = { app.use('/transcript', express.static(transcriptsPath)); app.get('/', (req, res) => { - res.send( - 'βœ… Serveur Transcript actif. Utilise /transcript/:id pour voir un ticket.' - ); + res.send('βœ… Serveur Transcript actif. Utilise /transcript/:id pour voir un ticket.'); }); app.get('/transcript/:id', (req, res) => { @@ -27,8 +26,10 @@ module.exports = { }); const PORT = process.env.TRANSCRIPT_PORT || 3000; + const DOMAIN = process.env.TRANSCRIPT_DOMAIN || 'http://localhost'; + app.listen(PORT, () => { - console.log(`🌐 Serveur Transcript dispo sur http://localhost:${PORT}`); + console.log(`🌐 Serveur Transcript dispo sur ${DOMAIN}:${PORT}`); }); }, -}; +}; \ No newline at end of file diff --git a/handlers/ticketCloser.js b/handlers/ticketCloser.js index afbc1b3..0390b01 100644 --- a/handlers/ticketCloser.js +++ b/handlers/ticketCloser.js @@ -110,6 +110,10 @@ async function generateTranscript(channel, user) { const filePath = path.join(transcriptsDir, `${channel.id}.html`); fs.writeFileSync(filePath, html, 'utf8'); + // === Lecture domaine/port depuis .env === + const DOMAIN = process.env.TRANSCRIPT_DOMAIN || 'http://localhost'; + const PORT = process.env.TRANSCRIPT_PORT || 3000; + // Logs const logChannel = await channel.client.channels .fetch(config.logsChannel) @@ -126,7 +130,7 @@ async function generateTranscript(channel, user) { }, { name: 'Transcript', - value: `http://localhost:3000/transcript/${channel.id}`, + value: `${DOMAIN}:${PORT}/transcript/${channel.id}`, } ) .setColor(0xe74c3c) @@ -141,4 +145,4 @@ async function closeTicketWithTranscript(channel, user) { await channel.delete().catch(() => {}); } -module.exports = { closeTicketWithTranscript }; +module.exports = { closeTicketWithTranscript }; \ No newline at end of file