@pikokr/command.ts 3.0.1-dev.4d426ce → 3.0.3

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.
Files changed (44) hide show
  1. package/dist/argumentConverter/decorator.d.ts +5 -0
  2. package/dist/argumentConverter/decorator.js +24 -0
  3. package/dist/argumentConverter/index.d.ts +1 -0
  4. package/dist/argumentConverter/index.js +13 -0
  5. package/dist/command/CommandManager.d.ts +16 -0
  6. package/dist/command/CommandManager.js +69 -0
  7. package/dist/debugTool/DebugModule.d.ts +7 -0
  8. package/dist/debugTool/DebugModule.js +56 -0
  9. package/dist/debugTool/commands/default.d.ts +7 -0
  10. package/dist/debugTool/commands/default.js +17 -0
  11. package/dist/debugTool/commands/eval.d.ts +9 -0
  12. package/dist/debugTool/commands/eval.js +103 -0
  13. package/dist/debugTool/commands/index.d.ts +6 -0
  14. package/dist/debugTool/commands/index.js +21 -0
  15. package/dist/debugTool/commands/load.d.ts +9 -0
  16. package/dist/debugTool/commands/load.js +36 -0
  17. package/dist/debugTool/commands/reload.d.ts +9 -0
  18. package/dist/debugTool/commands/reload.js +54 -0
  19. package/dist/debugTool/commands/unload.d.ts +9 -0
  20. package/dist/debugTool/commands/unload.js +54 -0
  21. package/dist/debugTool/index.d.ts +20 -0
  22. package/dist/debugTool/index.js +18 -0
  23. package/dist/defaultModules/BuiltInConverters.d.ts +13 -0
  24. package/dist/defaultModules/BuiltInConverters.js +72 -0
  25. package/dist/defaultModules/CommandHandler.d.ts +11 -0
  26. package/dist/defaultModules/CommandHandler.js +178 -0
  27. package/dist/defaultModules/index.d.ts +2 -0
  28. package/dist/defaultModules/index.js +14 -0
  29. package/dist/error/CheckFailedError.d.ts +5 -0
  30. package/dist/error/CheckFailedError.js +10 -0
  31. package/dist/error/Permissions.d.ts +36 -0
  32. package/dist/error/Permissions.js +55 -0
  33. package/dist/listener/ListenerManager.d.ts +25 -0
  34. package/dist/listener/ListenerManager.js +52 -0
  35. package/dist/slashCommand/SlashCommandManager.d.ts +33 -0
  36. package/dist/slashCommand/SlashCommandManager.js +138 -0
  37. package/dist/structures/Context.d.ts +9 -0
  38. package/dist/structures/Context.js +13 -0
  39. package/dist/structures/Registry.js +2 -2
  40. package/dist/types/index.d.ts +101 -0
  41. package/dist/types/index.js +2 -0
  42. package/package.json +2 -2
  43. package/src/structures/Registry.ts +2 -2
  44. package/test/modules/dev.ts +25 -0
@@ -182,12 +182,12 @@ class Registry {
182
182
  reloadAll() {
183
183
  return __awaiter(this, void 0, void 0, function* () {
184
184
  const results = [];
185
- for (const [, module] of this.modules.filter((x) => !!x.path)) {
185
+ for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(constants_1.KBuiltInModule, x))) {
186
186
  try {
187
187
  yield this.reloadModule(module);
188
188
  results.push({
189
189
  path: module.path,
190
- success: false,
190
+ success: true,
191
191
  });
192
192
  }
193
193
  catch (e) {
@@ -0,0 +1,101 @@
1
+ import { Module } from '../structures';
2
+ import { ApplicationCommandOptionData, Message, PermissionResolvable, Snowflake } from 'discord.js';
3
+ export declare type CommandClientOptions = {
4
+ owners: Snowflake[] | 'auto';
5
+ prefix: string | ((msg: Message) => string | Promise<string>);
6
+ slashCommands: {
7
+ autoRegister: boolean;
8
+ } & ({
9
+ guild: Snowflake | Snowflake[];
10
+ } | {
11
+ ownerCommandGuild: Snowflake;
12
+ });
13
+ commands: {
14
+ allowSelf: boolean;
15
+ allowBots: boolean;
16
+ };
17
+ };
18
+ export interface ICommandDecoratorOptions {
19
+ aliases: string[];
20
+ brief?: string;
21
+ description?: string;
22
+ name: string;
23
+ }
24
+ export interface ICommandArgument {
25
+ type: Function;
26
+ optional: boolean;
27
+ rest: boolean;
28
+ }
29
+ export interface ICommandDecoratorMetadata {
30
+ args: ICommandArgument[];
31
+ usesCtx: boolean;
32
+ key: string;
33
+ }
34
+ export interface ISlashCommandDecoratorMetadata {
35
+ options: ApplicationCommandOptionData[];
36
+ key: string;
37
+ }
38
+ export interface ISlashCommandArgument {
39
+ type: Function;
40
+ }
41
+ export interface ICommandArgument {
42
+ type: Function;
43
+ optional: boolean;
44
+ rest: boolean;
45
+ }
46
+ export interface ISlashCommandDecoratorOptions {
47
+ name: string;
48
+ options: ApplicationCommandOptionData[];
49
+ description: string;
50
+ }
51
+ export declare type ISlashCommandDecorator = ISlashCommandDecoratorMetadata & ISlashCommandDecoratorOptions;
52
+ export declare type ICommandDecorator = ICommandDecoratorOptions & ICommandDecoratorMetadata;
53
+ export interface Command {
54
+ execute: Function;
55
+ args: ICommandArgument[];
56
+ name: string;
57
+ aliases: string[];
58
+ description?: string;
59
+ brief?: string;
60
+ usesCtx: boolean;
61
+ module: Module;
62
+ ownerOnly: boolean;
63
+ checks: CheckFunction[];
64
+ userPermissions?: PermissionResolvable;
65
+ clientPermissions?: PermissionResolvable;
66
+ }
67
+ export interface SlashCommand {
68
+ execute: Function;
69
+ name: string;
70
+ description: string;
71
+ module: Module;
72
+ options: ApplicationCommandOptionData[];
73
+ ownerOnly: boolean;
74
+ checks: CheckFunction[];
75
+ userPermissions?: PermissionResolvable;
76
+ clientPermissions?: PermissionResolvable;
77
+ }
78
+ export interface IListener {
79
+ event: string;
80
+ id: string;
81
+ }
82
+ export declare type ListenerDecorator = IListener & {
83
+ key: string;
84
+ };
85
+ export declare type Listener = IListener & {
86
+ wrapper: (...args: any[]) => any;
87
+ module: Module;
88
+ };
89
+ export interface IArgConverterDecorator {
90
+ type: Function;
91
+ key: string;
92
+ }
93
+ export interface ArgConverter {
94
+ type: Function;
95
+ convert: (arg: string, msg: Message) => any;
96
+ module: Module;
97
+ }
98
+ export declare type CheckFunction = (msg: Message) => boolean | Promise<boolean>;
99
+ export declare type RequiredPermissions = {
100
+ permissions: PermissionResolvable;
101
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pikokr/command.ts",
3
3
  "description": "Discord.js command framework for typescript.",
4
- "version": "3.0.1-dev.4d426ce",
4
+ "version": "3.0.3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -31,4 +31,4 @@
31
31
  "docs:dev": "typedoc",
32
32
  "docs:build": "typedoc"
33
33
  }
34
- }
34
+ }
@@ -179,12 +179,12 @@ export class Registry {
179
179
  error?: Error
180
180
  }[] = []
181
181
 
182
- for (const [, module] of this.modules.filter((x) => !!x.path)) {
182
+ for (const [, module] of this.modules.filter((x) => !!x.path && !Reflect.getMetadata(KBuiltInModule, x))) {
183
183
  try {
184
184
  await this.reloadModule(module)
185
185
  results.push({
186
186
  path: module.path!,
187
- success: false,
187
+ success: true,
188
188
  })
189
189
  } catch (e: any) {
190
190
  results.push({
@@ -0,0 +1,25 @@
1
+ import { BuiltInModule, CommandClient, ownerOnly, slashCommand } from '../../src'
2
+ import { CommandInteraction } from 'discord.js'
3
+ import { SlashCommandBuilder } from '@discordjs/builders'
4
+
5
+ export class Dev extends BuiltInModule {
6
+ constructor(private cts: CommandClient) {
7
+ super()
8
+ }
9
+
10
+ @slashCommand({
11
+ command: new SlashCommandBuilder().setName('reload').setDescription('리로드 커맨드'),
12
+ })
13
+ @ownerOnly
14
+ async reload(i: CommandInteraction) {
15
+ const data = await this.cts.registry.reloadAll()
16
+ await i.reply({
17
+ ephemeral: true,
18
+ content: '```\n' + data.map((x) => (x.success ? `✅ ${x.path}` : `❌ ${x.path}\n${x.error}`)).join('\n') + '```',
19
+ })
20
+ }
21
+ }
22
+
23
+ export function install(cts: CommandClient) {
24
+ return new Dev(cts)
25
+ }