mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 23:36:35 +02:00
ajouter gif commande and corrige help and loadCommande
This commit is contained in:
+36
-17
@@ -1,6 +1,6 @@
|
||||
const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
|
||||
const db = require('quick.db');
|
||||
const GestionDb = new db.table("gestion");
|
||||
const sqlite3 = require('sqlite3').verbose();
|
||||
const db = new sqlite3.Database('myDatabase.db');
|
||||
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
@@ -11,22 +11,42 @@ module.exports = {
|
||||
utilisation: 'help [commande]',
|
||||
|
||||
async execute(message, args, client) {
|
||||
const botId = client.user.id;
|
||||
const botInfo = GestionDb.get(botId);
|
||||
const permissions = botInfo.permissions;
|
||||
const botId = client.user.id;
|
||||
const guildId = message.guild.id;
|
||||
const defaultprefix = "+";
|
||||
let mainPrefix = await GestionDb.get(`${botId}.prefix`);
|
||||
let serverPrefix = await GestionDb.get(`${botId}.${guildId}.prefix`);
|
||||
const prefix = serverPrefix !== undefined ? serverPrefix : mainPrefix !== undefined ? mainPrefix : defaultprefix;
|
||||
let data = await new Promise((resolve, reject) => {
|
||||
db.get('SELECT value FROM gestion WHERE id = ?', [botId], (err, row) => {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
reject(err);
|
||||
}
|
||||
resolve(row ? JSON.parse(row.value) : {});
|
||||
});
|
||||
});
|
||||
const permissions = data.permissions || {};
|
||||
const defaultPrefix = "+";
|
||||
let mainPrefix = data.prefixes && data.prefixes.main ? data.prefixes.main : defaultPrefix;
|
||||
let serverPrefix = data.prefixes && data.prefixes[guildId];
|
||||
const prefix = serverPrefix !== undefined ? serverPrefix : mainPrefix;
|
||||
if (args[0]) {
|
||||
const command = client.commands.get(args[0]);
|
||||
if (!command) {
|
||||
return message.reply(`Je n'ai pas trouvé de commande nommée "${args[0]}".`);
|
||||
}
|
||||
|
||||
|
||||
const commandPerm = await permissions[command.name];
|
||||
|
||||
|
||||
let customAliases = [];
|
||||
if (data.alias && data.alias[command.name]) {
|
||||
customAliases = Object.keys(data.alias[command.name]);
|
||||
}
|
||||
|
||||
const allAliases = [...(command.aliases || []), ...customAliases];
|
||||
|
||||
let aliasesField = { name: 'Alias', value: 'Aucun', inline: true };
|
||||
if (allAliases.length > 0) {
|
||||
aliasesField.value = allAliases.map(alias => `\`${alias}\``).join(', ');
|
||||
}
|
||||
|
||||
const embed_command = new EmbedBuilder()
|
||||
.setColor('#0099ff')
|
||||
.setTitle(`Aide pour la commande ${command.emote ? ` ${command.emote}` : '🔧'} ${command.name}`)
|
||||
@@ -34,16 +54,15 @@ module.exports = {
|
||||
.addFields(
|
||||
{ name: 'Utilisation', value: `\`${prefix}${command.utilisation ? `${command.utilisation}` : ''}\``, inline: true },
|
||||
{ name: 'Catégorie', value: command.category || 'Non spécifiée', inline: true },
|
||||
{ name: 'Alias', value: command.aliases ? command.aliases.map(alias => `\`${alias}\``).join(', ') : 'Aucun', inline: true },
|
||||
{ name: 'Permissions', value: `Perm level: ${commandPerm}` || 'Indéfini', inline: true },
|
||||
aliasesField,
|
||||
{ name: 'Permissions', value: commandPerm === 11 ? 'buyer' : commandPerm === 10 ? 'owner' : `Perm level: ${commandPerm}`, inline: true },
|
||||
)
|
||||
.setTimestamp()
|
||||
.setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL({dynamic: true})})
|
||||
|
||||
return message.reply({ embeds: [embed_command] });
|
||||
.setFooter({text: `${client.user.tag} © 2024`, iconURL: client.user.displayAvatarURL({dynamic: true})})
|
||||
|
||||
return message.reply({ embeds: [embed_command] });
|
||||
}
|
||||
|
||||
|
||||
const categories = {
|
||||
antiraid: [],
|
||||
botcontrol: [],
|
||||
|
||||
Reference in New Issue
Block a user