diff --git a/plugins/Admin/admin.js b/plugins/Admin/admin.js index 056c6ec8..129d621d 100644 --- a/plugins/Admin/admin.js +++ b/plugins/Admin/admin.js @@ -1,7 +1,8 @@ exports.commands = [ "setUsername", "log", - "uptime" + "uptime", + "userRole" ] var startTime = Date.now(); @@ -48,4 +49,20 @@ exports.uptime = { } msg.channel.send("**Uptime**: " + timestr); } +} + +exports.userRole = { + usage: "<@user> <@role>", + description: "Used to toggle @role of specified @user", + process: function(bot,msg,arg){ + var user, role; + if(typeof args[0] != 'undefined' && typeof args[1] != 'undefined'){ + try{ + if(msg.mentions.members.first()){ console.log('User mention'); user = msg.mentions.members.first(); } + if(msg.mentions.roles.first()){ console.log('Role mention '+msg.mentions.roles.first().id); role = msg.mentions.roles.first().id; } + }catch(err){ console.log('Error occured at: '+err+' Mentions.first() is undefined'); } + if(user.roles.cache.find(role => role.id === role)){ msg.member.roles.remove(role); msg.channel.send("Removed the role from "+user+"."); + }else{ user.roles.add(role); msg.channel.send("Added the role to "+user+"."); } + } else{ msg.channel.send('__Parameters can\'t be left blank: USer: '+typeof args[0]+', Role: '+typeof args[1]+'__'); } + } } \ No newline at end of file