-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCommandDescriptor.ts
26 lines (23 loc) · 965 Bytes
/
CommandDescriptor.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
import { BaseMessageOptions, ButtonInteraction, CacheType, ChatInputCommandInteraction } from "discord.js";
import { BotServices } from "./BotServices.js";
// Create a TypeScript interface for the command descriptor.
export interface CommandDescriptor {
commandName: string;
subCommandName: string | null;
execute(
interaction: ChatInputCommandInteraction<CacheType>,
services: BotServices
): Promise<void>;
handleError?: (error: unknown, services: BotServices) => Promise<string | BaseMessageOptions>;
handleButton?: (interaction: ButtonInteraction<CacheType>, services: BotServices) => Promise<void>;
handleButtonError?: (error: unknown, services: BotServices) => Promise<string | BaseMessageOptions>;
}
export function isCommandDescriptor(
object: object
): object is CommandDescriptor {
return (
"commandName" in object &&
"execute" in object &&
"subCommandName" in object
);
}