Files
gestion/commands/antiraid/antichannel.js
T
VALOU3336 9bd39c69ca grand commit que tutur attend ( marche pas le raidmode en dev)
sinon il y a pleins de truc comme les anti raid , des coorectif ect
2024-04-22 18:30:33 +02:00

61 lines
2.2 KiB
JavaScript

const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('myDatabase.db');
module.exports = {
name: 'antichannel',
description: 'Gère la protection contre les channel dans le serveur.',
utilisation: 'antichannel <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: `+antichannel 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].antichannel = null;
message.reply(`La protection contre les channel a été désactivée.`);
} else {
data[guildId].antichannel = {
type: type,
action: action
};
message.reply(`La protection contre les channel 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.');
}
});
},
};