feat: Ajout serveur transcript

This commit is contained in:
UltraLionFr
2025-08-27 19:01:26 +02:00
parent 3a80bc476e
commit 224f37b374
3 changed files with 15 additions and 8 deletions
+3 -1
View File
@@ -1,3 +1,5 @@
BOT_START_MESSAGE=QuantumCraft Studios - Bot lancé BOT_START_MESSAGE=QuantumCraft Studios - Bot lancé
DISCORD_TOKEN=votre_token_ici DISCORD_TOKEN=votre_token_ici
CLIENT_ID=votre_id_client_ici CLIENT_ID=votre_id_client_ici
TRANSCRIPT_DOMAIN=http://localhost
TRANSCRIPT_PORT=5417
+6 -5
View File
@@ -1,6 +1,7 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const express = require('express'); const express = require('express');
const { config } = require('../../handlers/configLoader');
module.exports = { module.exports = {
name: 'clientReady', name: 'clientReady',
@@ -12,9 +13,7 @@ module.exports = {
app.use('/transcript', express.static(transcriptsPath)); app.use('/transcript', express.static(transcriptsPath));
app.get('/', (req, res) => { app.get('/', (req, res) => {
res.send( res.send('✅ Serveur Transcript actif. Utilise /transcript/:id pour voir un ticket.');
'✅ Serveur Transcript actif. Utilise /transcript/:id pour voir un ticket.'
);
}); });
app.get('/transcript/:id', (req, res) => { app.get('/transcript/:id', (req, res) => {
@@ -27,8 +26,10 @@ module.exports = {
}); });
const PORT = process.env.TRANSCRIPT_PORT || 3000; const PORT = process.env.TRANSCRIPT_PORT || 3000;
const DOMAIN = process.env.TRANSCRIPT_DOMAIN || 'http://localhost';
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`🌐 Serveur Transcript dispo sur http://localhost:${PORT}`); console.log(`🌐 Serveur Transcript dispo sur ${DOMAIN}:${PORT}`);
}); });
}, },
}; };
+6 -2
View File
@@ -110,6 +110,10 @@ async function generateTranscript(channel, user) {
const filePath = path.join(transcriptsDir, `${channel.id}.html`); const filePath = path.join(transcriptsDir, `${channel.id}.html`);
fs.writeFileSync(filePath, html, 'utf8'); 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 // Logs
const logChannel = await channel.client.channels const logChannel = await channel.client.channels
.fetch(config.logsChannel) .fetch(config.logsChannel)
@@ -126,7 +130,7 @@ async function generateTranscript(channel, user) {
}, },
{ {
name: 'Transcript', name: 'Transcript',
value: `http://localhost:3000/transcript/${channel.id}`, value: `${DOMAIN}:${PORT}/transcript/${channel.id}`,
} }
) )
.setColor(0xe74c3c) .setColor(0xe74c3c)
@@ -141,4 +145,4 @@ async function closeTicketWithTranscript(channel, user) {
await channel.delete().catch(() => {}); await channel.delete().catch(() => {});
} }
module.exports = { closeTicketWithTranscript }; module.exports = { closeTicketWithTranscript };