add : backup , antilick and event for antilink , wiki, and upgrade whitelist system with unique whitelist for guild

This commit is contained in:
VALOU3336
2024-03-02 19:14:45 +01:00
parent bad16d792b
commit 5662934adb
17 changed files with 382 additions and 279 deletions
+36 -5
View File
@@ -12,14 +12,45 @@ module.exports = {
async execute(message, args, client) {
const botId = message.client.user.id;
const guildId = message.guild.id;
db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [botId, JSON.stringify({ whitelist: {} })], (err) => {
let data = await getWhitelistData(db, botId, guildId);
if (data.whitelist[guildId]) {
delete data.whitelist[guildId];
await updateWhitelist(db, botId, data);
message.reply("Toutes la whitelist a été supprimée pour cette guilde.");
} else {
message.reply("Il n'y avait pas de liste blanche à supprimer pour cette guilde.");
}
},
};
async function getWhitelistData(db, botId, guildId) {
return new Promise((resolve, reject) => {
db.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => {
if (err) {
console.error(err.message);
reject(err);
} else {
resolve({ message: 'La liste blanche a été effacée.' });
const data = row ? JSON.parse(row.value) : {};
data.whitelist = data.whitelist || {};
data.whitelist[guildId] = data.whitelist[guildId] || {};
resolve(data);
}
});
message.reply("Toutes la whitelist a etait supprimer")
},
};
});
}
async function updateWhitelist(db, botId, data) {
return new Promise((resolve, reject) => {
const updatedData = JSON.stringify(data);
db.run('UPDATE gestion SET value = ? WHERE id = ?', [updatedData, botId], (err) => {
if (err) {
console.error(err.message);
reject(err);
} else {
resolve();
}
});
});
}