After this, create two folders with name events and commands.
Step #4 - add event
In the folder events , create a file with name message.js and type in the following codes:
/events/message.js
module.exports= (client, message) => {// Ignore all botsif (message.author.bot) return;// Ignore messages not starting with the prefix (in config.json)if (message.content.indexOf(client.config.prefix) !==0) return;// Our standard argument/command name definition.constargs=message.content.slice(client.config.prefix.length).trim().split(/ +/g);constcommand=args.shift().toLowerCase();// Grab the command data from the client.commands Enmapconstcmd=client.commands.get(command);// If that command doesn't exist, silently exit and do nothingif (!cmd) return;// Run the commandcmd.run(client, message, args);};
Step #5 - adding commands
To add a command, create a file like: {command-name}.js Here is and example of the kick command
commands/kick.js
exports.run= (client, message, args) => {let reason = args;constmodRole=message.guild.roles.find(role =>role.name ==="Mods");if (!modRole)returnconsole.log("The Mods role does not exist");if (!message.member.roles.has(modRole.id))returnmessage.reply("You can't use this command.");if (message.mentions.members.size ===0)returnmessage.reply("Please mention a user to kick");if (!message.guild.me.hasPermission("KICK_MEMBERS"))returnmessage.reply("");constkickMember=message.mentions.members.first();kickMember.kick(reason.join(" ")).then(member => {message.reply(`${member.user.username} was succesfully kicked.`); });};