-
Notifications
You must be signed in to change notification settings - Fork 26
/
command.ts
33 lines (27 loc) · 1 KB
/
command.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ComponentType } from 'discord-api-types/v10';
import type { ModalSubmitInteraction } from '../structures';
import type { ComponentCommandInteractionMap, ComponentContext } from './componentcontext';
export const InteractionCommandType = {
COMPONENT: 0,
MODAL: 1,
} as const;
export interface ComponentCommand {
__filePath?: string;
}
export abstract class ComponentCommand {
type = InteractionCommandType.COMPONENT;
abstract componentType: keyof ComponentCommandInteractionMap;
abstract filter(interaction: ComponentContext<typeof this.componentType>): Promise<boolean> | boolean;
abstract run(interaction: ComponentContext<typeof this.componentType>): any;
get cType(): number {
return ComponentType[this.componentType];
}
}
export interface ModalCommand {
__filePath?: string;
}
export abstract class ModalCommand {
type = InteractionCommandType.MODAL;
abstract filter(interaction: ModalSubmitInteraction): Promise<boolean> | boolean;
abstract run(interaction: ModalSubmitInteraction): any;
}