@@ -24,18 +24,18 @@ const handleMessage = (msg) => {
24
24
const msgs = msg . content . split ( " " ) ;
25
25
const tonyCommands = TonyCommands ( msg ) ;
26
26
const roboCommands = RoboCommands ( msg ) ;
27
- let role = msg . member . guild . roles . find ( 'name' , 'Leadership' ) ;
27
+ let Leadrole = msg . member . guild . roles . find ( 'name' , 'Leadership' ) ;
28
28
29
29
//todo: check for leadership priviliges
30
30
// leadership commands
31
- if ( ( msgs [ 0 ] === PREFIX && msgs [ 1 ] === TonyKey ) && ( role . id === msg . member . guild . roles . find ( 'name' , 'Leadership' ) . id ) ) {
31
+ if ( ( msgs [ 0 ] === PREFIX && msgs [ 1 ] === TonyKey ) && ( msg . member . roles . has ( Leadrole . id ) ) ) {
32
32
// cutting prefixes
33
33
msgs . splice ( 0 , 2 ) ;
34
34
if ( msgs . length === 0 || msgs === undefined ) {
35
35
msg . reply ( 'At least one argument is need to complete a command.' ) ;
36
36
} else {
37
37
// ternary check for tony commands in map.
38
- ( tonyCommands [ msgs . join ( " " ) ] ) ? tonyCommands [ msgs . join ( " " ) ] ( ) : msg . reply ( 'The command you entered is could not be found.' ) ;
38
+ ( tonyCommands [ msgs . join ( " " ) ] ) ? tonyCommands [ msgs . join ( " " ) ] ( ) : msg . reply ( 'The command you entered is could not be found.' ) ;
39
39
}
40
40
} else if ( msgs [ 0 ] === PREFIX ) {
41
41
// non leadership commands
@@ -45,14 +45,15 @@ const handleMessage = (msg) => {
45
45
msg . reply ( 'At least one argument is need to complete a command.' ) ;
46
46
} else {
47
47
// ternary check for function in robocommands map
48
- ( roboCommands [ msgs . join ( " " ) ] ) ? roboCommands [ msgs . join ( " " ) ] ( ) : msg . reply ( 'The command you entered is could not be found.' ) ;
48
+ ( roboCommands [ msgs . join ( " " ) ] ) ? roboCommands [ msgs . join ( " " ) ] ( ) : msg . reply ( 'The command you entered is could not be found.' ) ;
49
49
}
50
50
}
51
51
52
52
}
53
53
54
54
bot . on ( 'ready' , ( ) => console . log ( 'Robo is on.' ) ) ;
55
55
56
+ // When a new member joins the Discord
56
57
bot . on ( 'guildMemberAdd' , member => {
57
58
const channel = member . guild . channels . find ( ch => ch . name === 'welcome' ) ;
58
59
if ( ! channel ) return ;
@@ -62,13 +63,18 @@ bot.on('guildMemberAdd', member => {
62
63
channel . send ( `Welcome to the server, ${ member } be sure to read #rules 👋` ) ;
63
64
} ) ;
64
65
66
+ // When a new member finishes reading the rules
65
67
bot . on ( 'message' , message => {
68
+ let Unrole = message . member . guild . roles . find ( 'name' , 'Unapproved' ) ;
66
69
if ( message . channel . name == 'rules' ) {
67
- let role = message . member . guild . roles . find ( 'name' , 'Unapproved' ) ;
68
- message . member . removeRole ( role ) ;
70
+ if ( message . content === 'READ' ) {
71
+ if ( message . member . roles . has ( Unrole . id ) ) {
72
+ message . member . removeRole ( Unrole ) ;
73
+ }
74
+ }
69
75
message . delete ( 0 )
70
- . then ( msg => console . log ( `Deleted message from ${ msg . author . username } ` ) )
71
- . catch ( console . error ) ;
76
+ . then ( msg => console . log ( `Deleted message from ${ msg . author . username } ` ) )
77
+ . catch ( console . error ) ;
72
78
}
73
79
} ) ;
74
80
0 commit comments