Update
This commit is contained in:
52
index.js
52
index.js
@@ -8,19 +8,19 @@ const chalk = require('chalk');
|
||||
const token = process.env.TOKEN;
|
||||
|
||||
if (!token) {
|
||||
console.error(chalk.red('❌ Le token Discord n\'est pas défini dans les variables d\'environnement !'));
|
||||
process.exit(1);
|
||||
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,
|
||||
],
|
||||
intents: [
|
||||
GatewayIntentBits.Guilds,
|
||||
GatewayIntentBits.GuildMembers,
|
||||
GatewayIntentBits.GuildPresences,
|
||||
GatewayIntentBits.GuildMessages,
|
||||
GatewayIntentBits.MessageContent,
|
||||
GatewayIntentBits.GuildVoiceStates,
|
||||
],
|
||||
});
|
||||
|
||||
const db = require('./functions/database/db.js');
|
||||
@@ -40,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.warn(chalk.yellow(`⚠️ La commande à ${filePath} manque une propriété requise "data" ou "execute".`));
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,15 +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).catch(err => {
|
||||
console.error(chalk.red('❌ Erreur lors de la connexion:'), err);
|
||||
process.exit(1);
|
||||
console.error(chalk.red('❌ Erreur lors de la connexion:'), err);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user