@pikokr/command.ts 4.0.6 → 5.0.0-dev.572678b

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 (95) hide show
  1. package/.github/workflows/codeql-analysis.yml +70 -0
  2. package/.github/workflows/docs.yml +1 -1
  3. package/.github/workflows/publish.stable.yml +1 -1
  4. package/.github/workflows/publish.yml +1 -1
  5. package/.vscode/settings.json +10 -0
  6. package/.vscode/templates/ts.lict +5 -0
  7. package/README.md +2 -0
  8. package/dist/index.d.ts +134 -296
  9. package/dist/index.js +1 -1
  10. package/dist/index.js.map +1 -1
  11. package/docs/index.yml +1 -1
  12. package/package.json +21 -14
  13. package/publish-version.js +20 -0
  14. package/renovate.json +5 -0
  15. package/scripts/docs.ts +8 -4
  16. package/src/applicationCommand/ApplicationCommand.ts +17 -0
  17. package/src/applicationCommand/ApplicationCommandExtension.ts +169 -0
  18. package/src/applicationCommand/ApplicationCommandOption.ts +16 -0
  19. package/src/applicationCommand/index.ts +10 -6
  20. package/src/core/components/BaseComponent.ts +56 -0
  21. package/src/core/components/ComponentArgument.ts +15 -0
  22. package/src/core/components/ComponentArgumentDecorator.ts +25 -0
  23. package/src/core/components/decoratorCreator.ts +81 -0
  24. package/src/core/components/index.ts +13 -0
  25. package/src/core/converter/index.ts +16 -0
  26. package/src/core/extensions/CTSExtension.ts +17 -0
  27. package/src/core/extensions/Extension.ts +62 -0
  28. package/src/core/extensions/index.ts +9 -0
  29. package/src/core/hooks/componentHook.ts +40 -0
  30. package/src/core/hooks/index.ts +11 -0
  31. package/src/core/hooks/moduleHook.ts +39 -0
  32. package/src/core/index.ts +15 -0
  33. package/src/core/listener/index.ts +29 -0
  34. package/src/core/structures/CommandClient.ts +71 -0
  35. package/src/core/structures/Registry.ts +110 -0
  36. package/src/core/structures/index.ts +10 -0
  37. package/src/core/symbols.ts +13 -0
  38. package/src/core/utils/checks.ts +27 -0
  39. package/src/core/utils/errors.ts +9 -0
  40. package/src/core/utils/index.ts +10 -0
  41. package/src/index.ts +11 -16
  42. package/src/textCommand/TextCommand.ts +11 -0
  43. package/src/textCommand/index.ts +1 -0
  44. package/test/index.ts +74 -21
  45. package/tsconfig.json +3 -3
  46. package/tsconfig.prod.json +8 -0
  47. package/tsup.config.ts +9 -4
  48. package/src/applicationCommand/AppCommand.ts +0 -32
  49. package/src/applicationCommand/decorator.ts +0 -62
  50. package/src/builtinModules/BuiltInModule.ts +0 -13
  51. package/src/builtinModules/BuiltinApplicationCommandConverters.ts +0 -16
  52. package/src/builtinModules/BuiltinCommandConverters.ts +0 -87
  53. package/src/builtinModules/CommandHandler.ts +0 -363
  54. package/src/builtinModules/index.ts +0 -7
  55. package/src/command/ArgumentConverter.ts +0 -22
  56. package/src/command/Command.ts +0 -35
  57. package/src/command/cooldown/adapter.ts +0 -22
  58. package/src/command/cooldown/decorator.ts +0 -67
  59. package/src/command/cooldown/error.ts +0 -9
  60. package/src/command/cooldown/index.ts +0 -9
  61. package/src/command/cooldown/type.ts +0 -12
  62. package/src/command/decorator.ts +0 -185
  63. package/src/command/index.ts +0 -9
  64. package/src/command/utils.ts +0 -33
  65. package/src/constants.ts +0 -31
  66. package/src/error/ArgumentConverterNotFound.ts +0 -18
  67. package/src/error/ArgumentNotProvided.ts +0 -12
  68. package/src/error/CommandCheckFailed.ts +0 -19
  69. package/src/error/CommandNotFound.ts +0 -11
  70. package/src/error/InvalidTargetError.ts +0 -9
  71. package/src/error/ModuleError.ts +0 -11
  72. package/src/error/PermissionRequired.ts +0 -17
  73. package/src/error/checks/DMOnlyCommand.ts +0 -9
  74. package/src/error/checks/GuildOnlyCommand.ts +0 -9
  75. package/src/error/checks/OwnerOnlyCommand.ts +0 -9
  76. package/src/error/checks/SlashCommandGlobalCheckError.ts +0 -11
  77. package/src/error/checks/index.ts +0 -8
  78. package/src/error/index.ts +0 -12
  79. package/src/interface/index.ts +0 -7
  80. package/src/listener/Listener.ts +0 -7
  81. package/src/listener/decorator.ts +0 -29
  82. package/src/listener/index.ts +0 -6
  83. package/src/messageComponents/base.ts +0 -16
  84. package/src/messageComponents/button.ts +0 -30
  85. package/src/messageComponents/index.ts +0 -6
  86. package/src/messageComponents/selectMenu.ts +0 -30
  87. package/src/structures/CommandClient.ts +0 -103
  88. package/src/structures/Module.ts +0 -54
  89. package/src/structures/Registry.ts +0 -253
  90. package/src/structures/index.ts +0 -7
  91. package/src/typings.ts +0 -35
  92. package/src/utils.ts +0 -10
  93. package/test/config.example.json +0 -3
  94. package/test/modules/dev.ts +0 -45
  95. package/test/modules/test.ts +0 -148
@@ -0,0 +1,70 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: 'CodeQL'
13
+
14
+ on:
15
+ push:
16
+ branches: [dev]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [dev]
20
+ schedule:
21
+ - cron: '31 4 * * 2'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: ['javascript']
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
37
+ # Learn more about CodeQL language support at https://git.io/codeql-language-support
38
+
39
+ steps:
40
+ - name: Checkout repository
41
+ uses: actions/checkout@v2
42
+
43
+ # Initializes the CodeQL tools for scanning.
44
+ - name: Initialize CodeQL
45
+ uses: github/codeql-action/init@v1
46
+ with:
47
+ languages: ${{ matrix.language }}
48
+ # If you wish to specify custom queries, you can do so here or in a config file.
49
+ # By default, queries listed here will override any specified in a config file.
50
+ # Prefix the list here with "+" to use these queries and those in the config file.
51
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
52
+
53
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
+ # If this step fails, then you should remove it and run the build manually (see below)
55
+ - name: Autobuild
56
+ uses: github/codeql-action/autobuild@v1
57
+
58
+ # ℹ️ Command-line programs to run using the OS shell.
59
+ # 📚 https://git.io/JvXDl
60
+
61
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
62
+ # and modify them (or add more) to build your code if your project
63
+ # uses a compiled language
64
+
65
+ #- run: |
66
+ # make bootstrap
67
+ # make release
68
+
69
+ - name: Perform CodeQL Analysis
70
+ uses: github/codeql-action/analyze@v1
@@ -76,4 +76,4 @@ jobs:
76
76
  git config user.email 41898282+github-actions[bot]@users.noreply.github.com
77
77
  git add .
78
78
  git commit -m "Docs build for ${BRANCH_OR_TAG} ${BRANCH_NAME}: ${SHA}" || true
79
- git push
79
+ git push
@@ -11,7 +11,7 @@ jobs:
11
11
  - uses: actions/checkout@v1
12
12
  - uses: actions/setup-node@v1
13
13
  with:
14
- node-version: 16.6
14
+ node-version: 16.16
15
15
  - run: yarn
16
16
  - uses: JS-DevTools/npm-publish@v1
17
17
  with:
@@ -11,7 +11,7 @@ jobs:
11
11
  - uses: actions/checkout@v1
12
12
  - uses: actions/setup-node@v1
13
13
  with:
14
- node-version: 16.6
14
+ node-version: 16.16
15
15
  - run: yarn
16
16
  - run: COMMIT_ID=$(git rev-parse --short HEAD) node publish-version.js
17
17
  - uses: JS-DevTools/npm-publish@v1
@@ -0,0 +1,10 @@
1
+ {
2
+ "license-header-manager.additionalCommentStyles": [
3
+ {
4
+ "extension": ".ts",
5
+ "commentStart": "/*",
6
+ "commentEnd": "*/",
7
+ "commentMiddle": "*"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,5 @@
1
+ File: %(File)
2
+
3
+ Copyright (c) %(CreationYear)-%(CurrentYear) %(Username)
4
+
5
+ Licensed under MIT License. Please see more defails in LICENSE file.
package/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![.github/workflows/publish.yml](https://github.com/pikokr/command.ts/actions/workflows/publish.yml/badge.svg)](https://github.com/pikokr/command.ts/actions/workflows/publish.yml) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
4
4
  [![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
5
+
5
6
  <!-- ALL-CONTRIBUTORS-BADGE:END -->
6
7
 
7
8
  ![cts](https://user-images.githubusercontent.com/68010770/145200458-b14c5e4e-6927-4516-8d48-c68a384d2a20.png)
@@ -11,6 +12,7 @@ Command framework for discord.js
11
12
  [Discord](https://discord.gg/EEhcPzsGHV) / [문서](https://v3.cts.pikokr.dev) / [V2 문서](https://command-ts-docs-ezojnktwv-pikokr.vercel.app/)
12
13
 
13
14
  ## Contributors
15
+
14
16
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
15
17
  <!-- prettier-ignore-start -->
16
18
  <!-- markdownlint-disable -->
package/dist/index.d.ts CHANGED
@@ -1,321 +1,159 @@
1
+ import * as discord_js from 'discord.js';
2
+ import { Collection, Snowflake, Interaction, ChatInputCommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction, Client, UserApplicationCommandData, MessageApplicationCommandData, ChatInputApplicationCommandData, ApplicationCommandType, APIApplicationCommandOption } from 'discord.js';
3
+ import EventEmitter from 'events';
1
4
  import * as tslog from 'tslog';
2
5
  import { Logger } from 'tslog';
3
- import { ApplicationCommandDataResolvable, Snowflake, MessageComponentInteraction, MessageComponentType, Collection, Message, CommandInteraction, Interaction, Client, ContextMenuInteraction, PermissionResolvable, GuildMember, Permissions } from 'discord.js';
4
6
 
5
- declare class Listener {
6
- name: string;
7
- execute: Function;
8
- constructor(name: string, execute: Function);
9
- }
10
-
11
- declare const listener: (event: string) => (target: Module, propertyKey: string) => void;
12
-
13
- declare type ApplicationCommandOptions$1 = {
14
- guild: Snowflake | Snowflake[];
15
- optionTypes?: any[];
7
+ declare type ModuleHookStore = Collection<string, Function[]>;
8
+ declare const getModuleHookStore: (target: object) => ModuleHookStore;
9
+ declare const moduleHook: (name: string) => MethodDecorator;
10
+
11
+ declare type ComponentHookFn = (...args: any[]) => void | Promise<void>;
12
+ declare type ComponentHookStore = Collection<string, ComponentHookFn[]>;
13
+ declare const createComponentHook: (name: string, fn: ComponentHookFn) => MethodDecorator;
14
+
15
+ declare class ComponentArgumentDecorator<Options = unknown> {
16
+ options: Options;
17
+ constructor(options: Partial<Options>);
18
+ defaultOptions(): Options;
19
+ }
20
+
21
+ declare class ComponentArgument {
22
+ type: unknown;
23
+ decorators: ComponentArgumentDecorator[];
24
+ constructor(type: unknown);
25
+ }
26
+
27
+ declare class BaseComponent<Options = unknown, OptionsArg = Options> {
28
+ options: Options;
29
+ method: Function;
30
+ hooks: ComponentHookStore;
31
+ argTypes: Collection<number, ComponentArgument>;
32
+ constructor(options: OptionsArg, method: Function, argTypes: unknown[]);
33
+ convertOptions(options: OptionsArg): Options;
34
+ executeHook(target: object, name: string, args: unknown[]): Promise<void>;
35
+ execute(target: object, args: unknown[], beforeCallArgs?: unknown[]): Promise<any>;
36
+ }
37
+
38
+ declare type ComponentStore = Collection<string | symbol, BaseComponent>;
39
+ declare type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>;
40
+ declare const getComponentStore: (target: object) => ComponentStore;
41
+ declare const getComponent: (target: object, key: string | symbol) => BaseComponent<unknown, unknown> | undefined;
42
+ declare const createComponentDecorator: <Options, OptionArgs>(type: {
43
+ new (options: OptionArgs, method: Function, argTypes: unknown[]): BaseComponent<Options, OptionArgs>;
44
+ }) => (options: OptionArgs) => MethodDecorator;
45
+ declare const getComponentArgumentStore: (target: object, key: string | symbol) => ComponentArgumentStore;
46
+ declare const createArgumentDecorator: <Options>(type: {
47
+ new (options: Partial<Options>): ComponentArgumentDecorator<Options>;
48
+ }) => (options: Options) => ParameterDecorator;
49
+
50
+ declare type Options = {
51
+ component: typeof BaseComponent<unknown>;
52
+ type: Function;
53
+ parameterless: boolean;
16
54
  };
17
- declare const applicationCommand: (opt: Partial<ApplicationCommandOptions$1> & {
18
- command: ApplicationCommandDataResolvable;
19
- }) => (target: Object, propertyKey: string) => void;
20
- declare const option: (key: string) => ParameterDecorator;
21
-
22
- declare type AppCommandArgument = {
23
- type: any;
24
- name?: string;
25
- };
26
- declare class AppCommand {
27
- command: ApplicationCommandDataResolvable;
28
- private run;
29
- module: Module;
30
- params: AppCommandArgument[];
31
- guild: Snowflake | Snowflake[] | undefined;
32
- private key;
33
- get checks(): ApplicationCommandCheckFunction[];
34
- execute(module: Module, args: any[]): any;
35
- constructor(command: ApplicationCommandDataResolvable, run: Function, module: Module, params: AppCommandArgument[], guild: Snowflake | Snowflake[] | undefined, key: string | symbol);
36
- }
37
-
38
- declare type MessageComponentExecutor = (i: MessageComponentInteraction) => void | Promise<void>;
39
- declare class MessageComponentHandler {
40
- componentId: string;
41
- componentType: Exclude<MessageComponentType, 'ACTION_ROW'>;
42
- execute: MessageComponentExecutor;
43
- constructor(componentId: string, componentType: Exclude<MessageComponentType, 'ACTION_ROW'>, execute: MessageComponentExecutor);
44
- run(module: Module, i: MessageComponentInteraction): void | Promise<void>;
55
+ declare class ConverterComponent extends BaseComponent<Options, Options & {
56
+ parameterless?: boolean;
57
+ }> {
45
58
  }
59
+ declare const argConverter: (options: Options & {
60
+ parameterless?: boolean | undefined;
61
+ }) => MethodDecorator;
46
62
 
47
- declare class Registry {
48
- client: CommandClient;
49
- constructor(client: CommandClient);
50
- modules: Collection<symbol, Module>;
51
- private get logger();
52
- get commands(): Command[];
53
- get argumentConverters(): ArgumentConverter[];
54
- get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[];
55
- get applicationCommands(): AppCommand[];
56
- get messageComponentHandlers(): MessageComponentHandler[];
57
- registerModule(module: Module): Module;
58
- loadModulesIn(dir: string, absolute?: boolean): Promise<void>;
59
- loadModule(file: string, absolute?: boolean): Promise<Module>;
60
- syncCommands(): Promise<void>;
61
- unregisterModule(module: Module): Promise<Module>;
62
- unloadModule(module: Module): Promise<void>;
63
- reloadModule(module: Module): Promise<boolean>;
64
- reloadAll(): Promise<{
65
- path: string;
66
- success: boolean;
67
- error?: Error | undefined;
68
- }[]>;
69
- }
70
-
71
- interface CommandOptions$1 {
72
- prefix: string | ((msg: any) => string | Promise<string | string[]> | string[]) | string[];
73
- check: (msg: Message) => boolean | Promise<boolean>;
74
- }
75
- interface SlashCommandOptions {
76
- check: (i: CommandInteraction) => boolean | Promise<boolean>;
77
- }
78
- interface ApplicationCommandOptions {
79
- guild?: Snowflake | Snowflake[];
80
- autoSync: boolean;
81
- beforeRunCheck: (i: Interaction) => void | Promise<void>;
82
- }
83
- interface CommandClientOptions {
84
- command: CommandOptions$1;
85
- owners: 'auto' | Snowflake[];
86
- slashCommands: SlashCommandOptions;
87
- applicationCommands: ApplicationCommandOptions;
88
- }
89
- interface CommandClientOptionsParam {
90
- command: Partial<CommandOptions$1>;
91
- owners: 'auto' | string[];
92
- slashCommands: Partial<SlashCommandOptions>;
93
- applicationCommands: Partial<ApplicationCommandOptions>;
94
- }
95
- declare class CommandClient {
96
- options: CommandClientOptions;
97
- owners: string[];
98
- registry: Registry;
99
- client: Client;
100
- coolDownAdapter: CoolDownAdapter;
101
- logger: Logger;
102
- private _isReady;
103
- private fetchOwners;
104
- ready(): Promise<void>;
105
- constructor({ client, coolDownAdapter, logger, ...options }: Partial<CommandClientOptionsParam> & {
106
- client: Client;
107
- coolDownAdapter?: CoolDownAdapter;
108
- logger?: Logger;
109
- });
110
- }
111
-
112
- declare abstract class Module {
113
- commandClient: CommandClient;
114
- get logger(): tslog.Logger;
115
- get commands(): Command[];
116
- get listeners(): Listener[];
117
- get argumentConverters(): ArgumentConverter[];
118
- get applicationCommandArgumentConverters(): ApplicationCommandArgumentConverter[];
119
- get applicationCommands(): AppCommand[];
120
- get messageComponentHandlers(): MessageComponentHandler[];
121
- get path(): string | undefined;
122
- load(): void;
123
- unload(): void;
124
- beforeReload(): void;
125
- afterReload(): void;
126
- }
127
-
128
- declare type Argument = {
129
- optional: boolean;
130
- type: any;
131
- rest: boolean;
132
- };
133
- declare type CheckFunction = (msg: Message) => boolean | Promise<boolean>;
134
- declare type ApplicationCommandCheckFunction = (i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>;
135
- declare class Command {
136
- private run;
137
- argTypes: Argument[];
138
- name: string;
139
- aliases: string[] | ((msg: Message) => string[] | Promise<string[]>);
140
- module: Module;
141
- key: symbol | string;
142
- execute(module: Module, args: any[]): any;
143
- get checks(): CheckFunction[];
144
- constructor(run: Function, argTypes: Argument[], name: string, aliases: string[] | ((msg: Message) => string[] | Promise<string[]>), module: Module, key: symbol | string);
145
- }
146
-
147
- declare type CommandOptions = {
148
- name: string;
149
- aliases: string[] | ((msg: Message) => string[]);
150
- optionTypes?: any[];
151
- };
152
- declare const command: (options?: Partial<CommandOptions>) => (target: Object, propertyKey: string) => void;
153
- declare const argumentConverter: (type: object, requireParameter?: boolean) => (target: Object, propertyKey: string) => void;
154
- declare const applicationCommandArgumentConverter: (type: object) => (target: Object, propertyKey: string) => void;
155
- declare const optional: ParameterDecorator;
156
- declare const rest: ParameterDecorator;
63
+ declare const createCheckDecorator: (fn: ComponentHookFn) => MethodDecorator;
157
64
  declare const ownerOnly: MethodDecorator;
158
- declare const guildOnly: MethodDecorator;
159
- declare const dmOnly: MethodDecorator;
160
- declare const requireUserPermissions: (permission: PermissionResolvable) => MethodDecorator;
161
- declare const requireClientPermissions: (permission: PermissionResolvable) => MethodDecorator;
162
-
163
- declare class ArgumentConverter {
164
- type: object;
165
- private run;
166
- withoutParameter: boolean;
167
- execute(module: Module, msg: Message, arg?: string): any;
168
- constructor(type: object, run: Function, withoutParameter: boolean);
169
- }
170
- declare class ApplicationCommandArgumentConverter {
171
- type: object;
172
- private run;
173
- execute(module: Module, interaction: CommandInteraction | ContextMenuInteraction): any;
174
- constructor(type: object, run: Function);
175
- }
176
-
177
- declare const createCheckDecorator: (execute: ((msg: Message) => boolean | Promise<boolean>) | null, executeApplicationCommand?: ((i: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction) => boolean | Promise<boolean>) | undefined) => MethodDecorator;
178
65
 
179
- declare enum CoolDownType {
180
- USER = 0,
181
- CHANNEL = 1,
182
- GUILD = 2,
183
- ROLE = 3,
184
- CATEGORY = 4,
185
- MEMBER = 5
66
+ declare class OwnerOnlyError {
186
67
  }
187
68
 
188
- declare const coolDown: (type: CoolDownType, seconds: number) => MethodDecorator;
189
-
190
- interface CoolDownAdapter {
191
- get(id: string): Promise<number | undefined>;
192
- set(id: string, value: number): Promise<void>;
193
- }
194
- declare class DefaultCoolDownAdapter implements CoolDownAdapter {
195
- map: Collection<string, number>;
196
- get(id: string): Promise<number | undefined>;
197
- set(id: string, value: number): Promise<void>;
69
+ declare class ListenerComponent extends BaseComponent<{
70
+ emitter: string;
71
+ event: string;
72
+ }, {
73
+ emitter?: string;
74
+ event: string;
75
+ }> {
76
+ defaultOptions(): {
77
+ emitter: string;
78
+ };
79
+ constructor(options: ListenerComponent['options'], method: Function, argTypes: unknown[]);
198
80
  }
81
+ declare const listener: (options: {
82
+ emitter?: string | undefined;
83
+ event: string;
84
+ }) => MethodDecorator;
199
85
 
200
- declare class CoolDownError extends Error {
201
- endsAt: Date;
202
- constructor(endsAt: Date);
203
- }
204
-
205
- declare module 'discord.js' {
206
- interface Message {
207
- data: {
208
- command: Command | null;
209
- prefix: string;
210
- cts: CommandClient;
211
- };
212
- }
213
- interface CommandInteraction {
214
- data: {
215
- command: AppCommand;
216
- cts: CommandClient;
217
- };
218
- }
219
- interface MessageComponentInteraction {
220
- data: {
221
- command: AppCommand;
222
- cts: CommandClient;
223
- };
224
- }
225
- interface ContextMenuInteraction {
226
- data: {
227
- command: AppCommand;
228
- cts: CommandClient;
229
- };
230
- }
231
- }
232
-
233
- declare class InvalidTargetError extends Error {
234
- constructor();
235
- }
236
-
237
- declare class ModuleLoadError extends Error {
238
- error: Error;
239
- constructor(file: string, error: Error);
240
- }
241
- declare class InvalidModuleError extends Error {
86
+ declare class Extension {
87
+ protected get commandClient(): CommandClient;
88
+ protected get client(): discord_js.Client<boolean>;
89
+ protected _logger?: Logger;
90
+ protected get logger(): Logger;
91
+ protected convertArguments(component: typeof BaseComponent<unknown>, argList: unknown[], args: Collection<number, ComponentArgument>, getConverterArgs: (arg: ComponentArgument, index: number) => unknown[] | Promise<unknown[]>): Promise<void>;
242
92
  }
243
93
 
244
- declare class ArgumentNotProvided extends Error {
245
- index: number;
246
- command: Command;
247
- msg: Message;
248
- constructor(index: number, command: Command, msg: Message);
94
+ declare class CTSExtension extends Extension {
95
+ protected get logger(): tslog.Logger;
249
96
  }
250
97
 
251
- declare class ArgumentConverterNotFound extends Error {
252
- type: Argument;
253
- msg: Message;
254
- constructor(type: Argument, msg: Message);
255
- }
256
- declare class ApplicationCommandArgumentConverterNotFound extends Error {
257
- type: AppCommandArgument;
258
- interaction: CommandInteraction | ContextMenuInteraction;
259
- constructor(type: AppCommandArgument, interaction: CommandInteraction | ContextMenuInteraction);
260
- }
261
-
262
- declare class CommandCheckFailed extends Error {
263
- msg: Message;
264
- command: Command;
265
- constructor(msg: Message, command: Command);
266
- }
267
- declare class ApplicationCommandCheckFailed extends Error {
268
- interaction: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction;
269
- command: AppCommand;
270
- constructor(interaction: CommandInteraction | MessageComponentInteraction | ContextMenuInteraction, command: AppCommand);
271
- }
272
-
273
- declare class UserPermissionRequired extends Error {
274
- user: GuildMember;
275
- permissions: Permissions;
276
- constructor(user: GuildMember, permissions: Permissions);
277
- }
278
- declare class ClientPermissionRequired extends Error {
279
- permissions: Permissions;
280
- constructor(permissions: Permissions);
281
- }
282
-
283
- declare class OwnerOnlyCommandError extends Error {
284
- constructor();
285
- }
286
-
287
- declare class GuildOnlyCommandError extends Error {
288
- constructor();
289
- }
290
-
291
- declare class DMOnlyCommandError extends Error {
292
- constructor();
293
- }
294
-
295
- declare class SlashCommandGlobalCheckError extends Error {
296
- i: CommandInteraction;
297
- constructor(i: CommandInteraction);
98
+ declare type ApplicationCommandExtensionConfig = {
99
+ guilds?: Snowflake[];
100
+ };
101
+ declare class ApplicationCommandExtension extends CTSExtension {
102
+ config: ApplicationCommandExtensionConfig;
103
+ constructor(config: ApplicationCommandExtensionConfig);
104
+ interactionCreate(i: Interaction): Promise<void>;
105
+ load(): Promise<void>;
106
+ sync(): Promise<void>;
107
+ chatInteraction(i: ChatInputCommandInteraction): Promise<ChatInputCommandInteraction<discord_js.CacheType>>;
108
+ messageInteraction(i: MessageContextMenuCommandInteraction): Promise<MessageContextMenuCommandInteraction<discord_js.CacheType>>;
109
+ userInteraction(i: UserContextMenuCommandInteraction): Promise<UserContextMenuCommandInteraction<discord_js.CacheType>>;
110
+ }
111
+
112
+ declare class CommandClient extends EventEmitter {
113
+ discord: Client;
114
+ logger: Logger;
115
+ ctsLogger: Logger;
116
+ registry: Registry;
117
+ owners: Set<Snowflake>;
118
+ constructor(discord: Client, logger?: Logger);
119
+ fetchOwners(): Promise<void>;
120
+ enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig): Promise<void>;
121
+ getApplicationCommandsExtension(): ApplicationCommandExtension | undefined;
122
+ static getFromModule(ext: object): CommandClient;
298
123
  }
299
124
 
300
- declare class CommandNotFound extends Error {
301
- commandName: string;
302
- msg: Message;
303
- args: string[];
304
- constructor(commandName: string, msg: Message, args: string[]);
125
+ declare class Registry {
126
+ client: CommandClient;
127
+ extensions: object[];
128
+ emitters: Collection<string, EventEmitter>;
129
+ logger: Logger;
130
+ constructor(logger: Logger, client: CommandClient);
131
+ getComponentsWithTypeGlobal<T extends typeof BaseComponent<Config>, Config>(type: T): InstanceType<T>[];
132
+ getComponentsWithType<T extends typeof BaseComponent<Config>, Config>(ext: object, type: T): InstanceType<T>[];
133
+ registerEventListeners(ext: object): void;
134
+ unregisterEventListeners(ext: object): void;
135
+ registerModule(ext: object): Promise<void>;
136
+ unregisterModule(ext: object): Promise<void>;
137
+ runModuleHook(ext: object, hookName: string, ...args: unknown[]): void;
138
+ registerEventEmitter(name: string, emitter: EventEmitter): void;
305
139
  }
306
140
 
307
- declare class BuiltInModule extends Module {
308
- constructor();
141
+ declare class ApplicationCommandComponent extends BaseComponent<(UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {
142
+ type: ApplicationCommandType;
143
+ }> {
309
144
  }
145
+ declare const applicationCommand: (options: (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, "options">) & {
146
+ type: ApplicationCommandType;
147
+ }) => MethodDecorator;
310
148
 
311
- declare class ButtonInteractionHandler extends MessageComponentHandler {
312
- constructor(id: string, execute: MessageComponentExecutor);
313
- }
314
- declare const messageButton: (id: string) => MethodDecorator;
149
+ declare const option: (options: APIApplicationCommandOption) => ParameterDecorator;
315
150
 
316
- declare class SelectMenuInteractionHandler extends MessageComponentHandler {
317
- constructor(id: string, execute: MessageComponentExecutor);
151
+ declare type TextCommandOptions = {
152
+ name: string;
153
+ description?: string;
154
+ };
155
+ declare class TextCommandComponent extends BaseComponent<TextCommandOptions> {
318
156
  }
319
- declare const messageSelectMenu: (id: string) => MethodDecorator;
157
+ declare const command: (options: TextCommandOptions) => MethodDecorator;
320
158
 
321
- export { AppCommand, AppCommandArgument, ApplicationCommandArgumentConverter, ApplicationCommandArgumentConverterNotFound, ApplicationCommandCheckFailed, ApplicationCommandCheckFunction, ApplicationCommandOptions, Argument, ArgumentConverter, ArgumentConverterNotFound, ArgumentNotProvided, BuiltInModule, ButtonInteractionHandler, CheckFunction, ClientPermissionRequired, Command, CommandCheckFailed, CommandClient, CommandClientOptions, CommandClientOptionsParam, CommandNotFound, CommandOptions$1 as CommandOptions, CoolDownAdapter, CoolDownError, CoolDownType, DMOnlyCommandError, DefaultCoolDownAdapter, GuildOnlyCommandError, InvalidModuleError, InvalidTargetError, Listener, Module, ModuleLoadError, OwnerOnlyCommandError, Registry, SelectMenuInteractionHandler, SlashCommandGlobalCheckError, SlashCommandOptions, UserPermissionRequired, applicationCommand, applicationCommandArgumentConverter, argumentConverter, command, coolDown, createCheckDecorator, dmOnly, guildOnly, listener, messageButton, messageSelectMenu, option, optional, ownerOnly, requireClientPermissions, requireUserPermissions, rest };
159
+ export { ApplicationCommandComponent, BaseComponent, CommandClient, ComponentArgument, ComponentArgumentDecorator, ComponentHookStore, ConverterComponent, Extension, ListenerComponent, OwnerOnlyError, Registry, TextCommandComponent, applicationCommand, argConverter, command, createArgumentDecorator, createCheckDecorator, createComponentDecorator, createComponentHook, getComponent, getComponentArgumentStore, getComponentStore, getModuleHookStore, listener, moduleHook, option, ownerOnly };