mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 15:07:26 +02:00
add prefix changeble with serveur and main prefix configurable
This commit is contained in:
@@ -3,7 +3,7 @@ const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
name: 'leave',
|
||||
description: 'Faire quitter le bot d\`un serveur',
|
||||
description: "Faire quitter le bot un serveur",
|
||||
emote: '🚪',
|
||||
utilisation: 'leave [guildId]',
|
||||
category: 'botcontrol',
|
||||
|
||||
@@ -5,6 +5,9 @@ const GestionDb = new db.table("gestion");
|
||||
module.exports = {
|
||||
name: 'change',
|
||||
description: 'Change le niveau de permission d\'une commande',
|
||||
emote: '🔄',
|
||||
utilisation: 'change <commande> <perm>',
|
||||
category: 'botcontrol',
|
||||
async execute(message, args, client) {
|
||||
const botId = client.user.id;
|
||||
const unchangeableCommands = ['owner', 'unowner','buyer'];
|
||||
|
||||
@@ -4,23 +4,20 @@ 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;
|
||||
// Récupère le niveau de permission/la commande et le rôle
|
||||
const permissionOrCommand = args[0].toLowerCase();
|
||||
const role = message.mentions.roles.first();
|
||||
|
||||
// Vérifie si le rôle est valide
|
||||
if (!role) {
|
||||
return message.reply('Veuillez mentionner un rôle valide.');
|
||||
}
|
||||
|
||||
// Vérifie si c'est un niveau de permission ou une commande
|
||||
if (['1', '2', '3', '4', '5', '6', '7', '8', '9'].includes(permissionOrCommand)) {
|
||||
// C'est un niveau de permission
|
||||
let roleIds = await GestionDb.get(`${botId}.${message.guild.id}.p${permissionOrCommand}`);
|
||||
if (roleIds) {
|
||||
// Si roleIds n'est pas un tableau, le convertir en tableau
|
||||
if (!Array.isArray(roleIds)) {
|
||||
roleIds = [roleIds];
|
||||
}
|
||||
@@ -32,10 +29,8 @@ module.exports = {
|
||||
}
|
||||
message.reply(`Le rôle pour ${permissionOrCommand} a été supprimé.`);
|
||||
} else {
|
||||
// C'est une commande
|
||||
let roleIds = await GestionDb.get(`${botId}.${message.guild.id}.c${permissionOrCommand}`);
|
||||
if (roleIds) {
|
||||
// Si roleIds n'est pas un tableau, le convertir en tableau
|
||||
if (!Array.isArray(roleIds)) {
|
||||
roleIds = [roleIds];
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ const { EmbedBuilder } = require('discord.js');
|
||||
module.exports = {
|
||||
name: 'perm',
|
||||
description: 'Affiche les rôles pour chaque niveau de permission et commande',
|
||||
emote: '🛡️',
|
||||
emote: '🛡️',
|
||||
utilisation: 'perm',
|
||||
category: 'botcontrol',
|
||||
category: 'gestion',
|
||||
async execute(message, client) {
|
||||
const botId = message.client.user.id;
|
||||
const embed = new EmbedBuilder()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
const db = require('quick.db');
|
||||
const GestionDb = new db.table("gestion");
|
||||
|
||||
module.exports = {
|
||||
name: 'prefix',
|
||||
description: 'Change le préfixe du bot ',
|
||||
emote: '🔧',
|
||||
utilisation: 'prefix <newprefix/main>',
|
||||
category: 'botcontrol',
|
||||
async execute(message, args, client) {
|
||||
const botId = client.user.id;
|
||||
const guildId = message.guild.id;
|
||||
|
||||
if (args.length < 1) {
|
||||
return message.reply('Veuillez spécifier un nouveau préfixe.');
|
||||
}
|
||||
if (args[0] === "main") {
|
||||
const newPrefix = args[1];
|
||||
await GestionDb.set(`${botId}.prefix`, newPrefix);
|
||||
message.reply(`Le main préfixe a été changé à ${newPrefix}.`);
|
||||
}else {
|
||||
const newPrefix = args[0];
|
||||
await GestionDb.set(`${botId}.${guildId}.prefix`, newPrefix);
|
||||
message.reply(`Le préfixe a été changé à ${newPrefix}.`);
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -5,7 +5,6 @@ module.exports = {
|
||||
emote: '🔄',
|
||||
utilisation: 'renew',
|
||||
category: 'gestion',
|
||||
|
||||
async execute(message, args, client) {
|
||||
const guild = message.guild;
|
||||
const channel = message.mentions.channels.first() || message.channel;
|
||||
|
||||
@@ -3,24 +3,22 @@ const GestionDb = new db.table("gestion");
|
||||
module.exports = {
|
||||
name: 'setperm',
|
||||
description: 'Définit un rôle pour un niveau de permission ou une commande',
|
||||
emote: '🔑',
|
||||
utilisation: 'setperm <perm/commande> @role',
|
||||
category: 'gestion',
|
||||
async execute(message, args, client) {
|
||||
const botId = message.client.user.id;
|
||||
// Récupère le niveau de permission/la commande et le rôle
|
||||
const permissionOrCommand = args[0].toLowerCase();
|
||||
const role = message.mentions.roles.first();
|
||||
|
||||
// Vérifie si le rôle est valide
|
||||
if (!role) {
|
||||
return message.reply('Veuillez mentionner un rôle valide.');
|
||||
}
|
||||
|
||||
// Vérifie si c'est un niveau de permission ou une commande
|
||||
if (['1', '2', '3', '4', '5', '6', '7', '8', '9'].includes(permissionOrCommand)) {
|
||||
// C'est un niveau de permission
|
||||
for (let i = 1; i <= 9; i++) {
|
||||
let oldRoleIds = await GestionDb.get(`${botId}.${message.guild.id}.p${i}`);
|
||||
if (oldRoleIds) {
|
||||
// Si oldRoleIds n'est pas un tableau, le convertir en tableau
|
||||
if (!Array.isArray(oldRoleIds)) {
|
||||
oldRoleIds = [oldRoleIds];
|
||||
}
|
||||
@@ -41,7 +39,6 @@ module.exports = {
|
||||
await GestionDb.set(`${botId}.${message.guild.id}.p${permissionOrCommand}`, roleIds);
|
||||
message.reply(`La permission ${permissionOrCommand} a été défini sur ${role.name}.`);
|
||||
} else {
|
||||
// C'est une commande
|
||||
if (!client.commands.has(permissionOrCommand)) {
|
||||
return message.reply('Cette commande n\'existe pas.');
|
||||
}
|
||||
|
||||
+11
-3
@@ -1,4 +1,6 @@
|
||||
const { EmbedBuilder, StringSelectMenuBuilder, ActionRowBuilder } = require("discord.js")
|
||||
const db = require('quick.db');
|
||||
const GestionDb = new db.table("gestion");
|
||||
module.exports = {
|
||||
name: 'help',
|
||||
description: 'Affiche la liste des commandes',
|
||||
@@ -6,18 +8,24 @@ module.exports = {
|
||||
emote: '📚',
|
||||
utilisation: 'help [commande]',
|
||||
async execute(message, args, client) {
|
||||
const defaultprefix = "+";
|
||||
const botId = client.user.id;
|
||||
const guildId = message.guild.id;
|
||||
let mainPrefix = await GestionDb.get(`${botId}.prefix`);
|
||||
let serverPrefix = await GestionDb.get(`${botId}.${guildId}.prefix`);
|
||||
const prefix = serverPrefix !== undefined ? serverPrefix : mainPrefix !== undefined ? mainPrefix : defaultprefix;
|
||||
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 embed_command = new EmbedBuilder()
|
||||
.setColor('#0099ff')
|
||||
.setTitle(`Aide pour la commande ${command.emote ? ` ${command.emote}` : '🔧'} ${command.name}`)
|
||||
.setDescription(command.description)
|
||||
.addFields(
|
||||
{ name: 'Utilisation', value: `\`+${command.utilisation ? ` **${command.utilisation}**` : ''}\``, inline: true },
|
||||
{ name: 'Utilisation', value: `\`${prefix}${command.utilisation ? ` **${command.utilisation}**` : ''}\``, inline: true },
|
||||
{ name: 'Catégorie', value: command.category || 'Non spécifiée', inline: true }
|
||||
);
|
||||
|
||||
@@ -59,7 +67,7 @@ module.exports = {
|
||||
for (const [category, commands] of Object.entries(categories)) {
|
||||
let description;
|
||||
if (commands.length > 0) {
|
||||
description = commands.map(command => `${command.emote ? ` ${command.emote}` : '🔧'} **+${command.utilisation ? ` ${command.utilisation}` : ''}**\n \`${command.description}\``).join('\n');
|
||||
description = commands.map(command => `${command.emote ? ` ${command.emote}` : '🔧'} **${prefix}${command.utilisation ? ` ${command.utilisation}` : ''}**\n \`${command.description}\``).join('\n');
|
||||
} else {
|
||||
description = 'Aucune commande dans cette catégorie.';
|
||||
}
|
||||
|
||||
@@ -56,8 +56,11 @@ module.exports = (client) => {
|
||||
const guildId = message.guild.id;
|
||||
const botInfo = GestionDb.get(botId);
|
||||
const permissions = botInfo.permissions;
|
||||
//const prefix = botTokens.coins[botId].prefix;
|
||||
const prefix = '+';
|
||||
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;
|
||||
|
||||
if (!message.content.startsWith(prefix) || message.author.bot) return;
|
||||
|
||||
const args = message.content.slice(prefix.length).trim().split(/ +/);
|
||||
|
||||
Reference in New Issue
Block a user