Update Bot (j'ai plus le repo sur GitHub)

Qui c'est la conne qui a delete le repo sur GitHub? C'EST MOIIIII
This commit is contained in:
2026-02-09 14:36:26 +01:00
parent eab4419e12
commit ad2014b7b2
586 changed files with 58986 additions and 25205 deletions

View File

@@ -3,13 +3,33 @@ require('dotenv').config();
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const token = process.env.TOKEN;
const chalk = require('chalk');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
const token = process.env.TOKEN;
const db = require ('./functions/database/db.js');
if (!token) {
console.error(chalk.red('❌ Le token Discord n\'est pas défini dans les variables d\'environnement !'));
process.exit(1);
}
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
],
});
const db = require('./functions/database/db.js');
const autoUnban = require('./functions/moderation/autoUnban.js');
const autoUnmute = require('./functions/moderation/autoUnmute.js');
const bumpReminder = require('./functions/bump/bumpReminder.js');
autoUnban(client, db);
autoUnmute(client, db);
bumpReminder(client, db);
client.commands = new Collection();
const foldersPath = path.join(__dirname, 'commands');
@@ -20,11 +40,15 @@ for (const folder of commandFolders) {
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
try {
const command = require(filePath);
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
} else {
console.warn(chalk.yellow(`⚠️ La commande à ${filePath} manque une propriété requise "data" ou "execute".`));
}
} catch (error) {
console.error(chalk.red(`❌ Erreur lors du chargement de la commande à ${filePath}:`), error);
}
}
}
@@ -34,12 +58,19 @@ const eventFiles = fs.readdirSync(eventsPath).filter(file => file.endsWith('.js'
for (const file of eventFiles) {
const filePath = path.join(eventsPath, file);
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
try {
const event = require(filePath);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
} catch (error) {
console.error(chalk.red(`❌ Erreur lors du chargement de l'événement à ${filePath}:`), error);
}
}
client.login(token);
client.login(token).catch(err => {
console.error(chalk.red('❌ Erreur lors de la connexion:'), err);
process.exit(1);
});