1
- import type { ChannelType , ChatInputCommandInteraction , ContextMenuCommandInteraction , Message } from 'discord.js' ;
1
+ import type { ChatInputCommandInteraction , ContextMenuCommandInteraction , Message } from 'discord.js' ;
2
2
import { Identifiers } from '../lib/errors/Identifiers' ;
3
- import type { ChatInputCommand , ContextMenuCommand , MessageCommand } from '../lib/structures/Command' ;
4
- import { AllFlowsPrecondition , type Preconditions , type RunInPreconditionCommandSpecificData } from '../lib/structures/Precondition' ;
3
+ import { Command , type ChatInputCommand , type ContextMenuCommand , type MessageCommand } from '../lib/structures/Command' ;
4
+ import { AllFlowsPrecondition , type Preconditions } from '../lib/structures/Precondition' ;
5
5
6
6
export interface RunInPreconditionContext extends AllFlowsPrecondition . Context {
7
7
types ?: Preconditions [ 'RunIn' ] [ 'types' ] ;
@@ -13,11 +13,11 @@ export class CorePrecondition extends AllFlowsPrecondition {
13
13
14
14
const channelType = message . channel . type ;
15
15
16
- if ( typesIsArray ( context . types ) ) {
17
- return context . types . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
16
+ if ( Command . runInTypeIsSpecificsObject ( context . types ) ) {
17
+ return context . types . messageRun . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
18
18
}
19
19
20
- return context . types . messageRun . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
20
+ return context . types . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
21
21
}
22
22
23
23
public override async chatInputRun (
@@ -29,11 +29,11 @@ export class CorePrecondition extends AllFlowsPrecondition {
29
29
30
30
const channelType = ( await this . fetchChannelFromInteraction ( interaction ) ) . type ;
31
31
32
- if ( typesIsArray ( context . types ) ) {
33
- return context . types . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
32
+ if ( Command . runInTypeIsSpecificsObject ( context . types ) ) {
33
+ return context . types . chatInputRun . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
34
34
}
35
35
36
- return context . types . chatInputRun . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
36
+ return context . types . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
37
37
}
38
38
39
39
public override async contextMenuRun (
@@ -45,11 +45,11 @@ export class CorePrecondition extends AllFlowsPrecondition {
45
45
46
46
const channelType = ( await this . fetchChannelFromInteraction ( interaction ) ) . type ;
47
47
48
- if ( typesIsArray ( context . types ) ) {
49
- return context . types . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
48
+ if ( Command . runInTypeIsSpecificsObject ( context . types ) ) {
49
+ return context . types . contextMenuRun . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
50
50
}
51
51
52
- return context . types . contextMenuRun . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
52
+ return context . types . includes ( channelType ) ? this . ok ( ) : this . makeSharedError ( context ) ;
53
53
}
54
54
55
55
private makeSharedError ( context : RunInPreconditionContext ) : AllFlowsPrecondition . Result {
@@ -60,7 +60,3 @@ export class CorePrecondition extends AllFlowsPrecondition {
60
60
} ) ;
61
61
}
62
62
}
63
-
64
- function typesIsArray ( types : readonly ChannelType [ ] | RunInPreconditionCommandSpecificData ) : types is readonly ChannelType [ ] {
65
- return Array . isArray ( types ) ;
66
- }
0 commit comments