correction quel que probleme , wl system , owner system + permssion system

This commit is contained in:
VALOU3336
2024-03-01 21:44:51 +01:00
parent 9fd591093d
commit 2d29003685
8 changed files with 133 additions and 76 deletions
+4 -7
View File
@@ -1,5 +1,6 @@
const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('myDatabase.db');
module.exports = {
name: 'unwl',
aliases: ['unwhitelist'],
@@ -18,7 +19,6 @@ module.exports = {
let data = await getWhitelistData(db, botId);
if (data.whitelist[user.id]) {
delete data.whitelist[user.id];
await updateWhitelist(db, botId, data);
@@ -44,18 +44,15 @@ async function getWhitelistData(db, botId) {
});
}
async function updateWhitelist(db, botId, userId) {
async function updateWhitelist(db, botId, data) {
return new Promise((resolve, reject) => {
db.run('INSERT OR REPLACE INTO gestion (id, value) VALUES (?, ?)', [botId, JSON.stringify({ whitelist: { [userId]: true } })], (err) => {
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();
const data = row ? JSON.parse(row.value) : {};
data.whitelist = data.whitelist || {};
resolve(data);
}
});
});