Skip to content

Commit c78f2a4

Browse files
committed
update github actions + centralise types
1 parent e2a01f3 commit c78f2a4

File tree

9 files changed

+130
-147
lines changed

9 files changed

+130
-147
lines changed

.github/workflows/dev-commandkit.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: (CommandKit) Publish Dev Build
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
paths:
88
- 'packages/commandkit/**'
99

.github/workflows/dev-create-commandkit.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: (Create CommandKit) Publish Dev Build
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
paths:
88
- 'packages/create-commandkit/**'
99

packages/commandkit/src/CommandKit.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import type {
2-
CommandKitData,
3-
CommandKitOptions,
4-
ReloadOptions,
5-
} from './typings';
1+
import type { CommandKitData, CommandKitOptions, ReloadOptions } from './types';
62
import type { CommandObject } from './types';
7-
83
import { CommandHandler, EventHandler, ValidationHandler } from './handlers';
9-
104
import colors from './utils/colors';
115

126
export class CommandKit {
@@ -17,7 +11,7 @@ export class CommandKit {
1711
* Create a new command and event handler with CommandKit.
1812
*
1913
* @param options - The default CommandKit configuration.
20-
* @see {@link https://commandkit.js.org/docs/commandkit-setup}
14+
* @see {@link https://commandkit.js.org/guide/commandkit-setup}
2115
*/
2216
constructor(options: CommandKitOptions) {
2317
if (!options.client) {

packages/commandkit/src/handlers/command-handler/CommandHandler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
CommandHandlerOptions,
44
CommandKitInteraction,
55
} from './typings';
6-
import type { CommandFileObject, ReloadOptions } from '../../typings';
6+
import type { CommandFileObject, ReloadOptions } from '../../types';
77

88
import { toFileURL } from '../../utils/resolve-file-url';
99
import { getFilePaths } from '../../utils/get-paths';

packages/commandkit/src/handlers/command-handler/functions/loadCommandsWithRest.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ApplicationCommandDataResolvable, Client } from 'discord.js';
2-
import type { CommandFileObject, ReloadOptions } from '../../../typings';
2+
import type { CommandFileObject, ReloadOptions } from '../../../types';
33

44
import colors from '../../../utils/colors';
55

packages/commandkit/src/handlers/command-handler/functions/registerCommands.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
GuildApplicationCommandManager,
66
ApplicationCommandDataResolvable,
77
} from 'discord.js';
8-
import type { CommandFileObject, ReloadOptions } from '../../../typings';
8+
import type { CommandFileObject, ReloadOptions } from '../../../types';
99

1010
import areSlashCommandsDifferent from '../utils/areSlashCommandsDifferent';
1111

packages/commandkit/src/handlers/command-handler/typings.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type {
55
ContextMenuCommandInteraction,
66
} from 'discord.js';
77
import type { CommandKit } from '../../CommandKit';
8-
import type { CommandFileObject } from '../../typings';
8+
import type { CommandFileObject } from '../../types';
99
import type { ValidationHandler } from '../validation-handler/ValidationHandler';
1010

1111
/**

packages/commandkit/src/types/index.ts renamed to packages/commandkit/src/types.ts

+122-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,129 @@
11
import type {
2-
RESTPostAPIApplicationCommandsJSONBody,
3-
MessageContextMenuCommandInteraction,
4-
UserContextMenuCommandInteraction,
5-
ContextMenuCommandInteraction,
6-
ChatInputCommandInteraction,
72
AutocompleteInteraction,
8-
PermissionsString,
3+
CacheType,
4+
ChatInputCommandInteraction,
95
Client,
6+
ContextMenuCommandInteraction,
7+
Interaction,
8+
MessageContextMenuCommandInteraction,
9+
PermissionsString,
10+
RESTPostAPIApplicationCommandsJSONBody,
11+
UserContextMenuCommandInteraction,
1012
} 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;
12127

13128
/**
14129
* Props for command run functions.

packages/commandkit/src/typings.ts

-126
This file was deleted.

0 commit comments

Comments
 (0)