bakit 1.0.0-beta.9 → 2.0.0-alpha.10

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/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # About us
2
+
3
+ Bakit is a framework that makes building Discord bots easier.
4
+ It's built on top of [discord.js](https://discord.js.org) and helps you handle the core system for your bot.
5
+
6
+ <div align="center">
7
+ <a href="https://npmjs.com/package/bakit"><img src="https://img.shields.io/npm/v/bakit?logo=npm" alt="npm" /></a>
8
+ <a href="LICENSE"><img src="https://img.shields.io/github/license/louiszn/bakit" alt="License" /></a>
9
+ <a href="https://discord.gg/pGnKbMfXke"><img src="https://img.shields.io/discord/1353321517437681724?logo=discord&logoColor=white" alt="Discord" /></a>
10
+ </div>
11
+
12
+ > [!CAUTION]
13
+ > This package is currently being rewritten. Many features from beta v1 have not yet been migrated.
14
+ > It is not production-ready, and use in production environments is strongly discouraged.
15
+
16
+ ## Why Bakit?
17
+
18
+ - 🧩 **Unified Command System** - write once for both slash and prefix command.
19
+ - 🚀 **Clean API interfaces** - well-structured commands and events.
20
+ - ⚡ **Lightweight** - minimal overhead, only what you need.
21
+ - ✨ **TypeScript + ESM first** - modern JavaScript tooling out of the box.
22
+
23
+ ## Documentation
24
+
25
+ Official documentation is now at https://bakit.louiszn.xyz.
26
+
27
+ # Contributing
28
+
29
+ Contributions are always welcome! But before doing that, make sure you have already checked existing issues and pull requests before making a new one.
30
+
31
+ # Support
32
+
33
+ If you like Bakit and want to support its development, you can buy me a coffee:
34
+
35
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/louiszn)
package/bin/bakit.js ADDED
@@ -0,0 +1,39 @@
1
+ // @ts-check
2
+ import { config as useEnv } from "dotenv";
3
+ import { program } from "commander";
4
+
5
+ program.name("bakit");
6
+
7
+ program.command("dev").action(async () => {
8
+ useEnv({
9
+ path: [".env.local", ".env"],
10
+ quiet: true,
11
+ });
12
+ const { default: nodemon } = await import("nodemon");
13
+
14
+ nodemon({
15
+ script: "src/index.ts",
16
+ exec: `${process.execPath} --import tsx`,
17
+ ext: "ts,js",
18
+ watch: ["src"],
19
+ env: {
20
+ ...process.env,
21
+ FORCE_COLOR: "1",
22
+ NODE_ENV: "development",
23
+ },
24
+ });
25
+
26
+ nodemon.on("start", () => {
27
+ console.log("Starting bakit app...");
28
+ });
29
+
30
+ nodemon.on("restart", () => {
31
+ console.log("Bakit detected changes! Restarting...");
32
+ });
33
+
34
+ nodemon.on("quit", () => {
35
+ process.exit();
36
+ });
37
+ });
38
+
39
+ program.parse();
package/dist/index.d.ts CHANGED
@@ -1,96 +1,414 @@
1
- import { B as BaseEntry, C as ConstructorLike, a as BaseHook, b as BaseMainHookMethod, c as BaseErrorHookMethod, d as BakitClient } from './BakitClient-D9kRvFS3.js';
2
- export { A as Arg, h as ArgumentOptions, f as ArgumentType, e as BakitClientOptions, g as BaseArgumentOptions, m as BaseCommandEntry, k as BaseCommandEntryOptions, n as BaseCommandGroupEntry, x as BaseContext, y as ChatInputContext, u as ChatInputContextSendOptions, s as Command, q as CommandAPI, r as CommandFactory, o as CommandGroupEntry, j as CommandHook, t as CommandRegistry, J as CommandSyntaxError, H as CommandSyntaxErrorOptions, F as CommandSyntaxErrorType, D as Context, w as ContextSendOptions, l as CreateCommandOptions, E as ErrorCommandHookMethod, G as GetSyntaxErrorMessageFunction, I as IntegerArgumentOptions, i as MainCommandHookMethod, M as MemberArgumentOptions, z as MessageContext, v as MessageContextSendOptions, N as NumberArgumentOptions, R as RootCommandEntry, S as StringArgumentOptions, p as SubcommandEntry, U as UserArgumentOptions } from './BakitClient-D9kRvFS3.js';
3
- import { AsyncLocalStorage } from 'node:async_hooks';
4
- import { ClientEvents } from 'discord.js';
5
- import EventEmitter from 'node:events';
6
- import { SetOptional } from 'type-fest';
7
-
8
- declare function extractId(value: string): string | null;
9
-
10
- type States = Record<string | symbol, unknown>;
11
- declare class StateBox {
12
- private static readonly STATES_KEY;
13
- static storage: AsyncLocalStorage<States>;
14
- private static getState;
15
- static run<R>(fn: () => R, store?: {}): R;
16
- static wrap<R>(fn: () => R): () => R;
17
- static use<T extends object>(defaultValue?: unknown): (target: T, key: keyof T) => void;
18
- }
19
-
20
- type EventsLike = Record<keyof unknown, unknown[]>;
21
- type MainListenerHookMethod<Args extends unknown[]> = BaseMainHookMethod<Args>;
22
- type ErrorListenerHookMethod<Args extends unknown[]> = BaseErrorHookMethod<Args>;
23
- interface ListenerHook<E extends EventsLike, K extends keyof E> extends BaseHook {
24
- method: MainListenerHookMethod<E[K] & unknown[]> | ErrorListenerHookMethod<E[K] & unknown[]>;
25
- }
26
- interface ListenerEntryOptions<E extends EventsLike, K extends keyof E> {
27
- name: K;
28
- once: boolean;
29
- emitter?: EventEmitter;
1
+ import * as discord_js from 'discord.js';
2
+ import { GatewayIntentBits, ClientOptions, ChatInputCommandInteraction, CacheType, Message, User, MessageCreateOptions, InteractionReplyOptions, Awaitable, Collection, Events, IntentsBitField, Client, ClientEvents } from 'discord.js';
3
+ import z$1, { z } from 'zod';
4
+ import * as jiti from 'jiti';
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
+ * Extracts a valid Discord Snowflake (User ID, Channel ID, etc.) from a string.
39
+ * @param input The raw string to parse
40
+ * @returns The extracted ID string, or null if invalid
41
+ */
42
+ declare function extractSnowflakeId(input: string): string | null;
43
+
44
+ declare const $jiti: jiti.Jiti;
45
+
46
+ declare class Context {
47
+ canceled: boolean;
48
+ cancel(): void;
30
49
  }
31
- declare class ListenerEntry<E extends EventsLike, K extends keyof E> extends BaseEntry<ConstructorLike, ListenerHook<E, K>, MainListenerHookMethod<E[K] & unknown[]>, ErrorListenerHookMethod<E[K] & unknown[]>> {
32
- options: ListenerEntryOptions<E, K>;
33
- constructor(options: ListenerEntryOptions<E, K>);
50
+
51
+ type ChatInputContextSendOptions = string | InteractionReplyOptions;
52
+ type MessageContextSendOptions = string | MessageCreateOptions;
53
+ type ContextSendOptions = ChatInputContextSendOptions | MessageContextSendOptions;
54
+ declare abstract class BaseCommandContext<Cached extends boolean, InGuild extends boolean> extends Context {
55
+ source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>;
56
+ constructor(source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>);
57
+ get client(): BakitClient<true>;
58
+ 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>;
59
+ get channelId(): string;
60
+ 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>;
61
+ get guildId(): discord_js.CacheTypeReducer<Cached extends true ? "cached" : CacheType, string, string, string, string | null> | discord_js.If<InGuild, string, null>;
62
+ 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;
63
+ inGuild(): this is CommandContext<Cached, true>;
64
+ inCachedGuild(): this is CommandContext<true, true>;
65
+ get user(): User;
66
+ isChatInput(): this is ChatInputContext;
67
+ isMessage(): this is MessageContext;
68
+ abstract send(options: ContextSendOptions): Promise<Message<InGuild>>;
69
+ }
70
+ declare class ChatInputContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseCommandContext<Cached, InGuild> {
71
+ source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType>;
72
+ send(options: ContextSendOptions): Promise<Message<InGuild>>;
34
73
  }
74
+ declare class MessageContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseCommandContext<Cached, InGuild> {
75
+ source: Message<InGuild>;
76
+ send(options: string | MessageCreateOptions): Promise<Message<InGuild>>;
77
+ }
78
+ type CommandContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> = ChatInputContext<Cached, InGuild> | MessageContext<Cached, InGuild>;
35
79
 
36
- declare namespace ListenerAPI {
37
- const ENTRY_KEY: unique symbol;
38
- function use<E extends EventsLike, K extends keyof E>(entry: ListenerEntry<E, K>): (target: ConstructorLike) => void;
39
- function getEntry<E extends EventsLike, K extends keyof E>(target: ConstructorLike): ListenerEntry<E, K> | undefined;
80
+ declare enum HookState {
81
+ Pre = "PRE",
82
+ Main = "MAIN",
83
+ Post = "POST",
84
+ Error = "ERROR"
85
+ }
86
+ declare enum HookOrder {
87
+ First = 0,
88
+ Last = 1
89
+ }
90
+ type MainHookCallback<C extends Context, Args extends unknown[]> = (context: C, ...args: Args) => Awaitable<void>;
91
+ type ErrorHookCallback<C extends Context, Args extends unknown[]> = (context: C, error: unknown, ...args: Args) => Awaitable<void>;
92
+ declare class LifecycleManager<C extends Context, Args extends unknown[]> {
93
+ id: string;
94
+ private readonly hooks;
95
+ constructor(id: string);
96
+ getName(name: string): string;
97
+ setHook(name: string, state: HookState.Post, callback: MainHookCallback<C, Args>, order?: HookOrder): this;
98
+ setHook(name: string, state: HookState.Main, callback: MainHookCallback<C, Args>, order?: HookOrder): this;
99
+ setHook(name: string, state: HookState.Pre, callback: MainHookCallback<C, Args>, order?: HookOrder): this;
100
+ setHook(name: string, state: HookState.Error, callback: ErrorHookCallback<C, Args>, order?: HookOrder): this;
101
+ main(callback: MainHookCallback<C, Args>): this;
102
+ pre(callback: MainHookCallback<C, Args>): this;
103
+ post(callback: MainHookCallback<C, Args>): this;
104
+ error(callback: ErrorHookCallback<C, Args>): this;
105
+ execute(context: C, ...args: Args): Promise<void>;
40
106
  }
41
- declare function ListenerFactory<E extends EventsLike = ClientEvents, K extends keyof E = keyof E>(options: SetOptional<ListenerEntryOptions<E, K>, "once"> | K): ListenerEntry<E, K>;
42
- declare const Listener: typeof ListenerFactory & typeof ListenerAPI;
43
107
 
44
- /**
45
- * The global listener registry of Bakit.
46
- */
47
- declare abstract class ListenerRegistry {
48
- private static client;
49
- static constructors: Set<ConstructorLike>;
50
- static instances: WeakMap<ConstructorLike, object>;
51
- static executors: WeakMap<object, (...args: unknown[]) => Promise<void>>;
108
+ declare enum ParamUserType {
109
+ Bot = "bot",
110
+ Normal = "normal",
111
+ Any = "any"
112
+ }
113
+ declare const BaseParamSchema: z.ZodObject<{
114
+ name: z.ZodString;
115
+ description: z.ZodOptional<z.ZodString>;
116
+ required: z.ZodDefault<z.ZodBoolean>;
117
+ }, z.core.$strip>;
118
+ declare const StringParamSchema: z.ZodObject<{
119
+ name: z.ZodString;
120
+ description: z.ZodOptional<z.ZodString>;
121
+ required: z.ZodDefault<z.ZodBoolean>;
122
+ maxLength: z.ZodOptional<z.ZodNumber>;
123
+ minLength: z.ZodOptional<z.ZodNumber>;
124
+ }, z.core.$strip>;
125
+ declare const NumberParamSchema: z.ZodObject<{
126
+ name: z.ZodString;
127
+ description: z.ZodOptional<z.ZodString>;
128
+ required: z.ZodDefault<z.ZodBoolean>;
129
+ maxValue: z.ZodOptional<z.ZodNumber>;
130
+ minValue: z.ZodOptional<z.ZodNumber>;
131
+ }, z.core.$strip>;
132
+ declare const UserParamSchema: z.ZodObject<{
133
+ name: z.ZodString;
134
+ description: z.ZodOptional<z.ZodString>;
135
+ required: z.ZodDefault<z.ZodBoolean>;
136
+ }, z.core.$strip>;
137
+ type BaseParamOptions = z.input<typeof BaseParamSchema>;
138
+ type StringOptions = z.input<typeof StringParamSchema>;
139
+ type NumberOptions = z.input<typeof NumberParamSchema>;
140
+ type UserOptions = z.input<typeof UserParamSchema>;
141
+
142
+ type ParamResolvedOutputType<OutputType, Required extends boolean = true> = Required extends true ? OutputType : OutputType | null;
143
+ declare abstract class BaseParam<Options extends BaseParamOptions, OutputType, Required extends boolean = true> {
144
+ private schema;
145
+ options: Options & {
146
+ required: Required;
147
+ };
52
148
  /**
53
- * Add and register a listener to the registry.
54
- * If `options.emitter` is not provided, the registry will use the base `client` by default.
55
- * @param constructor The listener class you want to add.
149
+ * **Internal Phantom Type**
150
+ *
151
+ * Used strictly for TypeScript type inference to determine the runtime value
152
+ * of this parameter. This property does not exist at runtime.
153
+ *
154
+ * @internal
56
155
  */
57
- static add(constructor: ConstructorLike): void;
156
+ readonly _type: Required extends true ? OutputType : OutputType | null;
157
+ constructor(options: Options, schema: z$1.ZodObject);
158
+ protected setOption(key: keyof Options, value: any): this;
159
+ name(value: string): this;
160
+ description(value: string): this;
161
+ required<V extends boolean>(value: V): BaseParam<Options, OutputType, V>;
162
+ resolve(context: CommandContext, value?: string): Promise<ParamResolvedOutputType<OutputType, Required>>;
163
+ abstract resolveMessage(context: MessageContext, value: string): Awaitable<ParamResolvedOutputType<OutputType, Required>>;
164
+ abstract resolveChatInput(context: ChatInputContext): Awaitable<ParamResolvedOutputType<OutputType, Required>>;
58
165
  /**
59
- * Remove and unregister a listener from the registry.
60
- * @param constructor The listener class you want to remove.
61
- * @returns `boolean`, returns `true` if the listener is removed successfully.
166
+ * Helper to normalize string inputs into an options object.
62
167
  */
63
- static remove(constructor: ConstructorLike): boolean;
168
+ protected static getOptions<Options>(options: Options | string): Options;
169
+ }
170
+ declare class StringParam<Required extends boolean = true> extends BaseParam<StringOptions, string, Required> {
171
+ constructor(options: string | StringOptions);
172
+ required<V extends boolean>(value: V): StringParam<V>;
173
+ resolveMessage(_context: CommandContext, value: string): ParamResolvedOutputType<string, Required>;
174
+ resolveChatInput(context: ChatInputContext): ParamResolvedOutputType<string, Required>;
64
175
  /**
65
- * Remove and unregister all listeners from the registry.
66
- * @returns Amount of removed listeners.
176
+ * Sets the minimum allowed length for this string.
177
+ * Pass `null` to remove this constraint.
67
178
  */
68
- static removeAll(): number;
179
+ min(length: number | null): this;
69
180
  /**
70
- * Set base client for the registry to fallback as default emitter. This should be used only by BakitClient and stay untouched.
71
- * @param newClient base client to set for the registry.
181
+ * Sets the maximum allowed length for this string.
182
+ * Pass `null` to remove this constraint.
72
183
  */
73
- protected static setClient(newClient: BakitClient): void;
74
- private static createExecutor;
184
+ max(length: number | null): this;
185
+ }
186
+ declare class NumberParam<Required extends boolean = true> extends BaseParam<NumberOptions, number, Required> {
187
+ constructor(options: string | NumberOptions);
188
+ required<V extends boolean>(value: V): NumberParam<V>;
189
+ resolveMessage(_context: CommandContext, value: string): ParamResolvedOutputType<number, Required>;
190
+ resolveChatInput(context: ChatInputContext): ParamResolvedOutputType<number, Required>;
75
191
  /**
76
- * Load and add all listeners which matched provided glob pattern to the registry.
77
- * @param pattern glob pattern to load.
78
- * @param parallel load all matched results in parallel, enabled by default.
79
- * @returns All loaded listener constructors.
192
+ * Sets the minimum allowed value for this number.
193
+ * Pass `null` to remove this constraint.
80
194
  */
81
- static load(pattern: string, parallel?: boolean): Promise<ConstructorLike[]>;
195
+ min(value: number | null): this;
196
+ /**
197
+ * Sets the maximum allowed value for this number.
198
+ * Pass `null` to remove this constraint.
199
+ */
200
+ max(value: number | null): this;
201
+ }
202
+ declare class UserParam<Required extends boolean = true> extends BaseParam<UserOptions, User, Required> {
203
+ constructor(options: string | UserOptions);
204
+ required<V extends boolean>(value: V): UserParam<V>;
205
+ resolveMessage(context: CommandContext, value: string): Promise<ParamResolvedOutputType<User, Required>>;
206
+ resolveChatInput(context: ChatInputContext): ParamResolvedOutputType<User, Required>;
82
207
  }
208
+ type AnyParam<Required extends boolean = true> = BaseParam<any, any, Required>;
209
+ /**
210
+ * Helper type to extract the runtime value of a Param instance.
211
+ *
212
+ * @example
213
+ * const p = new StringParam("name").required(false);
214
+ * type T = InferParamValue<typeof p>; // string | null
215
+ */
216
+ type InferParamValue<P extends AnyParam<any>> = P["_type"];
217
+ type InferParamTuple<T extends readonly BaseParam<any, any, any>[]> = {
218
+ [K in keyof T]: T[K] extends AnyParam<any> ? InferParamValue<T[K]> : never;
219
+ };
83
220
 
221
+ declare function validateParamsOrder(params: readonly AnyParam<boolean>[]): boolean;
222
+ declare const CommandOptionsSchema: z.ZodPipe<z.ZodObject<{
223
+ name: z.ZodReadonly<z.ZodString>;
224
+ description: z.ZodReadonly<z.ZodOptional<z.ZodString>>;
225
+ nsfw: z.ZodReadonly<z.ZodDefault<z.ZodBoolean>>;
226
+ params: z.ZodReadonly<z.ZodDefault<z.ZodArray<z.ZodCustom<BaseParam<{
227
+ name: string;
228
+ description?: string | undefined;
229
+ required?: boolean | undefined;
230
+ }, unknown, boolean>, BaseParam<{
231
+ name: string;
232
+ description?: string | undefined;
233
+ required?: boolean | undefined;
234
+ }, unknown, boolean>>>>>;
235
+ quotes: z.ZodReadonly<z.ZodDefault<z.ZodBoolean>>;
236
+ }, z.core.$strip>, z.ZodTransform<{
237
+ description: string;
238
+ name: string;
239
+ nsfw: boolean;
240
+ params: readonly BaseParam<{
241
+ name: string;
242
+ description?: string | undefined;
243
+ required?: boolean | undefined;
244
+ }, unknown, boolean>[];
245
+ quotes: boolean;
246
+ }, {
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
+ description?: string | undefined;
256
+ }>>;
257
+ type CommandOptionsInput = z.input<typeof CommandOptionsSchema>;
258
+ type CommandOptions = z.output<typeof CommandOptionsSchema>;
84
259
  /**
85
- * This file is used to redeclare original client to the custom one
86
- * Most of the structure is from Base, but some might be not
260
+ * The command entry, used for registering command.
87
261
  */
262
+ declare class Command<ParamsList extends readonly AnyParam<any>[] = any[]> extends LifecycleManager<CommandContext, [
263
+ ...args: InferParamTuple<ParamsList>
264
+ ]> {
265
+ options: CommandOptions;
266
+ constructor(options: (Omit<CommandOptionsInput, "params"> & {
267
+ params?: ParamsList;
268
+ }) | string);
269
+ private handleSyntaxError;
270
+ toSlashCommandJSON(): discord_js.RESTPostAPIChatInputApplicationCommandsJSONBody;
271
+ private initSlashCommandOptions;
272
+ private initSlashCommandOption;
273
+ }
274
+ /**
275
+ * Define command entry, usually for modules.
276
+ * @param options The command options.
277
+ * @returns The entry of the command to deploy or register hooks.
278
+ * @example
279
+ * ```ts
280
+ * import { defineCommand } from "bakit";
281
+ *
282
+ * const command = defineCommand({
283
+ * name: "ping",
284
+ * description: "Displays bot's latency.",
285
+ * });
286
+ *
287
+ * command.main(async (context) => {
288
+ * await context.send(`Pong! ${context.client.ws.ping}ms!`);
289
+ * });
290
+ *
291
+ * export default command;
292
+ * ```
293
+ */
294
+ declare function defineCommand<const ParamsList extends readonly AnyParam<any>[] = any[]>(options: (Omit<CommandOptionsInput, "params"> & {
295
+ params?: ParamsList;
296
+ }) | string): Command<ParamsList>;
297
+
298
+ declare class CommandManager extends BaseClientManager {
299
+ commands: Collection<string, Command<any[]>>;
300
+ loadModules(): Promise<Command[]>;
301
+ add(command: Command): void;
302
+ remove(target: string | Command): Command | undefined;
303
+ get(name: string): Command<any[]> | undefined;
304
+ }
305
+
306
+ declare const ListenerOptionsSchema: z$1.ZodObject<{
307
+ name: z$1.ZodEnum<typeof Events>;
308
+ once: z$1.ZodDefault<z$1.ZodBoolean>;
309
+ }, z$1.z.core.$strip>;
310
+ type ListenerOptions<K extends EventKey = EventKey> = Omit<z$1.input<typeof ListenerOptionsSchema>, "name"> & {
311
+ name: K;
312
+ };
313
+ type EventKey = keyof BakitClientEvents;
314
+ declare class Listener<K extends EventKey = EventKey> extends LifecycleManager<Context, [
315
+ ...args: BakitClientEvents[K]
316
+ ]> {
317
+ options: ListenerOptions<K>;
318
+ constructor(options: K | ListenerOptions<K>);
319
+ }
320
+ declare function defineListener<const K extends EventKey = EventKey>(options: K | ListenerOptions<K>): Listener<K>;
321
+
322
+ declare class ListenerManager extends BaseClientManager {
323
+ listeners: Listener[];
324
+ private executors;
325
+ loadModules(): Promise<Listener[]>;
326
+ add(listener: Listener): void;
327
+ remove(target: string | Listener): Listener[];
328
+ getBaseIntents(): IntentsBitField;
329
+ getNeededIntents(): IntentsBitField;
330
+ }
331
+
332
+ declare class ProjectCacheManager {
333
+ private readonly rootDir;
334
+ constructor(root?: string);
335
+ private ensureRoot;
336
+ getHash(data: unknown): string;
337
+ write(path: string, data: unknown): Promise<void>;
338
+ read<T>(path: string): Promise<T | null>;
339
+ clear(): Promise<void>;
340
+ clearSync(): void;
341
+ }
88
342
 
343
+ declare class Instance {
344
+ client: BakitClient;
345
+ cache: ProjectCacheManager;
346
+ constructor();
347
+ start(): Promise<void>;
348
+ private loadModules;
349
+ private initIntents;
350
+ }
351
+ declare function useApp(): Instance;
352
+
353
+ type GetPrefixFunction = (message: Message) => Awaitable<string[] | string>;
354
+ interface BakitClientEvents extends ClientEvents {
355
+ ready: [BakitClient<true>];
356
+ clientReady: [BakitClient<true>];
357
+ }
358
+ declare class BakitClient<Ready extends boolean = boolean> extends Client<Ready> {
359
+ instance: Instance;
360
+ managers: {
361
+ commands: CommandManager;
362
+ listeners: ListenerManager;
363
+ };
364
+ constructor(options: ClientOptions, instance: Instance);
365
+ /**
366
+ * Check if the client is connected to gateway successfully and finished initialization.
367
+ */
368
+ isReady(): this is BakitClient<true>;
369
+ on<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
370
+ once<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
371
+ off<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
372
+ removeAllListeners(event?: keyof BakitClientEvents): this;
373
+ removeListener<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
374
+ emit<K extends keyof BakitClientEvents>(event: K, ...args: BakitClientEvents[K]): boolean;
375
+ /**
376
+ * Override BakitClient output when using logger for security concern.
377
+ * @returns `BakitClient {}`
378
+ */
379
+ [inspect.custom](): string;
380
+ }
381
+
382
+ declare class BaseClientManager {
383
+ client: BakitClient;
384
+ constructor(client: BakitClient);
385
+ }
386
+
387
+ declare const Params: {
388
+ readonly string: <Required extends boolean = true>(options: string | {
389
+ name: string;
390
+ description?: string | undefined;
391
+ required?: boolean | undefined;
392
+ maxLength?: number | undefined;
393
+ minLength?: number | undefined;
394
+ }) => StringParam<Required>;
395
+ readonly number: <Required extends boolean = true>(options: string | {
396
+ name: string;
397
+ description?: string | undefined;
398
+ required?: boolean | undefined;
399
+ maxValue?: number | undefined;
400
+ minValue?: number | undefined;
401
+ }) => NumberParam<Required>;
402
+ };
403
+
404
+ declare class BakitError extends Error {
405
+ constructor(message: string);
406
+ }
89
407
 
90
- declare module "discord.js" {
91
- interface Base {
92
- client: BakitClient<true>;
93
- }
408
+ declare class ArgumentError extends BakitError {
409
+ target: string;
410
+ reason: string;
411
+ constructor(target: string, reason: string);
94
412
  }
95
413
 
96
- export { BakitClient, type ErrorListenerHookMethod, type EventsLike, Listener, ListenerAPI, ListenerEntry, type ListenerEntryOptions, ListenerFactory, type ListenerHook, ListenerRegistry, type MainListenerHookMethod, StateBox, type States, extractId };
414
+ 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, type UserOptions, UserParam, UserParamSchema, defineCommand, defineConfig, defineListener, extractSnowflakeId, getConfig, loadConfig, tokenize, useApp, validateParamsOrder };