bakit 1.0.0-beta.8 → 2.0.0-alpha.1
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 +35 -0
- package/dist/index.d.ts +37 -89
- package/dist/index.js +47 -1195
- package/package.json +16 -9
- package/dist/BakitClient-D9kRvFS3.d.ts +0 -224
- package/dist/command/index.d.ts +0 -3
- package/dist/command/index.js +0 -473
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
|
+
[](https://ko-fi.com/louiszn)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,96 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
|
30
|
-
}
|
|
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>);
|
|
34
|
-
}
|
|
35
|
-
|
|
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;
|
|
40
|
-
}
|
|
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
|
-
|
|
1
|
+
import { GatewayIntentBits, ClientOptions, Message, Awaitable, ClientEvents, Client } from 'discord.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
declare const ProjectConfigSchema: z.ZodObject<{
|
|
5
|
+
intents: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodBigInt, z.ZodArray<z.ZodEnum<typeof GatewayIntentBits>>]>>;
|
|
6
|
+
clientOptions: z.ZodOptional<z.ZodCustom<Omit<ClientOptions, "intents">, Omit<ClientOptions, "intents">>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
type ProjectConfigInput = z.input<typeof ProjectConfigSchema>;
|
|
9
|
+
type ProjectConfig = z.output<typeof ProjectConfigSchema>;
|
|
44
10
|
/**
|
|
45
|
-
*
|
|
11
|
+
* Define config object for your project. This is just a cleaner way to define config.
|
|
12
|
+
* @param config The partial version of project config.
|
|
13
|
+
* @returns The same config you provided earlier.
|
|
46
14
|
*/
|
|
47
|
-
declare
|
|
48
|
-
private static client;
|
|
49
|
-
static constructors: Set<ConstructorLike>;
|
|
50
|
-
static instances: WeakMap<ConstructorLike, object>;
|
|
51
|
-
static executors: WeakMap<object, (...args: unknown[]) => Promise<void>>;
|
|
52
|
-
/**
|
|
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.
|
|
56
|
-
*/
|
|
57
|
-
static add(constructor: ConstructorLike): void;
|
|
58
|
-
/**
|
|
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.
|
|
62
|
-
*/
|
|
63
|
-
static remove(constructor: ConstructorLike): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Remove and unregister all listeners from the registry.
|
|
66
|
-
* @returns Amount of removed listeners.
|
|
67
|
-
*/
|
|
68
|
-
static removeAll(): number;
|
|
69
|
-
/**
|
|
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.
|
|
72
|
-
*/
|
|
73
|
-
protected static setClient(newClient: BakitClient): void;
|
|
74
|
-
private static createExecutor;
|
|
75
|
-
/**
|
|
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.
|
|
80
|
-
*/
|
|
81
|
-
static load(pattern: string, parallel?: boolean): Promise<ConstructorLike[]>;
|
|
82
|
-
}
|
|
83
|
-
|
|
15
|
+
declare function defineConfig(config: ProjectConfigInput): ProjectConfigInput;
|
|
84
16
|
/**
|
|
85
|
-
*
|
|
86
|
-
*
|
|
17
|
+
* Load the config file and save them for later usage.
|
|
18
|
+
* @param cwd The location of the config file, uses root by default.
|
|
19
|
+
* @returns The complete config with default values from the validation.
|
|
87
20
|
*/
|
|
21
|
+
declare function loadConfig(cwd?: string): Promise<ProjectConfig>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the loaded config of the project.
|
|
24
|
+
* @returns The project config.
|
|
25
|
+
*/
|
|
26
|
+
declare function getConfig(): ProjectConfig;
|
|
88
27
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
28
|
+
type GetPrefixFunction = (message: Message) => Awaitable<string[] | string>;
|
|
29
|
+
interface BakitClientEvents extends ClientEvents {
|
|
30
|
+
ready: [BakitClient<true>];
|
|
31
|
+
clientReady: [BakitClient<true>];
|
|
32
|
+
}
|
|
33
|
+
declare class BakitClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
34
|
+
constructor(options: ClientOptions);
|
|
35
|
+
isReady(): this is BakitClient<true>;
|
|
36
|
+
on<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
37
|
+
once<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
38
|
+
off<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
39
|
+
removeAllListeners(event?: keyof BakitClientEvents): this;
|
|
40
|
+
removeListener<K extends keyof BakitClientEvents>(event: K, listener: (...args: BakitClientEvents[K]) => void): this;
|
|
41
|
+
emit<K extends keyof BakitClientEvents>(event: K, ...args: BakitClientEvents[K]): boolean;
|
|
94
42
|
}
|
|
95
43
|
|
|
96
|
-
export { BakitClient, type
|
|
44
|
+
export { BakitClient, type BakitClientEvents, type GetPrefixFunction, type ProjectConfig, type ProjectConfigInput, defineConfig, getConfig, loadConfig };
|