const Eris = require("eris"); const config = require("./config.json"); const regex = new RegExp(`(?:${config["keywords"].map(keyword => keyword.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|")})`); var bot = new Eris(config["token"]); bot.on("messageCreate", message => { let match = message.content.match(regex); if(match && typeof message.channel.guild !== "undefined") { bot.banGuildMember(message.channel.guild.id, message.author.id, 0, `User said "${match[0]}"`).catch(e => { console.log(`Failed to ban ${message.author.username}#${message.author.discriminator}. Do I have permission to ban people?\n\n${e.message}`); }); } }); bot.connect();