mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-10 19:04:21 +02:00
addc permiision update
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
const db = require('quick.db');
|
||||
const GestionDb = new db.table("gestion");
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
name: 'dbperm',
|
||||
description: 'Mettre à jour les permissions par défaut dans la base de données',
|
||||
async execute(message, args, client) {
|
||||
const botId = message.client.user.id;
|
||||
|
||||
const permissionsPath = path.resolve(__dirname, '../permissions.json');
|
||||
|
||||
const permissionsJson = JSON.parse(fs.readFileSync(permissionsPath));
|
||||
|
||||
const currentPermissions = GestionDb.get(`${botId}.permissions`) || {};
|
||||
|
||||
for (const command in permissionsJson) {
|
||||
if (!currentPermissions.hasOwnProperty(command)) {
|
||||
GestionDb.set(`${botId}.permissions.${command}`, permissionsJson[command]);
|
||||
}
|
||||
}
|
||||
|
||||
message.reply('Les permissions ont été mises à jour avec succès.');
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const db = require('quick.db');
|
||||
const GestionDb = new db.table("gestion");
|
||||
|
||||
module.exports = {
|
||||
name: 'permupdate',
|
||||
description: 'Mettre à jour les permissions dans le fichier permissions.json',
|
||||
async execute(message, args, client) {
|
||||
const commands = Array.from(client.commands.keys());
|
||||
const permissionsPath = path.resolve(__dirname, '../permissions.json');
|
||||
const permissionsJson = JSON.parse(fs.readFileSync(permissionsPath));
|
||||
|
||||
commands.forEach(command => {
|
||||
if (!permissionsJson.hasOwnProperty(command)) {
|
||||
permissionsJson[command] = 5;
|
||||
}
|
||||
});
|
||||
|
||||
fs.writeFileSync(permissionsPath, JSON.stringify(permissionsJson, null, 2));
|
||||
|
||||
message.reply('Les permissions ont été mises à jour avec succès.');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user