mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-15 15:56:27 +02:00
add : backup , antilick and event for antilink , wiki, and upgrade whitelist system with unique whitelist for guild
This commit is contained in:
@@ -11,16 +11,17 @@ module.exports = {
|
||||
|
||||
async execute(message, args) {
|
||||
const botId = message.client.user.id;
|
||||
const guildId = message.guild.id;
|
||||
const user = message.mentions.users.first() || (args[0] && message.client.users.cache.get(args[0]));
|
||||
|
||||
if (!user) {
|
||||
return message.channel.send('Veuillez mentionner un utilisateur à retirer de la liste blanche.');
|
||||
}
|
||||
|
||||
let data = await getWhitelistData(db, botId);
|
||||
let data = await getWhitelistData(db, botId, guildId);
|
||||
|
||||
if (data.whitelist[user.id]) {
|
||||
delete data.whitelist[user.id];
|
||||
if (data.whitelist[guildId] && data.whitelist[guildId][user.id]) {
|
||||
delete data.whitelist[guildId][user.id];
|
||||
await updateWhitelist(db, botId, data);
|
||||
message.channel.send('Utilisateur retiré de la liste blanche.');
|
||||
} else {
|
||||
@@ -29,7 +30,7 @@ module.exports = {
|
||||
},
|
||||
};
|
||||
|
||||
async function getWhitelistData(db, botId) {
|
||||
async function getWhitelistData(db, botId, guildId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => {
|
||||
if (err) {
|
||||
@@ -37,7 +38,8 @@ async function getWhitelistData(db, botId) {
|
||||
reject(err);
|
||||
} else {
|
||||
const data = row ? JSON.parse(row.value) : {};
|
||||
data.whitelist = data.whitelist || {};
|
||||
data.whitelist = data.whitelist || {};
|
||||
data.whitelist[guildId] = data.whitelist[guildId] || {};
|
||||
resolve(data);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user