implement fun facts
This commit is contained in:
parent
a8fa55d5d0
commit
2962784d70
6 changed files with 96 additions and 10 deletions
48
index.js
48
index.js
|
|
@ -1,26 +1,56 @@
|
|||
import 'dotenv/config';
|
||||
import { Client, GatewayIntentBits, Options, Events } from 'discord.js';
|
||||
import fs from 'fs';
|
||||
import { Client, GatewayIntentBits, Options, Events, Collection } from 'discord.js';
|
||||
import firstDetector from './detectors/allDetector.js';
|
||||
|
||||
|
||||
// --- Configuration Client et Intents ---
|
||||
const client = new Client({
|
||||
makeCache: Options.cacheWithLimits({
|
||||
MessageManager: 5, // opti de RAM mais 0 est trop agressif
|
||||
ThreadManager: 0, // peut rester a 0 car peu utilisé
|
||||
// commentées pour laisser par défaut, pas d'impact vu la RAM dispo
|
||||
// UserManager: 0,
|
||||
//ThreadManager: 0,
|
||||
// commentées pour laisser par défaut, pas d'impact vu la RAM dispo
|
||||
|
||||
}),
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.MessageContent, // required pour les détecteurs
|
||||
]
|
||||
});
|
||||
|
||||
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}`);
|
||||
// --- Gestion des Événements ---
|
||||
|
||||
// 1. login réussi
|
||||
client.on(Events.ClientReady, () => {
|
||||
console.log(`[SUCCESS] Logged in as ${client.user?.tag}`);
|
||||
});
|
||||
|
||||
// 2. gestion des commandes slash
|
||||
client.on(Events.InteractionCreate, async interaction => {
|
||||
// check que ça soit bien commande slash
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
const command = client.commands.get(interaction.commandName);
|
||||
if (!command) return;
|
||||
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error('Erreur exécution commande slash:', error);
|
||||
// message d'erreur (si besoin), montré qu'à l'auteur
|
||||
if (interaction.replied || interaction.deferred) {
|
||||
await interaction.followUp({ content: 'Erreur lors de l’exécution de la commande !', ephemeral: true });
|
||||
} else {
|
||||
await interaction.reply({ content: 'Erreur lors de l’exécution de la commande !', ephemeral: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 3. Gestion des Messages (Détecteurs Passifs)
|
||||
client.on('messageCreate', async (message) => {
|
||||
if (message.author.bot) return;
|
||||
|
||||
try {
|
||||
|
|
@ -31,8 +61,6 @@ client.on('messageCreate', async (message) => {
|
|||
}
|
||||
});
|
||||
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
|
||||
client.on(Events.ClientReady, () => {
|
||||
console.log(`[SUCCESS] Logged in as ${client.user?.tag}`); //check co Discord
|
||||
});
|
||||
// --- connexion ---
|
||||
client.login(process.env.DISCORD_TOKEN);
|
||||
Loading…
Add table
Add a link
Reference in a new issue