clean files
This commit is contained in:
parent
ee83c3fd94
commit
1ba0d50019
1 changed files with 0 additions and 84 deletions
|
|
@ -1,84 +0,0 @@
|
||||||
import 'dotenv/config';
|
|
||||||
import { Client, GatewayIntentBits, WebhookClient, AuditLogEvent, OAuth2Scopes, Options, Events } from 'discord.js';
|
|
||||||
|
|
||||||
// La variable des détecteurs est déclarée mais pas initialisée (elle le sera dans loadDetectors)
|
|
||||||
let firstDetector;
|
|
||||||
|
|
||||||
// Fonction de chargement asynchrone des modules locaux (pour contourner le blocage d'Alpine)
|
|
||||||
async function loadDetectors() {
|
|
||||||
try {
|
|
||||||
// Import dynamique qui attend la connexion réussie du bot
|
|
||||||
const detectorModule = await import('./detectors/allDetector.js');
|
|
||||||
firstDetector = detectorModule.default;
|
|
||||||
console.log("[STATUS] Détecteurs chargés avec succès. Bot prêt à troller.");
|
|
||||||
} catch (e) {
|
|
||||||
console.error("ALERTE: Impossible de charger les détecteurs locaux ! Vérifiez l'arborescence et 'data/index.js'.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1. CLIENT DÉFINITION
|
|
||||||
const client = new Client({
|
|
||||||
makeCache: Options.cacheWithLimits({
|
|
||||||
MessageManager: 0,
|
|
||||||
}),
|
|
||||||
intents: [
|
|
||||||
GatewayIntentBits.Guilds,
|
|
||||||
GatewayIntentBits.GuildMessages,
|
|
||||||
GatewayIntentBits.MessageContent,
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// -- GESTION DES LOGS GUILD (Non-critique, peut être décommenté) --
|
|
||||||
// client.on('guildCreate', ...
|
|
||||||
// client.on('guildDelete', ...
|
|
||||||
|
|
||||||
// -- 2. DÉMARRAGE & READY --
|
|
||||||
client.on(Events.ClientReady, async () => {
|
|
||||||
console.log(`[SUCCESS] Logged in as ${client.user?.tag}`);
|
|
||||||
console.log('Bot is ready!');
|
|
||||||
|
|
||||||
// DÉMARRAGE DU CHARGEMENT DES MODULES LOURDS APRÈS LA CONNEXION
|
|
||||||
await loadDetectors();
|
|
||||||
});
|
|
||||||
|
|
||||||
// -- 3. GESTION DES MESSAGES (Cœur du bot) --
|
|
||||||
async function handleMessage(message) {
|
|
||||||
// Le bot ne répond pas tant que le chargement dynamique n'est pas terminé
|
|
||||||
if (!firstDetector) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const reply = await firstDetector.createReply(message);
|
|
||||||
if (reply) {
|
|
||||||
await message.reply(reply);
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Erreur dans le détecteur:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client.on('messageCreate', async (message) => {
|
|
||||||
if (message.author.bot) return;
|
|
||||||
await handleMessage(message);
|
|
||||||
});
|
|
||||||
|
|
||||||
client.on('messageUpdate', async (oldMessage, newMessage) => {
|
|
||||||
let message = newMessage;
|
|
||||||
if (message.partial) {
|
|
||||||
try {
|
|
||||||
message = await message.fetch();
|
|
||||||
} catch (e) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!message.author || message.author.bot) return;
|
|
||||||
if (oldMessage.content === message.content) return;
|
|
||||||
|
|
||||||
if (oldMessage.content && oldMessage.content.match(/(\b|^)quoi(\b|$)/i)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
await handleMessage(message);
|
|
||||||
});
|
|
||||||
|
|
||||||
// 4. CONNEXION FINALE
|
|
||||||
client.login(process.env.DISCORD_TOKEN);
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue