@kotori-bot/core 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/lib/app/common.d.ts +6 -0
  2. package/lib/app/common.js +2 -2
  3. package/lib/app/config.d.ts +32 -0
  4. package/lib/app/config.js +2 -2
  5. package/lib/app/core.d.ts +139 -0
  6. package/lib/app/core.js +5 -5
  7. package/lib/app/index.d.ts +3 -0
  8. package/lib/app/index.js +2 -2
  9. package/lib/app/message.d.ts +34 -0
  10. package/lib/app/message.js +7 -7
  11. package/lib/components/adapter.d.ts +122 -0
  12. package/lib/components/adapter.js +2 -2
  13. package/lib/components/api.d.ts +420 -0
  14. package/lib/components/api.js +4 -4
  15. package/lib/components/cache.d.ts +37 -0
  16. package/lib/components/cache.js +3 -3
  17. package/lib/components/command.d.ts +153 -0
  18. package/lib/components/command.js +2 -2
  19. package/lib/components/elements.d.ts +144 -0
  20. package/lib/components/elements.js +4 -4
  21. package/lib/components/filter.d.ts +22 -0
  22. package/lib/components/filter.js +2 -2
  23. package/lib/components/index.d.ts +8 -0
  24. package/lib/components/index.js +2 -2
  25. package/lib/components/messages.d.ts +186 -0
  26. package/lib/components/messages.js +2 -2
  27. package/lib/components/session.d.ts +177 -0
  28. package/lib/components/session.js +2 -2
  29. package/lib/decorators/index.d.ts +7 -0
  30. package/lib/decorators/index.js +2 -2
  31. package/lib/decorators/plugin.d.ts +7 -0
  32. package/lib/decorators/plugin.js +2 -2
  33. package/lib/decorators/utils.d.ts +60 -0
  34. package/lib/decorators/utils.js +5 -5
  35. package/lib/global/constants.d.ts +8 -0
  36. package/lib/global/constants.js +2 -2
  37. package/lib/global/index.d.ts +2 -0
  38. package/lib/global/index.js +2 -2
  39. package/lib/global/symbols.d.ts +15 -0
  40. package/lib/global/symbols.js +2 -2
  41. package/lib/index.d.ts +13 -0
  42. package/lib/index.js +16 -16
  43. package/lib/types/adapter.d.ts +22 -0
  44. package/lib/types/adapter.js +2 -2
  45. package/lib/types/api.d.ts +71 -0
  46. package/lib/types/api.js +2 -2
  47. package/lib/types/command.d.ts +78 -0
  48. package/lib/types/command.js +2 -2
  49. package/lib/types/config.d.ts +21 -0
  50. package/lib/types/config.js +2 -2
  51. package/lib/types/events.d.ts +3 -0
  52. package/lib/types/events.js +2 -2
  53. package/lib/types/filter.d.ts +51 -0
  54. package/lib/types/filter.js +2 -2
  55. package/lib/types/index.d.ts +7 -0
  56. package/lib/types/index.js +2 -2
  57. package/lib/types/message.d.ts +176 -0
  58. package/lib/types/message.js +2 -2
  59. package/lib/types/session.d.ts +349 -0
  60. package/lib/types/session.js +2 -2
  61. package/lib/utils/container.d.ts +9 -0
  62. package/lib/utils/container.js +2 -2
  63. package/lib/utils/error.d.ts +49 -0
  64. package/lib/utils/error.js +2 -2
  65. package/lib/utils/factory.d.ts +12 -0
  66. package/lib/utils/factory.js +2 -2
  67. package/lib/utils/internal.d.ts +46 -0
  68. package/lib/utils/internal.js +2 -2
  69. package/lib/utils/jsx.d.ts +57 -0
  70. package/lib/utils/jsx.js +5 -4
  71. package/package.json +3 -3
@@ -0,0 +1,420 @@
1
+ import type { ChannelInfoResponse, GetFileDataResponse, GetFilePathResponse, GetFileUrlResponse, GroupInfoResponse, GuildInfoResponse, Message, SelfInfoResponse, SendMessageResponse, UploadFileResponse, UserInfoResponse } from '../types';
2
+ import type { EventsMapping } from '../types/events';
3
+ import type Adapter from './adapter';
4
+ import type { Session } from './session';
5
+ type ReverseList = {
6
+ [K in keyof EventsMapping]: Parameters<EventsMapping[K]>[0] extends Session ? K : never;
7
+ };
8
+ type SessionEvents = ReverseList[keyof ReverseList];
9
+ type Actions = Exclude<keyof Api, 'adapter' | 'getSupportedEvents' | 'getSupportedEvents'>;
10
+ /**
11
+ * Api which identify bot's standard platform apis.
12
+ *
13
+ * For different `api` child class, not most of them have implementation.
14
+ *
15
+ * @class
16
+ * @abstract
17
+ */
18
+ export declare abstract class Api {
19
+ /**
20
+ * Get supported actions for current api implementation.
21
+ *
22
+ * @returns Supported actions
23
+ */
24
+ getSupportedActions(): Actions[];
25
+ abstract getSupportedEvents(): SessionEvents[];
26
+ /**
27
+ * Current api's bot instance.
28
+ *
29
+ * @readonly
30
+ */
31
+ readonly adapter: Adapter<any, any, any>;
32
+ /**
33
+ * Api class constructor.
34
+ *
35
+ * @param adapter - Current api's bot instance
36
+ */
37
+ constructor(adapter: Adapter<any, any, any>);
38
+ /**
39
+ * Send a private message.
40
+ *
41
+ * @param message - Message content to send
42
+ * @param userId - Target user id
43
+ * @param meta - Extra meta data, optional
44
+ * @returns Message id and send time
45
+ *
46
+ * @async
47
+ */
48
+ sendPrivateMsg(message: Message, userId: string, meta?: object): Promise<SendMessageResponse>;
49
+ /**
50
+ * Send a group message.
51
+ *
52
+ * @param message - Message content to send
53
+ * @param groupId - Target group id
54
+ * @param meta - Extra meta data, optional
55
+ * @returns Message id and send time
56
+ *
57
+ * @async
58
+ */
59
+ sendGroupMsg(message: Message, groupId: string, meta?: object): Promise<SendMessageResponse>;
60
+ /**
61
+ * Send a channel message.
62
+ *
63
+ * @param message - Message content to send
64
+ * @param guildId - Target guild id
65
+ * @param channelId - Target channel id
66
+ * @param meta - Extra meta data, optional
67
+ * @returns Message id and send time
68
+ *
69
+ * @async
70
+ */
71
+ sendChannelMsg(message: Message, guildId: string, channelId: string, meta?: object): Promise<SendMessageResponse>;
72
+ /**
73
+ * Delete a message.
74
+ *
75
+ * Required target message that is sent by self or bot had manger permission.
76
+ *
77
+ * @param messageId - Target message id
78
+ * @param meta - Extra meta data, optional
79
+ *
80
+ * @async
81
+ */
82
+ deleteMsg(messageId: string, meta?: object): void;
83
+ /**
84
+ * Get information about the bot itself.
85
+ *
86
+ * @returns Self info
87
+ *
88
+ * @async
89
+ */
90
+ getSelfInfo(meta?: object): Promise<SelfInfoResponse>;
91
+ /**
92
+ * Get user information.
93
+ *
94
+ * @param userId - Target user id, can be the friend or the stronger
95
+ * @param meta - Extra meta data, optional
96
+ * @returns User info
97
+ *
98
+ * @async
99
+ */
100
+ getUserInfo(userId: string, meta?: object): Promise<UserInfoResponse>;
101
+ /**
102
+ * Get friend list.
103
+ *
104
+ * @param meta - Extra meta data, optional
105
+ * @returns Friend list information
106
+ *
107
+ * @async
108
+ */
109
+ getFriendList(meta?: object): Promise<UserInfoResponse[]>;
110
+ /**
111
+ * Get group information.
112
+ *
113
+ * @param groupId - Target group id
114
+ * @param meta - Extra meta data, optional
115
+ * @returns Group info
116
+ *
117
+ * @async
118
+ */
119
+ getGroupInfo(groupId: string, meta?: object): Promise<GroupInfoResponse>;
120
+ /**
121
+ * Get group list.
122
+ *
123
+ * @param meta - Extra meta data, optional
124
+ * @returns Group list information
125
+ *
126
+ * @async
127
+ */
128
+ getGroupList(meta?: object): Promise<GroupInfoResponse[]>;
129
+ /**
130
+ * Get group member information.
131
+ *
132
+ * @param groupId - Target group id
133
+ * @param userId - Target user id
134
+ * @param meta - Extra meta data, optional
135
+ * @returns Group member info
136
+ *
137
+ * @async
138
+ */
139
+ getGroupMemberInfo(groupId: string, userId: string, meta?: object): Promise<SelfInfoResponse>;
140
+ /**
141
+ * Get group member list.
142
+ *
143
+ * @param groupId - Target group id
144
+ * @param meta - Extra meta data, optional
145
+ * @returns Group member list information
146
+ *
147
+ * @async
148
+ */
149
+ getGroupMemberList(groupId: string, meta?: object): Promise<SelfInfoResponse[]>;
150
+ /**
151
+ * Set group information.
152
+ *
153
+ * @param groupId - Target group id
154
+ * @param groupName - Group name
155
+ * @param meta - Extra meta data, optional
156
+ */
157
+ setGroupName(groupId: string, groupName: string, meta?: object): void;
158
+ /**
159
+ * Leave a group, if bot is owner so it will be destroy the group.
160
+ *
161
+ * @param groupId - Target group id
162
+ * @param meta - Extra meta data, optional
163
+ */
164
+ leaveGroup(groupId: string, meta?: object): void;
165
+ /**
166
+ * Get guild information.
167
+ *
168
+ * @param guildId - Target guild id
169
+ * @param meta - Extra meta data, optional
170
+ * @returns Guild info
171
+ *
172
+ * @async
173
+ */
174
+ getGuildInfo(guildId: string, meta?: object): Promise<GuildInfoResponse>;
175
+ /**
176
+ * Get guild list.
177
+ *
178
+ * @param meta - Extra meta data, optional
179
+ * @returns Guild list information
180
+ *
181
+ * @async
182
+ */
183
+ getGuildList(meta?: object): Promise<GuildInfoResponse[]>;
184
+ /**
185
+ * Set guild information.
186
+ *
187
+ * @param guildId - Target guild id
188
+ * @param guildName - Guild name
189
+ * @param meta - Extra meta data, optional
190
+ */
191
+ setGuildName(guildId: string, guildName: string, meta?: object): void;
192
+ /**
193
+ * Get guild member information.
194
+ *
195
+ * @param guildId - Target guild id
196
+ * @param channelId - Target channel id
197
+ * @param userId - Target user id
198
+ * @param meta - Extra meta data, optional
199
+ * @returns Guild member info
200
+ *
201
+ * @async
202
+ */
203
+ getGuildMemberInfo(guildId: string, userId: string, meta?: object): Promise<UserInfoResponse>;
204
+ /**
205
+ * Get guild member list.
206
+ *
207
+ * @param guildId - Target guild id
208
+ * @param channelId - Target channel id
209
+ * @param meta - Extra meta data, optional
210
+ * @returns Guild member list information
211
+ *
212
+ * @async
213
+ */
214
+ getGuildMemberList(guildId: string, meta?: object): Promise<UserInfoResponse[]>;
215
+ /**
216
+ * Leave a guild.
217
+ *
218
+ * @param guildId - Target guild id
219
+ * @param meta - Extra meta data, optional
220
+ */
221
+ leaveGuild(guildId: string, meta?: object): void;
222
+ /**
223
+ * Get channel information.
224
+ *
225
+ * @param guildId - Target guild id
226
+ * @param channelId - Target channel id
227
+ * @param meta - Extra meta data, optional
228
+ * @returns Channel info
229
+ *
230
+ * @async
231
+ */
232
+ getChannelInfo(guildId: string, channelId: string, meta?: object): Promise<ChannelInfoResponse>;
233
+ /**
234
+ * Get channel list.
235
+ *
236
+ * @param guildId - Target guild id
237
+ * @param joinedOnly - Whether to get joined channels only, default is false
238
+ * @param meta - Extra meta data, optional
239
+ * @returns Channel list information
240
+ *
241
+ * @async
242
+ */
243
+ getChannelList(guildId: string, joinedOnly?: boolean, meta?: object): Promise<ChannelInfoResponse[]>;
244
+ /**
245
+ * Set channel information.
246
+ *
247
+ * @param guildId - Target guild id
248
+ * @param channelId - Target channel id
249
+ * @param channelName - Channel name
250
+ * @param meta - Extra meta data, optional
251
+ */
252
+ setChannelName(guildId: string, channelId: string, channelName: string, meta?: object): void;
253
+ /**
254
+ * Get channel member information.
255
+ *
256
+ * @param guildId - Target guild id
257
+ * @param channelId - Target channel id
258
+ * @param userId - Target user id
259
+ * @param meta - Extra meta data, optional
260
+ * @returns Channel member info
261
+ *
262
+ * @async
263
+ */
264
+ getChannelMemberInfo(guildId: string, channelId: string, userId: string, meta?: object): Promise<UserInfoResponse>;
265
+ /**
266
+ * Get channel member list.
267
+ *
268
+ * @param guildId - Target guild id
269
+ * @param channelId - Target channel id
270
+ * @param meta - Extra meta data, optional
271
+ * @returns Channel member list information
272
+ *
273
+ * @async
274
+ */
275
+ getChannelMemberList(guildId: string, channelId: string, meta?: object): Promise<UserInfoResponse[]>;
276
+ /**
277
+ * Leave a channel.
278
+ *
279
+ * @param guildId - Target guild id
280
+ * @param channelId - Target channel id
281
+ * @param meta - Extra meta data, optional
282
+ */
283
+ leaveChannel(guildId: string, channelId: string, meta?: object): void;
284
+ /**
285
+ * Upload file from url.
286
+ *
287
+ * @param name - File name
288
+ * @param url - File url
289
+ * @param headers - File download url headers, optional
290
+ * @param meta - Extra meta data, optional
291
+ * @returns File id
292
+ *
293
+ * @async
294
+ */
295
+ uploadFileUrl(name: string, url: string, headers?: Record<string, string>, meta?: object): Promise<UploadFileResponse>;
296
+ /**
297
+ * Upload file from path.
298
+ *
299
+ * @param name - File name
300
+ * @param path - File path
301
+ * @param meta - Extra meta data, optional
302
+ * @returns File id
303
+ *
304
+ * @async
305
+ */
306
+ uploadFilePath(name: string, path: string, meta?: object): Promise<UploadFileResponse>;
307
+ /**
308
+ * Upload file from data.
309
+ *
310
+ * @param name - File name
311
+ * @param data - File data
312
+ * @param meta - Extra meta data, optional
313
+ * @returns File id
314
+ *
315
+ * @async
316
+ */
317
+ uploadFileData(name: string, data: Buffer, meta?: object): Promise<UploadFileResponse>;
318
+ /**
319
+ * Get file url.
320
+ *
321
+ * @param filedId - File id
322
+ * @param meta - Extra meta data, optional
323
+ * @returns File url data
324
+ *
325
+ * @async
326
+ */
327
+ getFileUrl(filedId: string, meta?: object): Promise<GetFileUrlResponse>;
328
+ /**
329
+ * Get file path.
330
+ *
331
+ * @param filedId - File id
332
+ * @param meta - Extra meta data, optional
333
+ * @returns File path data
334
+ *
335
+ * @async
336
+ */
337
+ getFilePath(filedId: string, meta?: object): Promise<GetFilePathResponse>;
338
+ /**
339
+ * Get file data.
340
+ *
341
+ * @param filedId - File id
342
+ * @param meta - Extra meta data, optional
343
+ * @returns File data
344
+ *
345
+ * @async
346
+ */
347
+ getFileData(filedId: string, meta?: object): Promise<GetFileDataResponse>;
348
+ /**
349
+ * Set group avatar.
350
+ *
351
+ * @param groupId - Target group id
352
+ * @param image - Image data
353
+ * @param meta - Extra meta data, optional
354
+ *
355
+ * @experimental
356
+ */
357
+ setGroupAvatar(groupId: string, image: string, meta?: object): void;
358
+ /**
359
+ * Set group admin.
360
+ *
361
+ * @param groupId - Target group id
362
+ * @param userId - Target user id
363
+ * @param enable - Whether to set admin
364
+ * @param meta - Extra meta data, optional
365
+ *
366
+ * @experimental
367
+ */
368
+ setGroupAdmin(groupId: string, userId: string, enable: boolean, meta?: object): void;
369
+ /**
370
+ * Set group card.
371
+ *
372
+ * @param groupId - Target group id
373
+ * @param userId - Target user id
374
+ * @param card - Card content
375
+ * @param meta - Extra meta data, optional
376
+ *
377
+ * @experimental
378
+ */
379
+ setGroupCard(groupId: string, userId: string, card: string, meta?: object): void;
380
+ /**
381
+ * Set group members ban or unban.
382
+ *
383
+ * @param groupId - Target group id
384
+ * @param userId - Target user id
385
+ * @param time - Ban time, 0 means unban
386
+ * @param meta - Extra meta data, optional
387
+ *
388
+ * @experimental
389
+ */
390
+ setGroupBan(groupId: string, userId: string, time: number, meta?: object): void;
391
+ /**
392
+ * Set group new notice.
393
+ *
394
+ * @param groupId - Target group id
395
+ * @param content - Notice content
396
+ * @param image - Notice image, optional
397
+ * @param meta - Extra meta data, optional
398
+ *
399
+ * @experimental
400
+ */
401
+ sendGroupNotice(groupId: string, content: string, image?: string, meta?: object): void;
402
+ /**
403
+ * Set group whole ban
404
+ *
405
+ * @param groupId - Target group id
406
+ * @param enable - Whether to ban
407
+ */
408
+ setGroupWholeBan(groupId: string, enable?: boolean): void;
409
+ /**
410
+ * Set group members kicked.
411
+ *
412
+ * @param groupId - Target group id
413
+ * @param userId - Target user id
414
+ * @param meta - Extra meta data, optional
415
+ *
416
+ * @experimental
417
+ */
418
+ setGroupKick(groupId: string, userId: string, meta?: object): void;
419
+ }
420
+ export default Api;
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @Package @kotori-bot/core
3
- * @Version 1.7.1
3
+ * @Version 1.7.2
4
4
  * @Author Arimura Sena <me@hotaru.icu>
5
5
  * @Copyright 2024-2025 Hotaru. All rights reserved.
6
6
  * @License GPL-3.0
7
7
  * @Link https://github.com/kotorijs/kotori
8
- * @Date 2026/2/14 00:45:33
8
+ * @Date 2026/2/14 15:50:13
9
9
  */
10
10
  "use strict";
11
11
  var __defProp = Object.defineProperty;
@@ -48,14 +48,14 @@ class Api {
48
48
  *
49
49
  * @readonly
50
50
  */
51
- // biome-ignore lint:
51
+ // biome-ignore lint: *
52
52
  adapter;
53
53
  /**
54
54
  * Api class constructor.
55
55
  *
56
56
  * @param adapter - Current api's bot instance
57
57
  */
58
- // biome-ignore lint:
58
+ // biome-ignore lint: *
59
59
  constructor(adapter) {
60
60
  this.adapter = adapter;
61
61
  }
@@ -0,0 +1,37 @@
1
+ import { type Context, Service } from '../app';
2
+ type CacheKey = string | symbol | number;
3
+ type CacheValue = string | number | object;
4
+ type Container = Map<CacheKey, CacheValue>;
5
+ /**
6
+ * Cache service
7
+ *
8
+ * @class
9
+ * @extends Service
10
+ */
11
+ export declare class Cache extends Service {
12
+ private cache?;
13
+ constructor(ctx: Context);
14
+ start(): void;
15
+ stop(): void;
16
+ /**
17
+ * Get the container of current content instance.
18
+ *
19
+ * @returns THe container
20
+ */
21
+ getContainer(): Container;
22
+ /**
23
+ * Get the value from current the container.
24
+ *
25
+ * @param prop The property name
26
+ * @returns The value
27
+ */
28
+ get<T = CacheValue>(prop: CacheKey): T;
29
+ /**
30
+ * Set the value to current the container.
31
+ *
32
+ * @param prop The property name
33
+ * @param value The value
34
+ */
35
+ set(prop: CacheKey, value: CacheValue): void;
36
+ }
37
+ export default Cache;
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @Package @kotori-bot/core
3
- * @Version 1.7.1
3
+ * @Version 1.7.2
4
4
  * @Author Arimura Sena <me@hotaru.icu>
5
5
  * @Copyright 2024-2025 Hotaru. All rights reserved.
6
6
  * @License GPL-3.0
7
7
  * @Link https://github.com/kotorijs/kotori
8
- * @Date 2026/2/14 00:45:33
8
+ * @Date 2026/2/14 15:50:13
9
9
  */
10
10
  "use strict";
11
11
  var __defProp = Object.defineProperty;
@@ -31,8 +31,8 @@ __export(cache_exports, {
31
31
  default: () => cache_default
32
32
  });
33
33
  module.exports = __toCommonJS(cache_exports);
34
- var import_error = require("../utils/error");
35
34
  var import_app = require("../app");
35
+ var import_error = require("../utils/error");
36
36
  class Cache extends import_app.Service {
37
37
  cache = /* @__PURE__ */ new Map();
38
38
  constructor(ctx) {
@@ -0,0 +1,153 @@
1
+ import { type ArgsOrigin, type CommandAction, type CommandArgType, type CommandArgTypeSign, type CommandConfig, type OptsOrigin, UserAccess } from '../types';
2
+ import { CommandError } from '../utils/error';
3
+ /** Command argument */
4
+ interface CommandArg {
5
+ /** Argument displayname */
6
+ name: string;
7
+ /** Argument type */
8
+ type: CommandArgTypeSign;
9
+ /** Argument is wether optional */
10
+ optional: boolean;
11
+ /** Argument default value, if exists so `optional` is true */
12
+ default?: CommandArgType;
13
+ /** Argument is wether rest arguments */
14
+ rest: boolean;
15
+ }
16
+ /** Command option */
17
+ interface CommandOption {
18
+ /** Option short name, composed a uppercase letter */
19
+ name: string;
20
+ /** Option type */
21
+ type: CommandArgTypeSign;
22
+ /** Option full name (real name), composed some lowercase letters and connect by `-` between word and word */
23
+ realname: string;
24
+ /** Option description */
25
+ description?: string;
26
+ }
27
+ /**
28
+ * Command meta data.
29
+ *
30
+ * @template Args - Command arguments
31
+ * @template Opts - Command options
32
+ */
33
+ interface CommandData<Args = ArgsOrigin, Opts = OptsOrigin, Scope = 'all'> {
34
+ /** Command root content */
35
+ root: string;
36
+ /** Command alias (need bring command prefix) */
37
+ alias: string[];
38
+ /** Command shortcut (needn't bring command prefix) */
39
+ shortcut: string[];
40
+ /** Command is wether hide at the menu */
41
+ hide: boolean;
42
+ /** Command arguments */
43
+ args: CommandArg[];
44
+ /** Command options */
45
+ options: CommandOption[];
46
+ /** Command require message scope (session type) */
47
+ scope: CommandConfig['scope'];
48
+ /** Command require user access level */
49
+ access: UserAccess;
50
+ /** Command description */
51
+ description?: string;
52
+ /** Command help message, it has more details than `description` */
53
+ help?: string;
54
+ /** Command action */
55
+ action?: CommandAction<Args, Opts, Scope>;
56
+ }
57
+ type GetSignType<T extends string> = T extends `${string}number${string}` ? number : T extends `${string}boolean${string}` ? boolean : string;
58
+ type GetArgCtn<Template extends string> = Template extends `${string}:${infer Suffix}` ? Suffix extends `${infer T}=${string}` ? GetSignType<T> : GetSignType<Suffix> : Template extends `${infer T}=${string}` ? GetSignType<T> : string;
59
+ type ParseArgs<Template extends string> = string extends Template ? ArgsOrigin : Template extends `${string} ${`<${infer Ctn}>`}${infer Rest}` ? Ctn extends `...${infer Ctn2}` ? [...GetSignType<Ctn2>[]] : [GetArgCtn<Ctn>, ...ParseArgs<Rest>] : Template extends `${string} [${infer Ctn}]${infer Rest}` ? Ctn extends `${infer Ctn2}=${string}` ? Ctn2 extends `...${infer Ctn3}` ? [...GetSignType<Ctn3>[]] : [GetArgCtn<Ctn2>, ...ParseArgs<Rest>] : Ctn extends `...${infer Ctn2}` ? [...GetSignType<Ctn2>[]] : [GetArgCtn<Ctn>?, ...ParseArgs<Rest>] : [];
60
+ type ParseOpts<Template extends string> = string extends Template ? {} : Template extends `${infer K}:${infer V}` ? GetSignType<V> extends boolean ? {
61
+ [C in K]: GetSignType<V>;
62
+ } : {
63
+ [C in K]?: GetSignType<V>;
64
+ } : {};
65
+ /**
66
+ * Command.
67
+ *
68
+ * @template Template - Command template
69
+ * @template Opts - Command options
70
+ *
71
+ * @class
72
+ */
73
+ export declare class Command<Template extends string = string, Opts extends OptsOrigin = OptsOrigin, Scope extends CommandConfig['scope'] | 'all' = 'all'> {
74
+ private static handleDefaultValue;
75
+ private static parseArgs;
76
+ static run(input: string, data: CommandData): CommandError | {
77
+ args: ArgsOrigin;
78
+ options: OptsOrigin;
79
+ };
80
+ private template;
81
+ /**
82
+ * Command meta data.
83
+ *
84
+ * @readonly
85
+ */
86
+ readonly meta: CommandData<ParseArgs<Template>, Opts, Scope>;
87
+ /**
88
+ * Create a command instance
89
+ *
90
+ * @param template - Command template.
91
+ * @param config - Command config.
92
+ */
93
+ constructor(template: Template, config?: CommandConfig);
94
+ private parse;
95
+ /**
96
+ * Add command alias.
97
+ *
98
+ * @param alias - Command alias.
99
+ * @returns Command instance
100
+ */
101
+ alias(alias: string | string[]): this;
102
+ /**
103
+ * Add command shortcut.
104
+ *
105
+ * @param short - shortcut name
106
+ * @returns Command instance
107
+ */
108
+ shortcut(short: string | string[]): this;
109
+ /**
110
+ * Set the message scope which command require.
111
+ *
112
+ * @param scope - Message scope.
113
+ * @returns Command instance
114
+ */
115
+ scope<S extends CommandConfig['scope']>(scope: S): Command<Template, Opts, S>;
116
+ /**
117
+ * Set the user access level which command require.
118
+ *
119
+ * @param access - User access level.
120
+ * @returns Command instance
121
+ */
122
+ access(access: UserAccess): this;
123
+ /**
124
+ * Add command option.
125
+ *
126
+ * @param name - Option name.
127
+ * @param template - Option template.
128
+ * @returns Command instance
129
+ */
130
+ option<TemplateOpt extends string>(name: string, template: TemplateOpt): Command<Template, Opts & ParseOpts<TemplateOpt>>;
131
+ /**
132
+ * Set command action.
133
+ *
134
+ * @param callback - Command action.
135
+ * @returns Command instance
136
+ */
137
+ action(callback: CommandAction<ParseArgs<Template>, Opts, Scope>): this;
138
+ /**
139
+ * Set command help text.
140
+ *
141
+ * @param text - Command help text.
142
+ * @returns Command instance
143
+ */
144
+ help(text: string): this;
145
+ /**
146
+ * Set command hide.
147
+ *
148
+ * @param isHide - Command hide.
149
+ * @returns Command instance
150
+ */
151
+ hide(isHide?: boolean): this;
152
+ }
153
+ export default Command;
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @Package @kotori-bot/core
3
- * @Version 1.7.1
3
+ * @Version 1.7.2
4
4
  * @Author Arimura Sena <me@hotaru.icu>
5
5
  * @Copyright 2024-2025 Hotaru. All rights reserved.
6
6
  * @License GPL-3.0
7
7
  * @Link https://github.com/kotorijs/kotori
8
- * @Date 2026/2/14 00:45:33
8
+ * @Date 2026/2/14 15:50:13
9
9
  */
10
10
  "use strict";
11
11
  var __create = Object.create;