commandkit 0.1.1 → 0.1.3-dev.20231002185336

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/README.md CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  # CommandKit
7
7
 
8
- CommandKit is a library that makes it easy to handle commands (+ validations), and events in your Discord.js projects.
8
+ CommandKit is a library that makes it easy to handle commands and events in your Discord.js projects.
9
9
 
10
10
  **Supports Discord.js version 14**
11
11
 
12
- # Features
12
+ ## Features
13
13
 
14
14
  - Very beginner friendly 🚀
15
15
  - Support for slash and context menu commands ✅
@@ -18,11 +18,11 @@ CommandKit is a library that makes it easy to handle commands (+ validations), a
18
18
  - Supports multiple users as bot developers 👥
19
19
  - Object oriented 💻
20
20
 
21
- # Documentation
21
+ ## Documentation
22
22
 
23
- You can find the full documentation [here](https://commandkit.underctrl.io)
23
+ You can find the full documentation [here](https://commandkit.js.org)
24
24
 
25
- # Installation
25
+ ## Installation
26
26
 
27
27
  [![npm](https://nodei.co/npm/commandkit.png)](https://nodei.co/npm/commandkit/)
28
28
 
@@ -54,9 +54,11 @@ To install the development version of CommandKit, run the following command:
54
54
  npm install underctrl-io/commandkit#dev-build
55
55
  ```
56
56
 
57
- # Usage
57
+ > ⚠️ The development version is likely to have bugs.
58
58
 
59
- This is a simple overview of how to set up this library with all the options. You can read more in the [full documentation](https://commandkit.underctrl.io)
59
+ ## Usage
60
+
61
+ This is a simple overview of how to set up this library with all the options. You can read more in the [full documentation](https://commandkit.js.org)
60
62
 
61
63
  ```js
62
64
  // index.js
package/dist/index.d.mts CHANGED
@@ -1,21 +1,57 @@
1
1
  import { Client, Interaction, CommandInteraction, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
2
2
 
3
3
  interface CommandKitOptions {
4
+ /**
5
+ * The Discord.js client object to use with CommandKit.
6
+ */
4
7
  client: Client;
8
+ /**
9
+ * The path to your commands directory.
10
+ */
5
11
  commandsPath?: string;
12
+ /**
13
+ * The path to your events directory.
14
+ */
6
15
  eventsPath?: string;
16
+ /**
17
+ * The path to the validations directory.
18
+ */
7
19
  validationsPath?: string;
20
+ /**
21
+ * List of development guild IDs to restrict devOnly commands to.
22
+ */
8
23
  devGuildIds?: string[];
24
+ /**
25
+ * List of developer user IDs to restrict devOnly commands to.
26
+ */
9
27
  devUserIds?: string[];
28
+ /**
29
+ * List of developer role IDs to restrict devOnly commands to.
30
+ */
10
31
  devRoleIds?: string[];
32
+ /**
33
+ * Skip CommandKit's built-in validations (for devOnly commands).
34
+ */
11
35
  skipBuiltInValidations?: boolean;
36
+ /**
37
+ * Uses discordjs/rest to register application commands.
38
+ * @experimental
39
+ */
40
+ useRest?: boolean;
12
41
  }
13
-
14
42
  interface CommandFileObject {
15
43
  data: CommandData;
16
44
  options?: CommandOptions;
17
- run: ({}: { interaction: Interaction; client: Client; handler: CommandKit }) => void;
45
+ run: ({}: {
46
+ interaction: Interaction;
47
+ client: Client;
48
+ handler: CommandKit;
49
+ }) => void;
50
+ filePath: string;
51
+ category: string | null;
52
+ [key: string]: any;
18
53
  }
54
+ type ReloadOptions = 'dev' | 'global' | ReloadType;
19
55
 
20
56
  interface CommandProps {
21
57
  interaction: CommandInteraction;
@@ -52,28 +88,66 @@ declare enum CommandType {
52
88
  'User' = 2
53
89
  }
54
90
  type LocaleString = 'id' | 'en-US' | 'en-GB' | 'bg' | 'zh-CN' | 'zh-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';
55
- type CommandData = {
91
+ type BaseCommandData = {
56
92
  name: string;
57
- description: string;
58
93
  type?: CommandType;
59
94
  name_localizations?: Partial<Record<LocaleString, string | null>>;
60
- description_localizations?: Partial<Record<LocaleString, string | null>>;
61
95
  dm_permission?: boolean;
62
96
  default_member_permissions?: string;
63
97
  nsfw?: boolean;
98
+ };
99
+ type ChatInputCommandData = BaseCommandData & {
100
+ type?: CommandType.ChatInput;
101
+ description: string;
102
+ description_localizations?: Partial<Record<LocaleString, string | null>>;
64
103
  options?: Array<APIApplicationCommandOption>;
65
104
  };
105
+ type UserOrMessageCommandData = BaseCommandData & {
106
+ type: CommandType.User | CommandType.Message;
107
+ };
108
+ type CommandData = ChatInputCommandData | UserOrMessageCommandData;
66
109
  type CommandObject = Omit<CommandFileObject, 'run'>;
110
+ declare enum ReloadType {
111
+ 'Developer' = "dev",
112
+ 'Global' = "global"
113
+ }
67
114
 
68
115
  declare class CommandKit {
69
116
  #private;
70
- constructor({ ...options }: CommandKitOptions);
117
+ constructor(options: CommandKitOptions);
118
+ /**
119
+ * Updates application commands with the latest from "commandsPath".
120
+ * @experimental
121
+ */
122
+ reloadCommands(type?: ReloadOptions): Promise<void>;
71
123
  /**
72
- * Returns all the commands that CommandKit is handling.
73
- *
74
- * @returns An array of command objects
124
+ * @returns An array of objects of all the commands that CommandKit is handling.
75
125
  */
76
126
  get commands(): CommandObject[];
127
+ /**
128
+ * @returns The path to the commands folder which was set when instantiating CommandKit.
129
+ */
130
+ get commandsPath(): string | undefined;
131
+ /**
132
+ * @returns The path to the events folder which was set when instantiating CommandKit.
133
+ */
134
+ get eventsPath(): string | undefined;
135
+ /**
136
+ * @returns The path to the validations folder which was set when instantiating CommandKit.
137
+ */
138
+ get validationsPath(): string | undefined;
139
+ /**
140
+ * @returns An array of all the developer user IDs which was set when instantiating CommandKit.
141
+ */
142
+ get devUserIds(): string[];
143
+ /**
144
+ * @returns An array of all the developer guild IDs which was set when instantiating CommandKit.
145
+ */
146
+ get devGuildIds(): string[];
147
+ /**
148
+ * @returns An array of all the developer role IDs which was set when instantiating CommandKit.
149
+ */
150
+ get devRoleIds(): string[];
77
151
  }
78
152
 
79
- export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, SlashCommandProps, ValidationFunctionProps };
153
+ export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,57 @@
1
1
  import { Client, Interaction, CommandInteraction, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
2
2
 
3
3
  interface CommandKitOptions {
4
+ /**
5
+ * The Discord.js client object to use with CommandKit.
6
+ */
4
7
  client: Client;
8
+ /**
9
+ * The path to your commands directory.
10
+ */
5
11
  commandsPath?: string;
12
+ /**
13
+ * The path to your events directory.
14
+ */
6
15
  eventsPath?: string;
16
+ /**
17
+ * The path to the validations directory.
18
+ */
7
19
  validationsPath?: string;
20
+ /**
21
+ * List of development guild IDs to restrict devOnly commands to.
22
+ */
8
23
  devGuildIds?: string[];
24
+ /**
25
+ * List of developer user IDs to restrict devOnly commands to.
26
+ */
9
27
  devUserIds?: string[];
28
+ /**
29
+ * List of developer role IDs to restrict devOnly commands to.
30
+ */
10
31
  devRoleIds?: string[];
32
+ /**
33
+ * Skip CommandKit's built-in validations (for devOnly commands).
34
+ */
11
35
  skipBuiltInValidations?: boolean;
36
+ /**
37
+ * Uses discordjs/rest to register application commands.
38
+ * @experimental
39
+ */
40
+ useRest?: boolean;
12
41
  }
13
-
14
42
  interface CommandFileObject {
15
43
  data: CommandData;
16
44
  options?: CommandOptions;
17
- run: ({}: { interaction: Interaction; client: Client; handler: CommandKit }) => void;
45
+ run: ({}: {
46
+ interaction: Interaction;
47
+ client: Client;
48
+ handler: CommandKit;
49
+ }) => void;
50
+ filePath: string;
51
+ category: string | null;
52
+ [key: string]: any;
18
53
  }
54
+ type ReloadOptions = 'dev' | 'global' | ReloadType;
19
55
 
20
56
  interface CommandProps {
21
57
  interaction: CommandInteraction;
@@ -52,28 +88,66 @@ declare enum CommandType {
52
88
  'User' = 2
53
89
  }
54
90
  type LocaleString = 'id' | 'en-US' | 'en-GB' | 'bg' | 'zh-CN' | 'zh-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';
55
- type CommandData = {
91
+ type BaseCommandData = {
56
92
  name: string;
57
- description: string;
58
93
  type?: CommandType;
59
94
  name_localizations?: Partial<Record<LocaleString, string | null>>;
60
- description_localizations?: Partial<Record<LocaleString, string | null>>;
61
95
  dm_permission?: boolean;
62
96
  default_member_permissions?: string;
63
97
  nsfw?: boolean;
98
+ };
99
+ type ChatInputCommandData = BaseCommandData & {
100
+ type?: CommandType.ChatInput;
101
+ description: string;
102
+ description_localizations?: Partial<Record<LocaleString, string | null>>;
64
103
  options?: Array<APIApplicationCommandOption>;
65
104
  };
105
+ type UserOrMessageCommandData = BaseCommandData & {
106
+ type: CommandType.User | CommandType.Message;
107
+ };
108
+ type CommandData = ChatInputCommandData | UserOrMessageCommandData;
66
109
  type CommandObject = Omit<CommandFileObject, 'run'>;
110
+ declare enum ReloadType {
111
+ 'Developer' = "dev",
112
+ 'Global' = "global"
113
+ }
67
114
 
68
115
  declare class CommandKit {
69
116
  #private;
70
- constructor({ ...options }: CommandKitOptions);
117
+ constructor(options: CommandKitOptions);
118
+ /**
119
+ * Updates application commands with the latest from "commandsPath".
120
+ * @experimental
121
+ */
122
+ reloadCommands(type?: ReloadOptions): Promise<void>;
71
123
  /**
72
- * Returns all the commands that CommandKit is handling.
73
- *
74
- * @returns An array of command objects
124
+ * @returns An array of objects of all the commands that CommandKit is handling.
75
125
  */
76
126
  get commands(): CommandObject[];
127
+ /**
128
+ * @returns The path to the commands folder which was set when instantiating CommandKit.
129
+ */
130
+ get commandsPath(): string | undefined;
131
+ /**
132
+ * @returns The path to the events folder which was set when instantiating CommandKit.
133
+ */
134
+ get eventsPath(): string | undefined;
135
+ /**
136
+ * @returns The path to the validations folder which was set when instantiating CommandKit.
137
+ */
138
+ get validationsPath(): string | undefined;
139
+ /**
140
+ * @returns An array of all the developer user IDs which was set when instantiating CommandKit.
141
+ */
142
+ get devUserIds(): string[];
143
+ /**
144
+ * @returns An array of all the developer guild IDs which was set when instantiating CommandKit.
145
+ */
146
+ get devGuildIds(): string[];
147
+ /**
148
+ * @returns An array of all the developer role IDs which was set when instantiating CommandKit.
149
+ */
150
+ get devRoleIds(): string[];
77
151
  }
78
152
 
79
- export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, SlashCommandProps, ValidationFunctionProps };
153
+ export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps };