mirror of
https://github.com/arthur-pbty/gestion-perso.git
synced 2026-06-07 23:04:47 +02:00
add commands and events
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
const { Events } = require("discord.js");
|
||||
|
||||
module.exports = {
|
||||
name: Events.MessageCreate,
|
||||
async execute(message, client) {
|
||||
const prefix = "+";
|
||||
|
||||
if (message.author.bot) return;
|
||||
if (!message.content.startsWith(prefix)) return;
|
||||
|
||||
const args = message.content.slice(prefix.length).trim().split(/ +/);
|
||||
const commandName = args.shift().toLowerCase();
|
||||
|
||||
const command = client.commands.get(commandName);
|
||||
if (!command) return;
|
||||
|
||||
try {
|
||||
command.execute(message, args);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message.reply("Erreur lors de l'exécution de la commande");
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user