mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 15:07:26 +02:00
add util commande
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'channel',
|
||||
description: 'Affiche les informations sur un salon',
|
||||
async execute(message) {
|
||||
const channel = message.mentions.channels.first() || message.channel;
|
||||
|
||||
if (!channel || !channel.viewable) {
|
||||
return message.reply('Je ne peux pas accéder à ce salon.');
|
||||
}
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`Informations sur le salon **${channel.name}**`)
|
||||
.addFields(
|
||||
{ name: '**Nom**', value: `<#${channel.id}>`, inline: true },
|
||||
{ name: '**ID**', value: channel.id, inline: true },
|
||||
{ name: '**NSFW**', value: channel.nsfw ? '✅' : '❌', inline: true },
|
||||
{ name: '**Mode Lent**', value: channel.rateLimitPerUser ? `${channel.rateLimitPerUser} secondes` : '❌', inline: true },
|
||||
{ name: '**Créé le**', value: `<t:${Math.floor(channel.createdTimestamp / 1000)}:F>`, inline: true }
|
||||
)
|
||||
.setColor('#0099ff');
|
||||
|
||||
message.channel.send({ embeds: [embed] });
|
||||
},
|
||||
};
|
||||
@@ -8,9 +8,9 @@ module.exports = {
|
||||
emote: '📚',
|
||||
utilisation: 'help [commande]',
|
||||
async execute(message, args, client) {
|
||||
const defaultprefix = "+";
|
||||
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;
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
const { EmbedBuilder , ButtonBuilder, ButtonStyle, ActionRowBuilder } = require('discord.js');
|
||||
const db = require('quick.db');
|
||||
const GestionDb = new db.table("gestion");
|
||||
|
||||
module.exports = {
|
||||
name: 'helpall',
|
||||
description: 'Liste toutes les commandes disponibles par niveau de permission',
|
||||
async execute(message, args, client) {
|
||||
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;
|
||||
|
||||
const permissions = GestionDb.get(`${botId}.permissions`);
|
||||
|
||||
const commandsByPermission = {};
|
||||
for (const [commandName, permissionLevel] of Object.entries(permissions)) {
|
||||
if (!commandsByPermission[permissionLevel]) {
|
||||
commandsByPermission[permissionLevel] = [];
|
||||
}
|
||||
commandsByPermission[permissionLevel].push(commandName);
|
||||
}
|
||||
|
||||
const embeds = Object.entries(commandsByPermission).sort(([a], [b]) => a - b).map(([permissionLevel, commands]) => {
|
||||
const commandDescriptions = commands.map(commandName => {
|
||||
const command = client.commands.get(commandName);
|
||||
if (!command) {
|
||||
return null;
|
||||
}
|
||||
return `**${prefix}${commandName}**\n\`${command.description}\``;
|
||||
}).filter(Boolean);
|
||||
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`Commandes de niveau de permission ${permissionLevel === '10' ? 'Owner' : permissionLevel === '11' ? 'Buyer' : permissionLevel}`)
|
||||
.setColor('#0099ff');
|
||||
|
||||
if (commandDescriptions.length > 0) {
|
||||
embed.setDescription(commandDescriptions.join('\n'));
|
||||
} else {
|
||||
embed.setDescription('Aucune commande disponible pour ce niveau de permission.');
|
||||
}
|
||||
return embed;
|
||||
});
|
||||
const backButton = new ButtonBuilder()
|
||||
.setCustomId('back')
|
||||
.setLabel('⬅️')
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
const nextButton = new ButtonBuilder()
|
||||
.setCustomId('next')
|
||||
.setLabel('➡️')
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
// Create the action row with the buttons
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(backButton, nextButton);
|
||||
const msg = await message.channel.send({ embeds: [embeds[0]], components: [row] });
|
||||
|
||||
|
||||
const collector = msg.createMessageComponentCollector({
|
||||
filter: (interaction) => interaction.isButton() && interaction.user.id === message.author.id,
|
||||
time: 60000
|
||||
});
|
||||
|
||||
|
||||
let currentPage = 0;
|
||||
collector.on('collect', async (interaction) => {
|
||||
// Acknowledge the interaction
|
||||
await interaction.deferUpdate();
|
||||
|
||||
if (!interaction.isButton()) return;
|
||||
|
||||
if (interaction.customId === 'back') {
|
||||
currentPage = currentPage > 0 ? --currentPage : embeds.length - 1;
|
||||
} else if (interaction.customId === 'next') {
|
||||
currentPage = currentPage + 1 < embeds.length ? ++currentPage : 0;
|
||||
}
|
||||
|
||||
// Update the message with the new embed and the action row with buttons
|
||||
await msg.edit({ embeds: [embeds[currentPage]], components: [row] });
|
||||
});
|
||||
|
||||
|
||||
collector.on('end', () => msg.edit({ embeds: [embeds[currentPage]], components: [] }));
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
const { EmbedBuilder, PermissionsBitField } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'roleinfo',
|
||||
description: 'Affiche les informations sur un rôle',
|
||||
async execute(message, args) {
|
||||
if (args.length === 0) {
|
||||
return message.reply('Veuillez mentionner un rôle.');
|
||||
}
|
||||
|
||||
const role = message.mentions.roles.first();
|
||||
if (!role) {
|
||||
return message.reply('Veuillez mentionner un rôle valide.');
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`Informations sur le rôle ${role.name}`)
|
||||
.addFields(
|
||||
{ name: 'ID', value: role.id, inline: true },
|
||||
{ name: 'Nom', value: role.name, inline: true },
|
||||
{ name: 'Couleur', value: role.hexColor, inline: true },
|
||||
{ name: 'Membres', value: role.members.size.toString(), inline: true },
|
||||
{ name: 'Position', value: role.position.toString(), inline: true },
|
||||
{ name: 'Mentionnable', value: role.mentionable ? 'Oui' : 'Non', inline: true },
|
||||
{ name: 'Géré par une intégration', value: role.managed ? 'Oui' : 'Non', inline: true }
|
||||
)
|
||||
.setColor(role.hexColor);
|
||||
|
||||
if (role.permissions.has(PermissionsBitField.Flags.Administrator)) {
|
||||
embed.addFields({ name: 'Permissions', value: 'Administrateur', inline: true });
|
||||
} else {
|
||||
const permissions = role.permissions.toArray();
|
||||
if (permissions.length > 0) {
|
||||
embed.addFields({ name: 'Permissions', value: permissions.join(', '), inline: true });
|
||||
}
|
||||
}
|
||||
|
||||
message.channel.send({ embeds: [embed] });
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user