mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-23 18:04:41 +02:00
add : backup , antilick and event for antilink , wiki, and upgrade whitelist system with unique whitelist for guild
This commit is contained in:
@@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user