@@ -21,12 +21,9 @@ export interface CommandMetadata {
21
21
usage ?: string ,
22
22
}
23
23
24
- export interface ContextMetadata {
25
- contentUrl ?: string ,
26
- responseUrl ?: string ,
27
- }
28
-
29
24
export class BaseCommand < ParsedArgsFinished = Command . ParsedArgs > extends Command . Command < ParsedArgsFinished > {
25
+ nsfw = false ;
26
+
30
27
permissionsIgnoreClientOwner = true ;
31
28
triggerTypingAfter = 2000 ;
32
29
@@ -38,6 +35,10 @@ export class BaseCommand<ParsedArgsFinished = Command.ParsedArgs> extends Comman
38
35
{ duration : 500 , limit : 1 , type : 'channel' } ,
39
36
] ,
40
37
} , options ) ) ;
38
+ if ( this . metadata ) {
39
+ this . nsfw = this . metadata . nsfw || this . nsfw ;
40
+ this . metadata . nsfw = this . nsfw ;
41
+ }
41
42
}
42
43
43
44
get commandDescription ( ) : string {
@@ -48,6 +49,24 @@ export class BaseCommand<ParsedArgsFinished = Command.ParsedArgs> extends Comman
48
49
return '' ;
49
50
}
50
51
52
+ onBefore ( context : Command . Context ) {
53
+ if ( this . nsfw ) {
54
+ if ( context . channel ) {
55
+ return context . channel . isDm || context . channel . nsfw ;
56
+ }
57
+ return context . inDm ;
58
+ }
59
+ return true ;
60
+ }
61
+
62
+ onCancel ( context : Command . Context ) {
63
+ if ( this . nsfw ) {
64
+ if ( ! context . inDm && ( context . channel && ( ! context . channel . isDm || ! context . channel . nsfw ) ) ) {
65
+ return editOrReply ( context , '⚠ Not a NSFW channel.' ) ;
66
+ }
67
+ }
68
+ }
69
+
51
70
onCancelRun ( context : Command . Context , args : unknown ) {
52
71
const description = this . commandDescription ;
53
72
if ( description ) {
@@ -399,8 +418,6 @@ export class BaseImageCommand<ParsedArgsFinished = Command.ParsedArgs> extends B
399
418
400
419
401
420
export class BaseSearchCommand < ParsedArgsFinished = Command . ParsedArgs > extends BaseCommand < ParsedArgsFinished > {
402
- nsfw = false ;
403
-
404
421
constructor ( commandClient : CommandClient , options : Partial < Command . CommandOptions > ) {
405
422
super ( commandClient , {
406
423
label : 'query' ,
@@ -411,23 +428,6 @@ export class BaseSearchCommand<ParsedArgsFinished = Command.ParsedArgs> extends
411
428
] ,
412
429
...options ,
413
430
} ) ;
414
- if ( this . metadata ) {
415
- this . metadata . nsfw = this . nsfw ;
416
- }
417
- }
418
-
419
- onBefore ( context : Command . Context ) {
420
- if ( this . nsfw ) {
421
- if ( context . channel ) {
422
- return context . channel . isDm || context . channel . nsfw ;
423
- }
424
- return context . inDm ;
425
- }
426
- return true ;
427
- }
428
-
429
- onCancel ( context : Command . Context ) {
430
- return editOrReply ( context , '⚠ Not a NSFW channel.' ) ;
431
431
}
432
432
433
433
onBeforeRun ( context : Command . Context , args : { query : string } ) {
0 commit comments