mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
9bd39c69ca
sinon il y a pleins de truc comme les anti raid , des coorectif ect
60 lines
2.2 KiB
JavaScript
60 lines
2.2 KiB
JavaScript
const sqlite3 = require('sqlite3').verbose();
|
|
const db = new sqlite3.Database('myDatabase.db');
|
|
|
|
module.exports = {
|
|
name: 'antirole',
|
|
description: 'Gère la protection contre les rôles dans le serveur.',
|
|
utilisation: 'antirole <type> <action>',
|
|
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: `+antirole 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].antirole = null;
|
|
message.reply(`La protection contre les rôles a été désactivée.`);
|
|
} else {
|
|
data[guildId].antirole = {
|
|
type: type,
|
|
action: action
|
|
};
|
|
message.reply(`La protection contre les rôles 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.');
|
|
}
|
|
});
|
|
},
|
|
}; |