@@ -8,23 +8,33 @@ module.exports = new Clapp.Command({
8
8
desc : "Kicks a player from an event." ,
9
9
fn : ( argv , context ) => {
10
10
return new Promise ( ( fulfill , reject ) => {
11
+ let id = argv . args . user . match ( / < @ ( [ 0 - 9 ] + ) > / ) [ 1 ] ;
12
+
11
13
db . events . get ( argv . args . id ) . then ( event => {
12
14
if ( event !== null ) {
13
- db . confirms . getByUser ( event , context . msg . author ) . then ( attends => {
14
- if ( attends ) {
15
- db . confirms . add ( event , context . msg . author , false )
16
- . then ( ( ) => context . summaryHandler . updateSummary ( event ) )
17
- . then ( ( ) => {
18
- fulfill ( context . msg . author + " has been successfully kicked from " +
19
- "the event `" + argv . args . id + "`.\n" +
20
- "Please note that they are able to rejoin it at any time. To " +
21
- "prevent them from doing so, use the `blacklist-add` command." ) ;
22
- } ) . catch ( reject ) ;
15
+ context . summaryHandler . bot . fetchUser ( id ) . then ( user => {
16
+ db . confirms . getByUser ( event , context . msg . author ) . then ( attends => {
17
+ if ( attends ) {
18
+ db . confirms . add ( event , user , false )
19
+ . then ( ( ) => context . summaryHandler . updateSummary ( event ) )
20
+ . then ( ( ) => {
21
+ fulfill ( user + " has been successfully kicked from " +
22
+ "the event `" + argv . args . id + "`.\n" +
23
+ "Please note that they are able to rejoin it at any time. To " +
24
+ "prevent them from doing so, use the `blacklist-add` command." ) ;
25
+ } ) . catch ( reject ) ;
26
+ } else {
27
+ fulfill ( "Error: the specified user isn't attending the specified " +
28
+ "event." ) ;
29
+ }
30
+ } ) . catch ( reject ) ;
31
+ } ) . catch ( err => {
32
+ if ( err . status === 404 ) {
33
+ fulfill ( "Error: the specified user doesn't exist." ) ;
23
34
} else {
24
- fulfill ( "Error: the specifier user isn't attending the specified " +
25
- "event." ) ;
35
+ reject ( err ) ;
26
36
}
27
- } ) . catch ( reject ) ;
37
+ } ) ;
28
38
} else {
29
39
fulfill ( "Error: the specified event `" + argv . args . id + "` doesn't exist." ) ;
30
40
}
0 commit comments