From 09483a5eda95d8e4f6c1cb51b9cebece1bea986e Mon Sep 17 00:00:00 2001 From: Zerio <43386412+ZerioDev@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:06:54 +0200 Subject: [PATCH] =?UTF-8?q?=E2=8C=9B=EF=B8=8F=20Add=20events?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- events/message.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 events/message.js diff --git a/events/message.js b/events/message.js new file mode 100644 index 0000000..0de7eca --- /dev/null +++ b/events/message.js @@ -0,0 +1,27 @@ +const config = require(`../config/bot.json`) + +module.exports = (client, message) => { + + //Ignore all bots + if (message.author.bot) return; + + //Prefix + let prefix = config.prefix + + //Ignore messages not starting with the prefix (in config.json) + if (message.content.indexOf(prefix) !== 0) return; + + //Our standard argument/command name definition. + const args = message.content.slice(prefix.length).trim().split(/ +/g); + const command = args.shift().toLowerCase(); + + //Grab the command data from the client.commands Enmap + const cmd = client.commands.get(command); + + //If that command doesn't exist, silently exit and do nothing + if (!cmd) return; + + //Run the command + cmd.run(client, message, args); + +};