Skip to content

Commit

Permalink
Added userRole toggle as feature request chalda#70
Browse files Browse the repository at this point in the history
 On branch role-perm
 Changes to be committed:
	modified:   plugins/Admin/admin.js
  • Loading branch information
F9Alejandro committed Nov 3, 2020
1 parent e0c2040 commit 1b78a51
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion plugins/Admin/admin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
exports.commands = [
"setUsername",
"log",
"uptime"
"uptime",
"userRole"
]

var startTime = Date.now();
Expand Down Expand Up @@ -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]+'__'); }
}
}

0 comments on commit 1b78a51

Please sign in to comment.