commandkit 0.1.0 → 0.1.2

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
@@ -1,3 +1,8 @@
1
+ <h1 align="center">
2
+ <img src="https://raw.githubusercontent.com/underctrl-io/commandkit/master/apps/docs/public/ckit_logo.png" width="50%">
3
+ <br>
4
+ </h1>
5
+
1
6
  # CommandKit
2
7
 
3
8
  CommandKit is a library that makes it easy to handle commands (+ validations), and events in your Discord.js projects.
@@ -29,12 +34,26 @@ For npm:
29
34
  npm install commandkit
30
35
  ```
31
36
 
32
- For yarn:
37
+ Yarn:
33
38
 
34
39
  ```bash
35
40
  yarn add commandkit
36
41
  ```
37
42
 
43
+ pnpm:
44
+
45
+ ```bash
46
+ pnpm add commandkit
47
+ ```
48
+
49
+ ### Install development version
50
+
51
+ To install the development version of CommandKit, run the following command:
52
+
53
+ ```bash
54
+ npm install underctrl-io/commandkit#dev-build
55
+ ```
56
+
38
57
  # Usage
39
58
 
40
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)
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Client, Interaction, CommandInteraction, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandSubcommandOption, APIApplicationCommandSubcommandGroupOption } from 'discord.js';
1
+ import { Client, Interaction, CommandInteraction, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
2
2
 
3
3
  interface CommandKitOptions {
4
4
  client: Client;
@@ -52,17 +52,24 @@ declare enum CommandType {
52
52
  'User' = 2
53
53
  }
54
54
  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 = {
55
+ type BaseCommandData = {
56
56
  name: string;
57
- description: string;
58
57
  type?: CommandType;
59
58
  name_localizations?: Partial<Record<LocaleString, string | null>>;
60
- description_localizations?: Partial<Record<LocaleString, string | null>>;
61
59
  dm_permission?: boolean;
62
60
  default_member_permissions?: string;
63
61
  nsfw?: boolean;
64
- options?: Array<APIApplicationCommandSubcommandOption | APIApplicationCommandSubcommandGroupOption>;
65
62
  };
63
+ type ChatInputCommandData = BaseCommandData & {
64
+ type?: CommandType.ChatInput;
65
+ description: string;
66
+ description_localizations?: Partial<Record<LocaleString, string | null>>;
67
+ options?: Array<APIApplicationCommandOption>;
68
+ };
69
+ type UserOrMessageCommandData = BaseCommandData & {
70
+ type: CommandType.User | CommandType.Message;
71
+ };
72
+ type CommandData = ChatInputCommandData | UserOrMessageCommandData;
66
73
  type CommandObject = Omit<CommandFileObject, 'run'>;
67
74
 
68
75
  declare class CommandKit {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Client, Interaction, CommandInteraction, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandSubcommandOption, APIApplicationCommandSubcommandGroupOption } from 'discord.js';
1
+ import { Client, Interaction, CommandInteraction, ChatInputCommandInteraction, ContextMenuCommandInteraction, PermissionResolvable, APIApplicationCommandOption } from 'discord.js';
2
2
 
3
3
  interface CommandKitOptions {
4
4
  client: Client;
@@ -52,17 +52,24 @@ declare enum CommandType {
52
52
  'User' = 2
53
53
  }
54
54
  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 = {
55
+ type BaseCommandData = {
56
56
  name: string;
57
- description: string;
58
57
  type?: CommandType;
59
58
  name_localizations?: Partial<Record<LocaleString, string | null>>;
60
- description_localizations?: Partial<Record<LocaleString, string | null>>;
61
59
  dm_permission?: boolean;
62
60
  default_member_permissions?: string;
63
61
  nsfw?: boolean;
64
- options?: Array<APIApplicationCommandSubcommandOption | APIApplicationCommandSubcommandGroupOption>;
65
62
  };
63
+ type ChatInputCommandData = BaseCommandData & {
64
+ type?: CommandType.ChatInput;
65
+ description: string;
66
+ description_localizations?: Partial<Record<LocaleString, string | null>>;
67
+ options?: Array<APIApplicationCommandOption>;
68
+ };
69
+ type UserOrMessageCommandData = BaseCommandData & {
70
+ type: CommandType.User | CommandType.Message;
71
+ };
72
+ type CommandData = ChatInputCommandData | UserOrMessageCommandData;
66
73
  type CommandObject = Omit<CommandFileObject, 'run'>;
67
74
 
68
75
  declare class CommandKit {
package/dist/index.js CHANGED
@@ -506,6 +506,9 @@ var EventHandler = class {
506
506
  for (const eventFilePath of eventFilePaths) {
507
507
  const modulePath = toFileURL(eventFilePath);
508
508
  let eventFunction = (await import(modulePath)).default;
509
+ if (eventFunction?.default) {
510
+ eventFunction = eventFunction.default;
511
+ }
509
512
  const compactFilePath = eventFilePath.split(process.cwd())[1] || eventFilePath;
510
513
  if (typeof eventFunction !== "function") {
511
514
  console.log(
@@ -558,6 +561,9 @@ var ValidationHandler = class {
558
561
  for (const validationFilePath of validationFilePaths) {
559
562
  const modulePath = toFileURL(validationFilePath);
560
563
  let validationFunction = (await import(modulePath)).default;
564
+ if (validationFunction?.default) {
565
+ validationFunction = validationFunction.default;
566
+ }
561
567
  const compactFilePath = validationFilePath.split(process.cwd())[1] || validationFilePath;
562
568
  if (typeof validationFunction !== "function") {
563
569
  console.log(
package/dist/index.mjs CHANGED
@@ -469,6 +469,9 @@ var EventHandler = class {
469
469
  for (const eventFilePath of eventFilePaths) {
470
470
  const modulePath = toFileURL(eventFilePath);
471
471
  let eventFunction = (await import(modulePath)).default;
472
+ if (eventFunction?.default) {
473
+ eventFunction = eventFunction.default;
474
+ }
472
475
  const compactFilePath = eventFilePath.split(process.cwd())[1] || eventFilePath;
473
476
  if (typeof eventFunction !== "function") {
474
477
  console.log(
@@ -521,6 +524,9 @@ var ValidationHandler = class {
521
524
  for (const validationFilePath of validationFilePaths) {
522
525
  const modulePath = toFileURL(validationFilePath);
523
526
  let validationFunction = (await import(modulePath)).default;
527
+ if (validationFunction?.default) {
528
+ validationFunction = validationFunction.default;
529
+ }
524
530
  const compactFilePath = validationFilePath.split(process.cwd())[1] || validationFilePath;
525
531
  if (typeof validationFunction !== "function") {
526
532
  console.log(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commandkit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",