module.exports = (bot, trigger, lib) => { trigger.add({ name: 'umode', call: /^\!umode .*/i, level: 100, active: 1, func: (e) => { var processModes = (modes) => { var delta, modeList = []; console.log(modes.split('')); if(modes.split('').some((token) => { if(token === '-') {delta = false; return;} if(token === '+') {delta = true; return;} if(token === ' ') return; if(typeof delta === "undefined") return true; modeList.push({ delta: delta, mode: token }); })) return false; else return modeList; }; var allowedModes = [ 'q','a','o','h','v' ]; var tmp = e.message.trim().split(' '); tmp.shift(); var user = tmp[tmp.length - 1]; if(user.match(/(\+|-)/)) user = e.user.getNick(); else tmp.pop(); e.reply("input: "+JSON.stringify(tmp)); var modes = processModes(tmp.join(' ')); e.reply("output: "+JSON.stringify(modes)); e.reply("user: "+user); return; var user = modes[modes.length - 1]; if(user.toLowerCase() != bot.me.nick.toLowerCase()) { if(user.match(/(\+|-)/)) user = e.user.getNick(); modes.shift(); var tmp = []; modes.forEach((entry,i,a) => { if(entry.match(/((\+|-)[a-z]{1}$)/)) tmp.push(entry); }); if(tmp.length > 0) { e.reply('modes: ' + JSON.stringify(tmp) + ' to user: '+user); tmp.forEach((entry,i,a) => { bot.mode(e.channel, entry+' '+user, e.network); }); } else e.reply('no modes given'); } else e.reply('f0ck you.'); }, desc: 'change Usermodes' }); };