@@ -9,15 +9,26 @@ function banphrase(defaultPunishmentDuration, punishmentType) {
9
9
const duration = _ . get ( matched , 1 , '' ) ;
10
10
const bannedPhrase = _ . get ( matched , 2 , '' ) . toLowerCase ( ) ;
11
11
let parsedDuration = defaultPunishmentDuration ;
12
+
12
13
if ( duration !== '' ) {
13
14
parsedDuration = parseDurationToSeconds ( duration ) ;
14
15
if ( parsedDuration === null ) {
15
- return new CommandOutput (
16
+ return new Promise . resolve ( new CommandOutput (
16
17
null ,
17
18
'Could not parse the duration. Usage: "!AddX {amount}{m,h,d,w} {some banned phrase} " !AddMute 1d YOU BEEN GNOMED' ,
18
- ) ;
19
+ ) ) ;
19
20
}
20
21
}
22
+
23
+ if ( / ^ \/ .* \/ $ / . test ( bannedPhrase ) ) {
24
+ try {
25
+ // eslint-disable-next-line no-new
26
+ new RegExp ( bannedPhrase ) ;
27
+ } catch ( e ) {
28
+ return new Promise . resolve ( new CommandOutput ( null , 'Could not add phrase. Invalid Regex.' ) ) ;
29
+ }
30
+ }
31
+
21
32
return services . sql
22
33
. addBannedPhrase ( bannedPhrase , parsedDuration , punishmentType )
23
34
. then ( ( ) => {
@@ -32,7 +43,7 @@ function banphrase(defaultPunishmentDuration, punishmentType) {
32
43
if ( err . errno === 19 ) {
33
44
return new CommandOutput ( null , 'Phrase already banned!' ) ;
34
45
}
35
- return new Command ( err , 'Oops. Something did not work. Check the logs.' ) ;
46
+ return new CommandOutput ( err , 'Oops. Something did not work. Check the logs.' ) ;
36
47
} ) ;
37
48
} ;
38
49
}
0 commit comments