commandkit 0.1.6-dev.20231124165615 → 0.1.6-dev.20231124182258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,202 +1,169 @@
1
- import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionsString, APIApplicationCommandOption, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
1
+ import { Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, PermissionsString, RESTPostAPIApplicationCommandsJSONBody, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
2
2
 
3
3
  /**
4
- * Base props for commands.
4
+ * Options for instantiating a CommandKit handler.
5
5
  */
6
- interface CommandProps {
6
+ interface CommandKitOptions {
7
7
  /**
8
- * Represents the command's interaction.
8
+ * The Discord.js client object to use with CommandKit.
9
9
  */
10
- interaction: CommandInteraction;
10
+ client: Client;
11
11
  /**
12
- * The client created in your main file.
12
+ * The path to your commands directory.
13
13
  */
14
- client: Client<true>;
14
+ commandsPath?: string;
15
15
  /**
16
- * The main CommandKit handler that instantiated this.
16
+ * The path to your events directory.
17
17
  */
18
- handler: CommandKit;
18
+ eventsPath?: string;
19
+ /**
20
+ * The path to the validations directory.
21
+ */
22
+ validationsPath?: string;
23
+ /**
24
+ * List of development guild IDs to restrict devOnly commands to.
25
+ */
26
+ devGuildIds?: string[];
27
+ /**
28
+ * List of developer user IDs to restrict devOnly commands to.
29
+ */
30
+ devUserIds?: string[];
31
+ /**
32
+ * List of developer role IDs to restrict devOnly commands to.
33
+ */
34
+ devRoleIds?: string[];
35
+ /**
36
+ * Skip CommandKit's built-in validations (for devOnly commands).
37
+ */
38
+ skipBuiltInValidations?: boolean;
39
+ /**
40
+ * Bulk register application commands instead of one-by-one.
41
+ */
42
+ bulkRegister?: boolean;
19
43
  }
20
44
  /**
21
- * Props for slash command run functions.
45
+ * A reload type for commands.
22
46
  */
23
- interface SlashCommandProps {
47
+ type ReloadOptions = 'dev' | 'global' | ReloadType;
48
+
49
+ /**
50
+ * Props for command run functions.
51
+ */
52
+ interface CommandProps {
24
53
  /**
25
- * Represents the command's interaction.
54
+ * The current command interaction object.
26
55
  */
27
- interaction: ChatInputCommandInteraction;
56
+ interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction | UserContextMenuCommandInteraction | MessageContextMenuCommandInteraction;
28
57
  /**
29
- * The client created in your main file.
58
+ * The Discord.js client object that CommandKit is handling.
30
59
  */
31
60
  client: Client<true>;
32
61
  /**
33
- * The CommandKit handler that instantiated this.
62
+ * The current CommandKit handler instance.
34
63
  */
35
64
  handler: CommandKit;
36
65
  }
37
66
  /**
38
- * Props for context menu command run functions.
67
+ * Props for slash (chat input) command run functions.
39
68
  */
40
- interface ContextMenuCommandProps {
69
+ interface SlashCommandProps extends CommandProps {
41
70
  /**
42
- * Represents the command's interaction.
71
+ * The current slash (chat input) command interaction object.
43
72
  */
44
- interaction: ContextMenuCommandInteraction;
45
- /**
46
- * The client created in your main file.
47
- */
48
- client: Client<true>;
73
+ interaction: ChatInputCommandInteraction;
74
+ }
75
+ /**
76
+ * Props for context menu command run functions.
77
+ */
78
+ interface ContextMenuCommandProps extends CommandProps {
49
79
  /**
50
- * The CommandKit handler that instantiated this.
80
+ * The current context menu command interaction object.
51
81
  */
52
- handler: CommandKit;
82
+ interaction: ContextMenuCommandInteraction;
83
+ }
84
+ /**
85
+ * Props for user context menu command run functions.
86
+ */
87
+ interface UserContextMenuCommandProps extends CommandProps {
88
+ interaction: UserContextMenuCommandInteraction;
53
89
  }
54
90
  /**
55
- * Props for command validations.
91
+ * Props for message context menu command run functions.
92
+ */
93
+ interface MessageContextMenuCommandProps extends CommandProps {
94
+ interaction: MessageContextMenuCommandInteraction;
95
+ }
96
+ /**
97
+ * Props for command validation functions.
56
98
  */
57
99
  interface ValidationFunctionProps {
58
100
  /**
59
- * Represents the command's interaction.
60
- * Either a slash command or a context menu command interaction.
101
+ * The current command interaction object.
61
102
  */
62
103
  interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction;
63
104
  /**
64
- * The client created in your main file.
65
- * Represented as a ready client (`Client<true>`).
105
+ * The Discord.js client object that CommandKit is handling.
66
106
  */
67
107
  client: Client<true>;
68
108
  /**
69
- * The command object that is being validated.
109
+ * The current (local) target command object.
70
110
  */
71
111
  commandObj: CommandObject;
72
112
  /**
73
- * The CommandKit handler that instantiated this.
113
+ * The current CommandKit handler instance.
74
114
  */
75
115
  handler: CommandKit;
76
116
  }
77
117
  /**
78
- * Configuration for commands.
118
+ * Additional command configuration options.
79
119
  */
80
120
  interface CommandOptions {
81
121
  /**
82
- * Boolean indicating whether the command is guild-only.
83
- * @deprecated - Use `dm_permission` in the command's data instead.
122
+ * A boolean indicating whether the command is guild-only.
123
+ * Used for built-in validation.
124
+ *
125
+ * @deprecated Use `dm_permission` in the command's `data` object instead.
84
126
  */
85
127
  guildOnly?: boolean;
86
128
  /**
87
- * Boolean indicating whether the command is developer only.
129
+ * A boolean indicating whether the command is developer-only.
130
+ * Used for registration and built-in validation.
88
131
  */
89
132
  devOnly?: boolean;
90
133
  /**
91
- * Boolean indicating whether the command is deleted and should not be registered.
134
+ * A boolean indicating whether the command is deleted/ignored on restart/reload.
92
135
  */
93
136
  deleted?: boolean;
94
137
  /**
95
- * An array of user permissions.
138
+ * A string or array of permissions that a user needs for the current command to be executed.
139
+ * Used for built-in validation.
96
140
  *
97
141
  * @example
98
- * userPermissions: ['BanMembers']
142
+ * userPermissions: 'BanMembers'
143
+ * or
144
+ * userPermissions: ['BanMembers', 'KickMembers']
99
145
  */
100
- userPermissions?: PermissionsString[];
146
+ userPermissions?: PermissionsString | PermissionsString[];
101
147
  /**
102
- * An array of bot permissions.
148
+ * A string or array of permissions that the bot needs to execute the current command.
149
+ * Used for built-in validation.
103
150
  *
104
151
  * @example
105
- * botPermissions: ['BanMembers']
152
+ * botPermissions: 'BanMembers'
153
+ * or
154
+ * botPermissions: ['BanMembers', 'KickMembers']
106
155
  */
107
- botPermissions?: PermissionsString[];
156
+ botPermissions?: PermissionsString | PermissionsString[];
108
157
  [key: string]: any;
109
158
  }
110
- declare enum CommandType {
111
- /**
112
- * Slash commands.
113
- */
114
- 'ChatInput' = 1,
115
- /**
116
- * Message context menu commands.
117
- */
118
- 'Message' = 3,
119
- /**
120
- * User context menu commands.
121
- */
122
- 'User' = 2
123
- }
124
- type LocaleString = 'id' | `en-${'GB' | 'US'}` | 'bg' | `zh-${'CN' | 'TW'}` | 'hr' | 'cs' | 'da' | 'nl' | 'fi' | 'fr' | 'de' | 'el' | 'hi' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'ru' | 'es-ES' | 'sv-SE' | 'th' | 'tr' | 'uk' | 'vi';
125
- /**
126
- * Common items for command data.
127
- */
128
- type BaseCommandData = {
129
- /**
130
- * The name of the command.
131
- */
132
- name: string;
133
- /**
134
- * The type of the command.
135
- */
136
- type?: CommandType;
137
- /**
138
- * i18n for the command name.
139
- */
140
- name_localizations?: Partial<Record<LocaleString, string | null>>;
141
- /**
142
- * Whether to allow this command in DMs.
143
- */
144
- dm_permission?: boolean;
145
- /**
146
- * Default permissions for members for the command.
147
- */
148
- default_member_permissions?: string;
149
- /**
150
- * Whether the command is age-restricted.
151
- */
152
- nsfw?: boolean;
153
- };
154
- /**
155
- * Data for chat input commands.
156
- */
157
- type ChatInputCommandData = BaseCommandData & {
158
- /**
159
- * The command's type.
160
- */
161
- type?: CommandType.ChatInput;
162
- /**
163
- * The description of the command.
164
- */
165
- description: string;
166
- /**
167
- * i18n for the command description.
168
- */
169
- description_localizations?: Partial<Record<LocaleString, string | null>>;
170
- /**
171
- * Chat input command options.
172
- */
173
- options?: Array<APIApplicationCommandOption>;
174
- };
175
- /**
176
- * Represents any context menu command data.
177
- */
178
- type UserOrMessageCommandData = BaseCommandData & {
179
- type: CommandType.User | CommandType.Message;
180
- };
181
- type CommandData = ChatInputCommandData | UserOrMessageCommandData;
159
+ type CommandData = RESTPostAPIApplicationCommandsJSONBody;
182
160
  type CommandObject = {
183
161
  /**
184
- * Command data which is a slash command builder or raw JSON data.
185
- * @example
186
- * {
187
- * name: 'ping',
188
- * description: 'Replies with Pong!'
189
- * }
162
+ * An object which defines the structure of the application command.
190
163
  */
191
164
  data: CommandData;
192
165
  /**
193
- * CommandKit command options.
194
- * @example
195
- * {
196
- * devOnly: true,
197
- * userPermissions: ['ManageGuild'],
198
- * botPermissions: ['ManageGuild'],
199
- * }
166
+ * Additional command configuration options.
200
167
  */
201
168
  options?: CommandOptions;
202
169
  /**
@@ -204,7 +171,13 @@ type CommandObject = {
204
171
  */
205
172
  filePath: string;
206
173
  /**
207
- * The command's category.
174
+ * The command's category. Determined based on the command folder.
175
+ *
176
+ * @example
177
+ * ```txt
178
+ * "/src/commands/ping.js" -> null
179
+ * "/src/commands/Misc/ping.js" -> "Misc"
180
+ * ```
208
181
  */
209
182
  category: string | null;
210
183
  [key: string]: any;
@@ -220,57 +193,12 @@ declare enum ReloadType {
220
193
  Global = "global"
221
194
  }
222
195
 
223
- /**
224
- * Options for instantiating a CommandKit handler.
225
- */
226
- interface CommandKitOptions {
227
- /**
228
- * The Discord.js client object to use with CommandKit.
229
- */
230
- client: Client;
231
- /**
232
- * The path to your commands directory.
233
- */
234
- commandsPath?: string;
235
- /**
236
- * The path to your events directory.
237
- */
238
- eventsPath?: string;
239
- /**
240
- * The path to the validations directory.
241
- */
242
- validationsPath?: string;
243
- /**
244
- * List of development guild IDs to restrict devOnly commands to.
245
- */
246
- devGuildIds?: string[];
247
- /**
248
- * List of developer user IDs to restrict devOnly commands to.
249
- */
250
- devUserIds?: string[];
251
- /**
252
- * List of developer role IDs to restrict devOnly commands to.
253
- */
254
- devRoleIds?: string[];
255
- /**
256
- * Skip CommandKit's built-in validations (for devOnly commands).
257
- */
258
- skipBuiltInValidations?: boolean;
259
- /**
260
- * Bulk register application commands instead of one-by-one.
261
- */
262
- bulkRegister?: boolean;
263
- }
264
- /**
265
- * A reload type for commands.
266
- */
267
- type ReloadOptions = 'dev' | 'global' | ReloadType;
268
-
269
196
  declare class CommandKit {
270
197
  #private;
271
198
  /**
272
- * Create a new handler with CommandKit.
273
- * @param options - Options to use (client, commandsPath, eventsPath, etc.)
199
+ * Create a new command and event handler with CommandKit.
200
+ *
201
+ * @param options - The default CommandKit configuration.
274
202
  * @see {@link https://commandkit.js.org/docs/commandkit-setup}
275
203
  */
276
204
  constructor(options: CommandKitOptions);
@@ -430,4 +358,4 @@ declare function createSignal<T = unknown>(value?: CommandKitSignalInitializer<T
430
358
  */
431
359
  declare function createEffect(callback: CommandKitEffectCallback): void;
432
360
 
433
- export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitConfig, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal, defineConfig, getConfig };
361
+ export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitConfig, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, ContextMenuCommandProps, MessageContextMenuCommandProps, ReloadType, SlashCommandProps, UserContextMenuCommandProps, ValidationFunctionProps, createEffect, createSignal, defineConfig, getConfig };
package/dist/index.d.ts CHANGED
@@ -1,202 +1,169 @@
1
- import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionsString, APIApplicationCommandOption, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
1
+ import { Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, PermissionsString, RESTPostAPIApplicationCommandsJSONBody, ButtonInteraction, Awaitable, Message, InteractionCollectorOptions, ButtonBuilder } from 'discord.js';
2
2
 
3
3
  /**
4
- * Base props for commands.
4
+ * Options for instantiating a CommandKit handler.
5
5
  */
6
- interface CommandProps {
6
+ interface CommandKitOptions {
7
7
  /**
8
- * Represents the command's interaction.
8
+ * The Discord.js client object to use with CommandKit.
9
9
  */
10
- interaction: CommandInteraction;
10
+ client: Client;
11
11
  /**
12
- * The client created in your main file.
12
+ * The path to your commands directory.
13
13
  */
14
- client: Client<true>;
14
+ commandsPath?: string;
15
15
  /**
16
- * The main CommandKit handler that instantiated this.
16
+ * The path to your events directory.
17
17
  */
18
- handler: CommandKit;
18
+ eventsPath?: string;
19
+ /**
20
+ * The path to the validations directory.
21
+ */
22
+ validationsPath?: string;
23
+ /**
24
+ * List of development guild IDs to restrict devOnly commands to.
25
+ */
26
+ devGuildIds?: string[];
27
+ /**
28
+ * List of developer user IDs to restrict devOnly commands to.
29
+ */
30
+ devUserIds?: string[];
31
+ /**
32
+ * List of developer role IDs to restrict devOnly commands to.
33
+ */
34
+ devRoleIds?: string[];
35
+ /**
36
+ * Skip CommandKit's built-in validations (for devOnly commands).
37
+ */
38
+ skipBuiltInValidations?: boolean;
39
+ /**
40
+ * Bulk register application commands instead of one-by-one.
41
+ */
42
+ bulkRegister?: boolean;
19
43
  }
20
44
  /**
21
- * Props for slash command run functions.
45
+ * A reload type for commands.
22
46
  */
23
- interface SlashCommandProps {
47
+ type ReloadOptions = 'dev' | 'global' | ReloadType;
48
+
49
+ /**
50
+ * Props for command run functions.
51
+ */
52
+ interface CommandProps {
24
53
  /**
25
- * Represents the command's interaction.
54
+ * The current command interaction object.
26
55
  */
27
- interaction: ChatInputCommandInteraction;
56
+ interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction | UserContextMenuCommandInteraction | MessageContextMenuCommandInteraction;
28
57
  /**
29
- * The client created in your main file.
58
+ * The Discord.js client object that CommandKit is handling.
30
59
  */
31
60
  client: Client<true>;
32
61
  /**
33
- * The CommandKit handler that instantiated this.
62
+ * The current CommandKit handler instance.
34
63
  */
35
64
  handler: CommandKit;
36
65
  }
37
66
  /**
38
- * Props for context menu command run functions.
67
+ * Props for slash (chat input) command run functions.
39
68
  */
40
- interface ContextMenuCommandProps {
69
+ interface SlashCommandProps extends CommandProps {
41
70
  /**
42
- * Represents the command's interaction.
71
+ * The current slash (chat input) command interaction object.
43
72
  */
44
- interaction: ContextMenuCommandInteraction;
45
- /**
46
- * The client created in your main file.
47
- */
48
- client: Client<true>;
73
+ interaction: ChatInputCommandInteraction;
74
+ }
75
+ /**
76
+ * Props for context menu command run functions.
77
+ */
78
+ interface ContextMenuCommandProps extends CommandProps {
49
79
  /**
50
- * The CommandKit handler that instantiated this.
80
+ * The current context menu command interaction object.
51
81
  */
52
- handler: CommandKit;
82
+ interaction: ContextMenuCommandInteraction;
83
+ }
84
+ /**
85
+ * Props for user context menu command run functions.
86
+ */
87
+ interface UserContextMenuCommandProps extends CommandProps {
88
+ interaction: UserContextMenuCommandInteraction;
53
89
  }
54
90
  /**
55
- * Props for command validations.
91
+ * Props for message context menu command run functions.
92
+ */
93
+ interface MessageContextMenuCommandProps extends CommandProps {
94
+ interaction: MessageContextMenuCommandInteraction;
95
+ }
96
+ /**
97
+ * Props for command validation functions.
56
98
  */
57
99
  interface ValidationFunctionProps {
58
100
  /**
59
- * Represents the command's interaction.
60
- * Either a slash command or a context menu command interaction.
101
+ * The current command interaction object.
61
102
  */
62
103
  interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction;
63
104
  /**
64
- * The client created in your main file.
65
- * Represented as a ready client (`Client<true>`).
105
+ * The Discord.js client object that CommandKit is handling.
66
106
  */
67
107
  client: Client<true>;
68
108
  /**
69
- * The command object that is being validated.
109
+ * The current (local) target command object.
70
110
  */
71
111
  commandObj: CommandObject;
72
112
  /**
73
- * The CommandKit handler that instantiated this.
113
+ * The current CommandKit handler instance.
74
114
  */
75
115
  handler: CommandKit;
76
116
  }
77
117
  /**
78
- * Configuration for commands.
118
+ * Additional command configuration options.
79
119
  */
80
120
  interface CommandOptions {
81
121
  /**
82
- * Boolean indicating whether the command is guild-only.
83
- * @deprecated - Use `dm_permission` in the command's data instead.
122
+ * A boolean indicating whether the command is guild-only.
123
+ * Used for built-in validation.
124
+ *
125
+ * @deprecated Use `dm_permission` in the command's `data` object instead.
84
126
  */
85
127
  guildOnly?: boolean;
86
128
  /**
87
- * Boolean indicating whether the command is developer only.
129
+ * A boolean indicating whether the command is developer-only.
130
+ * Used for registration and built-in validation.
88
131
  */
89
132
  devOnly?: boolean;
90
133
  /**
91
- * Boolean indicating whether the command is deleted and should not be registered.
134
+ * A boolean indicating whether the command is deleted/ignored on restart/reload.
92
135
  */
93
136
  deleted?: boolean;
94
137
  /**
95
- * An array of user permissions.
138
+ * A string or array of permissions that a user needs for the current command to be executed.
139
+ * Used for built-in validation.
96
140
  *
97
141
  * @example
98
- * userPermissions: ['BanMembers']
142
+ * userPermissions: 'BanMembers'
143
+ * or
144
+ * userPermissions: ['BanMembers', 'KickMembers']
99
145
  */
100
- userPermissions?: PermissionsString[];
146
+ userPermissions?: PermissionsString | PermissionsString[];
101
147
  /**
102
- * An array of bot permissions.
148
+ * A string or array of permissions that the bot needs to execute the current command.
149
+ * Used for built-in validation.
103
150
  *
104
151
  * @example
105
- * botPermissions: ['BanMembers']
152
+ * botPermissions: 'BanMembers'
153
+ * or
154
+ * botPermissions: ['BanMembers', 'KickMembers']
106
155
  */
107
- botPermissions?: PermissionsString[];
156
+ botPermissions?: PermissionsString | PermissionsString[];
108
157
  [key: string]: any;
109
158
  }
110
- declare enum CommandType {
111
- /**
112
- * Slash commands.
113
- */
114
- 'ChatInput' = 1,
115
- /**
116
- * Message context menu commands.
117
- */
118
- 'Message' = 3,
119
- /**
120
- * User context menu commands.
121
- */
122
- 'User' = 2
123
- }
124
- type LocaleString = 'id' | `en-${'GB' | 'US'}` | 'bg' | `zh-${'CN' | 'TW'}` | 'hr' | 'cs' | 'da' | 'nl' | 'fi' | 'fr' | 'de' | 'el' | 'hi' | 'hu' | 'it' | 'ja' | 'ko' | 'lt' | 'no' | 'pl' | 'pt-BR' | 'ro' | 'ru' | 'es-ES' | 'sv-SE' | 'th' | 'tr' | 'uk' | 'vi';
125
- /**
126
- * Common items for command data.
127
- */
128
- type BaseCommandData = {
129
- /**
130
- * The name of the command.
131
- */
132
- name: string;
133
- /**
134
- * The type of the command.
135
- */
136
- type?: CommandType;
137
- /**
138
- * i18n for the command name.
139
- */
140
- name_localizations?: Partial<Record<LocaleString, string | null>>;
141
- /**
142
- * Whether to allow this command in DMs.
143
- */
144
- dm_permission?: boolean;
145
- /**
146
- * Default permissions for members for the command.
147
- */
148
- default_member_permissions?: string;
149
- /**
150
- * Whether the command is age-restricted.
151
- */
152
- nsfw?: boolean;
153
- };
154
- /**
155
- * Data for chat input commands.
156
- */
157
- type ChatInputCommandData = BaseCommandData & {
158
- /**
159
- * The command's type.
160
- */
161
- type?: CommandType.ChatInput;
162
- /**
163
- * The description of the command.
164
- */
165
- description: string;
166
- /**
167
- * i18n for the command description.
168
- */
169
- description_localizations?: Partial<Record<LocaleString, string | null>>;
170
- /**
171
- * Chat input command options.
172
- */
173
- options?: Array<APIApplicationCommandOption>;
174
- };
175
- /**
176
- * Represents any context menu command data.
177
- */
178
- type UserOrMessageCommandData = BaseCommandData & {
179
- type: CommandType.User | CommandType.Message;
180
- };
181
- type CommandData = ChatInputCommandData | UserOrMessageCommandData;
159
+ type CommandData = RESTPostAPIApplicationCommandsJSONBody;
182
160
  type CommandObject = {
183
161
  /**
184
- * Command data which is a slash command builder or raw JSON data.
185
- * @example
186
- * {
187
- * name: 'ping',
188
- * description: 'Replies with Pong!'
189
- * }
162
+ * An object which defines the structure of the application command.
190
163
  */
191
164
  data: CommandData;
192
165
  /**
193
- * CommandKit command options.
194
- * @example
195
- * {
196
- * devOnly: true,
197
- * userPermissions: ['ManageGuild'],
198
- * botPermissions: ['ManageGuild'],
199
- * }
166
+ * Additional command configuration options.
200
167
  */
201
168
  options?: CommandOptions;
202
169
  /**
@@ -204,7 +171,13 @@ type CommandObject = {
204
171
  */
205
172
  filePath: string;
206
173
  /**
207
- * The command's category.
174
+ * The command's category. Determined based on the command folder.
175
+ *
176
+ * @example
177
+ * ```txt
178
+ * "/src/commands/ping.js" -> null
179
+ * "/src/commands/Misc/ping.js" -> "Misc"
180
+ * ```
208
181
  */
209
182
  category: string | null;
210
183
  [key: string]: any;
@@ -220,57 +193,12 @@ declare enum ReloadType {
220
193
  Global = "global"
221
194
  }
222
195
 
223
- /**
224
- * Options for instantiating a CommandKit handler.
225
- */
226
- interface CommandKitOptions {
227
- /**
228
- * The Discord.js client object to use with CommandKit.
229
- */
230
- client: Client;
231
- /**
232
- * The path to your commands directory.
233
- */
234
- commandsPath?: string;
235
- /**
236
- * The path to your events directory.
237
- */
238
- eventsPath?: string;
239
- /**
240
- * The path to the validations directory.
241
- */
242
- validationsPath?: string;
243
- /**
244
- * List of development guild IDs to restrict devOnly commands to.
245
- */
246
- devGuildIds?: string[];
247
- /**
248
- * List of developer user IDs to restrict devOnly commands to.
249
- */
250
- devUserIds?: string[];
251
- /**
252
- * List of developer role IDs to restrict devOnly commands to.
253
- */
254
- devRoleIds?: string[];
255
- /**
256
- * Skip CommandKit's built-in validations (for devOnly commands).
257
- */
258
- skipBuiltInValidations?: boolean;
259
- /**
260
- * Bulk register application commands instead of one-by-one.
261
- */
262
- bulkRegister?: boolean;
263
- }
264
- /**
265
- * A reload type for commands.
266
- */
267
- type ReloadOptions = 'dev' | 'global' | ReloadType;
268
-
269
196
  declare class CommandKit {
270
197
  #private;
271
198
  /**
272
- * Create a new handler with CommandKit.
273
- * @param options - Options to use (client, commandsPath, eventsPath, etc.)
199
+ * Create a new command and event handler with CommandKit.
200
+ *
201
+ * @param options - The default CommandKit configuration.
274
202
  * @see {@link https://commandkit.js.org/docs/commandkit-setup}
275
203
  */
276
204
  constructor(options: CommandKitOptions);
@@ -430,4 +358,4 @@ declare function createSignal<T = unknown>(value?: CommandKitSignalInitializer<T
430
358
  */
431
359
  declare function createEffect(callback: CommandKitEffectCallback): void;
432
360
 
433
- export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitConfig, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps, createEffect, createSignal, defineConfig, getConfig };
361
+ export { ButtonKit, CommandData, CommandKit, CommandKitButtonBuilderInteractionCollectorDispatch, CommandKitButtonBuilderInteractionCollectorDispatchContextData, CommandKitConfig, CommandKitEffectCallback, CommandKitSignal, CommandKitSignalInitializer, CommandKitSignalUpdater, CommandObject, CommandOptions, CommandProps, ContextMenuCommandProps, MessageContextMenuCommandProps, ReloadType, SlashCommandProps, UserContextMenuCommandProps, ValidationFunctionProps, createEffect, createSignal, defineConfig, getConfig };
package/dist/index.js CHANGED
@@ -39,8 +39,15 @@ __export(src_exports, {
39
39
  });
40
40
  module.exports = __toCommonJS(src_exports);
41
41
 
42
- // src/utils/get-paths.ts
42
+ // src/utils/resolve-file-url.ts
43
43
  var import_path = __toESM(require("path"));
44
+ function toFileURL(filePath) {
45
+ const resolvedPath = import_path.default.resolve(filePath);
46
+ return "file://" + resolvedPath.replace(/\\\\|\\/g, "/");
47
+ }
48
+
49
+ // src/utils/get-paths.ts
50
+ var import_path2 = __toESM(require("path"));
44
51
  var import_promises = __toESM(require("fs/promises"));
45
52
  async function getFilePaths(directory, nesting) {
46
53
  let filePaths = [];
@@ -48,7 +55,7 @@ async function getFilePaths(directory, nesting) {
48
55
  return filePaths;
49
56
  const files = await import_promises.default.readdir(directory, { withFileTypes: true });
50
57
  for (const file of files) {
51
- const filePath = import_path.default.join(directory, file.name);
58
+ const filePath = import_path2.default.join(directory, file.name);
52
59
  if (file.isFile()) {
53
60
  filePaths.push(filePath);
54
61
  }
@@ -64,7 +71,7 @@ async function getFolderPaths(directory, nesting) {
64
71
  return folderPaths;
65
72
  const folders = await import_promises.default.readdir(directory, { withFileTypes: true });
66
73
  for (const folder of folders) {
67
- const folderPath = import_path.default.join(directory, folder.name);
74
+ const folderPath = import_path2.default.join(directory, folder.name);
68
75
  if (folder.isDirectory()) {
69
76
  folderPaths.push(folderPath);
70
77
  if (nesting) {
@@ -75,13 +82,6 @@ async function getFolderPaths(directory, nesting) {
75
82
  return folderPaths;
76
83
  }
77
84
 
78
- // src/utils/resolve-file-url.ts
79
- var import_path2 = __toESM(require("path"));
80
- function toFileURL(filePath) {
81
- const resolvedPath = import_path2.default.resolve(filePath);
82
- return "file://" + resolvedPath.replace(/\\\\|\\/g, "/");
83
- }
84
-
85
85
  // src/utils/colors.ts
86
86
  var resetColor = "\x1B[0m";
87
87
  var colors_default = {
@@ -393,26 +393,21 @@ function devOnly_default({ interaction, targetCommand, handlerData }) {
393
393
  }
394
394
  }
395
395
 
396
- // src/handlers/command-handler/validations/guildOnly.ts
397
- function guildOnly_default({ interaction, targetCommand }) {
398
- if (targetCommand.options?.guildOnly && !interaction.inGuild()) {
399
- interaction.reply({
400
- content: "\u274C This command can only be used inside a server.",
401
- ephemeral: true
402
- });
403
- return true;
404
- }
405
- }
406
-
407
396
  // src/handlers/command-handler/validations/permissions.ts
408
397
  var import_discord = require("discord.js");
409
398
  function permissions_default({ interaction, targetCommand }) {
410
399
  const userPermissions = interaction.memberPermissions;
411
400
  let userPermissionsRequired = targetCommand.options?.userPermissions;
412
401
  let missingUserPermissions = [];
402
+ if (typeof userPermissionsRequired === "string") {
403
+ userPermissionsRequired = [userPermissionsRequired];
404
+ }
413
405
  const botPermissions = interaction.guild?.members.me?.permissions;
414
406
  let botPermissionsRequired = targetCommand.options?.botPermissions;
415
407
  let missingBotPermissions = [];
408
+ if (typeof botPermissionsRequired === "string") {
409
+ botPermissionsRequired = [botPermissionsRequired];
410
+ }
416
411
  if (!userPermissionsRequired?.length && !botPermissionsRequired?.length) {
417
412
  return;
418
413
  }
@@ -463,7 +458,7 @@ function permissions_default({ interaction, targetCommand }) {
463
458
  }
464
459
 
465
460
  // src/handlers/command-handler/validations/index.ts
466
- var validations_default = [devOnly_default, guildOnly_default, permissions_default];
461
+ var validations_default = [devOnly_default, permissions_default];
467
462
 
468
463
  // src/handlers/command-handler/CommandHandler.ts
469
464
  var import_rfdc = __toESM(require("rfdc"));
@@ -788,8 +783,9 @@ var ValidationHandler = class {
788
783
  var CommandKit = class {
789
784
  #data;
790
785
  /**
791
- * Create a new handler with CommandKit.
792
- * @param options - Options to use (client, commandsPath, eventsPath, etc.)
786
+ * Create a new command and event handler with CommandKit.
787
+ *
788
+ * @param options - The default CommandKit configuration.
793
789
  * @see {@link https://commandkit.js.org/docs/commandkit-setup}
794
790
  */
795
791
  constructor(options) {
package/dist/index.mjs CHANGED
@@ -6,8 +6,15 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
6
  throw Error('Dynamic require of "' + x + '" is not supported');
7
7
  });
8
8
 
9
- // src/utils/get-paths.ts
9
+ // src/utils/resolve-file-url.ts
10
10
  import path from "path";
11
+ function toFileURL(filePath) {
12
+ const resolvedPath = path.resolve(filePath);
13
+ return "file://" + resolvedPath.replace(/\\\\|\\/g, "/");
14
+ }
15
+
16
+ // src/utils/get-paths.ts
17
+ import path2 from "path";
11
18
  import fs from "fs/promises";
12
19
  async function getFilePaths(directory, nesting) {
13
20
  let filePaths = [];
@@ -15,7 +22,7 @@ async function getFilePaths(directory, nesting) {
15
22
  return filePaths;
16
23
  const files = await fs.readdir(directory, { withFileTypes: true });
17
24
  for (const file of files) {
18
- const filePath = path.join(directory, file.name);
25
+ const filePath = path2.join(directory, file.name);
19
26
  if (file.isFile()) {
20
27
  filePaths.push(filePath);
21
28
  }
@@ -31,7 +38,7 @@ async function getFolderPaths(directory, nesting) {
31
38
  return folderPaths;
32
39
  const folders = await fs.readdir(directory, { withFileTypes: true });
33
40
  for (const folder of folders) {
34
- const folderPath = path.join(directory, folder.name);
41
+ const folderPath = path2.join(directory, folder.name);
35
42
  if (folder.isDirectory()) {
36
43
  folderPaths.push(folderPath);
37
44
  if (nesting) {
@@ -42,13 +49,6 @@ async function getFolderPaths(directory, nesting) {
42
49
  return folderPaths;
43
50
  }
44
51
 
45
- // src/utils/resolve-file-url.ts
46
- import path2 from "path";
47
- function toFileURL(filePath) {
48
- const resolvedPath = path2.resolve(filePath);
49
- return "file://" + resolvedPath.replace(/\\\\|\\/g, "/");
50
- }
51
-
52
52
  // src/utils/colors.ts
53
53
  var resetColor = "\x1B[0m";
54
54
  var colors_default = {
@@ -360,26 +360,21 @@ function devOnly_default({ interaction, targetCommand, handlerData }) {
360
360
  }
361
361
  }
362
362
 
363
- // src/handlers/command-handler/validations/guildOnly.ts
364
- function guildOnly_default({ interaction, targetCommand }) {
365
- if (targetCommand.options?.guildOnly && !interaction.inGuild()) {
366
- interaction.reply({
367
- content: "\u274C This command can only be used inside a server.",
368
- ephemeral: true
369
- });
370
- return true;
371
- }
372
- }
373
-
374
363
  // src/handlers/command-handler/validations/permissions.ts
375
364
  import { EmbedBuilder } from "discord.js";
376
365
  function permissions_default({ interaction, targetCommand }) {
377
366
  const userPermissions = interaction.memberPermissions;
378
367
  let userPermissionsRequired = targetCommand.options?.userPermissions;
379
368
  let missingUserPermissions = [];
369
+ if (typeof userPermissionsRequired === "string") {
370
+ userPermissionsRequired = [userPermissionsRequired];
371
+ }
380
372
  const botPermissions = interaction.guild?.members.me?.permissions;
381
373
  let botPermissionsRequired = targetCommand.options?.botPermissions;
382
374
  let missingBotPermissions = [];
375
+ if (typeof botPermissionsRequired === "string") {
376
+ botPermissionsRequired = [botPermissionsRequired];
377
+ }
383
378
  if (!userPermissionsRequired?.length && !botPermissionsRequired?.length) {
384
379
  return;
385
380
  }
@@ -430,7 +425,7 @@ function permissions_default({ interaction, targetCommand }) {
430
425
  }
431
426
 
432
427
  // src/handlers/command-handler/validations/index.ts
433
- var validations_default = [devOnly_default, guildOnly_default, permissions_default];
428
+ var validations_default = [devOnly_default, permissions_default];
434
429
 
435
430
  // src/handlers/command-handler/CommandHandler.ts
436
431
  import rdfc from "rfdc";
@@ -755,8 +750,9 @@ var ValidationHandler = class {
755
750
  var CommandKit = class {
756
751
  #data;
757
752
  /**
758
- * Create a new handler with CommandKit.
759
- * @param options - Options to use (client, commandsPath, eventsPath, etc.)
753
+ * Create a new command and event handler with CommandKit.
754
+ *
755
+ * @param options - The default CommandKit configuration.
760
756
  * @see {@link https://commandkit.js.org/docs/commandkit-setup}
761
757
  */
762
758
  constructor(options) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "commandkit",
3
3
  "description": "Beginner friendly command & event handler for Discord.js",
4
- "version": "0.1.6-dev.20231124165615",
4
+ "version": "0.1.6-dev.20231124182258",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.mjs",