commandkit 0.1.3 → 0.1.4-dev.20231003142112
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 +17 -10
- package/dist/index.d.mts +87 -28
- package/dist/index.d.ts +87 -28
- package/dist/index.js +531 -295
- package/dist/index.mjs +537 -294
- package/package.json +47 -47
package/README.md
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
<
|
|
2
|
-
<img src="https://raw.githubusercontent.com/underctrl-io/commandkit/master/apps/docs/public/ckit_logo.png" width="
|
|
3
|
-
<br
|
|
4
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/underctrl-io/commandkit/master/apps/docs/public/ckit_logo.png" width="60%" />
|
|
3
|
+
<br />
|
|
4
|
+
<a href="https://ctrl.lol/discord"><img src="https://img.shields.io/discord/1055188344188973066?color=5865F2&logo=discord&logoColor=white" alt="support server" /></a>
|
|
5
|
+
<a href="https://www.npmjs.com/package/commandkit"><img src="https://img.shields.io/npm/v/commandkit?maxAge=3600" alt="npm version" /></a>
|
|
6
|
+
<a href="https://www.npmjs.com/package/commandkit"><img src="https://img.shields.io/npm/dt/commandkit?maxAge=3600" alt="npm downloads" /></a>
|
|
7
|
+
</div>
|
|
5
8
|
|
|
6
9
|
# CommandKit
|
|
7
10
|
|
|
8
11
|
CommandKit is a library that makes it easy to handle commands and events in your Discord.js projects.
|
|
9
12
|
|
|
10
|
-
**Supports Discord.js version 14**
|
|
13
|
+
> **Supports Discord.js version 14**
|
|
11
14
|
|
|
12
15
|
## Features
|
|
13
16
|
|
|
@@ -20,7 +23,7 @@ CommandKit is a library that makes it easy to handle commands and events in your
|
|
|
20
23
|
|
|
21
24
|
## Documentation
|
|
22
25
|
|
|
23
|
-
You can find the full documentation [here](https://commandkit.js.org)
|
|
26
|
+
You can find the full documentation [here](https://commandkit.js.org).
|
|
24
27
|
|
|
25
28
|
## Installation
|
|
26
29
|
|
|
@@ -51,7 +54,7 @@ pnpm add commandkit
|
|
|
51
54
|
To install the development version of CommandKit, run the following command:
|
|
52
55
|
|
|
53
56
|
```bash
|
|
54
|
-
npm install
|
|
57
|
+
npm install commandkit@dev
|
|
55
58
|
```
|
|
56
59
|
|
|
57
60
|
> ⚠️ The development version is likely to have bugs.
|
|
@@ -88,13 +91,13 @@ new CommandKit({
|
|
|
88
91
|
validationsPath: path.join(__dirname, 'validations'),
|
|
89
92
|
|
|
90
93
|
// Array of development server IDs (used to register and run devOnly commands)
|
|
91
|
-
devGuildIds: ['
|
|
94
|
+
devGuildIds: ['1234567890', '0987654321'],
|
|
92
95
|
|
|
93
96
|
// Array of developer user IDs (used for devOnly commands)
|
|
94
|
-
devUserIds: ['
|
|
97
|
+
devUserIds: ['1234567890', '0987654321'],
|
|
95
98
|
|
|
96
99
|
// Array of developer role IDs (used for devOnly commands)
|
|
97
|
-
devRoleIds: ['
|
|
100
|
+
devRoleIds: ['1234567890', '0987654321'],
|
|
98
101
|
|
|
99
102
|
// A property that disables CommandKit's built-in validations
|
|
100
103
|
skipBuiltInValidations: true,
|
|
@@ -102,3 +105,7 @@ new CommandKit({
|
|
|
102
105
|
|
|
103
106
|
client.login('YOUR_TOKEN_HERE');
|
|
104
107
|
```
|
|
108
|
+
|
|
109
|
+
## Support and Suggestions
|
|
110
|
+
|
|
111
|
+
If you are looking for support or want to provide suggestions, check out the [Discord](https://ctrl.lol/discord).
|
package/dist/index.d.mts
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
interface CommandKitOptions {
|
|
4
|
-
client: Client;
|
|
5
|
-
commandsPath?: string;
|
|
6
|
-
eventsPath?: string;
|
|
7
|
-
validationsPath?: string;
|
|
8
|
-
devGuildIds?: string[];
|
|
9
|
-
devUserIds?: string[];
|
|
10
|
-
devRoleIds?: string[];
|
|
11
|
-
skipBuiltInValidations?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface CommandFileObject {
|
|
15
|
-
data: CommandData;
|
|
16
|
-
options?: CommandOptions;
|
|
17
|
-
run: ({}: { interaction: Interaction; client: Client; handler: CommandKit }) => void;
|
|
18
|
-
}
|
|
1
|
+
import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
|
|
19
2
|
|
|
20
3
|
interface CommandProps {
|
|
21
4
|
interaction: CommandInteraction;
|
|
@@ -70,25 +53,101 @@ type UserOrMessageCommandData = BaseCommandData & {
|
|
|
70
53
|
type: CommandType.User | CommandType.Message;
|
|
71
54
|
};
|
|
72
55
|
type CommandData = ChatInputCommandData | UserOrMessageCommandData;
|
|
73
|
-
type CommandObject =
|
|
56
|
+
type CommandObject = {
|
|
57
|
+
data: CommandData;
|
|
58
|
+
options?: CommandOptions;
|
|
59
|
+
filePath: string;
|
|
60
|
+
category: string | null;
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
};
|
|
63
|
+
declare enum ReloadType {
|
|
64
|
+
'Developer' = "dev",
|
|
65
|
+
'Global' = "global"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface CommandKitOptions {
|
|
69
|
+
/**
|
|
70
|
+
* The Discord.js client object to use with CommandKit.
|
|
71
|
+
*/
|
|
72
|
+
client: Client;
|
|
73
|
+
/**
|
|
74
|
+
* The path to your commands directory.
|
|
75
|
+
*/
|
|
76
|
+
commandsPath?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The path to your events directory.
|
|
79
|
+
*/
|
|
80
|
+
eventsPath?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The path to the validations directory.
|
|
83
|
+
*/
|
|
84
|
+
validationsPath?: string;
|
|
85
|
+
/**
|
|
86
|
+
* List of development guild IDs to restrict devOnly commands to.
|
|
87
|
+
*/
|
|
88
|
+
devGuildIds?: string[];
|
|
89
|
+
/**
|
|
90
|
+
* List of developer user IDs to restrict devOnly commands to.
|
|
91
|
+
*/
|
|
92
|
+
devUserIds?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* List of developer role IDs to restrict devOnly commands to.
|
|
95
|
+
*/
|
|
96
|
+
devRoleIds?: string[];
|
|
97
|
+
/**
|
|
98
|
+
* Skip CommandKit's built-in validations (for devOnly commands).
|
|
99
|
+
*/
|
|
100
|
+
skipBuiltInValidations?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Bulk register application commands instead of one-by-one.
|
|
103
|
+
*/
|
|
104
|
+
bulkRegister?: boolean;
|
|
105
|
+
}
|
|
106
|
+
type ReloadOptions = 'dev' | 'global' | ReloadType;
|
|
74
107
|
|
|
75
108
|
declare class CommandKit {
|
|
76
109
|
#private;
|
|
77
|
-
constructor(
|
|
78
|
-
/**
|
|
110
|
+
constructor(options: CommandKitOptions);
|
|
111
|
+
/**
|
|
112
|
+
* Updates application commands with the latest from "commandsPath".
|
|
113
|
+
*/
|
|
114
|
+
reloadCommands(type?: ReloadOptions): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Updates application events with the latest from "eventsPath".
|
|
117
|
+
*/
|
|
118
|
+
reloadEvents(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Updates application command validations with the latest from "validationsPath".
|
|
121
|
+
*/
|
|
122
|
+
reloadValidations(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
125
|
+
*/
|
|
79
126
|
get commands(): CommandObject[];
|
|
80
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* @returns The path to the commands folder which was set when instantiating CommandKit.
|
|
129
|
+
*/
|
|
81
130
|
get commandsPath(): string | undefined;
|
|
82
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* @returns The path to the events folder which was set when instantiating CommandKit.
|
|
133
|
+
*/
|
|
83
134
|
get eventsPath(): string | undefined;
|
|
84
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* @returns The path to the validations folder which was set when instantiating CommandKit.
|
|
137
|
+
*/
|
|
85
138
|
get validationsPath(): string | undefined;
|
|
86
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* @returns An array of all the developer user IDs which was set when instantiating CommandKit.
|
|
141
|
+
*/
|
|
87
142
|
get devUserIds(): string[];
|
|
88
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* @returns An array of all the developer guild IDs which was set when instantiating CommandKit.
|
|
145
|
+
*/
|
|
89
146
|
get devGuildIds(): string[];
|
|
90
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* @returns An array of all the developer role IDs which was set when instantiating CommandKit.
|
|
149
|
+
*/
|
|
91
150
|
get devRoleIds(): string[];
|
|
92
151
|
}
|
|
93
152
|
|
|
94
|
-
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,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
interface CommandKitOptions {
|
|
4
|
-
client: Client;
|
|
5
|
-
commandsPath?: string;
|
|
6
|
-
eventsPath?: string;
|
|
7
|
-
validationsPath?: string;
|
|
8
|
-
devGuildIds?: string[];
|
|
9
|
-
devUserIds?: string[];
|
|
10
|
-
devRoleIds?: string[];
|
|
11
|
-
skipBuiltInValidations?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface CommandFileObject {
|
|
15
|
-
data: CommandData;
|
|
16
|
-
options?: CommandOptions;
|
|
17
|
-
run: ({}: { interaction: Interaction; client: Client; handler: CommandKit }) => void;
|
|
18
|
-
}
|
|
1
|
+
import { CommandInteraction, Client, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
|
|
19
2
|
|
|
20
3
|
interface CommandProps {
|
|
21
4
|
interaction: CommandInteraction;
|
|
@@ -70,25 +53,101 @@ type UserOrMessageCommandData = BaseCommandData & {
|
|
|
70
53
|
type: CommandType.User | CommandType.Message;
|
|
71
54
|
};
|
|
72
55
|
type CommandData = ChatInputCommandData | UserOrMessageCommandData;
|
|
73
|
-
type CommandObject =
|
|
56
|
+
type CommandObject = {
|
|
57
|
+
data: CommandData;
|
|
58
|
+
options?: CommandOptions;
|
|
59
|
+
filePath: string;
|
|
60
|
+
category: string | null;
|
|
61
|
+
[key: string]: any;
|
|
62
|
+
};
|
|
63
|
+
declare enum ReloadType {
|
|
64
|
+
'Developer' = "dev",
|
|
65
|
+
'Global' = "global"
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface CommandKitOptions {
|
|
69
|
+
/**
|
|
70
|
+
* The Discord.js client object to use with CommandKit.
|
|
71
|
+
*/
|
|
72
|
+
client: Client;
|
|
73
|
+
/**
|
|
74
|
+
* The path to your commands directory.
|
|
75
|
+
*/
|
|
76
|
+
commandsPath?: string;
|
|
77
|
+
/**
|
|
78
|
+
* The path to your events directory.
|
|
79
|
+
*/
|
|
80
|
+
eventsPath?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The path to the validations directory.
|
|
83
|
+
*/
|
|
84
|
+
validationsPath?: string;
|
|
85
|
+
/**
|
|
86
|
+
* List of development guild IDs to restrict devOnly commands to.
|
|
87
|
+
*/
|
|
88
|
+
devGuildIds?: string[];
|
|
89
|
+
/**
|
|
90
|
+
* List of developer user IDs to restrict devOnly commands to.
|
|
91
|
+
*/
|
|
92
|
+
devUserIds?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* List of developer role IDs to restrict devOnly commands to.
|
|
95
|
+
*/
|
|
96
|
+
devRoleIds?: string[];
|
|
97
|
+
/**
|
|
98
|
+
* Skip CommandKit's built-in validations (for devOnly commands).
|
|
99
|
+
*/
|
|
100
|
+
skipBuiltInValidations?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Bulk register application commands instead of one-by-one.
|
|
103
|
+
*/
|
|
104
|
+
bulkRegister?: boolean;
|
|
105
|
+
}
|
|
106
|
+
type ReloadOptions = 'dev' | 'global' | ReloadType;
|
|
74
107
|
|
|
75
108
|
declare class CommandKit {
|
|
76
109
|
#private;
|
|
77
|
-
constructor(
|
|
78
|
-
/**
|
|
110
|
+
constructor(options: CommandKitOptions);
|
|
111
|
+
/**
|
|
112
|
+
* Updates application commands with the latest from "commandsPath".
|
|
113
|
+
*/
|
|
114
|
+
reloadCommands(type?: ReloadOptions): Promise<void>;
|
|
115
|
+
/**
|
|
116
|
+
* Updates application events with the latest from "eventsPath".
|
|
117
|
+
*/
|
|
118
|
+
reloadEvents(): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Updates application command validations with the latest from "validationsPath".
|
|
121
|
+
*/
|
|
122
|
+
reloadValidations(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* @returns An array of objects of all the commands that CommandKit is handling.
|
|
125
|
+
*/
|
|
79
126
|
get commands(): CommandObject[];
|
|
80
|
-
/**
|
|
127
|
+
/**
|
|
128
|
+
* @returns The path to the commands folder which was set when instantiating CommandKit.
|
|
129
|
+
*/
|
|
81
130
|
get commandsPath(): string | undefined;
|
|
82
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* @returns The path to the events folder which was set when instantiating CommandKit.
|
|
133
|
+
*/
|
|
83
134
|
get eventsPath(): string | undefined;
|
|
84
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* @returns The path to the validations folder which was set when instantiating CommandKit.
|
|
137
|
+
*/
|
|
85
138
|
get validationsPath(): string | undefined;
|
|
86
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* @returns An array of all the developer user IDs which was set when instantiating CommandKit.
|
|
141
|
+
*/
|
|
87
142
|
get devUserIds(): string[];
|
|
88
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* @returns An array of all the developer guild IDs which was set when instantiating CommandKit.
|
|
145
|
+
*/
|
|
89
146
|
get devGuildIds(): string[];
|
|
90
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* @returns An array of all the developer role IDs which was set when instantiating CommandKit.
|
|
149
|
+
*/
|
|
91
150
|
get devRoleIds(): string[];
|
|
92
151
|
}
|
|
93
152
|
|
|
94
|
-
export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, SlashCommandProps, ValidationFunctionProps };
|
|
153
|
+
export { CommandData, CommandKit, CommandObject, CommandOptions, CommandProps, CommandType, ContextMenuCommandProps, ReloadType, SlashCommandProps, ValidationFunctionProps };
|