diff --git a/commands/checkperm.js b/commands/checkperm.js new file mode 100644 index 0000000..e7dd892 --- /dev/null +++ b/commands/checkperm.js @@ -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.'); + }, +}; \ No newline at end of file diff --git a/commands/permupdate.js b/commands/permupdate.js new file mode 100644 index 0000000..e436196 --- /dev/null +++ b/commands/permupdate.js @@ -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.'); + }, +}; \ No newline at end of file diff --git a/permissions.json b/permissions.json index 5fbf550..d0c1344 100644 --- a/permissions.json +++ b/permissions.json @@ -1,4 +1,7 @@ { + "2048": 0, + "permupdate": 4, + "dbperm": 4, "clear": 4, "help": 0, "support": 0, @@ -48,8 +51,8 @@ "tempmute": 5, "mutelist": 5, "banlist": 5, - "warn": 5, - "unwarn": 5, + "warn": 3, + "unwarn": 3, "sanction": 5, "kick": 5, "addrole": 5, @@ -95,7 +98,6 @@ "pfc": 0, "vc": 0, "flood": 0, - "2048": 0, "findemoji": 0, "guesspokemon": 0, "slot": 0, @@ -105,5 +107,10 @@ "wordle": 0, "pdefault": 11, "changelog": 0, - "mod": 10 + "mod": 10, + "bunker": 5, + "play": 5, + "set": 5, + "poll": 5, + "userinfo": 5 } \ No newline at end of file