@@ -20,10 +20,13 @@ class Bind extends Command {
20
20
const channelNames = ( server . bind || [ ] ) . forEach ( ( id ) => {
21
21
const channel = server . guild . channels . cache . get ( id ) ;
22
22
const user = server . guild . members . cache . get ( id ) ;
23
+ const role = server . guild . roles . cache . get ( id ) ;
23
24
if ( user ) {
24
25
obj [ user . displayName ] = id ;
25
26
} else if ( channel && channel . name ) {
26
27
obj [ channel . name ] = id ;
28
+ } else if ( role ) {
29
+ obj [ role . name ] = id ;
27
30
} else {
28
31
obj [ id ] = 'Channel Not Found' ;
29
32
}
@@ -51,6 +54,7 @@ class Bind extends Command {
51
54
[ command + ' voice_channel_id' ] : server . lang ( 'bindusage.channel' ) ,
52
55
[ command + ' #text_channel' ] : server . lang ( 'bindusage.text_channel' ) ,
53
56
[ command + ' @username' ] : server . lang ( 'bindusage.username' ) ,
57
+ [ command + ' @role' ] : server . lang ( 'bindusage.role' ) ,
54
58
[ command + ' permit' ] : server . lang ( 'bindusage.permit' ) ,
55
59
[ command + ' unpermit' ] : server . lang ( 'bindusage.unpermit' ) ,
56
60
} ,
@@ -99,11 +103,18 @@ class Bind extends Command {
99
103
} ) ;
100
104
}
101
105
106
+ if ( mentions . roles . size ) {
107
+ mentions . roles . forEach ( ( role ) => {
108
+ if ( ! server . bind . includes ( role . id ) ) server . bind . push ( role . id ) ;
109
+ } ) ;
110
+ }
111
+
102
112
for ( const id of input . args ) {
103
113
if ( id . length > 15 && / ^ \d + $ / . test ( id . trim ( ) ) ) {
104
114
const user = server . guild . members . cache . get ( id ) ;
105
115
const channel = server . guild . channels . cache . get ( id ) ;
106
- if ( user || ( channel && channel . type != 'voice' ) ) continue ;
116
+ const role = server . guild . roles . cache . get ( id ) ;
117
+ if ( user || ( channel && channel . type != 'voice' ) || role ) continue ;
107
118
108
119
if ( ! server . bind . includes ( id ) ) server . bind . push ( id ) ;
109
120
}
@@ -125,7 +136,13 @@ class Bind extends Command {
125
136
async onUserJoinedChannel ( { channelState, member, server } ) {
126
137
// throw out these states
127
138
if ( ! member . voice . channelID ) return ;
128
- if ( ! server . bind || ! server . bind . length || ! server . bind . includes ( channelState . channelID ) ) return ;
139
+ if ( ! server . bind || ! server . bind . length ) return ;
140
+
141
+ if (
142
+ ! server . bind . includes ( channelState . channelID ) &&
143
+ ! server . bind . some ( ( id ) => member . roles . cache . has ( id ) )
144
+ )
145
+ return ;
129
146
130
147
if ( ! server . isBound ( ) ) {
131
148
server . setMaster ( member ) ;
@@ -148,7 +165,9 @@ class Bind extends Command {
148
165
//not a channel
149
166
( ! server . bind . includes ( channel . id ) &&
150
167
//not a user
151
- ! server . bind . includes ( member . id ) )
168
+ ! server . bind . includes ( member . id ) &&
169
+ // not a role
170
+ ! server . bind . some ( ( id ) => mentions . roles . has ( id ) ) )
152
171
) {
153
172
return ;
154
173
}
0 commit comments