bakit 1.0.0-beta.1 → 1.0.0-beta.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 +25 -2
- package/dist/BakitClient-D9kRvFS3.d.ts +224 -0
- package/dist/command/index.d.ts +1 -1
- package/dist/command/index.js +249 -240
- package/dist/index.d.ts +82 -4
- package/dist/index.js +540 -351
- package/package.json +10 -22
- package/LICENSE +0 -21
- package/dist/BakitClient-BWxRFtSg.d.ts +0 -199
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
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';
|
|
2
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
|
-
import 'discord.js';
|
|
4
|
-
import '
|
|
4
|
+
import { ClientEvents } from 'discord.js';
|
|
5
|
+
import EventEmitter from 'node:events';
|
|
6
|
+
import { SetOptional } from 'type-fest';
|
|
5
7
|
|
|
6
8
|
declare function extractId(value: string): string | null;
|
|
7
9
|
|
|
@@ -15,4 +17,80 @@ declare class StateBox {
|
|
|
15
17
|
static use<T extends object>(defaultValue?: unknown): (target: T, key: keyof T) => void;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
|
|
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
|
+
|
|
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>>;
|
|
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
|
+
|
|
84
|
+
/**
|
|
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
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
declare module "discord.js" {
|
|
91
|
+
interface Base {
|
|
92
|
+
client: BakitClient<true>;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { BakitClient, type ErrorListenerHookMethod, type EventsLike, Listener, ListenerAPI, ListenerEntry, type ListenerEntryOptions, ListenerFactory, type ListenerHook, ListenerRegistry, type MainListenerHookMethod, StateBox, type States, extractId };
|