bakit 1.0.0-beta.9 → 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/package.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bakit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
4
|
"description": "A framework for discord.js",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"types": "./dist/index.d.ts",
|
|
9
|
-
"import": "./dist/index.js"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": "./dist/index.js",
|
|
12
8
|
"scripts": {
|
|
13
9
|
"build": "tsup",
|
|
14
10
|
"type-check": "tsc --noEmit",
|
|
@@ -17,6 +13,14 @@
|
|
|
17
13
|
"files": [
|
|
18
14
|
"dist"
|
|
19
15
|
],
|
|
16
|
+
"homepage": "https://github.com/louiszn/bakit#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/louiszn/bakit.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/louiszn/bakit/issues"
|
|
23
|
+
},
|
|
20
24
|
"keywords": [
|
|
21
25
|
"discord.js",
|
|
22
26
|
"discord-bot",
|
|
@@ -30,8 +34,11 @@
|
|
|
30
34
|
"discord.js": "^14.0.0"
|
|
31
35
|
},
|
|
32
36
|
"dependencies": {
|
|
33
|
-
"reflect-metadata": "^0.2.2",
|
|
34
37
|
"tiny-glob": "^0.2.9",
|
|
35
|
-
"type-fest": "^4.41.0"
|
|
38
|
+
"type-fest": "^4.41.0",
|
|
39
|
+
"zod": "^4.1.12"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@swc/core": "^1.13.5"
|
|
36
43
|
}
|
|
37
44
|
}
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import * as discord_js from 'discord.js';
|
|
2
|
-
import { Awaitable, ChatInputCommandInteraction, CacheType, Message, InteractionReplyOptions, MessageCreateOptions, User, Collection, RESTPostAPIApplicationCommandsJSONBody, Client, ClientOptions, IntentsBitField } from 'discord.js';
|
|
3
|
-
import { SetOptional } from 'type-fest';
|
|
4
|
-
|
|
5
|
-
type ConstructorLike = new (...args: unknown[]) => object;
|
|
6
|
-
declare enum HookExecutionState {
|
|
7
|
-
Main = "MAIN",
|
|
8
|
-
Pre = "PRE",
|
|
9
|
-
Post = "POST",
|
|
10
|
-
Error = "ERROR"
|
|
11
|
-
}
|
|
12
|
-
type BaseMainHookMethod<Args extends unknown[]> = (...args: Args) => Awaitable<void>;
|
|
13
|
-
type BaseErrorHookMethod<Args extends unknown[]> = (error: unknown, ...args: Args) => Awaitable<void>;
|
|
14
|
-
interface BaseHook {
|
|
15
|
-
state: HookExecutionState;
|
|
16
|
-
method: BaseMainHookMethod<never> | BaseErrorHookMethod<never>;
|
|
17
|
-
entry: unknown;
|
|
18
|
-
}
|
|
19
|
-
declare class BaseEntry<Constructor extends ConstructorLike, Hook extends BaseHook, MainHookMethod extends BaseMainHookMethod<never>, ErrorHookMethod extends BaseErrorHookMethod<never>> {
|
|
20
|
-
protected target?: Constructor;
|
|
21
|
-
hooks: Record<HookExecutionState, Hook | undefined>;
|
|
22
|
-
main: <T extends MainHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
23
|
-
pre: <T extends MainHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
24
|
-
post: <T extends MainHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
25
|
-
error: <T extends MainHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
26
|
-
constructor();
|
|
27
|
-
setTarget(target: Constructor): void;
|
|
28
|
-
createMainHookDecorator(state: HookExecutionState): <T extends MainHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
29
|
-
createErrorHookDecorator(state: HookExecutionState): <T extends ErrorHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
30
|
-
protected addHook<T extends Hook["method"]>(state: HookExecutionState, target: object, descriptor: TypedPropertyDescriptor<T>): void;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
type ChatInputContextSendOptions = string | InteractionReplyOptions;
|
|
34
|
-
type MessageContextSendOptions = string | MessageCreateOptions;
|
|
35
|
-
type ContextSendOptions = ChatInputContextSendOptions | MessageContextSendOptions;
|
|
36
|
-
declare abstract class BaseContext<Cached extends boolean, InGuild extends boolean> {
|
|
37
|
-
source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>;
|
|
38
|
-
constructor(source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>);
|
|
39
|
-
get client(): BakitClient<true>;
|
|
40
|
-
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>;
|
|
41
|
-
get channelId(): string;
|
|
42
|
-
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>;
|
|
43
|
-
get guildId(): discord_js.CacheTypeReducer<Cached extends true ? "cached" : CacheType, string, string, string, string | null> | discord_js.If<InGuild, string, null>;
|
|
44
|
-
inGuild(): this is Context<Cached, true>;
|
|
45
|
-
inCachedGuild(): this is Context<true, true>;
|
|
46
|
-
get author(): User;
|
|
47
|
-
isChatInput(): this is ChatInputContext;
|
|
48
|
-
isMessage(): this is MessageContext;
|
|
49
|
-
abstract send(options: ContextSendOptions): Promise<Message<InGuild>>;
|
|
50
|
-
}
|
|
51
|
-
declare class ChatInputContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseContext<Cached, InGuild> {
|
|
52
|
-
source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType>;
|
|
53
|
-
send(options: ContextSendOptions): Promise<Message<InGuild>>;
|
|
54
|
-
}
|
|
55
|
-
declare class MessageContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseContext<Cached, InGuild> {
|
|
56
|
-
source: Message<InGuild>;
|
|
57
|
-
send(options: string | MessageCreateOptions): Promise<Message<InGuild>>;
|
|
58
|
-
}
|
|
59
|
-
type Context<Cached extends boolean = boolean, InGuild extends boolean = boolean> = ChatInputContext<Cached, InGuild> | MessageContext<Cached, InGuild>;
|
|
60
|
-
|
|
61
|
-
type MainCommandHookMethod = BaseMainHookMethod<[context: Context, ...args: unknown[]]>;
|
|
62
|
-
type ErrorCommandHookMethod = BaseErrorHookMethod<[context: Context, ...args: unknown[]]>;
|
|
63
|
-
interface CommandHook extends BaseHook {
|
|
64
|
-
method: MainCommandHookMethod | ErrorCommandHookMethod;
|
|
65
|
-
}
|
|
66
|
-
interface BaseCommandEntryOptions {
|
|
67
|
-
name: string;
|
|
68
|
-
description: string;
|
|
69
|
-
nsfw?: boolean;
|
|
70
|
-
}
|
|
71
|
-
type CreateCommandOptions<T extends BaseCommandEntryOptions> = SetOptional<T, "description"> | string;
|
|
72
|
-
declare class BaseCommandEntry extends BaseEntry<ConstructorLike, CommandHook, MainCommandHookMethod, ErrorCommandHookMethod> {
|
|
73
|
-
options: BaseCommandEntryOptions;
|
|
74
|
-
constructor(options: BaseCommandEntryOptions);
|
|
75
|
-
}
|
|
76
|
-
declare class BaseCommandGroupEntry extends BaseCommandEntry {
|
|
77
|
-
children: Collection<string, CommandGroupEntry | SubcommandEntry>;
|
|
78
|
-
subcommand(options: CreateCommandOptions<BaseCommandEntryOptions>): SubcommandEntry;
|
|
79
|
-
}
|
|
80
|
-
declare class RootCommandEntry extends BaseCommandGroupEntry {
|
|
81
|
-
group(options: CreateCommandOptions<BaseCommandEntryOptions>): CommandGroupEntry;
|
|
82
|
-
}
|
|
83
|
-
declare class CommandGroupEntry extends BaseCommandGroupEntry {
|
|
84
|
-
parent: RootCommandEntry;
|
|
85
|
-
children: Collection<string, SubcommandEntry>;
|
|
86
|
-
constructor(options: BaseCommandEntryOptions, parent: RootCommandEntry);
|
|
87
|
-
}
|
|
88
|
-
declare class SubcommandEntry extends BaseCommandEntry {
|
|
89
|
-
parent: BaseCommandGroupEntry;
|
|
90
|
-
constructor(options: BaseCommandEntryOptions, parent: BaseCommandGroupEntry);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
declare enum ArgumentType {
|
|
94
|
-
String = "string",
|
|
95
|
-
Integer = "integer",
|
|
96
|
-
Number = "number",
|
|
97
|
-
User = "user",
|
|
98
|
-
Member = "member"
|
|
99
|
-
}
|
|
100
|
-
interface BaseArgumentOptions {
|
|
101
|
-
type: ArgumentType;
|
|
102
|
-
name: string;
|
|
103
|
-
description?: string;
|
|
104
|
-
required?: boolean;
|
|
105
|
-
tuple?: boolean;
|
|
106
|
-
}
|
|
107
|
-
interface StringArgumentOptions extends BaseArgumentOptions {
|
|
108
|
-
type: ArgumentType.String;
|
|
109
|
-
maxLength?: number;
|
|
110
|
-
minLength?: number;
|
|
111
|
-
}
|
|
112
|
-
interface IntegerArgumentOptions extends BaseArgumentOptions {
|
|
113
|
-
type: ArgumentType.Integer;
|
|
114
|
-
maxValue?: number;
|
|
115
|
-
minValue?: number;
|
|
116
|
-
}
|
|
117
|
-
interface NumberArgumentOptions extends BaseArgumentOptions {
|
|
118
|
-
type: ArgumentType.Number;
|
|
119
|
-
maxValue?: number;
|
|
120
|
-
minValue?: number;
|
|
121
|
-
}
|
|
122
|
-
interface UserArgumentOptions extends BaseArgumentOptions {
|
|
123
|
-
type: ArgumentType.User;
|
|
124
|
-
}
|
|
125
|
-
interface MemberArgumentOptions extends BaseArgumentOptions {
|
|
126
|
-
type: ArgumentType.Member;
|
|
127
|
-
}
|
|
128
|
-
type ArgumentOptions = StringArgumentOptions | IntegerArgumentOptions | NumberArgumentOptions | UserArgumentOptions | MemberArgumentOptions;
|
|
129
|
-
|
|
130
|
-
declare function getMethodArguments(method: CommandHook["method"]): readonly ArgumentOptions[];
|
|
131
|
-
declare function getMethodArguments(method: CommandHook["method"], init: true): ArgumentOptions[];
|
|
132
|
-
declare function createArgument<Options extends ArgumentOptions>(type: Options["type"]): (options: Omit<Options, "type"> | string) => (target: object, key: string | symbol, _index: number) => void;
|
|
133
|
-
declare function describeArgumentExpectation(arg: ArgumentOptions): string;
|
|
134
|
-
declare function format(arg: ArgumentOptions): string;
|
|
135
|
-
declare const Arg: {
|
|
136
|
-
getMethodArguments: typeof getMethodArguments;
|
|
137
|
-
createArgument: typeof createArgument;
|
|
138
|
-
describeArgumentExpectation: typeof describeArgumentExpectation;
|
|
139
|
-
format: typeof format;
|
|
140
|
-
string: (options: string | Omit<StringArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
141
|
-
number: (options: string | Omit<NumberArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
142
|
-
integer: (options: string | Omit<IntegerArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
143
|
-
user: (options: string | Omit<UserArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
144
|
-
member: (options: string | Omit<MemberArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
declare namespace CommandAPI {
|
|
148
|
-
function use(root: RootCommandEntry): (target: ConstructorLike) => void;
|
|
149
|
-
function getRoot(constructor: ConstructorLike): RootCommandEntry | undefined;
|
|
150
|
-
}
|
|
151
|
-
declare function CommandFactory(options: CreateCommandOptions<BaseCommandEntryOptions> | string): RootCommandEntry;
|
|
152
|
-
declare const Command: typeof CommandFactory & typeof CommandAPI;
|
|
153
|
-
|
|
154
|
-
declare class CommandRegistry {
|
|
155
|
-
static constructors: Collection<string, ConstructorLike>;
|
|
156
|
-
static instances: Collection<string, object>;
|
|
157
|
-
/**
|
|
158
|
-
* Add a command to the registry.
|
|
159
|
-
* @param constructor The command class you want to add.
|
|
160
|
-
*/
|
|
161
|
-
static add(constructor: ConstructorLike): void;
|
|
162
|
-
/**
|
|
163
|
-
* Load and add all commands which matched provided glob pattern to the registry.
|
|
164
|
-
* @param pattern glob pattern to load.
|
|
165
|
-
* @param parallel load all matched results in parallel, enabled by default.
|
|
166
|
-
* @returns All loaded command constructors.
|
|
167
|
-
*/
|
|
168
|
-
static load(pattern: string, parallel?: boolean): Promise<ConstructorLike[]>;
|
|
169
|
-
/**
|
|
170
|
-
* Build a command into application command data.
|
|
171
|
-
* @param constructor The command class you want to build.
|
|
172
|
-
* @returns a REST JSON version of the application command data.
|
|
173
|
-
*/
|
|
174
|
-
static buildSlashCommand(constructor: ConstructorLike): RESTPostAPIApplicationCommandsJSONBody;
|
|
175
|
-
private static getMainHookArguments;
|
|
176
|
-
private static buildSlashCommandSubcommands;
|
|
177
|
-
private static buildSlashCommandOptions;
|
|
178
|
-
private static attachSlashCommandOption;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
declare enum CommandSyntaxErrorType {
|
|
182
|
-
MissingRequireArgument = "MISSING_REQUIRE_ARGUMENT",
|
|
183
|
-
InvalidArgument = "INVALID_ARGUMENT",
|
|
184
|
-
InvalidVariadicArgumentValue = "INVALID_VARIADIC_ARGUMENT_VALUE"
|
|
185
|
-
}
|
|
186
|
-
interface CommandSyntaxErrorOptions {
|
|
187
|
-
arg: ArgumentOptions;
|
|
188
|
-
type: CommandSyntaxErrorType;
|
|
189
|
-
received: unknown;
|
|
190
|
-
}
|
|
191
|
-
declare class CommandSyntaxError extends Error {
|
|
192
|
-
readonly arg: ArgumentOptions;
|
|
193
|
-
readonly type: CommandSyntaxErrorType;
|
|
194
|
-
readonly expected: unknown;
|
|
195
|
-
readonly received: unknown;
|
|
196
|
-
constructor(options: CommandSyntaxErrorOptions);
|
|
197
|
-
get name(): string;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
type GetSyntaxErrorMessageFunction = (command: object, error: CommandSyntaxError, context: MessageContext, args: readonly ArgumentOptions[], prefix: string) => Awaitable<MessageCreateOptions | undefined>;
|
|
201
|
-
interface BakitClientOptions extends ClientOptions {
|
|
202
|
-
prefixes?: string[];
|
|
203
|
-
enableMentionPrefix?: boolean;
|
|
204
|
-
getSyntaxErrorMessage?: GetSyntaxErrorMessageFunction | null;
|
|
205
|
-
}
|
|
206
|
-
declare class BakitClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
207
|
-
options: Omit<BakitClientOptions, "intents"> & {
|
|
208
|
-
intents: IntentsBitField;
|
|
209
|
-
};
|
|
210
|
-
constructor(options: BakitClientOptions);
|
|
211
|
-
static getSyntaxErrorMessage: GetSyntaxErrorMessageFunction;
|
|
212
|
-
private registerApplicationCommands;
|
|
213
|
-
private handleMessage;
|
|
214
|
-
private handleInteraction;
|
|
215
|
-
private handleChatInputHooks;
|
|
216
|
-
private handleMessageHooks;
|
|
217
|
-
private handleChildMessageHooks;
|
|
218
|
-
private runMessageHooks;
|
|
219
|
-
private runChatInputHooks;
|
|
220
|
-
private runHooks;
|
|
221
|
-
private getChatInputTargetHooks;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export { Arg as A, BaseEntry as B, type ConstructorLike as C, type Context as D, type ErrorCommandHookMethod as E, CommandSyntaxErrorType as F, type GetSyntaxErrorMessageFunction as G, type CommandSyntaxErrorOptions as H, type IntegerArgumentOptions as I, CommandSyntaxError as J, type MemberArgumentOptions as M, type NumberArgumentOptions as N, RootCommandEntry as R, type StringArgumentOptions as S, type UserArgumentOptions as U, type BaseHook as a, type BaseMainHookMethod as b, type BaseErrorHookMethod as c, BakitClient as d, type BakitClientOptions as e, ArgumentType as f, type BaseArgumentOptions as g, type ArgumentOptions as h, type MainCommandHookMethod as i, type CommandHook as j, type BaseCommandEntryOptions as k, type CreateCommandOptions as l, BaseCommandEntry as m, BaseCommandGroupEntry as n, CommandGroupEntry as o, SubcommandEntry as p, CommandAPI as q, CommandFactory as r, Command as s, CommandRegistry as t, type ChatInputContextSendOptions as u, type MessageContextSendOptions as v, type ContextSendOptions as w, BaseContext as x, ChatInputContext as y, MessageContext as z };
|
package/dist/command/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { A as Arg, h as ArgumentOptions, f as ArgumentType, 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, D as Context, w as ContextSendOptions, l as CreateCommandOptions, E as ErrorCommandHookMethod, 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
|
-
import 'discord.js';
|
|
3
|
-
import 'type-fest';
|