-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
812 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// commands/moderation/autorole.js | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { PermissionsBitField } = require('discord.js'); | ||
const configPath = path.join(__dirname, '../../config.json'); | ||
|
||
module.exports = { | ||
name: 'autorole', | ||
description: 'Configure un rôle à attribuer automatiquement aux nouveaux membres.', | ||
async execute(message, args) { | ||
// Vérifier si l'utilisateur a les permissions nécessaires | ||
if (!message.member.permissions.has(PermissionsBitField.Flags.Administrator)) { | ||
return message.reply({ content: 'Tu n\'as pas la permission de configurer l\'autorole.', ephemeral: true }); | ||
} | ||
|
||
// Vérifier si un rôle est mentionné | ||
const role = message.mentions.roles.first(); | ||
if (!role) { | ||
return message.reply({ content: 'Tu dois mentionner le rôle à attribuer.', ephemeral: true }); | ||
} | ||
|
||
// Mettre à jour la configuration | ||
let config; | ||
try { | ||
config = JSON.parse(fs.readFileSync(configPath, 'utf-8')); | ||
} catch (error) { | ||
console.error('Erreur lors de la lecture de la configuration:', error); | ||
return message.reply({ content: 'Erreur lors de la lecture de la configuration.', ephemeral: true }); | ||
} | ||
|
||
config.autoRole = role.id; | ||
|
||
try { | ||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8'); | ||
} catch (error) { | ||
console.error('Erreur lors de la sauvegarde de la configuration:', error); | ||
return message.reply({ content: 'Erreur lors de la sauvegarde de la configuration.', ephemeral: true }); | ||
} | ||
|
||
// Envoyer un message de confirmation | ||
return message.reply({ content: `Le rôle ${role.name} sera attribué automatiquement aux nouveaux membres.`, ephemeral: true }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// commands/moderation/config_bienvenue.js | ||
|
||
const { EmbedBuilder, PermissionsBitField } = require('discord.js'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const configPath = path.join(__dirname, '../../config.json'); // Assurez-vous que le chemin est correct | ||
|
||
module.exports = { | ||
name: 'config_bienvenue', | ||
description: 'Configure le salon pour envoyer un message de bienvenue.', | ||
async execute(message, args) { | ||
// Vérifier si l'utilisateur a les permissions nécessaires | ||
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageChannels)) { | ||
return message.reply({ content: 'Vous n\'avez pas la permission de gérer les salons.', ephemeral: true }); | ||
} | ||
|
||
// Vérifier si un ID de salon est fourni | ||
if (args.length === 0) { | ||
return message.reply({ content: 'Veuillez fournir l\'ID du salon où le message de bienvenue sera envoyé.', ephemeral: true }); | ||
} | ||
|
||
const channelId = args[0]; | ||
const channel = message.guild.channels.cache.get(channelId); | ||
|
||
if (!channel || !channel.isTextBased()) { | ||
return message.reply({ content: 'ID de salon invalide ou le salon n\'est pas un salon textuel.', ephemeral: true }); | ||
} | ||
|
||
// Mettre à jour la configuration | ||
let config; | ||
try { | ||
config = JSON.parse(fs.readFileSync(configPath, 'utf-8')); | ||
} catch (error) { | ||
console.error('Erreur lors de la lecture de la configuration:', error); | ||
return message.reply({ content: 'Erreur lors de la lecture de la configuration.', ephemeral: true }); | ||
} | ||
|
||
config.welcomeChannel = channelId; | ||
|
||
try { | ||
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8'); | ||
} catch (error) { | ||
console.error('Erreur lors de la sauvegarde de la configuration:', error); | ||
return message.reply({ content: 'Erreur lors de la sauvegarde de la configuration.', ephemeral: true }); | ||
} | ||
|
||
// Envoyer un message de confirmation | ||
const confirmationEmbed = new EmbedBuilder() | ||
.setColor('#0099ff') | ||
.setTitle('Configuration du Salon de Bienvenue') | ||
.setDescription(`Le salon de bienvenue a été configuré avec succès : <#${channelId}>`) | ||
.setTimestamp(); | ||
|
||
await message.reply({ embeds: [confirmationEmbed], ephemeral: true }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
const { EmbedBuilder } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: 'help', | ||
description: 'Affiche une liste des commandes disponibles ou des détails sur une commande spécifique.', | ||
async execute(message, args) { | ||
const { commands } = message.client; | ||
|
||
// Si un argument est fourni, affiche les détails de cette commande | ||
const commandName = args[0]; | ||
if (commandName) { | ||
const command = commands.get(commandName); | ||
if (!command) { | ||
return message.reply('Cette commande n\'existe pas.'); | ||
} | ||
|
||
const embed = new EmbedBuilder() | ||
.setColor('#0099ff') | ||
.setTitle(`Détails de la commande : ${command.name}`) | ||
.setDescription(command.description || 'Pas de description disponible.') | ||
.addFields( | ||
{ name: 'Usage', value: command.usage ? `\`${command.usage}\`` : 'Pas de format de commande disponible.' }, | ||
{ name: 'Exemple', value: command.example ? `\`${command.example}\`` : 'Pas d\'exemple disponible.' } | ||
); | ||
|
||
return message.reply({ embeds: [embed] }); | ||
} | ||
|
||
// Sinon, affiche la liste des commandes disponibles | ||
const commandList = Array.from(commands.values()); // Convertit la Map en tableau | ||
const embed = new EmbedBuilder() | ||
.setColor('#0099ff') | ||
.setTitle('Liste des Commandes') | ||
.setDescription('Voici la liste des commandes disponibles :') | ||
.addFields( | ||
commandList.map(command => ({ | ||
name: `\`${command.name}\``, | ||
value: command.description || 'Pas de description disponible.' | ||
})) | ||
); | ||
|
||
return message.reply({ embeds: [embed] }); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// commands/moderation/ban.js | ||
|
||
const { EmbedBuilder, PermissionsBitField } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: 'ban', | ||
description: 'Bannit un utilisateur.', | ||
async execute(message, args) { | ||
// Vérifiez si l'utilisateur a la permission de bannir des membres | ||
if (!message.member.permissions.has(PermissionsBitField.Flags.BanMembers)) { | ||
return message.reply({ content: 'Tu n\'as pas la permission de bannir des membres.', ephemeral: true }); | ||
} | ||
|
||
// Récupérez l'utilisateur mentionné | ||
const user = message.mentions.users.first(); | ||
if (!user) { | ||
return message.reply({ content: 'Tu dois mentionner un utilisateur à bannir.', ephemeral: true }); | ||
} | ||
|
||
const member = message.guild.members.resolve(user); | ||
if (member) { | ||
try { | ||
// Envoyer un message privé à l'utilisateur avant de le bannir | ||
await user.send({ | ||
content: 'Vous avez été banni de notre serveur Discord. Si vous pensez que cela est une erreur, veuillez contacter un administrateur.', | ||
embeds: [new EmbedBuilder().setTitle('Bannissement').setDescription('Vous avez été banni du serveur.')] | ||
}); | ||
|
||
// Bannir l'utilisateur | ||
await member.ban(); | ||
await message.reply({ content: `L'utilisateur ${user.tag} a été banni.`, ephemeral: true }); | ||
} catch (err) { | ||
console.error('Erreur lors du bannissement :', err); | ||
await message.reply({ content: 'Je n\'ai pas pu bannir cet utilisateur ou envoyer un message privé.', ephemeral: true }); | ||
} | ||
} else { | ||
await message.reply({ content: 'Cet utilisateur n\'est pas dans le serveur.', ephemeral: true }); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// commands/moderation/clear.js | ||
|
||
const { PermissionsBitField } = require('discord.js'); | ||
|
||
module.exports = { | ||
name: 'clear', | ||
description: 'Supprime un certain nombre de messages dans le salon.', | ||
async execute(message, args) { | ||
// Vérifiez si l'utilisateur a la permission de gérer les messages | ||
if (!message.member.permissions.has(PermissionsBitField.Flags.ManageMessages)) { | ||
return message.reply({ content: 'Tu n\'as pas la permission de gérer les messages.', ephemeral: true }); | ||
} | ||
|
||
// Vérifiez si un nombre de messages est spécifié | ||
const amount = parseInt(args[0]); | ||
if (isNaN(amount) || amount <= 0) { | ||
return message.reply({ content: 'Tu dois spécifier un nombre de messages à supprimer supérieur à 0.', ephemeral: true }); | ||
} | ||
|
||
try { | ||
// Récupérer les messages du salon | ||
let messages = await message.channel.messages.fetch({ limit: Math.min(amount, 100) }); | ||
|
||
if (messages.size < amount) { | ||
// Si le nombre de messages est inférieur au nombre demandé, vider le salon | ||
let allMessages = messages; | ||
while (messages.size === 100) { | ||
const lastMessageId = messages.last().id; | ||
messages = await message.channel.messages.fetch({ limit: 100, before: lastMessageId }); | ||
allMessages = allMessages.concat(messages); | ||
} | ||
// Supprimer tous les messages récupérés | ||
await message.channel.bulkDelete(allMessages, { filterOld: true }); | ||
} else { | ||
// Supprimer le nombre spécifié de messages | ||
await message.channel.bulkDelete(messages, { filterOld: true }); | ||
} | ||
} catch (error) { | ||
console.error('Erreur lors de la suppression des messages :', error); | ||
// Ignorer les erreurs de suppression des messages, comme les messages trop vieux ou non accessibles | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// commands/moderation/unban.js | ||
|
||
const { EmbedBuilder, PermissionsBitField } = require('discord.js'); | ||
const { handleUnbanCommand } = require('../../handlers/unbanHandler'); | ||
|
||
module.exports = { | ||
name: 'unban', | ||
description: 'Débannit un utilisateur en utilisant son ID.', | ||
async execute(message, args) { | ||
// Vérifiez si l'utilisateur a la permission de débannir des membres | ||
if (!message.member.permissions.has(PermissionsBitField.Flags.BanMembers)) { | ||
return message.reply({ content: 'Tu n\'as pas la permission de débannir des membres.', ephemeral: true }); | ||
} | ||
|
||
if (args.length === 0) { | ||
// Afficher les membres bannis si aucun ID n'est fourni | ||
try { | ||
await handleUnbanCommand(message); | ||
} catch (error) { | ||
console.error('Erreur lors de l\'exécution de la commande unban :', error); | ||
await message.reply({ content: 'Il y a eu une erreur lors de la récupération des membres bannis.', ephemeral: true }); | ||
} | ||
} else { | ||
// Débannir l'utilisateur avec l'ID fourni | ||
const userId = args[0]; | ||
if (!userId) { | ||
return message.reply({ content: 'Tu dois fournir l\'ID de l\'utilisateur à débannir.', ephemeral: true }); | ||
} | ||
|
||
try { | ||
const bannedUsers = await message.guild.bans.fetch(); | ||
const user = bannedUsers.get(userId); | ||
|
||
if (!user) { | ||
return message.reply({ content: 'Cet utilisateur n\'est pas banni.', ephemeral: true }); | ||
} | ||
|
||
await message.guild.bans.remove(userId); | ||
await message.reply({ content: `L'utilisateur ${user.user.tag} a été débanni.`, ephemeral: true }); | ||
} catch (error) { | ||
console.error('Erreur lors du débannissement de l\'utilisateur :', error); | ||
await message.reply({ content: 'Il y a eu une erreur lors du débannissement de cet utilisateur.', ephemeral: true }); | ||
} | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
name: 'ping', | ||
description: 'Répond avec Pong!', | ||
execute(message, args) { | ||
message.channel.send('Pong!'); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"token": "Your token", | ||
"prefix": "+", | ||
"autoRole": "LeaveBlank", | ||
"welcomeChannel": "LeaveBlank" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { EmbedBuilder } = require('discord.js'); | ||
const configPath = path.join(__dirname, '../config.json'); | ||
|
||
module.exports = { | ||
name: 'guildMemberAdd', | ||
async execute(member) { | ||
let config; | ||
try { | ||
config = JSON.parse(fs.readFileSync(configPath)); | ||
} catch (error) { | ||
console.error('Erreur lors de la lecture de la configuration.', error); | ||
return; | ||
} | ||
|
||
// Attribution automatique du rôle | ||
const roleID = config.autoRole; | ||
if (roleID) { | ||
const role = member.guild.roles.cache.get(roleID); | ||
if (role) { | ||
try { | ||
await member.roles.add(role); | ||
console.log(`Le rôle ${role.name} a été attribué à ${member.user.tag}.`); | ||
} catch (error) { | ||
console.error(`Impossible d'attribuer le rôle ${role.name} à ${member.user.tag}.`, error); | ||
} | ||
} else { | ||
console.log(`Rôle avec l'ID ${roleID} non trouvé.`); | ||
} | ||
} else { | ||
console.log('Aucun rôle automatique configuré.'); | ||
} | ||
|
||
// Envoi du message de bienvenue dans le salon configuré | ||
const welcomeChannelId = config.welcomeChannel; | ||
if (welcomeChannelId) { | ||
const channel = member.guild.channels.cache.get(welcomeChannelId); | ||
if (channel && channel.isTextBased()) { | ||
const embed = new EmbedBuilder() | ||
.setColor('#0099ff') | ||
.setTitle('Bienvenue !') | ||
.setDescription(`Bienvenue ${member.user}! Sur ${member.guild.name}! Grâce à toi, nous sommes maintenant ${member.guild.memberCount} !`) | ||
.setThumbnail(member.user.displayAvatarURL()) | ||
.setTimestamp(); | ||
|
||
await channel.send({ | ||
content: `<@${member.id}>`, | ||
embeds: [embed], | ||
}); | ||
} else { | ||
console.log(`Salon de bienvenue avec l'ID ${welcomeChannelId} non trouvé.`); | ||
} | ||
} else { | ||
console.log('Aucun salon de bienvenue configuré.'); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const config = require('../config.json'); | ||
|
||
const commandCategories = ['owner', 'configuration', 'moderation', 'information', 'giveaway', 'invitation', 'level', 'logs', 'protection', 'reactionrole', 'ticket']; | ||
|
||
module.exports.handleCommands = (client) => { | ||
client.on('messageCreate', async (message) => { | ||
if (!message.content.startsWith(config.prefix) || message.author.bot) return; | ||
|
||
const args = message.content.slice(config.prefix.length).trim().split(/ +/); | ||
const commandName = args.shift().toLowerCase(); | ||
|
||
let commandFilePath = null; | ||
for (const category of commandCategories) { | ||
const filePath = path.join(__dirname, `../commands/${category}`, `${commandName}.js`); | ||
if (fs.existsSync(filePath)) { | ||
commandFilePath = filePath; | ||
break; | ||
} | ||
} | ||
|
||
if (!commandFilePath) return; | ||
|
||
const command = require(commandFilePath); | ||
|
||
try { | ||
await command.execute(message, args); | ||
} catch (error) { | ||
console.error(error); | ||
message.reply('Il y a eu une erreur en exécutant cette commande.'); | ||
} | ||
}); | ||
|
||
client.commands = new Map(); | ||
for (const category of commandCategories) { | ||
const commandFiles = fs.readdirSync(path.join(__dirname, `../commands/${category}`)).filter(file => file.endsWith('.js')); | ||
for (const file of commandFiles) { | ||
const command = require(path.join(__dirname, `../commands/${category}`, file)); | ||
client.commands.set(command.name, command); | ||
} | ||
} | ||
}; |
Oops, something went wrong.