mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-03 15:07:26 +02:00
add rolebutton
This commit is contained in:
@@ -6,7 +6,7 @@ module.exports = {
|
||||
name: 'rolelimit',
|
||||
description: 'Affiche et gère les rôles limités',
|
||||
emote: '🔒',
|
||||
utilisation: '+rolelimit',
|
||||
utilisation: 'rolelimit',
|
||||
category: 'antiraid',
|
||||
|
||||
async execute(interaction) {
|
||||
|
||||
@@ -5,7 +5,7 @@ module.exports = {
|
||||
name: 'autoreact',
|
||||
description: 'Ajoute des réactions automatiques à un salon',
|
||||
emote: '🔄',
|
||||
utilisation: '+autoreact #salon/id <emojie1> <emoite2> ...',
|
||||
utilisation: 'autoreact #salon/id <emojie1> <emoite2> ...',
|
||||
category: 'gestion',
|
||||
async execute(message, args) {
|
||||
if (args[0] === "remove" || args[0] === "del" ){
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
const { EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require('discord.js');
|
||||
|
||||
module.exports = {
|
||||
name: 'rolebutton',
|
||||
description: 'Crée un message avec des boutons pour gérer les rôles',
|
||||
emote: '🎭',
|
||||
utilisation: 'rolebutton #salon/id ',
|
||||
category: 'gestion',
|
||||
async execute(message, args, client) {
|
||||
const channel = message.mentions.channels.first() || message.guild.channels.cache.get(args[0]);
|
||||
if (!channel) {
|
||||
return message.reply('Salon invalide.');
|
||||
}
|
||||
let buttonToRole = {};
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle('Gestion des rôles')
|
||||
.setDescription('Cliquez sur les boutons pour gérer les rôles.');
|
||||
const addButton = new ButtonBuilder()
|
||||
.setCustomId('add_role')
|
||||
.setLabel('Ajouté')
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
|
||||
const removeButton = new ButtonBuilder()
|
||||
.setCustomId('remove_role')
|
||||
.setLabel('Supprime')
|
||||
.setStyle(ButtonStyle.Danger);
|
||||
|
||||
const sendButton = new ButtonBuilder()
|
||||
.setCustomId('send_role')
|
||||
.setLabel('Envoyé')
|
||||
.setStyle(ButtonStyle.Success);
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(addButton, removeButton, sendButton);
|
||||
|
||||
const baseembed = await message.channel.send({ embeds: [embed], components: [row] });
|
||||
|
||||
const filter = i => i.user.id === message.author.id;
|
||||
const filter2 = m => m.author.id === message.author.id;
|
||||
const collector = channel.createMessageComponentCollector({ filter: filter, time: 60000 * 2 });
|
||||
|
||||
collector.on('collect', async i => {
|
||||
if (i.customId === 'add_role') {
|
||||
await i.reply('Veuillez entrer le nom du rôle, l\'émoji, et le nom du bouton pour le bouton. Exemple : roleId notification 📧');
|
||||
|
||||
const collector = i.channel.createMessageCollector({ filter: filter2, max: 1, time: 60000 });
|
||||
collector.on('collect', async m => {
|
||||
const [roleID, buttonName, emoji] = m.content.split(' ');
|
||||
if (!roleID || !buttonName) {
|
||||
return i.followUp('Format invalide. Veuillez entrer le nom du rôle et le nom du bouton séparés par des espaces.');
|
||||
}
|
||||
|
||||
const emojiToUse = emoji || "aucun";
|
||||
|
||||
const role = m.guild.roles.cache.get(roleID);
|
||||
if (!role) {
|
||||
const role = m.guild.roles.cache.find(r => r.name.toLowerCase() === buttonName.toLowerCase());
|
||||
if (!role) {
|
||||
return i.followUp('Rôle invalide. Veuillez entrer un ID de rôle valide ou un nom de rôle existant.');
|
||||
}
|
||||
}
|
||||
const roleExists = Object.values(buttonToRole).some(button => button.roleId === role.id);
|
||||
if (roleExists) {
|
||||
return i.followUp('Le rôle est déjà associé à un bouton.');
|
||||
}
|
||||
buttonToRole[buttonName] = { emoji: emojiToUse, roleId: role.id };
|
||||
|
||||
await m.delete();
|
||||
await i.deleteReply();
|
||||
|
||||
const updatedEmbed = new EmbedBuilder()
|
||||
.setTitle('Gestion des rôles')
|
||||
.setDescription('Cliquez sur les boutons pour gérer les rôles.');
|
||||
|
||||
for (const [buttonName, { emoji, roleId }] of Object.entries(buttonToRole)) {
|
||||
const role = message.guild.roles.cache.get(roleId);
|
||||
const roleName = role ? role.name : 'Rôle non trouvé';
|
||||
updatedEmbed.addFields({name: buttonName, value: `${emoji} ${roleName}`});
|
||||
}
|
||||
|
||||
await i.message.edit({ embeds: [updatedEmbed] });
|
||||
});
|
||||
} else if (i.customId === 'remove_role') {
|
||||
|
||||
await i.reply('Veuillez entrer le nom du rôle à supprimer.');
|
||||
} else if (i.customId === 'send_role') {
|
||||
await i.reply('Veuillez entrer l\'ID du message à mettre à jour.');
|
||||
|
||||
const filter = m => m.author.id === i.user.id;
|
||||
const collector = i.channel.createMessageCollector({ filter: filter, max: 1, time: 60000 });
|
||||
|
||||
collector.on('collect', async m => {
|
||||
const messageId = m.content;
|
||||
try {
|
||||
const messageToUpdate = await channel.messages.fetch(messageId);
|
||||
if(messageToUpdate.author.id !== client.user.id){
|
||||
i.followUp("Le message n'a pas etait envoyer par moi")
|
||||
}
|
||||
|
||||
const buttons = [];
|
||||
for (const [buttonName, { emoji, roleId }] of Object.entries(buttonToRole)) {
|
||||
const button = new ButtonBuilder()
|
||||
.setCustomId(`rolebuttons_${roleId}`)
|
||||
.setLabel(buttonName)
|
||||
.setStyle(ButtonStyle.Primary);
|
||||
if (emoji !== "aucun") {
|
||||
button.setEmoji(emoji);
|
||||
}
|
||||
buttons.push(button);
|
||||
}
|
||||
const actionRow = new ActionRowBuilder().addComponents(buttons);
|
||||
|
||||
await messageToUpdate.edit({ components: [actionRow] });
|
||||
await baseembed.edit({ components : []})
|
||||
await m.delete();
|
||||
await i.deleteReply();
|
||||
await message.channel.send(`Les boutons ont bien été envoyés sur le message. Voici le lien : ${messageToUpdate.url}`);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
await i.followUp('Une erreur est survenue lors de la mise à jour du message.');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: 'Configure les paramètres pour le salon de confession.',
|
||||
category: 'gestion',
|
||||
emote: '🙏',
|
||||
usage: 'confession [channel|send] [channelID|#channel]',
|
||||
utilisation: 'confession [channel|send] [channelID|#channel]',
|
||||
async execute(message, args) {
|
||||
const guildId = message.guild.id;
|
||||
if (!args.length) return message.reply('Veuillez spécifier une sous-commande: channel ou send.');
|
||||
|
||||
@@ -5,7 +5,7 @@ module.exports = {
|
||||
name: 'rvocal',
|
||||
description: 'Enregistre les rôles associés à un salon vocal',
|
||||
emote: '🔊',
|
||||
utilisation: '+rvocal <salon ou id de salon> <role ou id de role>',
|
||||
utilisation: 'rvocal <salon ou id de salon> <role ou id de role>',
|
||||
category: 'gestion',
|
||||
|
||||
async execute(message, args) {
|
||||
|
||||
@@ -4,7 +4,7 @@ module.exports = {
|
||||
description: "Synchronise les permissions d'un salon avec sa catégorie ou synchronise tous les salons d'une catégorie.",
|
||||
category: 'gestion',
|
||||
emote: '🔄',
|
||||
utilisation: '+sync [#salon/id/all]',
|
||||
utilisation: 'sync [#salon/id/all]',
|
||||
async execute(message, args, client) {
|
||||
let channel;
|
||||
if (args[0] === 'all') {
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: 'Active ou désactive l\'alerte.',
|
||||
category: 'gestion',
|
||||
emote: '📢',
|
||||
utilisation: '+alerte <on/off>',
|
||||
utilisation: 'alerte <on/off>',
|
||||
async execute(message, args) {
|
||||
if (!args.length) return message.reply('Veuillez spécifier "on" ou "off".');
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: 'Affiche et configure les logs du serveur.',
|
||||
category: 'gestion',
|
||||
emote: '📝',
|
||||
utilisation: '+logs',
|
||||
utilisation: 'logs',
|
||||
async execute(message, args) {
|
||||
let data = await new Promise((resolve, reject) => {
|
||||
db.get('SELECT value FROM gestion WHERE id = ?', [message.client.user.id], (err, row) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = {
|
||||
description: 'Enregistre l\'ID d\'un salon pour les logs de messages.',
|
||||
category: 'gestion',
|
||||
emote: '📝',
|
||||
utilisation: '+messagelog [#salon/id]',
|
||||
utilisation: 'messagelog [#salon/id]',
|
||||
async execute(message, args, client) {
|
||||
let channelId;
|
||||
const mentionedChannel = message.mentions.channels.first();
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = {
|
||||
description: 'Enregistre l\'ID d\'un salon pour les logs de modération.',
|
||||
category: 'gestion',
|
||||
emote: '📝',
|
||||
utilisation: '+modlog [#salon/id]',
|
||||
utilisation: 'modlog [#salon/id]',
|
||||
async execute(message, args) {
|
||||
let channelId;
|
||||
const mentionedChannel = message.mentions.channels.first();
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: 'Enregistre l\'ID d\'un salon pour les logs de raid.',
|
||||
category: 'gestion',
|
||||
emote: '📝',
|
||||
utilisation: '+raidlog [#salon/id]',
|
||||
utilisation: 'raidlog [#salon/id]',
|
||||
async execute(message, args) {
|
||||
let channelId;
|
||||
const mentionedChannel = message.mentions.channels.first();
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: 'Enregistre le message pour les logs de raid.',
|
||||
category: 'antiraid',
|
||||
emote: '📝',
|
||||
utilisation: '+raidping <message>',
|
||||
utilisation: 'raidping <message>',
|
||||
async execute(message, args) {
|
||||
// Join all elements from args[0] onwards to form the full message
|
||||
const messageContent = args.slice(0).join(' ');
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: 'Enregistre l\'ID d\'un salon pour les logs de rôles.',
|
||||
category: 'gestion',
|
||||
emote: '📝',
|
||||
utilisation: '+rolelog [#salon/id]',
|
||||
utilisation: 'rolelog [#salon/id]',
|
||||
async execute(message, args) {
|
||||
let channelId;
|
||||
const mentionedChannel = message.mentions.channels.first();
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: 'Enregistre l\'ID d\'un salon pour les logs vocaux.',
|
||||
category: 'gestion',
|
||||
emote: '📝',
|
||||
utilisation: '+vocallog [#salon/id]',
|
||||
utilisation: 'vocallog [#salon/id]',
|
||||
async execute(message, args) {
|
||||
let channelId;
|
||||
const mentionedChannel = message.mentions.channels.first();
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
description: "Configure le salon de prison pour le serveur.",
|
||||
category: 'gestion',
|
||||
emote: '🔒',
|
||||
utilisation: '+prison [@user/remove/config] [#channel/@user]',
|
||||
utilisation: 'prison [@user/remove/config] [#channel/@user]',
|
||||
async execute(message, args) {
|
||||
|
||||
if (args[0] === 'config') {
|
||||
|
||||
@@ -3,7 +3,7 @@ module.exports = {
|
||||
description: "Met le salon en mode lent avec un délai spécifié en secondes.",
|
||||
category: 'moderation',
|
||||
emote: '⏳',
|
||||
utilisation: '+slownmode <temps en secondes>',
|
||||
utilisation: 'slownmode <temps en secondes>',
|
||||
async execute(message, args) {
|
||||
|
||||
if (!args[0] || isNaN(args[0])) {
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = {
|
||||
aliases: ['botconfig'],
|
||||
category: 'gestion',
|
||||
emote: '🤖',
|
||||
utilisation: '+botconfig',
|
||||
utilisation: 'botconfig',
|
||||
|
||||
async execute(message, args, client) {
|
||||
const bot = client.user;
|
||||
|
||||
@@ -108,7 +108,7 @@ module.exports = {
|
||||
let description = `Sélectionnez une catégorie parmi les options ci-dessous pour obtenir de l'aide sur les commandes correspondantes.\n Il y a ${totalCommands} commandes disponibles\n\n`;
|
||||
|
||||
for (const [category, commands] of Object.entries(categories)) {
|
||||
description += `**Catégorie ${category}**\n`;
|
||||
description += `**Catégorie ${category}** (${commands.length})\n`;
|
||||
description += commands.length > 0 ? '> ' + commands.map(command => `\`${command.name}\``).join(', ') : '> Aucune commande dans cette catégorie';
|
||||
description += '\n\n';
|
||||
}
|
||||
|
||||
+16
-13
@@ -1,6 +1,12 @@
|
||||
const weather = require('weather');
|
||||
const Weather = require('weather');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
const appID = '';
|
||||
const appCode = '';
|
||||
|
||||
const weather = new Weather({
|
||||
appID,
|
||||
appCode
|
||||
});
|
||||
module.exports = {
|
||||
name: 'weather',
|
||||
description: 'Affiche les informations météorologiques d\'une ville',
|
||||
@@ -8,19 +14,16 @@ module.exports = {
|
||||
emote: '☀️',
|
||||
utilisation: 'weather [ville]',
|
||||
async execute(message, args) {
|
||||
if (!args.length) {
|
||||
return message.channel.send('Veuillez fournir une ville.');
|
||||
if (args.length < 2) {
|
||||
return message.channel.send('Veuillez fournir une ville et un pays.');
|
||||
}
|
||||
|
||||
const city = args.join(' ');
|
||||
const woeid = await weather.find({ search: city, degreeType: 'C' });
|
||||
|
||||
if (!woeid || woeid.length === 0) {
|
||||
return message.channel.send('Ville non trouvée.');
|
||||
}
|
||||
|
||||
const weatherData = await weather.get({ search: woeid[0].title, degreeType: 'C' });
|
||||
|
||||
|
||||
const city = args[0];
|
||||
const country = args[1];
|
||||
|
||||
const weatherData = await weather.now(`${city}, ${country}`).then((results) => {
|
||||
console.log(results);
|
||||
});
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(`🌤️ Météo pour ${weatherData.location.name}`)
|
||||
.setDescription(`Température: ${weatherData.current.temperature}°C`)
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
const {Events } = require("discord.js")
|
||||
|
||||
module.exports = {
|
||||
name: Events.InteractionCreate,
|
||||
async execute(interaction, client) {
|
||||
const botId = client.user.id;
|
||||
const customId = interaction.customId;
|
||||
if (!customId.startsWith('rolebuttons_')) return;
|
||||
|
||||
const roleId = customId.split('_')[1];
|
||||
const role = interaction.guild.roles.cache.get(roleId);
|
||||
|
||||
if (!role) {
|
||||
return;
|
||||
}
|
||||
|
||||
const member = interaction.member;
|
||||
if (!member) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (member.roles.cache.has(role.id)) {
|
||||
await member.roles.remove(role);
|
||||
await interaction.reply({ content: `Le rôle ${role.name} a été retiré.`, ephemeral: true });
|
||||
} else {
|
||||
await member.roles.add(role);
|
||||
await interaction.reply({ content: `Le rôle ${role.name} a été ajouté.`, ephemeral: true });
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user