const fs = require('node:fs'); const deepl = require('deepl-node'); const path = require('node:path'); const deploy = require('./deploy_command.js') const update = require('./displayer.js'); const clean = require('./cleaner.js'); const { Client, GatewayIntentBits, Collection, Events } = require('discord.js'); const client = new Client({ intents: [GatewayIntentBits.GuildMembers,GatewayIntentBits.GuildMessages] }); const args = process.argv; const token = args[2].toString(); const pterodactyl = args[3].toString(); const palworldToken = args[4].toString(); const deeplToken = args[5] ? args[5].toString() : null; // Ajoutez le token DeepL comme 5Γ¨me argument const headers = { "Accept": "application/json", "Content-Type": "application/json", "Authorization": "Bearer "+pterodactyl }; const numbers=["𝟎","𝟏","𝟐","πŸ‘","πŸ’","πŸ“","πŸ”","πŸ•","πŸ–","πŸ—","𝟏𝟎","𝟏𝟏","𝟏𝟐","πŸπŸ‘","πŸπŸ’","πŸπŸ“","πŸπŸ”","πŸπŸ•","πŸπŸ–","πŸπŸ—","𝟐𝟎","𝟐𝟏","𝟐𝟐","πŸπŸ‘","πŸπŸ’","πŸπŸ“","πŸπŸ”","πŸπŸ•","πŸπŸ–","πŸπŸ—","πŸ‘πŸŽ","πŸ‘πŸ","πŸ‘πŸ"]; const translator = deeplToken ? new deepl.Translator(deeplToken) : null; client.commands = new Collection(); const foldersPath = path.join(__dirname, 'commands'); const commandFolders = fs.readdirSync(foldersPath); for (const folder of commandFolders) { const commandsPath = path.join(foldersPath, folder); 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); // Set a new item in the Collection with the key as the command name and the value as the exported module 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.`); } } } client.on('ready', () => { client.user.setPresence({ activities: [{ name: 'Rygain', type: 'WATCHING' }], status: 'online' }); console.log('Bot started !'); deploy(token); }); client.on(Events.InteractionCreate, async interaction => { if (!interaction.isChatInputCommand()) return; const command = interaction.client.commands.get(interaction.commandName); if (!command) { console.error(`No command matching ${interaction.commandName} was found.`); return; } try { if (interaction.commandName === 'server-stats') { await command.execute(interaction, palworldToken); }else{ await command.execute(interaction); } } catch (error) { console.error(error); if (interaction.replied || interaction.deferred) { await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true }); } else { await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true }); } } }); client.on(Events.MessageReactionAdd, async (reaction, user, details) => { // Ignorer les rΓ©actions du bot lui-mΓͺme if (user.bot) return; // VΓ©rifier si c'est l'emoji ❓ if (reaction.emoji.name !== '❓') return; // VΓ©rifier si DeepL est configurΓ© if (!translator) { console.log('DeepL token not provided, translation feature disabled'); return; } try { // RΓ©cupΓ©rer le message complet si nΓ©cessaire if (reaction.partial) { await reaction.fetch(); } if (reaction.message.partial) { await reaction.message.fetch(); } const message = reaction.message; console.log(message); // VΓ©rifier qu'il y a du contenu Γ  traduire if (!message.content || message.content.trim() === '') { return; } // Traduire le message en franΓ§ais const result = await translator.translateText(message.content, null, 'fr'); // CrΓ©er la rΓ©ponse avec la traduction const translationMessage = `πŸ‡«πŸ‡· **Traduction :**\n${result.text}\n\n*Message original de ${message.author.username}*`; // Envoyer la traduction dans le mΓͺme canal await message.reply(translationMessage); } catch (error) { console.error('Erreur lors de la traduction:', error); // Optionnel : notifier l'utilisateur de l'erreur await reaction.message.reply('❌ Erreur lors de la traduction du message.'); } }); client.login(token); setInterval(()=>{update(headers,numbers,client,palworldToken)}, 300000); setInterval(()=>{clean(client)}, 86400000);