️ Add events

This commit is contained in:
Zerio
2020-06-24 15:06:54 +02:00
committed by GitHub
parent c242ed43a6
commit 09483a5eda

27
events/message.js Normal file
View File

@@ -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);
};