const sqlite3 = require('sqlite3').verbose(); const db = new sqlite3.Database('myDatabase.db'); module.exports = { name: 'antiadmin', description: 'Gère la protection contre les actions d\'administrateur dans le serveur.', utilisation: 'antiadmin ', category: 'antiraid', emote: '🛡️', async execute(message, args, client) { const botId = client.user.id; const guildId = message.guild.id; let type = args[0]; let action = args[1]; if (!type || !action || (type !== 'whitelist' && type !== 'wl' && type !== 'owner' && type !== 'buyer' && type !== 'off') || (action !== 'derank' && action !== 'kick' && action !== 'ban' && action !== 'nothing' && action !== 'rien')) { return message.reply('Veuillez utiliser la commande correctement: `+antiadmin whitelist/owner/buyer/off derank/kick/ban/nothing`.'); } if (type === 'wl') { type = 'whitelist'; } if (action === 'rien') { action = 'nothing'; } let data = await new Promise((resolve, reject) => { db.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => { if (err) { console.error(err.message); reject(err); } resolve(row ? JSON.parse(row.value) : {}); }); }); if (!data[guildId]) { data[guildId] = {}; } if (type === 'off') { data[guildId].antiadmin = null; message.reply(`La protection contre les actions d'administrateur a été désactivée.`); } else { data[guildId].antiadmin = { type: type, action: action }; message.reply(`La protection contre les actions d'administrateur a été configurée pour les ${type} avec l'action ${action}.`); } db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [botId, JSON.stringify(data)], function(err) { if (err) { console.error(err.message); return message.reply('Une erreur est survenue lors de la mise à jour de la configuration.'); } }); }, };