@pikokr/command.ts 4.0.5 → 5.0.0-dev.9796a99

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 (74) hide show
  1. package/.github/workflows/codeql-analysis.yml +70 -0
  2. package/.github/workflows/publish.stable.yml +1 -1
  3. package/.github/workflows/publish.yml +1 -1
  4. package/.vscode/settings.json +10 -0
  5. package/.vscode/templates/ts.lict +5 -0
  6. package/dist/index.d.ts +40 -318
  7. package/dist/index.js +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/package.json +11 -8
  10. package/publish-version.js +10 -0
  11. package/scripts/docs.ts +8 -4
  12. package/src/applicationCommand/ApplicationCommand.ts +17 -0
  13. package/src/applicationCommand/ApplicationCommandOption.ts +9 -0
  14. package/src/applicationCommand/index.ts +2 -6
  15. package/src/core/components/BaseComponent.ts +32 -0
  16. package/src/core/components/ComponentArgument.ts +7 -0
  17. package/src/core/components/ComponentArgumentDecorator.ts +17 -0
  18. package/src/core/components/decoratorCreator.ts +68 -0
  19. package/src/core/components/index.ts +3 -0
  20. package/src/core/index.ts +1 -0
  21. package/src/core/symbols.ts +2 -0
  22. package/src/index.ts +10 -16
  23. package/test/index.ts +32 -25
  24. package/tsconfig.json +1 -1
  25. package/tsconfig.prod.json +4 -0
  26. package/tsup.config.ts +8 -4
  27. package/src/applicationCommand/AppCommand.ts +0 -32
  28. package/src/applicationCommand/decorator.ts +0 -62
  29. package/src/builtinModules/BuiltInModule.ts +0 -13
  30. package/src/builtinModules/BuiltinApplicationCommandConverters.ts +0 -16
  31. package/src/builtinModules/BuiltinCommandConverters.ts +0 -87
  32. package/src/builtinModules/CommandHandler.ts +0 -363
  33. package/src/builtinModules/index.ts +0 -7
  34. package/src/command/ArgumentConverter.ts +0 -22
  35. package/src/command/Command.ts +0 -35
  36. package/src/command/cooldown/adapter.ts +0 -22
  37. package/src/command/cooldown/decorator.ts +0 -67
  38. package/src/command/cooldown/error.ts +0 -9
  39. package/src/command/cooldown/index.ts +0 -9
  40. package/src/command/cooldown/type.ts +0 -12
  41. package/src/command/decorator.ts +0 -185
  42. package/src/command/index.ts +0 -9
  43. package/src/command/utils.ts +0 -33
  44. package/src/constants.ts +0 -31
  45. package/src/error/ArgumentConverterNotFound.ts +0 -18
  46. package/src/error/ArgumentNotProvided.ts +0 -12
  47. package/src/error/CommandCheckFailed.ts +0 -19
  48. package/src/error/CommandNotFound.ts +0 -11
  49. package/src/error/InvalidTargetError.ts +0 -9
  50. package/src/error/ModuleError.ts +0 -11
  51. package/src/error/PermissionRequired.ts +0 -17
  52. package/src/error/checks/DMOnlyCommand.ts +0 -9
  53. package/src/error/checks/GuildOnlyCommand.ts +0 -9
  54. package/src/error/checks/OwnerOnlyCommand.ts +0 -9
  55. package/src/error/checks/SlashCommandGlobalCheckError.ts +0 -11
  56. package/src/error/checks/index.ts +0 -8
  57. package/src/error/index.ts +0 -12
  58. package/src/interface/index.ts +0 -7
  59. package/src/listener/Listener.ts +0 -7
  60. package/src/listener/decorator.ts +0 -29
  61. package/src/listener/index.ts +0 -6
  62. package/src/messageComponents/base.ts +0 -16
  63. package/src/messageComponents/button.ts +0 -30
  64. package/src/messageComponents/index.ts +0 -6
  65. package/src/messageComponents/selectMenu.ts +0 -30
  66. package/src/structures/CommandClient.ts +0 -103
  67. package/src/structures/Module.ts +0 -54
  68. package/src/structures/Registry.ts +0 -245
  69. package/src/structures/index.ts +0 -7
  70. package/src/typings.ts +0 -35
  71. package/src/utils.ts +0 -10
  72. package/test/config.example.json +0 -3
  73. package/test/modules/dev.ts +0 -45
  74. 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
@@ -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/dist/index.d.ts CHANGED
@@ -1,321 +1,43 @@
1
- import * as tslog from 'tslog';
2
- import { Logger } from 'tslog';
3
- import { ApplicationCommandDataResolvable, Snowflake, MessageComponentInteraction, MessageComponentType, Collection, Message, CommandInteraction, Interaction, Client, ContextMenuInteraction, PermissionResolvable, GuildMember, Permissions } from 'discord.js';
4
-
5
- declare class Listener {
1
+ import { Collection, APIApplicationCommandOption } from 'discord.js';
2
+
3
+ declare class ComponentArgumentDecorator<Options = unknown> {
4
+ options: Options;
5
+ constructor(options: Partial<Options>);
6
+ defaultOptions(): Options;
7
+ }
8
+
9
+ declare class ComponentArgument {
10
+ type: unknown;
11
+ decorators: ComponentArgumentDecorator[];
12
+ constructor(type: unknown);
13
+ }
14
+
15
+ declare class BaseComponent<Options = unknown> {
16
+ options: Options;
17
+ method: Function;
18
+ argTypes: Collection<number, ComponentArgument>;
19
+ constructor(options: Partial<Options>, method: Function, argTypes: unknown[]);
20
+ defaultOptions(): Options;
21
+ execute(target: object, args: unknown[]): any;
22
+ }
23
+
24
+ declare type ComponentStore = Collection<string | symbol, BaseComponent>;
25
+ declare type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>;
26
+ declare const getComponentStore: (target: object) => ComponentStore;
27
+ declare const getComponent: (target: object, key: string | symbol) => BaseComponent<unknown> | undefined;
28
+ declare const createComponentDecorator: <Options>(type: {
29
+ new (options: Partial<Options>, method: Function, argTypes: unknown[]): BaseComponent<Options>;
30
+ }) => (options: Options) => MethodDecorator;
31
+ declare const getComponentArgumentStore: (target: object, key: string | symbol) => ComponentArgumentStore;
32
+ declare const createArgumentDecorator: <Options>(type: {
33
+ new (options: Partial<Options>): ComponentArgumentDecorator<Options>;
34
+ }) => (options: Options) => ParameterDecorator;
35
+
36
+ declare const applicationCommand: (options: {
6
37
  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[];
16
- };
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>;
45
- }
46
-
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
- }
38
+ description: string;
39
+ }) => MethodDecorator;
70
40
 
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;
157
- 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
-
179
- declare enum CoolDownType {
180
- USER = 0,
181
- CHANNEL = 1,
182
- GUILD = 2,
183
- ROLE = 3,
184
- CATEGORY = 4,
185
- MEMBER = 5
186
- }
187
-
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>;
198
- }
199
-
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 {
242
- }
243
-
244
- declare class ArgumentNotProvided extends Error {
245
- index: number;
246
- command: Command;
247
- msg: Message;
248
- constructor(index: number, command: Command, msg: Message);
249
- }
250
-
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);
298
- }
299
-
300
- declare class CommandNotFound extends Error {
301
- commandName: string;
302
- msg: Message;
303
- args: string[];
304
- constructor(commandName: string, msg: Message, args: string[]);
305
- }
306
-
307
- declare class BuiltInModule extends Module {
308
- constructor();
309
- }
310
-
311
- declare class ButtonInteractionHandler extends MessageComponentHandler {
312
- constructor(id: string, execute: MessageComponentExecutor);
313
- }
314
- declare const messageButton: (id: string) => MethodDecorator;
315
-
316
- declare class SelectMenuInteractionHandler extends MessageComponentHandler {
317
- constructor(id: string, execute: MessageComponentExecutor);
318
- }
319
- declare const messageSelectMenu: (id: string) => MethodDecorator;
41
+ declare const option: (options: APIApplicationCommandOption) => ParameterDecorator;
320
42
 
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 };
43
+ export { BaseComponent, applicationCommand, createArgumentDecorator, createComponentDecorator, getComponent, getComponentArgumentStore, getComponentStore, option };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var dt=Object.create;var z=Object.defineProperty;var lt=Object.getOwnPropertyDescriptor;var ut=Object.getOwnPropertyNames,Se=Object.getOwnPropertySymbols,pt=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty,ft=Object.prototype.propertyIsEnumerable;var Oe=n=>z(n,"__esModule",{value:!0}),i=(n,e)=>z(n,"name",{value:e,configurable:!0});var ke=(n,e)=>{var t={};for(var r in n)ve.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&Se)for(var r of Se(n))e.indexOf(r)<0&&ft.call(n,r)&&(t[r]=n[r]);return t};var ht=(n,e)=>{for(var t in e)z(n,t,{get:e[t],enumerable:!0})},Te=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ut(e))!ve.call(n,o)&&(t||o!=="default")&&z(n,o,{get:()=>e[o],enumerable:!(r=lt(e,o))||r.enumerable});return n},de=(n,e)=>Te(Oe(z(n!=null?dt(pt(n)):{},"default",!e&&n&&n.__esModule?{get:()=>n.default,enumerable:!0}:{value:n,enumerable:!0})),n),gt=(n=>(e,t)=>n&&n.get(e)||(t=Te(Oe({}),e,1),n&&n.set(e,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var _t={};ht(_t,{AppCommand:()=>me,ApplicationCommandArgumentConverter:()=>ae,ApplicationCommandArgumentConverterNotFound:()=>O,ApplicationCommandCheckFailed:()=>k,ArgumentConverter:()=>ie,ArgumentConverterNotFound:()=>I,ArgumentNotProvided:()=>j,BuiltInModule:()=>C,ButtonInteractionHandler:()=>fe,ClientPermissionRequired:()=>K,Command:()=>se,CommandCheckFailed:()=>Z,CommandClient:()=>be,CommandNotFound:()=>te,CoolDownError:()=>B,CoolDownType:()=>g,DMOnlyCommandError:()=>U,DefaultCoolDownAdapter:()=>ce,GuildOnlyCommandError:()=>P,InvalidModuleError:()=>_,InvalidTargetError:()=>v,Listener:()=>oe,Module:()=>x,ModuleLoadError:()=>X,OwnerOnlyCommandError:()=>D,Registry:()=>ne,SelectMenuInteractionHandler:()=>he,SlashCommandGlobalCheckError:()=>ee,UserPermissionRequired:()=>L,applicationCommand:()=>Ot,applicationCommandArgumentConverter:()=>wt,argumentConverter:()=>E,command:()=>yt,coolDown:()=>vt,createCheckDecorator:()=>M,dmOnly:()=>bt,guildOnly:()=>Mt,listener:()=>ue,messageButton:()=>Tt,messageSelectMenu:()=>At,option:()=>kt,optional:()=>xt,ownerOnly:()=>Rt,requireClientPermissions:()=>St,requireUserPermissions:()=>Et,rest:()=>Ct});var Jn=require("reflect-metadata");var F=Symbol("Command.TS Commands"),$=Symbol("Command.TS Slash Commands"),le=Symbol("Command.TS Slash Command Options"),W=Symbol("Command.TS Listeners"),A=Symbol("Command.TS Module Path"),xe=Symbol("Command.TS Module Identifier"),q=Symbol("Command.TS Built-In Module"),Ce=Symbol("Command.TS Optional Parameters"),Re=Symbol("Command.TS Rest Parameter"),Y=Symbol("Command.TS Argument Converter"),J=Symbol("Command.TS Slash Argument Converter"),Q=Symbol("Command.TS Command Checks"),V=Symbol("Command.TS Slash Command Checks"),b=Symbol("Command.TS Message Component Handlers");var x=class{get logger(){return this.commandClient.logger.getChildLogger({name:this.constructor.name})}get commands(){return Reflect.getMetadata(F,this)||[]}get listeners(){return Reflect.getMetadata(W,this)||[]}get argumentConverters(){return Reflect.getMetadata(Y,this)||[]}get applicationCommandArgumentConverters(){return Reflect.getMetadata(J,this)||[]}get applicationCommands(){return Reflect.getMetadata($,this)||[]}get messageComponentHandlers(){return Reflect.getMetadata(b,this)||[]}get path(){return Reflect.getMetadata(A,this)}load(){}unload(){}beforeReload(){}afterReload(){}};i(x,"Module");var at=de(require("lodash"));var re=de(require("path"));var v=class extends Error{constructor(){super('Class does not extend "Module" class.')}};i(v,"InvalidTargetError");var X=class extends Error{constructor(e,t){super("Failed to load module "+e);this.error=t}};i(X,"ModuleLoadError");var _=class extends Error{};i(_,"InvalidModuleError");var j=class extends Error{constructor(e,t,r){super(`Required argument #${e} not provided.`);this.index=e,this.command=t,this.msg=r}};i(j,"ArgumentNotProvided");var I=class extends Error{constructor(e,t){super(`Argument converter ${e.type.name} not found.`);this.type=e,this.msg=t}};i(I,"ArgumentConverterNotFound");var O=class extends Error{constructor(e,t){super(`Argument converter ${e.type.name} not found.`);this.type=e,this.interaction=t}};i(O,"ApplicationCommandArgumentConverterNotFound");var Z=class extends Error{constructor(e,t){super();this.msg=e,this.command=t}};i(Z,"CommandCheckFailed");var k=class extends Error{constructor(e,t){super();this.interaction=e,this.command=t}};i(k,"ApplicationCommandCheckFailed");var L=class extends Error{constructor(e,t){super();this.user=e,this.permissions=t}};i(L,"UserPermissionRequired");var K=class extends Error{constructor(e){super();this.permissions=e}};i(K,"ClientPermissionRequired");var D=class extends Error{constructor(){super()}};i(D,"OwnerOnlyCommandError");var P=class extends Error{constructor(){super()}};i(P,"GuildOnlyCommandError");var U=class extends Error{constructor(){super()}};i(U,"DMOnlyCommandError");var ee=class extends Error{constructor(e){super("Slash command before-run check failed.");this.i=e}};i(ee,"SlashCommandGlobalCheckError");var te=class extends Error{constructor(e,t,r){super(`Command ${e} not found.`);this.commandName=e,this.msg=t,this.args=r}};i(te,"CommandNotFound");var Ae=require("discord.js"),_e=de(require("walk-sync")),je=de(require("fs")),ne=class{constructor(e){this.client=e,this.modules=new Ae.Collection}get logger(){return this.client.logger.getChildLogger({name:"Registry"})}get commands(){let e=[];for(let[,t]of this.modules)e.push(...t.commands);return e}get argumentConverters(){let e=[];for(let[,t]of this.modules)e.push(...t.argumentConverters);return e}get applicationCommandArgumentConverters(){let e=[];for(let[,t]of this.modules)e.push(...t.applicationCommandArgumentConverters);return e}get applicationCommands(){let e=[];for(let[,t]of this.modules)e.push(...t.applicationCommands);return e}get messageComponentHandlers(){let e=[];for(let[,t]of this.modules)e.push(...t.messageComponentHandlers);return e}registerModule(e){e.commandClient=this.client,this.modules.set(Symbol(e.constructor.name),e);let t=[];for(let r of e.listeners){let o=r.execute.bind(e);t.push({event:r.name,execute:o}),this.client.client.on(r.name,o)}return Reflect.defineMetadata(xe,t,e),e}async loadModulesIn(e,t=!1){let r=t?e:re.default.join(require.main.path,e);for(let o of(0,_e.default)(r))if(je.lstatSync(re.default.join(r,o)).isFile()){if(o.endsWith(".map"))continue;await this.loadModule(re.default.join(r,o),!0)}}async loadModule(e,t=!1){let r=t?e:re.default.join(require.main.path,e),o;try{o=require(r)}catch(c){throw new X(r,c)}if(o.loaded)throw new Error("MODULE_ALREADY_LOADED");if(!o.install)throw new _("Install function not found.");let s=o.install(this.client);if(!(s instanceof x))throw new v;return Reflect.defineMetadata(A,require.resolve(r),s),this.registerModule(s),await s.load(),o.loaded=!0,s}async syncCommands(){var c;this.logger.debug("Syncing commands...");let e=this.applicationCommands.filter(a=>!a.guild),t=this.client.options.applicationCommands.guild,r=i(async(a,m)=>{this.logger.debug(`Syncing for guild ${a.name}(${a.id})`);let l=m.map(u=>u.command);this.logger.debug(`Command List: ${l.map(u=>u.name).join(", ")}`),await a.commands.set(l)},"syncForGuild");if(t)if(typeof t=="string")await r(await this.client.client.guilds.fetch(t),e);else for(let a of t)await r(await this.client.client.guilds.fetch(a),e);else this.logger.debug("Syncing global..."),await((c=this.client.client.application)==null?void 0:c.commands.set(e.map(a=>a.command)));let o=this.applicationCommands.filter(a=>!!a.guild),s=new Set;for(let a of o)if(!!a.guild)if(typeof a.guild=="string")s.add(a.guild);else for(let m of a.guild)s.add(m);for(let a of s)await r(await this.client.client.guilds.fetch(a),o.filter(m=>m.guild&&(typeof m.guild=="string"?a===m.guild:m.guild.includes(a))));this.logger.debug("Syncing ended.")}async unregisterModule(e){if(Reflect.getMetadata(q,e))throw new Error("Built-in modules cannot be unloaded");let t=this.modules.findKey(o=>o===e);if(!t)return e;await e.unload();let r=Reflect.getMetadata(xe,e);for(let o of r)this.client.client.removeListener(o.event,o.execute);return this.modules.delete(t),e}async unloadModule(e){let t=Reflect.getMetadata(A,e);if(!t)throw new _("This module is not loaded by loadModule.");await this.unregisterModule(e),delete require.cache[t]}async reloadModule(e){await e.beforeReload();let t=Reflect.getMetadata(A,e);return await this.unloadModule(e),await(await this.loadModule(t,!0)).afterReload(),!0}async reloadAll(){let e=[];for(let[,t]of this.modules.filter(r=>!!r.path&&!Reflect.getMetadata(q,r)))try{await this.reloadModule(t),e.push({path:t.path,success:!0})}catch(r){e.push({error:r,path:t.path,success:!1})}return e}};i(ne,"Registry");var ct=require("discord.js");var C=class extends x{constructor(){super();Reflect.defineMetadata(q,!0,this)}};i(C,"BuiltInModule");var oe=class{constructor(e,t){this.name=e,this.execute=t}};i(oe,"Listener");var w=i(n=>{if(!(n instanceof x))throw new v},"checkTarget");var ue=i(n=>(e,t)=>{w(e);let r=Reflect.getMetadata(W,e),o=new oe(n,Reflect.get(e,t));r?r.push(o):(r=[o],Reflect.defineMetadata(W,r,e))},"listener");var f=require("discord.js");function Ie(n,e,t,r,o){var s={};Object.keys(r).forEach(function(a){s[a]=r[a]}),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=t.slice().reverse().reduce(function(a,m){return m&&m(n,e,a)||a},s),o&&s.initializer!==void 0&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0);var c=Object.getOwnPropertyDescriptor(n,e);return c&&(c.get||c.set)&&(delete s.writable,delete s.initializer),s.initializer===void 0&&(Object.defineProperty(n,e,s),s=null),s}i(Ie,"_applyDecoratedDescriptor");var R,Le,Ke,De,Pe,Ue,Be,Ne=(R=i(class extends C{constructor(e){super();this.registry=e,this.client=e.client}async message(e){let t=i(r=>this.client.client.emit("commandError",r,e),"error1");try{let r=typeof this.client.options.command.prefix=="string"?this.client.options.command.prefix:typeof this.client.options.command.prefix=="function"?await this.client.options.command.prefix(e):this.client.options.command.prefix,o;if(typeof r=="object"){let u=r.find(y=>e.content.includes(y));if(!u)return;o=u}else{if(!e.content.includes(r))return;o=r}if(!e.content.startsWith(o))return;let s=e.content.slice(o.length).split(" "),c=s.shift();if(!c)return;let a=null;for(let u of this.registry.commands)if([...typeof u.aliases=="function"?await u.aliases(e):u.aliases,u.name].some(S=>S===c)){a=u;break}if(e.data={cts:this.client,command:a,prefix:o},!await this.client.options.command.check(e))return;if(!a)return t(new te(c,e,s));let m=this.registry.modules.find(u=>u.commands.includes(a));if(!m)return;let l=[];for(let u of a.checks)if(!await u(e))return t(new Z(e,a));for(let u=0;u<a.argTypes.length;u++){let y=a.argTypes[u],S=this.registry.argumentConverters.find(G=>G.type===y.type);if(y.rest){let G=s.join(" ");l.push(G);break}if(!S)return t(new I(y,e));let ge=this.registry.modules.find(G=>G.argumentConverters.includes(S));if(!ge)return t(new I(y,e));if(S.withoutParameter){l.push(await S.execute(ge,e));continue}let ye=s.shift();if(y.optional&&!ye)break;if(!ye)return t(new j(u,a,e));let we=await S.execute(ge,e,ye);if(we==null&&!y.optional)return t(new j(u,a,e));l.push(we)}try{await a.execute(m,l)}catch(u){return t(u)}}catch(r){return t(r)}}async command(e){var r,o;let t=i(s=>this.client.client.emit("applicationCommandError",s,e),"error2");try{let s=this.registry.applicationCommands.find(m=>m.command.type==="CHAT_INPUT"&&m.command.name===e.commandName);if(!s)return;let c=this.registry.modules.find(m=>m.applicationCommands.includes(s));if(!c)return;let a=[];if(e.data={cts:this.client,command:s},!await this.client.options.slashCommands.check(e))return t(new ee(e));for(let m of s.checks)if(!await m(e))return t(new k(e,s));for(let m=0;m<s.params.length;m++){let l=s.params[m],u=this.registry.applicationCommandArgumentConverters.find(y=>y.type===l.type);if(l.type===f.CommandInteraction){a.push(e);continue}if(l.type===f.CommandInteractionOptionResolver){a.push(e.options);continue}if(l.name){switch(l.type){case String:a.push(e.options.getString(l.name,!1)||void 0);break;case f.Role:a.push(e.options.getRole(l.name,!1)||void 0);break;case f.User:a.push(e.options.getUser(l.name,!1)||void 0);break;case f.GuildMember:a.push(e.options.getMember(l.name,!1)||void 0);break;case Boolean:a.push(e.options.getBoolean(l.name,!1)||void 0);break;case Number:let y=e.options.get(l.name,!1);if(!y){a.push(void 0);break}if(y.type=="NUMBER"){a.push((r=e.options.getNumber(l.name,!1))!=null?r:void 0);break}if(y.type=="INTEGER"){a.push((o=e.options.getInteger(l.name,!1))!=null?o:void 0);break}}continue}if(!u)return t(new O(l,e));a.push(await u.execute(c,e))}await s.execute(c,a)}catch(s){return t(s)}}async messageComponent(e){let t=i(r=>this.client.client.emit("messageComponentError",r),"error");try{let r=[];for(let o of this.registry.messageComponentHandlers)o.componentId===o.componentId&&o.componentType===e.componentType&&r.push(o);for(let o of r){let s=this.registry.modules.find(c=>c.messageComponentHandlers.includes(o));!s||await o.run(s,e)}}catch(r){t(r)}}async userContextMenu(e){let t=i(r=>this.client.client.emit("applicationCommandError",r,e),"error3");try{let r=this.registry.applicationCommands.find(c=>c.command.type==="USER"&&c.command.name===e.commandName);if(!r)return;let o=this.registry.modules.find(c=>c.applicationCommands.includes(r));if(!o)return;e.data={cts:this.client,command:r};for(let c of r.checks)if(!await c(e))return t(new k(e,r));let s=[];for(let c=0;c<r.params.length;c++){let a=r.params[c],m=this.registry.applicationCommandArgumentConverters.find(l=>l.type===a.type);if(a.type===f.UserContextMenuInteraction){s.push(e);continue}if(!m)return t(new O(a,e));s.push(await m.execute(o,e))}await r.execute(o,s)}catch(r){return t(r)}}async messageContextMenu(e){let t=i(r=>this.client.client.emit("applicationCommandError",r,e),"error4");try{let r=this.registry.applicationCommands.find(c=>c.command.type==="MESSAGE"&&c.command.name===e.commandName);if(!r)return;let o=this.registry.modules.find(c=>c.applicationCommands.includes(r));if(!o)return;e.data={cts:this.client,command:r};for(let c of r.checks)if(!await c(e))return t(new k(e,r));let s=[];for(let c=0;c<r.params.length;c++){let a=r.params[c],m=this.registry.applicationCommandArgumentConverters.find(l=>l.type===a.type);if(a.type===f.MessageContextMenuInteraction){s.push(e);continue}if(!m)return t(new O(a,e));s.push(await m.execute(o,e))}await r.execute(o,s)}catch(r){return t(r)}}async interaction(e){let t=i(r=>this.client.client.emit("interactionError",r,e),"error");try{if(await this.client.options.applicationCommands.beforeRunCheck(e),e.isCommand()){await this.command(e);return}if(e.isMessageComponent()){await this.messageComponent(e);return}if(e.isMessageContextMenu()){await this.messageContextMenu(e);return}if(e.isUserContextMenu()){await this.userContextMenu(e);return}}catch(r){return t(r)}}},"CommandHandler"),Le=ue("messageCreate"),Ke=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),De=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof f.Message=="undefined"?Object:f.Message]),Ie(R.prototype,"message",[Le,Ke,De],Object.getOwnPropertyDescriptor(R.prototype,"message"),R.prototype),Pe=ue("interactionCreate"),Ue=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),Be=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof f.Interaction=="undefined"?Object:f.Interaction]),Ie(R.prototype,"interaction",[Pe,Ue,Be],Object.getOwnPropertyDescriptor(R.prototype,"interaction"),R.prototype),R);var se=class{execute(e,t){return this.run.apply(e,t)}get checks(){return Reflect.getMetadata(Q,this.module,this.key)||[]}constructor(e,t,r,o,s,c){this.run=e,this.argTypes=t,this.name=r,this.aliases=o,this.module=s,this.key=c}};i(se,"Command");var ie=class{execute(e,t,r){return this.run.apply(e,[t,r])}constructor(e,t,r){this.type=e,this.run=t,this.withoutParameter=r}};i(ie,"ArgumentConverter");var ae=class{execute(e,t){return this.run.apply(e,[t])}constructor(e,t){this.type=e,this.run=t}};i(ae,"ApplicationCommandArgumentConverter");var M=i((n,e)=>(t,r)=>{if(n){let o=Reflect.getMetadata(Q,t,r);o?o.push(n):(o=[n],Reflect.defineMetadata(Q,o,t,r))}if(e){let o=Reflect.getMetadata(V,t,r);o?o.push(e):(o=[e],Reflect.defineMetadata(V,o,t,r))}},"createCheckDecorator");var T=require("discord.js");var yt=i((n={})=>(e,t)=>{var m;w(e);let r=Reflect.getMetadata(F,e),o=(m=n.optionTypes)!=null?m:Reflect.getMetadata("design:paramtypes",e,t),s=Reflect.getMetadata(Ce,e,t)||-1,c=Reflect.getMetadata(Re,e,t)||-1,a=new se(Reflect.get(e,t),o.map((l,u)=>({type:l,optional:s===-1?!1:s<=u,rest:c===-1?!1:c===u})),n.name||t,n.aliases||[],e,t);r?r.push(a):(r=[a],Reflect.defineMetadata(F,r,e))},"command"),E=i((n,e=!0)=>(t,r)=>{w(t);let o=Reflect.getMetadata(Y,t),s=new ie(n,Reflect.get(t,r),!e);o?o.push(s):(o=[s],Reflect.defineMetadata(Y,o,t))},"argumentConverter"),wt=i(n=>(e,t)=>{w(e);let r=Reflect.getMetadata(J,e),o=new ae(n,Reflect.get(e,t));r?r.push(o):(r=[o],Reflect.defineMetadata(J,r,e))},"applicationCommandArgumentConverter"),xt=i((n,e,t)=>{w(n),Reflect.defineMetadata(Ce,t,n,e)},"optional"),Ct=i((n,e,t)=>{w(n);let r=Reflect.getMetadata("design:paramtypes",n,e);if(r.length-1!==t)throw new Error("Rest decorator must be used at last argument.");if(r[t]!==String)throw new Error('Rest argument type must be "String"');Reflect.defineMetadata(Re,t,n,e)},"rest"),Rt=M(n=>{if(n.data.cts.owners.includes(n.author.id))return!0;throw new D},n=>{if(n.data.cts.owners.includes(n.user.id))return!0;throw new D}),Mt=M(n=>{if(n.guild)return!0;throw new P},n=>{if(n.guildId)return!0;throw new P}),bt=M(n=>{if(!n.guild)return!0;throw new U},n=>{if(!n.guildId)return!0;throw new U}),Et=i(n=>M(e=>{if(!e.guild||!e.member)throw new Error("This command must be used in guild.");if(e.member.permissionsIn(e.channel).has(n))return!0;throw new L(e.member,new T.Permissions(n))},e=>{if(!e.guild||!e.member)throw new Error("This command must be used in guild.");if(!(e.member instanceof T.GuildMember)||e.member.permissionsIn(e.channel).has(n))return!0;throw new L(e.member,new T.Permissions(n))}),"requireUserPermissions"),St=i(n=>M(e=>{if(!e.guild)throw new Error("This command must be used in guild.");if(e.guild.me.permissionsIn(e.channel).has(n))return!0;throw new K(new T.Permissions(n))},e=>{if(!e.guild)throw new Error("This command must be used in guild.");if(e.guild.me.permissionsIn(e.channel).has(n))return!0;throw new K(new T.Permissions(n))}),"requireClientPermissions");var g;(function(n){n[n.USER=0]="USER",n[n.CHANNEL=1]="CHANNEL",n[n.GUILD=2]="GUILD",n[n.ROLE=3]="ROLE",n[n.CATEGORY=4]="CATEGORY",n[n.MEMBER=5]="MEMBER"})(g||(g={}));var Me=require("discord.js");var B=class extends Error{constructor(e){super();this.endsAt=e}};i(B,"CoolDownError");var vt=i((n,e)=>M(async t=>{var m;let r=t.data.cts.coolDownAdapter,s=i(()=>{var l;switch(n){case g.USER:return t.author.id;case g.GUILD:return(t.guild||t.author).id;case g.CHANNEL:return t.channel.id;case g.MEMBER:return`${(l=t.guild)==null?void 0:l.id}.${t.author.id}`;case g.ROLE:return(t.channel instanceof Me.DMChannel?t.channel:t.member.roles.highest).id;case g.CATEGORY:return(t.channel.parent||t.channel).id}},"getKey")()+"-command-"+((m=t.data.command)==null?void 0:m.name),c=await r.get(s),a=Date.now();if(!c||!(a-c<e*1e3))return await r.set(s,a),!0;throw new B(new Date(c+e*1e3))},async t=>{if(t.isMessageComponent())return!0;let r=t.data.cts.coolDownAdapter,s=i(()=>{var m;switch(n){case g.USER:return t.user.id+".user";case g.GUILD:return(t.guild||t.user).id+".guild";case g.CHANNEL:return t.channel.id+".channel";case g.MEMBER:return`${(m=t.guild)==null?void 0:m.id}.${t.user.id}`;case g.ROLE:return(t.channel instanceof Me.DMChannel?t.channel:t.member.roles.highest).id+".role";case g.CATEGORY:return(t.channel.parent||t.channel).id+".category"}},"getKey")()+"-appCommand-"+t.commandName,c=await r.get(s),a=Date.now();if(!c||!(a-c<e*1e3))return await r.set(s,a),!0;throw new B(new Date(c+e*1e3))}),"coolDown");var He=require("discord.js"),ce=class{async get(e){return this.map.get(e)}async set(e,t){this.map.set(e,t)}constructor(){this.map=new He.Collection}};i(ce,"DefaultCoolDownAdapter");var h=require("discord.js");function N(n,e,t,r,o){var s={};Object.keys(r).forEach(function(a){s[a]=r[a]}),s.enumerable=!!s.enumerable,s.configurable=!!s.configurable,("value"in s||s.initializer)&&(s.writable=!0),s=t.slice().reverse().reduce(function(a,m){return m&&m(n,e,a)||a},s),o&&s.initializer!==void 0&&(s.value=s.initializer?s.initializer.call(o):void 0,s.initializer=void 0);var c=Object.getOwnPropertyDescriptor(n,e);return c&&(c.get||c.set)&&(delete s.writable,delete s.initializer),s.initializer===void 0&&(Object.defineProperty(n,e,s),s=null),s}i(N,"_applyDecoratedDescriptor");var p,Ge,ze,Fe,$e,We,qe,Ye,Je,Qe,Ve,Xe,Ze,et,tt,rt,nt,ot,st,it=(p=i(class extends C{constructor(e){super();this.cts=e,this.client=e.client}message(e){return e}string(e,t){return t}getUserIDByMention(e){if(!!e&&e.startsWith("<@")&&e.endsWith(">"))return e=e.slice(2,-1),e.startsWith("!")&&(e=e.slice(1)),e}user(e,t){let r=this.client.users.cache.get(t);if(r||(r=this.client.users.cache.find(s=>s.tag===t||s.username===t),r))return r;let o=this.getUserIDByMention(t);return o?(r=this.client.users.cache.get(o),r||null):null}member(e,t){var s,c,a;let r=(s=e.guild)==null?void 0:s.members.cache.get(t);if(!r||(r=(c=e.guild)==null?void 0:c.members.cache.find(m=>m.user.tag===t),r))return r;let o=this.getUserIDByMention(t);if(!!o)return r=(a=e.guild)==null?void 0:a.members.cache.get(o),r||void 0}number(e,t){let r=Number(t);return isNaN(r)?void 0:r}getRoleIDByMention(e){if(!!e&&e.startsWith("<@")&&e.endsWith(">"))return e=e.slice(2,-1),e.startsWith("&")&&(e=e.slice(1)),e}role(e,t){var s;let r=this.getRoleIDByMention(t);return r&&((s=e.guild)==null?void 0:s.roles.cache.get(r))||void 0}},"BuiltinCommandConverters"),Ge=E(h.Message,!1),ze=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),Fe=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof h.Message=="undefined"?Object:h.Message]),N(p.prototype,"message",[Ge,ze,Fe],Object.getOwnPropertyDescriptor(p.prototype,"message"),p.prototype),$e=E(String),We=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),qe=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof h.Message=="undefined"?Object:h.Message,String]),N(p.prototype,"string",[$e,We,qe],Object.getOwnPropertyDescriptor(p.prototype,"string"),p.prototype),Ye=E(h.User),Je=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),Qe=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof h.Message=="undefined"?Object:h.Message,String]),N(p.prototype,"user",[Ye,Je,Qe],Object.getOwnPropertyDescriptor(p.prototype,"user"),p.prototype),Ve=E(h.GuildMember),Xe=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),Ze=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof h.Message=="undefined"?Object:h.Message,String]),N(p.prototype,"member",[Ve,Xe,Ze],Object.getOwnPropertyDescriptor(p.prototype,"member"),p.prototype),et=E(Number),tt=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),rt=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof h.Message=="undefined"?Object:h.Message,String]),N(p.prototype,"number",[et,tt,rt],Object.getOwnPropertyDescriptor(p.prototype,"number"),p.prototype),nt=E(h.Role),ot=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:type",Function),st=typeof Reflect!="undefined"&&typeof Reflect.metadata=="function"&&Reflect.metadata("design:paramtypes",[typeof h.Message=="undefined"?Object:h.Message,String]),N(p.prototype,"role",[nt,ot,st],Object.getOwnPropertyDescriptor(p.prototype,"role"),p.prototype),p);var pe=class extends C{constructor(e){super();this.cts=e,this.client=e.client}};i(pe,"BuiltinApplicationCommandConverters");var mt=require("tslog"),be=class{async fetchOwners(){var t,r;await((t=this.client.application)==null?void 0:t.fetch());let e=(r=this.client.application)==null?void 0:r.owner;return e?e instanceof ct.User?[e.id]:e.members.map(o=>o.id):[]}async ready(){if(!this._isReady){if(this._isReady=!0,this.options.owners==="auto"){let e=await this.fetchOwners();this.owners.push(...e)}this.options.applicationCommands.autoSync&&await this.registry.syncCommands()}}constructor(s){var c=s,{client:e,coolDownAdapter:t,logger:r}=c,o=ke(c,["client","coolDownAdapter","logger"]);this.owners=[],this.registry=new ne(this),this._isReady=!1,this.client=e,this.coolDownAdapter=t||new ce,this.options=at.default.merge({command:{prefix:"!",check:()=>!0},owners:"auto",slashCommands:{check:()=>!0},applicationCommands:{autoSync:!1,beforeRunCheck:()=>{}}},o),this.logger=r!=null?r:new mt.Logger({name:"Command.TS"}),this.options.owners!=="auto"&&(this.owners=this.options.owners),this.client.once("ready",()=>this.ready()),this.registry.registerModule(new Ne(this.registry)),this.registry.registerModule(new it(this)),this.registry.registerModule(new pe(this))}};i(be,"CommandClient");var Ee=require("discord.js");var me=class{get checks(){return Reflect.getMetadata(V,this.module,this.key)||[]}execute(e,t){return this.run.apply(e,t)}constructor(e,t,r,o,s,c){this.command=e,this.run=t,this.module=r,this.params=o,this.guild=s,this.key=c}};i(me,"AppCommand");var Ot=i(n=>(e,t)=>{var a;w(e);let r=Reflect.getMetadata($,e),o=(a=n.optionTypes)!=null?a:Reflect.getMetadata("design:paramtypes",e,t),s=Reflect.getMetadata(le,e,t)||new Ee.Collection,c=new me(n.command,Reflect.get(e,t),e,o.map((m,l)=>({type:m,name:s.get(l)})),n.guild,t);r?r.push(c):(r=[c],Reflect.defineMetadata($,r,e))},"applicationCommand"),kt=i(n=>(e,t,r)=>{w(e);let o=Reflect.getMetadata(le,e,t);o||(o=new Ee.Collection,Reflect.defineMetadata(le,o,e,t)),o.set(r,n)},"option");var H=class{constructor(e,t,r){this.componentId=e,this.componentType=t,this.execute=r}run(e,t){return this.execute.apply(e,[t])}};i(H,"MessageComponentHandler");var fe=class extends H{constructor(e,t){super(e,"BUTTON",t)}};i(fe,"ButtonInteractionHandler");var Tt=i(n=>(e,t)=>{w(e);let r=new fe(n,Reflect.get(e,t)),o=Reflect.getMetadata(b,e);o?o.push(r):(o=[r],Reflect.defineMetadata(b,o,e))},"messageButton");var he=class extends H{constructor(e,t){super(e,"SELECT_MENU",t)}};i(he,"SelectMenuInteractionHandler");var At=i(n=>(e,t)=>{w(e);let r=new he(n,Reflect.get(e,t)),o=Reflect.getMetadata(b,e);o?o.push(r):(o=[r],Reflect.defineMetadata(b,o,e))},"messageSelectMenu");module.exports=gt(_t);0&&(module.exports={AppCommand,ApplicationCommandArgumentConverter,ApplicationCommandArgumentConverterNotFound,ApplicationCommandCheckFailed,ArgumentConverter,ArgumentConverterNotFound,ArgumentNotProvided,BuiltInModule,ButtonInteractionHandler,ClientPermissionRequired,Command,CommandCheckFailed,CommandClient,CommandNotFound,CoolDownError,CoolDownType,DMOnlyCommandError,DefaultCoolDownAdapter,GuildOnlyCommandError,InvalidModuleError,InvalidTargetError,Listener,Module,ModuleLoadError,OwnerOnlyCommandError,Registry,SelectMenuInteractionHandler,SlashCommandGlobalCheckError,UserPermissionRequired,applicationCommand,applicationCommandArgumentConverter,argumentConverter,command,coolDown,createCheckDecorator,dmOnly,guildOnly,listener,messageButton,messageSelectMenu,option,optional,ownerOnly,requireClientPermissions,requireUserPermissions,rest});
1
+ var E=Object.create;var m=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var b=e=>m(e,"__esModule",{value:!0}),r=(e,t)=>m(e,"name",{value:t,configurable:!0});var G=(e,t)=>{for(var o in t)m(e,o,{get:t[o],enumerable:!0})},w=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of z(t))!F.call(e,n)&&(o||n!=="default")&&m(e,n,{get:()=>t[n],enumerable:!(s=q(t,n))||s.enumerable});return e},R=(e,t)=>w(b(m(e!=null?E(B(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),H=(e=>(t,o)=>e&&e.get(t)||(o=w(b({}),t,1),e&&e.set(t,o),o))(typeof WeakMap!="undefined"?new WeakMap:0);var J={};G(J,{BaseComponent:()=>a,applicationCommand:()=>O,createArgumentDecorator:()=>h,createComponentDecorator:()=>d,getComponent:()=>I,getComponentArgumentStore:()=>g,getComponentStore:()=>x,option:()=>j});var X=require("reflect-metadata");var M=require("discord.js"),D=R(require("lodash"));var f=class{constructor(t){this.type=t,this.decorators=[]}};r(f,"ComponentArgument");var a=class{argTypes=new M.Collection;constructor(t,o,s){typeof t=="object"?this.options=D.default.merge(this.defaultOptions(),t):this.options=t,this.method=o;for(let n=0;n<s.length;n++){let c=s[n];this.argTypes.set(n,new f(c))}}defaultOptions(){return{}}execute(t,o){return this.method.apply(t,o)}};r(a,"BaseComponent");var u=require("discord.js");var i=Symbol(),Q=Symbol();var x=r(e=>{let t=Reflect.getMetadata(i,e);return t||(t=new u.Collection,Reflect.defineMetadata(i,t,e)),t},"getComponentStore"),I=r((e,t)=>x(e).get(t),"getComponent"),d=r(e=>t=>(o,s)=>{var n=new e(t,Reflect.get(o,s),Reflect.getMetadata("design:paramtypes",o,s));let c=x(o);g(o,s).forEach((T,_)=>{var y;(y=n.argTypes.get(_))==null||y.decorators.push(T)}),c.set(s,n)},"createComponentDecorator"),g=r((e,t)=>{let o=Reflect.getMetadata(i,e,t);return o||(o=new u.Collection,Reflect.defineMetadata(i,o,e,t)),o},"getComponentArgumentStore"),h=r(e=>t=>(o,s,n)=>{var c=new e(t);g(o,s).set(n,c)},"createArgumentDecorator");var C=class extends a{defaultOptions(){return{name:"",description:""}}};r(C,"SlashCommand");var O=d(C);var A=R(require("lodash")),l=class{constructor(t){typeof t=="object"?this.options=A.default.merge(this.defaultOptions(),t):this.options=t}defaultOptions(){return{}}};r(l,"ComponentArgumentDecorator");var S=class extends l{};r(S,"ApplicationCommandOption");var j=h(S);module.exports=H(J);0&&(module.exports={BaseComponent,applicationCommand,createArgumentDecorator,createComponentDecorator,getComponent,getComponentArgumentStore,getComponentStore,option});
2
2
  //# sourceMappingURL=index.js.map