mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-06 06:10:39 +02:00
46 lines
1.9 KiB
JavaScript
46 lines
1.9 KiB
JavaScript
const db = require('quick.db');
|
|
const GestionDb = new db.table("gestion");
|
|
|
|
module.exports = {
|
|
name: 'delperm',
|
|
description: 'Supprime un rôle d\'un niveau de permission ou d\'une commande',
|
|
emote: '❌',
|
|
utilisation: 'delperm <perm/commande> @role',
|
|
category: 'gestion',
|
|
async execute(message, args, client) {
|
|
const botId = client.user.id;
|
|
const permissionOrCommand = args[0].toLowerCase();
|
|
const role = message.mentions.roles.first();
|
|
|
|
if (!role) {
|
|
return message.reply('Veuillez mentionner un rôle valide.');
|
|
}
|
|
if (['1', '2', '3', '4', '5', '6', '7', '8', '9'].includes(permissionOrCommand)) {
|
|
let roleIds = await GestionDb.get(`${botId}.${message.guild.id}.p${permissionOrCommand}`);
|
|
if (roleIds) {
|
|
if (!Array.isArray(roleIds)) {
|
|
roleIds = [roleIds];
|
|
}
|
|
const index = roleIds.indexOf(role.id);
|
|
if (index !== -1) {
|
|
roleIds.splice(index, 1);
|
|
await GestionDb.set(`${botId}.${message.guild.id}.p${permissionOrCommand}`, roleIds);
|
|
}
|
|
}
|
|
message.reply(`Le rôle pour ${permissionOrCommand} a été supprimé.`);
|
|
} else {
|
|
let roleIds = await GestionDb.get(`${botId}.${message.guild.id}.c${permissionOrCommand}`);
|
|
if (roleIds) {
|
|
if (!Array.isArray(roleIds)) {
|
|
roleIds = [roleIds];
|
|
}
|
|
const index = roleIds.indexOf(role.id);
|
|
if (index !== -1) {
|
|
roleIds.splice(index, 1);
|
|
await GestionDb.set(`${botId}.${message.guild.id}.c${permissionOrCommand}`, roleIds);
|
|
}
|
|
}
|
|
message.reply(`L commande ${permissionOrCommand} a été supprimé du role.`);
|
|
}
|
|
},
|
|
}; |