ajoute messageCreate

This commit is contained in:
VALOU3336
2024-02-14 08:19:27 +01:00
parent 7469ee4736
commit 576f5eb05b
6 changed files with 86 additions and 24 deletions
+23
View File
@@ -0,0 +1,23 @@
module.exports = {
name: 'messageCreate',
async execute(client, message) {
const prefix = '!'; // Assurez-vous que le préfixe est défini ici aussi
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
// Si la commande n'existe pas, ne faites rien
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName);
try {
command.execute(client, message, args);
} catch (error) {
console.error(error);
message.reply('Il y a eu une erreur lors de l\'exécution de cette commande.');
}
},
};
+6 -6
View File
@@ -2,13 +2,13 @@ const { Events, ActivityType } = require("discord.js")
module.exports = {
name : Events.ClientReady,
async run(client) {
async execute(client) {
if (client.commands && Array.isArray(client.commands)) {
client.application.commands.set(client.commands.map(command => command.data));
} else {
console.error('Les commandes du client sont manquantes ou mal formatées');
}
//if (client.commands && Array.isArray(client.commands)) {
// client.application.commands.set(client.commands.map(command => command.data));
//} else {
//console.error('Les commandes du client sont manquantes ou mal formatées');
//}
console.log(`${client.user.username} est en ligne`);
},