mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
58 lines
2.3 KiB
JavaScript
58 lines
2.3 KiB
JavaScript
const db = require('quick.db');
|
|
const GestionDb = new db.table("gestion");
|
|
const { EmbedBuilder } = require('discord.js');
|
|
|
|
module.exports = {
|
|
name: 'perm',
|
|
aliases: ['permissions', 'permissionslist', 'permis', 'perms', 'permlist', 'permliste', 'perml'],
|
|
description: 'Affiche les rôles pour chaque niveau de permission et commande',
|
|
emote: '🛡️',
|
|
utilisation: 'perm',
|
|
category: 'gestion',
|
|
|
|
async execute(message, client) {
|
|
const botId = message.client.user.id;
|
|
const embed = new EmbedBuilder()
|
|
.setTitle('Rôles de permission et de commande')
|
|
.setColor('#0099ff');
|
|
|
|
for (let i = 1; i <= 9; i++) {
|
|
let roleIds = await GestionDb.get(`${botId}.${message.guild.id}.p${i}`);
|
|
let roles = 'Aucun rôle défini';
|
|
if (roleIds) {
|
|
if (!Array.isArray(roleIds)) {
|
|
roleIds = [roleIds];
|
|
}
|
|
roles = roleIds.map(id => `<@&${id}>`).join(', ');
|
|
}
|
|
embed.addFields({ name: `Perm ${i}`, value: roles});
|
|
}
|
|
const commandNames = await GestionDb.get(`${botId}.${message.guild.id}.commandNames`);
|
|
if (commandNames && commandNames.length > 0) {
|
|
// Créez un objet pour regrouper les commandes par rôle
|
|
const commandsByRole = {};
|
|
|
|
for (const commandName of commandNames) {
|
|
const roleIds = await GestionDb.get(`${botId}.${message.guild.id}.c${commandName}`);
|
|
if (roleIds && roleIds.length > 0) {
|
|
for (const roleId of roleIds) {
|
|
if (!commandsByRole[roleId]) {
|
|
commandsByRole[roleId] = [];
|
|
}
|
|
commandsByRole[roleId].push(commandName);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Ajoutez chaque groupe de commandes à l'embed
|
|
for (const roleId in commandsByRole) {
|
|
const role = message.guild.roles.cache.get(roleId);
|
|
const commands = commandsByRole[roleId].join('\n');
|
|
embed.addFields({ name: `${role.name}`,value: commands , inline: true });
|
|
}
|
|
}
|
|
|
|
|
|
message.channel.send({ embeds: [embed] });
|
|
},
|
|
}; |