mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-13 15:56:36 +02:00
correction quel que probleme , wl system , owner system + permssion system
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user