forked from NullDev/CSZ-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommand.ts
44 lines (36 loc) · 1.58 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
34
35
36
37
38
39
40
41
42
43
44
import type {
AutocompleteInteraction,
CommandInteraction,
ContextMenuCommandBuilder,
PermissionsString,
SlashCommandBuilder,
} from "discord.js";
import type { ProcessableMessage } from "@/service/command.js";
import type { BotContext } from "@/context.js";
export type Command = ApplicationCommand | AutocompleteCommand | MessageCommand | SpecialCommand;
export interface CommandBase {
readonly modCommand?: boolean;
readonly name: string;
readonly aliases?: string[];
readonly description: string;
readonly requiredPermissions?: readonly PermissionsString[];
}
/** aka "Slash Commands" */
export interface ApplicationCommand extends CommandBase {
readonly applicationCommand: Pick<SlashCommandBuilder | ContextMenuCommandBuilder, "toJSON">;
handleInteraction(command: CommandInteraction, context: BotContext): Promise<void>;
}
export interface AutocompleteCommand extends ApplicationCommand {
autocomplete(interaction: AutocompleteInteraction, context: BotContext): Promise<void>;
}
/** Traditional command invoked via text message (for example, `.hilfe`) */
export interface MessageCommand extends CommandBase {
handleMessage(message: ProcessableMessage, context: BotContext): Promise<void>;
}
// For SpecialCommands we require a pattern and a randomness (<= 1)
export interface SpecialCommand extends CommandBase {
readonly randomness: number;
readonly cooldownTime?: number;
matches(message: ProcessableMessage, context: BotContext): boolean;
handleSpecialMessage(message: ProcessableMessage, context: BotContext): Promise<void>;
}