mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-06 14:20:38 +02:00
grand commit que tutur attend ( marche pas le raidmode en dev)
sinon il y a pleins de truc comme les anti raid , des coorectif ect
This commit is contained in:
+32
-16
@@ -1,6 +1,7 @@
|
||||
const { EmbedBuilder , ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
const db = new sqlite3.Database('myDatabase.db');
|
||||
const { getPermissionLevel } = require('../../fonction/getPermissionLevel');
|
||||
module.exports = {
|
||||
name: 'helpall',
|
||||
description: 'Liste toutes les commandes disponibles par niveau de permission',
|
||||
@@ -35,27 +36,43 @@ try {
|
||||
commandsByPermission[permissionLevel].push(commandName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const embeds = Object.entries(commandsByPermission).map(([permissionLevel, commands]) => {
|
||||
const commandDescriptions = commands.map(commandName => {
|
||||
const command = client.commands.get(commandName);
|
||||
if (!command) {
|
||||
if (!command || permissions[command.name] === "off") {
|
||||
return null;
|
||||
}
|
||||
return `**${prefix}${commandName}**\n\`${command.description}\``;
|
||||
return `* \`${prefix}${command.utilisation}\``;
|
||||
}).filter(Boolean);
|
||||
|
||||
if (commandDescriptions.length === 0) {
|
||||
return null;
|
||||
if (commandDescriptions.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`Commandes de niveau de permission ${permissionLevel}`)
|
||||
.setColor('#0099ff');
|
||||
const embedsForPermissionLevel = [];
|
||||
let currentEmbedDescription = '';
|
||||
commandDescriptions.forEach(description => {
|
||||
if ((currentEmbedDescription + description).length <= 4096) {
|
||||
currentEmbedDescription += description + '\n';
|
||||
} else {
|
||||
embedsForPermissionLevel.push(currentEmbedDescription);
|
||||
currentEmbedDescription = description + '\n';
|
||||
}
|
||||
});
|
||||
if (currentEmbedDescription) {
|
||||
embedsForPermissionLevel.push(currentEmbedDescription);
|
||||
}
|
||||
|
||||
embed.setDescription(commandDescriptions.join('\n'));
|
||||
return embed;
|
||||
}).filter(Boolean)
|
||||
return embedsForPermissionLevel.map(description => {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`Commandes de niveau de permission ${permissionLevel === '0' ? "public" : permissionLevel === '10' ? "owner" : permissionLevel === '11' ? "buyer" : permissionLevel}`)
|
||||
.setColor('#0099ff');
|
||||
embed.setDescription(description);
|
||||
embed.permissionLevel = permissionLevel
|
||||
return embed;
|
||||
});
|
||||
}).flat().filter(Boolean);
|
||||
|
||||
if (embeds.length === 0) {
|
||||
return message.reply("Aucune commande disponible pour ce serveur.");
|
||||
@@ -81,22 +98,21 @@ try {
|
||||
filter: (interaction) => interaction.isButton() && interaction.user.id === message.author.id,
|
||||
time: 60000
|
||||
});
|
||||
|
||||
const userPermissionLevel = await getPermissionLevel(message.member, client);
|
||||
let currentPage = 0;
|
||||
collector.on('collect', async (interaction) => {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
if (interaction.customId === 'back') {
|
||||
currentPage = currentPage > 0 ? --currentPage : embeds.length - 1;
|
||||
currentPage = currentPage > 0 ? --currentPage : 0;
|
||||
} else if (interaction.customId === 'next') {
|
||||
currentPage = currentPage + 1 < embeds.length ? ++currentPage : 0;
|
||||
currentPage = currentPage + 1 < embeds.length && embeds[currentPage + 1].permissionLevel <= userPermissionLevel ? ++currentPage : 0;
|
||||
}
|
||||
|
||||
await msg.edit({ embeds: [embeds[currentPage]], components: [row] });
|
||||
});
|
||||
|
||||
collector.on('end', () => msg.edit({ embeds: [embeds[currentPage]], components: [] }));
|
||||
}catch (error) {
|
||||
console.log(error);
|
||||
return message.reply("Veuillez changer des commandes de permission pour avoir accès au helpall.");
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user