feur fonctionnel

This commit is contained in:
Lou 2025-11-25 20:18:47 +01:00
parent 65e09de7e2
commit f3377cd30c

View file

@ -1,14 +1,14 @@
import 'dotenv/config'; import 'dotenv/config';
import { Client, GatewayIntentBits, Options, Events } from 'discord.js'; import { Client, GatewayIntentBits, Options, Events } from 'discord.js';
// Import statique : si ça plante ici (RAM), tu le sauras tout de suite
import firstDetector from './detectors/allDetector.js'; import firstDetector from './detectors/allDetector.js';
const client = new Client({ const client = new Client({
makeCache: Options.cacheWithLimits({ makeCache: Options.cacheWithLimits({
MessageManager: 0, //opti de RAM MessageManager: 5, // opti de RAM mais 0 est trop agressif
UserManager: 0, ThreadManager: 0, // peut rester a 0 car peu utilisé
GuildMemberManager: 0, // commentées pour laisser par défaut, pas d'impact vu la RAM dispo
ThreadManager: 0, // UserManager: 0,
//ThreadManager: 0,
}), }),
intents: [ intents: [
GatewayIntentBits.Guilds, GatewayIntentBits.Guilds,
@ -17,21 +17,22 @@ const client = new Client({
] ]
}); });
client.on(Events.ClientReady, () => {
console.log(`[SUCCESS] Logged in as ${client.user?.tag}`);
});
client.on('messageCreate', async (message) => { client.on('messageCreate', async (message) => {
// DEBUG : Vérifie si le message arrive bien
console.log(`[DEBUG] Message reçu de ${message.author?.tag}: ${message.content}`);
if (message.author.bot) return; if (message.author.bot) return;
try { try {
const reply = await firstDetector.createReply(message); // Plus besoin de vérifier si firstDetector existe const reply = await firstDetector.createReply(message);
if (reply) await message.reply(reply); if (reply) await message.reply(reply);
} catch (e) { } catch (e) {
console.error('Erreur détecteur:', e); console.error('Erreur détecteur:', e);
} }
}); });
// ... (Reste du code inchangé) client.login(process.env.DISCORD_TOKEN);
client.login(process.env.DISCORD_TOKEN); client.on(Events.ClientReady, () => {
console.log(`[SUCCESS] Logged in as ${client.user?.tag}`); //check co Discord
});