|
1 | 1 | import type {
|
2 |
| - RESTPostAPIApplicationCommandsJSONBody, |
3 |
| - MessageContextMenuCommandInteraction, |
4 |
| - UserContextMenuCommandInteraction, |
5 |
| - ContextMenuCommandInteraction, |
6 |
| - ChatInputCommandInteraction, |
7 | 2 | AutocompleteInteraction,
|
8 |
| - PermissionsString, |
| 3 | + CacheType, |
| 4 | + ChatInputCommandInteraction, |
9 | 5 | Client,
|
| 6 | + ContextMenuCommandInteraction, |
| 7 | + Interaction, |
| 8 | + MessageContextMenuCommandInteraction, |
| 9 | + PermissionsString, |
| 10 | + RESTPostAPIApplicationCommandsJSONBody, |
| 11 | + UserContextMenuCommandInteraction, |
10 | 12 | } from 'discord.js';
|
11 |
| -import type { CommandKit } from '../CommandKit'; |
| 13 | + |
| 14 | +import type { CommandKit } from './CommandKit'; |
| 15 | +import { CommandHandler, EventHandler, ValidationHandler } from './handlers'; |
| 16 | + |
| 17 | +/** |
| 18 | + * Options for instantiating a CommandKit handler. |
| 19 | + */ |
| 20 | +export interface CommandKitOptions { |
| 21 | + /** |
| 22 | + * The Discord.js client object to use with CommandKit. |
| 23 | + */ |
| 24 | + client: Client; |
| 25 | + |
| 26 | + /** |
| 27 | + * The path to your commands directory. |
| 28 | + */ |
| 29 | + commandsPath?: string; |
| 30 | + |
| 31 | + /** |
| 32 | + * The path to your events directory. |
| 33 | + */ |
| 34 | + eventsPath?: string; |
| 35 | + |
| 36 | + /** |
| 37 | + * The path to the validations directory. |
| 38 | + */ |
| 39 | + validationsPath?: string; |
| 40 | + |
| 41 | + /** |
| 42 | + * List of development guild IDs to restrict devOnly commands to. |
| 43 | + */ |
| 44 | + devGuildIds?: string[]; |
| 45 | + |
| 46 | + /** |
| 47 | + * List of developer user IDs to restrict devOnly commands to. |
| 48 | + */ |
| 49 | + devUserIds?: string[]; |
| 50 | + |
| 51 | + /** |
| 52 | + * List of developer role IDs to restrict devOnly commands to. |
| 53 | + */ |
| 54 | + devRoleIds?: string[]; |
| 55 | + |
| 56 | + /** |
| 57 | + * Skip CommandKit's built-in validations (for devOnly commands). |
| 58 | + */ |
| 59 | + skipBuiltInValidations?: boolean; |
| 60 | + |
| 61 | + /** |
| 62 | + * Bulk register application commands instead of one-by-one. |
| 63 | + */ |
| 64 | + bulkRegister?: boolean; |
| 65 | + /** |
| 66 | + * Options for experimental features. |
| 67 | + */ |
| 68 | + experimental?: { |
| 69 | + /** |
| 70 | + * Enable hooks. This allows you to utilize hooks such as `useInteraction()` to access the interaction object anywhere inside the command. |
| 71 | + */ |
| 72 | + hooks?: boolean; |
| 73 | + }; |
| 74 | +} |
| 75 | + |
| 76 | +/** |
| 77 | + * Private data for the CommandKit class. |
| 78 | + */ |
| 79 | +export interface CommandKitData extends CommandKitOptions { |
| 80 | + commandHandler?: CommandHandler; |
| 81 | + eventHandler?: EventHandler; |
| 82 | + validationHandler?: ValidationHandler; |
| 83 | +} |
| 84 | + |
| 85 | +/** |
| 86 | + * Represents a command context. |
| 87 | + */ |
| 88 | +export interface CommandContext< |
| 89 | + T extends Interaction, |
| 90 | + Cached extends CacheType, |
| 91 | +> { |
| 92 | + /** |
| 93 | + * The interaction that triggered this command. |
| 94 | + */ |
| 95 | + interaction: Interaction<CacheType>; |
| 96 | + /** |
| 97 | + * The client that instantiated this command. |
| 98 | + */ |
| 99 | + client: Client; |
| 100 | + /** |
| 101 | + * The command data. |
| 102 | + */ |
| 103 | + handler: CommandKit; |
| 104 | +} |
| 105 | + |
| 106 | +/** |
| 107 | + * Represents a command file. |
| 108 | + */ |
| 109 | +export interface CommandFileObject { |
| 110 | + data: CommandData; |
| 111 | + options?: CommandOptions; |
| 112 | + run: <Cached extends CacheType = CacheType>( |
| 113 | + ctx: CommandContext<Interaction, Cached>, |
| 114 | + ) => Awaited<void>; |
| 115 | + autocomplete?: <Cached extends CacheType = CacheType>( |
| 116 | + ctx: CommandContext<Interaction, Cached>, |
| 117 | + ) => Awaited<void>; |
| 118 | + filePath: string; |
| 119 | + category: string | null; |
| 120 | + [key: string]: any; |
| 121 | +} |
| 122 | + |
| 123 | +/** |
| 124 | + * A reload type for commands. |
| 125 | + */ |
| 126 | +export type ReloadOptions = 'dev' | 'global' | ReloadType; |
12 | 127 |
|
13 | 128 | /**
|
14 | 129 | * Props for command run functions.
|
|
0 commit comments