bakit 2.0.0-alpha.8 → 2.0.0
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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +4 -423
- package/dist/index.js +4 -830
- package/package.json +44 -47
- package/README.md +0 -35
- package/bin/bakit.js +0 -39
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Louis Johnson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,423 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { inspect } from 'node:util';
|
|
6
|
-
|
|
7
|
-
declare const ProjectConfigSchema: z.ZodObject<{
|
|
8
|
-
intents: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodBigInt, z.ZodArray<z.ZodEnum<typeof GatewayIntentBits>>]>>;
|
|
9
|
-
clientOptions: z.ZodOptional<z.ZodCustom<Omit<ClientOptions, "intents">, Omit<ClientOptions, "intents">>>;
|
|
10
|
-
entryDir: z.ZodDefault<z.ZodString>;
|
|
11
|
-
prefixes: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
12
|
-
token: z.ZodString;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
type ProjectConfigInput = z.input<typeof ProjectConfigSchema>;
|
|
15
|
-
type ProjectConfig = z.output<typeof ProjectConfigSchema>;
|
|
16
|
-
/**
|
|
17
|
-
* Define config object for your project. This is just a cleaner way to define config.
|
|
18
|
-
* @param config The partial version of project config.
|
|
19
|
-
* @returns The same config you provided earlier.
|
|
20
|
-
*/
|
|
21
|
-
declare function defineConfig(config: ProjectConfigInput): ProjectConfigInput;
|
|
22
|
-
/**
|
|
23
|
-
* Load the config file and save them for later usage.
|
|
24
|
-
* @param cwd The location of the config file, uses root by default.
|
|
25
|
-
* @returns The complete config with default values from the validation.
|
|
26
|
-
*/
|
|
27
|
-
declare function loadConfig(cwd?: string): Promise<ProjectConfig>;
|
|
28
|
-
/**
|
|
29
|
-
* Get the loaded config of the project.
|
|
30
|
-
* @returns The project config.
|
|
31
|
-
*/
|
|
32
|
-
declare function getConfig(): ProjectConfig;
|
|
33
|
-
|
|
34
|
-
declare const EVENT_INTENT_MAPPING: Record<string, number[]>;
|
|
35
|
-
|
|
36
|
-
declare function tokenize(content: string): string[];
|
|
37
|
-
|
|
38
|
-
declare const $jiti: jiti.Jiti;
|
|
39
|
-
|
|
40
|
-
declare class Context {
|
|
41
|
-
canceled: boolean;
|
|
42
|
-
cancel(): void;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
type ChatInputContextSendOptions = string | InteractionReplyOptions;
|
|
46
|
-
type MessageContextSendOptions = string | MessageCreateOptions;
|
|
47
|
-
type ContextSendOptions = ChatInputContextSendOptions | MessageContextSendOptions;
|
|
48
|
-
declare abstract class BaseCommandContext<Cached extends boolean, InGuild extends boolean> extends Context {
|
|
49
|
-
source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>;
|
|
50
|
-
constructor(source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>);
|
|
51
|
-
get client(): BakitClient<true>;
|
|
52
|
-
get channel(): discord_js.CacheTypeReducer<Cached extends true ? "cached" : CacheType, discord_js.GuildTextBasedChannel | null, discord_js.GuildTextBasedChannel | null, discord_js.GuildTextBasedChannel | null, discord_js.TextBasedChannel | null> | discord_js.If<InGuild, discord_js.GuildTextBasedChannel, discord_js.TextBasedChannel>;
|
|
53
|
-
get channelId(): string;
|
|
54
|
-
get guild(): discord_js.CacheTypeReducer<Cached extends true ? "cached" : CacheType, discord_js.Guild, null, discord_js.Guild | null, discord_js.Guild | null> | discord_js.If<InGuild, discord_js.Guild, null>;
|
|
55
|
-
get guildId(): discord_js.CacheTypeReducer<Cached extends true ? "cached" : CacheType, string, string, string, string | null> | discord_js.If<InGuild, string, null>;
|
|
56
|
-
get member(): discord_js.GuildMember | discord_js.CacheTypeReducer<Cached extends true ? "cached" : CacheType, discord_js.GuildMember, discord_js.APIInteractionGuildMember, discord_js.GuildMember | discord_js.APIInteractionGuildMember, discord_js.GuildMember | discord_js.APIInteractionGuildMember | null> | null;
|
|
57
|
-
inGuild(): this is CommandContext<Cached, true>;
|
|
58
|
-
inCachedGuild(): this is CommandContext<true, true>;
|
|
59
|
-
get user(): User;
|
|
60
|
-
isChatInput(): this is ChatInputContext;
|
|
61
|
-
isMessage(): this is MessageContext;
|
|
62
|
-
abstract send(options: ContextSendOptions): Promise<Message<InGuild>>;
|
|
63
|
-
}
|
|
64
|
-
declare class ChatInputContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseCommandContext<Cached, InGuild> {
|
|
65
|
-
source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType>;
|
|
66
|
-
send(options: ContextSendOptions): Promise<Message<InGuild>>;
|
|
67
|
-
}
|
|
68
|
-
declare class MessageContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseCommandContext<Cached, InGuild> {
|
|
69
|
-
source: Message<InGuild>;
|
|
70
|
-
send(options: string | MessageCreateOptions): Promise<Message<InGuild>>;
|
|
71
|
-
}
|
|
72
|
-
type CommandContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> = ChatInputContext<Cached, InGuild> | MessageContext<Cached, InGuild>;
|
|
73
|
-
|
|
74
|
-
declare enum HookState {
|
|
75
|
-
Pre = "PRE",
|
|
76
|
-
Main = "MAIN",
|
|
77
|
-
Post = "POST",
|
|
78
|
-
Error = "ERROR"
|
|
79
|
-
}
|
|
80
|
-
declare enum HookOrder {
|
|
81
|
-
First = 0,
|
|
82
|
-
Last = 1
|
|
83
|
-
}
|
|
84
|
-
type MainHookCallback<C extends Context, Args extends unknown[]> = (context: C, ...args: Args) => Awaitable<void>;
|
|
85
|
-
type ErrorHookCallback<C extends Context, Args extends unknown[]> = (context: C, error: unknown, ...args: Args) => Awaitable<void>;
|
|
86
|
-
declare class LifecycleManager<C extends Context, Args extends unknown[]> {
|
|
87
|
-
id: string;
|
|
88
|
-
private readonly hooks;
|
|
89
|
-
constructor(id: string);
|
|
90
|
-
getName(name: string): string;
|
|
91
|
-
setHook(name: string, state: HookState.Post, callback: MainHookCallback<C, Args>, order?: HookOrder): this;
|
|
92
|
-
setHook(name: string, state: HookState.Main, callback: MainHookCallback<C, Args>, order?: HookOrder): this;
|
|
93
|
-
setHook(name: string, state: HookState.Pre, callback: MainHookCallback<C, Args>, order?: HookOrder): this;
|
|
94
|
-
setHook(name: string, state: HookState.Error, callback: ErrorHookCallback<C, Args>, order?: HookOrder): this;
|
|
95
|
-
main(callback: MainHookCallback<C, Args>): this;
|
|
96
|
-
pre(callback: MainHookCallback<C, Args>): this;
|
|
97
|
-
post(callback: MainHookCallback<C, Args>): this;
|
|
98
|
-
error(callback: ErrorHookCallback<C, Args>): this;
|
|
99
|
-
execute(context: C, ...args: Args): Promise<void>;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
declare enum ParamUserType {
|
|
103
|
-
Bot = "bot",
|
|
104
|
-
Normal = "normal",
|
|
105
|
-
Any = "any"
|
|
106
|
-
}
|
|
107
|
-
declare const BaseParamSchema: z.ZodObject<{
|
|
108
|
-
name: z.ZodString;
|
|
109
|
-
description: z.ZodOptional<z.ZodString>;
|
|
110
|
-
required: z.ZodDefault<z.ZodBoolean>;
|
|
111
|
-
}, z.core.$strip>;
|
|
112
|
-
declare const StringParamSchema: z.ZodPipe<z.ZodObject<{
|
|
113
|
-
name: z.ZodString;
|
|
114
|
-
description: z.ZodOptional<z.ZodString>;
|
|
115
|
-
required: z.ZodDefault<z.ZodBoolean>;
|
|
116
|
-
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
117
|
-
minLength: z.ZodOptional<z.ZodNumber>;
|
|
118
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
119
|
-
name: string;
|
|
120
|
-
required: boolean;
|
|
121
|
-
description?: string | undefined;
|
|
122
|
-
maxLength?: number | undefined;
|
|
123
|
-
minLength?: number | undefined;
|
|
124
|
-
} & {
|
|
125
|
-
description: string;
|
|
126
|
-
}, {
|
|
127
|
-
name: string;
|
|
128
|
-
required: boolean;
|
|
129
|
-
description?: string | undefined;
|
|
130
|
-
maxLength?: number | undefined;
|
|
131
|
-
minLength?: number | undefined;
|
|
132
|
-
}>>;
|
|
133
|
-
declare const NumberParamSchema: z.ZodPipe<z.ZodObject<{
|
|
134
|
-
name: z.ZodString;
|
|
135
|
-
description: z.ZodOptional<z.ZodString>;
|
|
136
|
-
required: z.ZodDefault<z.ZodBoolean>;
|
|
137
|
-
maxValue: z.ZodOptional<z.ZodNumber>;
|
|
138
|
-
minValue: z.ZodOptional<z.ZodNumber>;
|
|
139
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
140
|
-
name: string;
|
|
141
|
-
required: boolean;
|
|
142
|
-
description?: string | undefined;
|
|
143
|
-
maxValue?: number | undefined;
|
|
144
|
-
minValue?: number | undefined;
|
|
145
|
-
} & {
|
|
146
|
-
description: string;
|
|
147
|
-
}, {
|
|
148
|
-
name: string;
|
|
149
|
-
required: boolean;
|
|
150
|
-
description?: string | undefined;
|
|
151
|
-
maxValue?: number | undefined;
|
|
152
|
-
minValue?: number | undefined;
|
|
153
|
-
}>>;
|
|
154
|
-
type BaseParamOptions = z.input<typeof BaseParamSchema>;
|
|
155
|
-
type StringOptions = z.input<typeof StringParamSchema>;
|
|
156
|
-
type NumberOptions = z.input<typeof NumberParamSchema>;
|
|
157
|
-
|
|
158
|
-
type ParamResolvedOutputType<OutputType, Required extends boolean = true> = Required extends true ? OutputType : OutputType | null;
|
|
159
|
-
declare abstract class BaseParam<Options extends BaseParamOptions, OutputType, Required extends boolean = true> {
|
|
160
|
-
options: Options & {
|
|
161
|
-
required: Required;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* **Internal Phantom Type**
|
|
165
|
-
*
|
|
166
|
-
* Used strictly for TypeScript type inference to determine the runtime value
|
|
167
|
-
* of this parameter. This property does not exist at runtime.
|
|
168
|
-
*
|
|
169
|
-
* @internal
|
|
170
|
-
*/
|
|
171
|
-
readonly _type: Required extends true ? OutputType : OutputType | null;
|
|
172
|
-
constructor(options: Options);
|
|
173
|
-
protected setOption(key: keyof Options, value: any): this;
|
|
174
|
-
name(value: string): this;
|
|
175
|
-
description(value: string): this;
|
|
176
|
-
required<V extends boolean>(value: V): BaseParam<Options, OutputType, V>;
|
|
177
|
-
resolve(context: CommandContext, value?: string): Promise<ParamResolvedOutputType<OutputType, Required>>;
|
|
178
|
-
abstract resolveMessage(context: MessageContext, value: string | undefined): Awaitable<ParamResolvedOutputType<OutputType, Required>>;
|
|
179
|
-
abstract resolveChatInput(context: ChatInputContext): Awaitable<ParamResolvedOutputType<OutputType, Required>>;
|
|
180
|
-
/**
|
|
181
|
-
* Helper to normalize string inputs into an options object.
|
|
182
|
-
*/
|
|
183
|
-
protected static getOptions<Options>(options: Options | string): Options;
|
|
184
|
-
}
|
|
185
|
-
declare class StringParam<Required extends boolean = true> extends BaseParam<StringOptions, string, Required> {
|
|
186
|
-
constructor(options: string | StringOptions);
|
|
187
|
-
required<V extends boolean>(value: V): StringParam<V>;
|
|
188
|
-
resolveMessage(_context: CommandContext, value: string | undefined): ParamResolvedOutputType<string, Required>;
|
|
189
|
-
resolveChatInput(context: ChatInputContext): ParamResolvedOutputType<string, Required>;
|
|
190
|
-
/**
|
|
191
|
-
* Sets the minimum allowed length for this string.
|
|
192
|
-
* Pass `null` to remove this constraint.
|
|
193
|
-
*/
|
|
194
|
-
min(length: number | null): this;
|
|
195
|
-
/**
|
|
196
|
-
* Sets the maximum allowed length for this string.
|
|
197
|
-
* Pass `null` to remove this constraint.
|
|
198
|
-
*/
|
|
199
|
-
max(length: number | null): this;
|
|
200
|
-
}
|
|
201
|
-
declare class NumberParam<Required extends boolean = true> extends BaseParam<NumberOptions, number, Required> {
|
|
202
|
-
constructor(options: string | NumberOptions);
|
|
203
|
-
required<V extends boolean>(value: V): NumberParam<V>;
|
|
204
|
-
resolveMessage(ctx: CommandContext, value: string | undefined): ParamResolvedOutputType<number, Required>;
|
|
205
|
-
resolveChatInput(context: ChatInputContext): ParamResolvedOutputType<number, Required>;
|
|
206
|
-
/**
|
|
207
|
-
* Sets the minimum allowed value for this number.
|
|
208
|
-
* Pass `null` to remove this constraint.
|
|
209
|
-
*/
|
|
210
|
-
min(value: number | null): this;
|
|
211
|
-
/**
|
|
212
|
-
* Sets the maximum allowed value for this number.
|
|
213
|
-
* Pass `null` to remove this constraint.
|
|
214
|
-
*/
|
|
215
|
-
max(value: number | null): this;
|
|
216
|
-
}
|
|
217
|
-
type AnyParam<Required extends boolean = true> = BaseParam<any, any, Required>;
|
|
218
|
-
/**
|
|
219
|
-
* Helper type to extract the runtime value of a Param instance.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* const p = new StringParam("name").required(false);
|
|
223
|
-
* type T = InferParamValue<typeof p>; // string | null
|
|
224
|
-
*/
|
|
225
|
-
type InferParamValue<P extends AnyParam<any>> = P["_type"];
|
|
226
|
-
type InferParamTuple<T extends readonly BaseParam<any, any, any>[]> = {
|
|
227
|
-
[K in keyof T]: T[K] extends AnyParam<any> ? InferParamValue<T[K]> : never;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
declare function validateParamsOrder(params: readonly AnyParam<boolean>[]): boolean;
|
|
231
|
-
declare const CommandOptionsSchema: z.ZodPipe<z.ZodObject<{
|
|
232
|
-
name: z.ZodReadonly<z.ZodString>;
|
|
233
|
-
description: z.ZodReadonly<z.ZodOptional<z.ZodString>>;
|
|
234
|
-
nsfw: z.ZodReadonly<z.ZodDefault<z.ZodBoolean>>;
|
|
235
|
-
params: z.ZodReadonly<z.ZodDefault<z.ZodArray<z.ZodCustom<BaseParam<{
|
|
236
|
-
name: string;
|
|
237
|
-
description?: string | undefined;
|
|
238
|
-
required?: boolean | undefined;
|
|
239
|
-
}, unknown, boolean>, BaseParam<{
|
|
240
|
-
name: string;
|
|
241
|
-
description?: string | undefined;
|
|
242
|
-
required?: boolean | undefined;
|
|
243
|
-
}, unknown, boolean>>>>>;
|
|
244
|
-
quotes: z.ZodReadonly<z.ZodDefault<z.ZodBoolean>>;
|
|
245
|
-
}, z.core.$strip>, z.ZodTransform<{
|
|
246
|
-
description: string;
|
|
247
|
-
name: string;
|
|
248
|
-
nsfw: boolean;
|
|
249
|
-
params: readonly BaseParam<{
|
|
250
|
-
name: string;
|
|
251
|
-
description?: string | undefined;
|
|
252
|
-
required?: boolean | undefined;
|
|
253
|
-
}, unknown, boolean>[];
|
|
254
|
-
quotes: boolean;
|
|
255
|
-
}, {
|
|
256
|
-
name: string;
|
|
257
|
-
nsfw: boolean;
|
|
258
|
-
params: readonly BaseParam<{
|
|
259
|
-
name: string;
|
|
260
|
-
description?: string | undefined;
|
|
261
|
-
required?: boolean | undefined;
|
|
262
|
-
}, unknown, boolean>[];
|
|
263
|
-
quotes: boolean;
|
|
264
|
-
description?: string | undefined;
|
|
265
|
-
}>>;
|
|
266
|
-
type CommandOptionsInput = z.input<typeof CommandOptionsSchema>;
|
|
267
|
-
type CommandOptions = z.output<typeof CommandOptionsSchema>;
|
|
268
|
-
/**
|
|
269
|
-
* The command entry, used for registering command.
|
|
270
|
-
*/
|
|
271
|
-
declare class Command<ParamsList extends readonly AnyParam<any>[] = any[]> extends LifecycleManager<CommandContext, [
|
|
272
|
-
...args: InferParamTuple<ParamsList>
|
|
273
|
-
]> {
|
|
274
|
-
options: CommandOptions;
|
|
275
|
-
constructor(options: (Omit<CommandOptionsInput, "params"> & {
|
|
276
|
-
params?: ParamsList;
|
|
277
|
-
}) | string);
|
|
278
|
-
private handleSyntaxError;
|
|
279
|
-
toSlashCommandJSON(): discord_js.RESTPostAPIChatInputApplicationCommandsJSONBody;
|
|
280
|
-
private initSlashCommandOptions;
|
|
281
|
-
private initSlashCommandOption;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Define command entry, usually for modules.
|
|
285
|
-
* @param options The command options.
|
|
286
|
-
* @returns The entry of the command to deploy or register hooks.
|
|
287
|
-
* @example
|
|
288
|
-
* ```ts
|
|
289
|
-
* import { defineCommand } from "bakit";
|
|
290
|
-
*
|
|
291
|
-
* const command = defineCommand({
|
|
292
|
-
* name: "ping",
|
|
293
|
-
* description: "Displays bot's latency.",
|
|
294
|
-
* });
|
|
295
|
-
*
|
|
296
|
-
* command.main(async (context) => {
|
|
297
|
-
* await context.send(`Pong! ${context.client.ws.ping}ms!`);
|
|
298
|
-
* });
|
|
299
|
-
*
|
|
300
|
-
* export default command;
|
|
301
|
-
* ```
|
|
302
|
-
*/
|
|
303
|
-
declare function defineCommand<const ParamsList extends readonly AnyParam<any>[] = any[]>(options: (Omit<CommandOptionsInput, "params"> & {
|
|
304
|
-
params?: ParamsList;
|
|
305
|
-
}) | string): Command<ParamsList>;
|
|
306
|
-
|
|
307
|
-
declare class CommandManager extends BaseClientManager {
|
|
308
|
-
commands: Collection<string, Command<any[]>>;
|
|
309
|
-
loadModules(): Promise<Command[]>;
|
|
310
|
-
add(command: Command): void;
|
|
311
|
-
remove(target: string | Command): Command | undefined;
|
|
312
|
-
get(name: string): Command<any[]> | undefined;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
declare const ListenerOptionsSchema: z$1.ZodObject<{
|
|
316
|
-
name: z$1.ZodEnum<typeof Events>;
|
|
317
|
-
once: z$1.ZodDefault<z$1.ZodBoolean>;
|
|
318
|
-
}, z$1.z.core.$strip>;
|
|
319
|
-
type ListenerOptions<K extends EventKey = EventKey> = Omit<z$1.input<typeof ListenerOptionsSchema>, "name"> & {
|
|
320
|
-
name: K;
|
|
321
|
-
};
|
|
322
|
-
type EventKey = keyof BakitClientEvents;
|
|
323
|
-
declare class Listener<K extends EventKey = EventKey> extends LifecycleManager<Context, [
|
|
324
|
-
...args: BakitClientEvents[K]
|
|
325
|
-
]> {
|
|
326
|
-
options: ListenerOptions<K>;
|
|
327
|
-
constructor(options: K | ListenerOptions<K>);
|
|
328
|
-
}
|
|
329
|
-
declare function defineListener<const K extends EventKey = EventKey>(options: K | ListenerOptions<K>): Listener<K>;
|
|
330
|
-
|
|
331
|
-
declare class ListenerManager extends BaseClientManager {
|
|
332
|
-
listeners: Listener[];
|
|
333
|
-
private executors;
|
|
334
|
-
loadModules(): Promise<Listener[]>;
|
|
335
|
-
add(listener: Listener): void;
|
|
336
|
-
remove(target: string | Listener): Listener[];
|
|
337
|
-
getBaseIntents(): IntentsBitField;
|
|
338
|
-
getNeededIntents(): IntentsBitField;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
declare class ProjectCacheManager {
|
|
342
|
-
private readonly rootDir;
|
|
343
|
-
constructor(root?: string);
|
|
344
|
-
private ensureRoot;
|
|
345
|
-
getHash(data: unknown): string;
|
|
346
|
-
write(path: string, data: unknown): Promise<void>;
|
|
347
|
-
read<T>(path: string): Promise<T | null>;
|
|
348
|
-
clear(): Promise<void>;
|
|
349
|
-
clearSync(): void;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
declare class Instance {
|
|
353
|
-
client: BakitClient;
|
|
354
|
-
cache: ProjectCacheManager;
|
|
355
|
-
constructor();
|
|
356
|
-
start(): Promise<void>;
|
|
357
|
-
private loadModules;
|
|
358
|
-
private initIntents;
|
|
359
|
-
}
|
|
360
|
-
declare function useApp(): Instance;
|
|
361
|
-
|
|
362
|
-
type GetPrefixFunction = (message: Message) => Awaitable<string[] | string>;
|
|
363
|
-
interface BakitClientEvents extends ClientEvents {
|
|
364
|
-
ready: [BakitClient<true>];
|
|
365
|
-
clientReady: [BakitClient<true>];
|
|
366
|
-
}
|
|
367
|
-
declare class BakitClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
368
|
-
instance: Instance;
|
|
369
|
-
managers: {
|
|
370
|
-
commands: CommandManager;
|
|
371
|
-
listeners: ListenerManager;
|
|
372
|
-
};
|
|
373
|
-
constructor(options: ClientOptions, instance: Instance);
|
|
374
|
-
/**
|
|
375
|
-
* Check if the client is connected to gateway successfully and finished initialization.
|
|
376
|
-
*/
|
|
377
|
-
isReady(): this is BakitClient<true>;
|
|
378
|
-
on<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
379
|
-
once<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
380
|
-
off<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
381
|
-
removeAllListeners(event?: keyof BakitClientEvents): this;
|
|
382
|
-
removeListener<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
383
|
-
emit<K extends keyof BakitClientEvents>(event: K, ...args: BakitClientEvents[K]): boolean;
|
|
384
|
-
/**
|
|
385
|
-
* Override BakitClient output when using logger for security concern.
|
|
386
|
-
* @returns `BakitClient {}`
|
|
387
|
-
*/
|
|
388
|
-
[inspect.custom](): string;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
declare class BaseClientManager {
|
|
392
|
-
client: BakitClient;
|
|
393
|
-
constructor(client: BakitClient);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
declare const Params: {
|
|
397
|
-
readonly string: <Required extends boolean = true>(options: string | {
|
|
398
|
-
name: string;
|
|
399
|
-
description?: string | undefined;
|
|
400
|
-
required?: boolean | undefined;
|
|
401
|
-
maxLength?: number | undefined;
|
|
402
|
-
minLength?: number | undefined;
|
|
403
|
-
}) => StringParam<Required>;
|
|
404
|
-
readonly number: <Required extends boolean = true>(options: string | {
|
|
405
|
-
name: string;
|
|
406
|
-
description?: string | undefined;
|
|
407
|
-
required?: boolean | undefined;
|
|
408
|
-
maxValue?: number | undefined;
|
|
409
|
-
minValue?: number | undefined;
|
|
410
|
-
}) => NumberParam<Required>;
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
declare class BakitError extends Error {
|
|
414
|
-
constructor(message: string);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
declare class ArgumentError extends BakitError {
|
|
418
|
-
target: string;
|
|
419
|
-
reason: string;
|
|
420
|
-
constructor(target: string, reason: string);
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
export { $jiti, type AnyParam, ArgumentError, BakitClient, type BakitClientEvents, BakitError, BaseClientManager, BaseCommandContext, BaseParam, type BaseParamOptions, BaseParamSchema, ChatInputContext, type ChatInputContextSendOptions, Command, type CommandContext, CommandManager, type CommandOptions, type CommandOptionsInput, CommandOptionsSchema, Context, type ContextSendOptions, EVENT_INTENT_MAPPING, type ErrorHookCallback, type GetPrefixFunction, HookOrder, HookState, type InferParamTuple, type InferParamValue, Instance, LifecycleManager, Listener, ListenerManager, type ListenerOptions, ListenerOptionsSchema, type MainHookCallback, MessageContext, type MessageContextSendOptions, type NumberOptions, NumberParam, NumberParamSchema, type ParamResolvedOutputType, ParamUserType, Params, type ProjectConfig, type ProjectConfigInput, ProjectConfigSchema, type StringOptions, StringParam, StringParamSchema, defineCommand, defineConfig, defineListener, getConfig, loadConfig, tokenize, useApp, validateParamsOrder };
|
|
1
|
+
export { DEFAULT_GATEWAY_MANAGER_OPTIONS, DEFAULT_WORKER_PATH, GatewayManager, GatewayManagerEvents, GatewayManagerOptions, GatewayWorker, GatewayWorkerEvents, GatewayWorkerOptions, GatewayWorkerState, createGatewayManager, createWorker } from '@bakit/gateway';
|
|
2
|
+
export { REST, RESTEndpoint, RESTEvents, RESTMethod, RESTOptions, RESTTransportServer, RESTTransportServerOptions, createREST, createRESTTransportServer } from '@bakit/rest';
|
|
3
|
+
export { Awaitable, Collection, EventBus, EventMap, FunctionLike, Promisify, PromisifyValue, Queue, QueueOptions, ReadonlyCollection, RejectFn, ResolveFn, attachEventBus, capitalize, createEventBus, createQueue, isPlainObject, isPromiseLike, promisify, sleep } from '@bakit/utils';
|
|
4
|
+
export { RPCError, RPCErrorPayload, RPCHandler, RPCRequestMessage, RPCResponseMessage, Serializable, Service, ServiceClient, ServiceFunction, ServiceOptions, ServiceServer, TransportClient, TransportClientOptions, TransportDriver, TransportEvents, TransportServer, TransportServerOptions, createIPCClient, createIPCServer, createService, createServiceClient, createServiceServer, createTransportClient, createTransportServer, deserializeRPCError, getIPCPath, serializeRPCError } from '@bakit/service';
|