@pikokr/command.ts 5.0.2-dev.f4dfec1 → 5.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 (2) hide show
  1. package/dist/index.d.ts +131 -131
  2. package/package.json +2 -2
package/dist/index.d.ts CHANGED
@@ -4,173 +4,173 @@ import EventEmitter from 'events';
4
4
  import * as tslog from 'tslog';
5
5
  import { Logger } from 'tslog';
6
6
 
7
- declare type ModuleHookStore = Collection<string, Function[]>;
8
- declare const getModuleHookStore: (target: object) => ModuleHookStore;
7
+ declare type ModuleHookStore = Collection<string, Function[]>;
8
+ declare const getModuleHookStore: (target: object) => ModuleHookStore;
9
9
  declare const moduleHook: (name: string) => MethodDecorator;
10
10
 
11
- declare type ComponentHookFn = (...args: any[]) => void | Promise<void>;
12
- declare type ComponentHookStore = Collection<string, ComponentHookFn[]>;
11
+ declare type ComponentHookFn = (...args: any[]) => void | Promise<void>;
12
+ declare type ComponentHookStore = Collection<string, ComponentHookFn[]>;
13
13
  declare const createComponentHook: (name: string, fn: ComponentHookFn) => MethodDecorator;
14
14
 
15
- declare class ComponentArgumentDecorator<Options = unknown> {
16
- options: Options;
17
- constructor(options: Partial<Options>);
18
- defaultOptions(): Options;
15
+ declare class ComponentArgumentDecorator<Options = unknown> {
16
+ options: Options;
17
+ constructor(options: Partial<Options>);
18
+ defaultOptions(): Options;
19
19
  }
20
20
 
21
- declare class ComponentArgument {
22
- type: unknown;
23
- decorators: ComponentArgumentDecorator[];
24
- constructor(type: unknown);
21
+ declare class ComponentArgument {
22
+ type: unknown;
23
+ decorators: ComponentArgumentDecorator[];
24
+ constructor(type: unknown);
25
25
  }
26
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>;
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
36
  }
37
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>;
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
48
  }) => (options: Options) => ParameterDecorator;
49
49
 
50
- declare type Options = {
51
- component: typeof BaseComponent<unknown>;
52
- type: Function;
53
- parameterless: boolean;
54
- };
55
- declare class ConverterComponent extends BaseComponent<Options, Omit<Options, 'parameterless'> & {
56
- parameterless?: boolean;
57
- }> {
58
- }
59
- declare const argConverter: (options: Omit<Options, "parameterless"> & {
60
- parameterless?: boolean | undefined;
50
+ declare type Options = {
51
+ component: typeof BaseComponent<unknown>;
52
+ type: Function;
53
+ parameterless: boolean;
54
+ };
55
+ declare class ConverterComponent extends BaseComponent<Options, Omit<Options, 'parameterless'> & {
56
+ parameterless?: boolean;
57
+ }> {
58
+ }
59
+ declare const argConverter: (options: Omit<Options, "parameterless"> & {
60
+ parameterless?: boolean | undefined;
61
61
  }) => MethodDecorator;
62
62
 
63
- declare const createCheckDecorator: (fn: ComponentHookFn) => MethodDecorator;
63
+ declare const createCheckDecorator: (fn: ComponentHookFn) => MethodDecorator;
64
64
  declare const ownerOnly: MethodDecorator;
65
65
 
66
- declare class OwnerOnlyError {
66
+ declare class OwnerOnlyError {
67
67
  }
68
68
 
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[]);
80
- }
81
- declare const listener: (options: {
82
- emitter?: string | undefined;
83
- event: string;
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[]);
80
+ }
81
+ declare const listener: (options: {
82
+ emitter?: string | undefined;
83
+ event: string;
84
84
  }) => MethodDecorator;
85
85
 
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, converter: ConverterComponent) => unknown[] | Promise<unknown[]>): Promise<void>;
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, converter: ConverterComponent) => unknown[] | Promise<unknown[]>): Promise<void>;
92
92
  }
93
93
 
94
- declare class CTSExtension extends Extension {
95
- protected get logger(): tslog.Logger;
94
+ declare class CTSExtension extends Extension {
95
+ protected get logger(): tslog.Logger;
96
96
  }
97
97
 
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>>;
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
110
  }
111
111
 
112
- declare type TextCommandOptions = {
113
- name: string;
114
- aliases?: string;
115
- description?: string;
116
- };
117
- declare class TextCommandComponent extends BaseComponent<TextCommandOptions> {
118
- }
112
+ declare type TextCommandOptions = {
113
+ name: string;
114
+ aliases?: string;
115
+ description?: string;
116
+ };
117
+ declare class TextCommandComponent extends BaseComponent<TextCommandOptions> {
118
+ }
119
119
  declare const command: (options: TextCommandOptions) => MethodDecorator;
120
120
 
121
- declare type TextCommandConfig = {
122
- prefix: string | string[] | ((msg: Message) => Promise<string | string[]> | string | string[]);
121
+ declare type TextCommandConfig = {
122
+ prefix: string | string[] | ((msg: Message) => Promise<string | string[]> | string | string[]);
123
123
  };
124
124
 
125
- declare class TextCommandRestOption extends ComponentArgumentDecorator<void> {
126
- }
125
+ declare class TextCommandRestOption extends ComponentArgumentDecorator<void> {
126
+ }
127
127
  declare const rest: (options: void) => ParameterDecorator;
128
128
 
129
- declare class CommandClient extends EventEmitter {
130
- discord: Client;
131
- logger: Logger;
132
- ctsLogger: Logger;
133
- registry: Registry;
134
- owners: Set<Snowflake>;
135
- constructor(discord: Client, logger?: Logger);
136
- fetchOwners(): Promise<void>;
137
- enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig): Promise<void>;
138
- enableTextCommandsExtension(config: TextCommandConfig): Promise<void>;
139
- getApplicationCommandsExtension(): ApplicationCommandExtension | undefined;
140
- static getFromModule(ext: object): CommandClient;
129
+ declare class CommandClient extends EventEmitter {
130
+ discord: Client;
131
+ logger: Logger;
132
+ ctsLogger: Logger;
133
+ registry: Registry;
134
+ owners: Set<Snowflake>;
135
+ constructor(discord: Client, logger?: Logger);
136
+ fetchOwners(): Promise<void>;
137
+ enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig): Promise<void>;
138
+ enableTextCommandsExtension(config: TextCommandConfig): Promise<void>;
139
+ getApplicationCommandsExtension(): ApplicationCommandExtension | undefined;
140
+ static getFromModule(ext: object): CommandClient;
141
141
  }
142
142
 
143
- declare class Registry {
144
- client: CommandClient;
145
- extensions: object[];
146
- emitters: Collection<string, EventEmitter>;
147
- logger: Logger;
148
- constructor(logger: Logger, client: CommandClient);
149
- getComponentsWithTypeGlobal<T extends typeof BaseComponent<Config>, Config>(type: T): InstanceType<T>[];
150
- getComponentsWithType<T extends typeof BaseComponent<Config>, Config>(ext: object, type: T): InstanceType<T>[];
151
- registerEventListeners(ext: object): void;
152
- unregisterEventListeners(ext: object): void;
153
- loadAllModulesInDirectory(dir: string): Promise<object[]>;
154
- private registerModules;
155
- reloadModules(): Promise<{
156
- file: string;
157
- result: boolean;
158
- error?: Error | undefined;
159
- }[]>;
160
- registerModule(ext: object): Promise<void>;
161
- unregisterModule(ext: object): Promise<void>;
162
- runModuleHook(ext: object, hookName: string, ...args: unknown[]): void;
163
- registerEventEmitter(name: string, emitter: EventEmitter): void;
143
+ declare class Registry {
144
+ client: CommandClient;
145
+ extensions: object[];
146
+ emitters: Collection<string, EventEmitter>;
147
+ logger: Logger;
148
+ constructor(logger: Logger, client: CommandClient);
149
+ getComponentsWithTypeGlobal<T extends typeof BaseComponent<Config>, Config>(type: T): InstanceType<T>[];
150
+ getComponentsWithType<T extends typeof BaseComponent<Config>, Config>(ext: object, type: T): InstanceType<T>[];
151
+ registerEventListeners(ext: object): void;
152
+ unregisterEventListeners(ext: object): void;
153
+ loadAllModulesInDirectory(dir: string): Promise<object[]>;
154
+ private registerModules;
155
+ reloadModules(): Promise<{
156
+ file: string;
157
+ result: boolean;
158
+ error?: Error | undefined;
159
+ }[]>;
160
+ registerModule(ext: object): Promise<void>;
161
+ unregisterModule(ext: object): Promise<void>;
162
+ runModuleHook(ext: object, hookName: string, ...args: unknown[]): void;
163
+ registerEventEmitter(name: string, emitter: EventEmitter): void;
164
164
  }
165
165
 
166
- declare class ApplicationCommandComponent extends BaseComponent<(UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {
167
- type: ApplicationCommandType;
168
- guilds?: Snowflake[];
169
- }> {
170
- }
171
- declare const applicationCommand: (options: (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, "options">) & {
172
- type: ApplicationCommandType;
173
- guilds?: string[] | undefined;
166
+ declare class ApplicationCommandComponent extends BaseComponent<(UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {
167
+ type: ApplicationCommandType;
168
+ guilds?: Snowflake[];
169
+ }> {
170
+ }
171
+ declare const applicationCommand: (options: (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, "options">) & {
172
+ type: ApplicationCommandType;
173
+ guilds?: string[] | undefined;
174
174
  }) => MethodDecorator;
175
175
 
176
176
  declare const option: (options: APIApplicationCommandOption) => ParameterDecorator;
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": "5.0.2-dev.f4dfec1",
4
+ "version": "5.0.3",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
@@ -43,4 +43,4 @@
43
43
  "peerDependencies": {
44
44
  "discord.js": "^14.0.1"
45
45
  }
46
- }
46
+ }