File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 1
1
exports . commands = [
2
2
"setUsername" ,
3
3
"log" ,
4
- "uptime"
4
+ "uptime" ,
5
+ "userRole"
5
6
]
6
7
7
8
var startTime = Date . now ( ) ;
@@ -48,4 +49,20 @@ exports.uptime = {
48
49
}
49
50
msg . channel . send ( "**Uptime**: " + timestr ) ;
50
51
}
52
+ }
53
+
54
+ exports . userRole = {
55
+ usage : "<@user> <@role>" ,
56
+ description : "Used to toggle @role of specified @user" ,
57
+ process : function ( bot , msg , arg ) {
58
+ var user , role ;
59
+ if ( typeof args [ 0 ] != 'undefined' && typeof args [ 1 ] != 'undefined' ) {
60
+ try {
61
+ if ( msg . mentions . members . first ( ) ) { console . log ( 'User mention' ) ; user = msg . mentions . members . first ( ) ; }
62
+ if ( msg . mentions . roles . first ( ) ) { console . log ( 'Role mention ' + msg . mentions . roles . first ( ) . id ) ; role = msg . mentions . roles . first ( ) . id ; }
63
+ } catch ( err ) { console . log ( 'Error occured at: ' + err + ' Mentions.first() is undefined' ) ; }
64
+ if ( user . roles . cache . find ( role => role . id === role ) ) { msg . member . roles . remove ( role ) ; msg . channel . send ( "Removed the role from " + user + "." ) ;
65
+ } else { user . roles . add ( role ) ; msg . channel . send ( "Added the role to " + user + "." ) ; }
66
+ } else { msg . channel . send ( '__Parameters can\'t be left blank: USer: ' + typeof args [ 0 ] + ', Role: ' + typeof args [ 1 ] + '__' ) ; }
67
+ }
51
68
}
You can’t perform that action at this time.
0 commit comments