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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bakit",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "A framework for discord.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,12 +12,19 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsup",
|
|
14
14
|
"type-check": "tsc --noEmit",
|
|
15
|
-
"test": "vitest run --pass-with-no-tests"
|
|
16
|
-
"prepare": "husky"
|
|
15
|
+
"test": "vitest run --pass-with-no-tests"
|
|
17
16
|
},
|
|
18
17
|
"files": [
|
|
19
18
|
"dist"
|
|
20
19
|
],
|
|
20
|
+
"homepage": "https://github.com/louiszn/bakit#readme",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/louiszn/bakit.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/louiszn/bakit/issues"
|
|
27
|
+
},
|
|
21
28
|
"keywords": [
|
|
22
29
|
"discord.js",
|
|
23
30
|
"discord-bot",
|
|
@@ -30,25 +37,6 @@
|
|
|
30
37
|
"peerDependencies": {
|
|
31
38
|
"discord.js": "^14.0.0"
|
|
32
39
|
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@eslint/js": "^9.34.0",
|
|
35
|
-
"@types/node": "^24.3.0",
|
|
36
|
-
"@vitest/ui": "^3.2.4",
|
|
37
|
-
"discord.js": "^14.22.1",
|
|
38
|
-
"dotenv": "^17.2.1",
|
|
39
|
-
"eslint": "^9.34.0",
|
|
40
|
-
"eslint-config-prettier": "^10.1.8",
|
|
41
|
-
"eslint-plugin-prettier": "^5.5.4",
|
|
42
|
-
"husky": "^9.1.7",
|
|
43
|
-
"lint-staged": "^16.1.5",
|
|
44
|
-
"prettier": "^3.6.2",
|
|
45
|
-
"tsup": "^8.5.0",
|
|
46
|
-
"tsx": "^4.20.5",
|
|
47
|
-
"typescript": "^5.9.2",
|
|
48
|
-
"typescript-eslint": "^8.40.0",
|
|
49
|
-
"vitest": "^3.2.4",
|
|
50
|
-
"bakit": "link:../../.local/share/pnpm/global/5/node_modules/bakit"
|
|
51
|
-
},
|
|
52
40
|
"dependencies": {
|
|
53
41
|
"reflect-metadata": "^0.2.2",
|
|
54
42
|
"tiny-glob": "^0.2.9",
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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.
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import * as discord_js from 'discord.js';
|
|
2
|
-
import { ChatInputCommandInteraction, CacheType, Message, InteractionReplyOptions, MessageCreateOptions, User, Awaitable, Collection, RESTPostAPIApplicationCommandsJSONBody, Client, ClientOptions, IntentsBitField } from 'discord.js';
|
|
3
|
-
import { SetOptional } from 'type-fest';
|
|
4
|
-
|
|
5
|
-
type ChatInputContextSendOptions = string | InteractionReplyOptions;
|
|
6
|
-
type MessageContextSendOptions = string | MessageCreateOptions;
|
|
7
|
-
type ContextSendOptions = ChatInputContextSendOptions | MessageContextSendOptions;
|
|
8
|
-
declare abstract class BaseContext<Cached extends boolean, InGuild extends boolean> {
|
|
9
|
-
source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>;
|
|
10
|
-
constructor(source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType> | Message<InGuild>);
|
|
11
|
-
get client(): BakitClient<true>;
|
|
12
|
-
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>;
|
|
13
|
-
get channelId(): string;
|
|
14
|
-
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>;
|
|
15
|
-
get guildId(): discord_js.CacheTypeReducer<Cached extends true ? "cached" : CacheType, string, string, string, string | null> | discord_js.If<InGuild, string, null>;
|
|
16
|
-
inGuild(): this is Context<Cached, true>;
|
|
17
|
-
inCachedGuild(): this is Context<true, true>;
|
|
18
|
-
get author(): User;
|
|
19
|
-
isChatInput(): this is ChatInputContext;
|
|
20
|
-
isMessage(): this is MessageContext;
|
|
21
|
-
abstract send(options: ContextSendOptions): Promise<Message<InGuild>>;
|
|
22
|
-
}
|
|
23
|
-
declare class ChatInputContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseContext<Cached, InGuild> {
|
|
24
|
-
source: ChatInputCommandInteraction<Cached extends true ? "cached" : CacheType>;
|
|
25
|
-
send(options: ContextSendOptions): Promise<Message<InGuild>>;
|
|
26
|
-
}
|
|
27
|
-
declare class MessageContext<Cached extends boolean = boolean, InGuild extends boolean = boolean> extends BaseContext<Cached, InGuild> {
|
|
28
|
-
source: Message<InGuild>;
|
|
29
|
-
send(options: string | MessageCreateOptions): Promise<Message<InGuild>>;
|
|
30
|
-
}
|
|
31
|
-
type Context<Cached extends boolean = boolean, InGuild extends boolean = boolean> = ChatInputContext<Cached, InGuild> | MessageContext<Cached, InGuild>;
|
|
32
|
-
|
|
33
|
-
type CommandConstructor = new (...args: unknown[]) => object;
|
|
34
|
-
declare abstract class Command {
|
|
35
|
-
static create(options: CreateOptions<BaseCommandEntryOptions>): RootCommandEntry;
|
|
36
|
-
static use(command: RootCommandEntry): (target: CommandConstructor) => void;
|
|
37
|
-
static getRoot(constructor: CommandConstructor): RootCommandEntry | undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
declare enum HookExecutionState {
|
|
41
|
-
Main = "main",
|
|
42
|
-
Pre = "pre",
|
|
43
|
-
Post = "post",
|
|
44
|
-
Error = "error"
|
|
45
|
-
}
|
|
46
|
-
type CommandHookMethod = (ctx: Context, ...args: any[]) => Awaitable<void>;
|
|
47
|
-
interface CommandHook {
|
|
48
|
-
state: HookExecutionState;
|
|
49
|
-
method: CommandHookMethod;
|
|
50
|
-
entry: CommandEntry;
|
|
51
|
-
}
|
|
52
|
-
interface BaseCommandEntryOptions {
|
|
53
|
-
name: string;
|
|
54
|
-
description: string;
|
|
55
|
-
nsfw?: boolean;
|
|
56
|
-
}
|
|
57
|
-
type CreateOptions<T extends BaseCommandEntryOptions> = SetOptional<T, "description"> | string;
|
|
58
|
-
declare const HOOKS_KEY: unique symbol;
|
|
59
|
-
declare abstract class BaseCommandEntry {
|
|
60
|
-
options: BaseCommandEntryOptions;
|
|
61
|
-
private static cache;
|
|
62
|
-
main: <T extends CommandHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
63
|
-
pre: <T extends CommandHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
64
|
-
post: <T extends CommandHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
65
|
-
error: <T extends CommandHookMethod>(target: object, _key: string, descriptor: TypedPropertyDescriptor<T>) => void;
|
|
66
|
-
constructor(options: BaseCommandEntryOptions);
|
|
67
|
-
static getHooks(constructor: CommandConstructor): readonly CommandHook[];
|
|
68
|
-
static getHooks(constructor: CommandConstructor, init: true): CommandHook[];
|
|
69
|
-
private static createMainHookDecorator;
|
|
70
|
-
private static createErrorHookDecorator;
|
|
71
|
-
private static addHook;
|
|
72
|
-
}
|
|
73
|
-
declare abstract class BaseCommandGroupEntry extends BaseCommandEntry {
|
|
74
|
-
children: Collection<string, CommandGroupEntry | SubcommandEntry>;
|
|
75
|
-
subcommand(options: CreateOptions<BaseCommandEntryOptions>): SubcommandEntry;
|
|
76
|
-
}
|
|
77
|
-
declare class CommandGroupEntry extends BaseCommandGroupEntry {
|
|
78
|
-
options: BaseCommandEntryOptions;
|
|
79
|
-
parent: RootCommandEntry;
|
|
80
|
-
children: Collection<string, SubcommandEntry>;
|
|
81
|
-
constructor(options: BaseCommandEntryOptions, parent: RootCommandEntry);
|
|
82
|
-
}
|
|
83
|
-
declare class RootCommandEntry extends BaseCommandGroupEntry {
|
|
84
|
-
options: BaseCommandEntryOptions;
|
|
85
|
-
constructor(options: BaseCommandEntryOptions);
|
|
86
|
-
group(options: CreateOptions<BaseCommandEntryOptions>): CommandGroupEntry;
|
|
87
|
-
}
|
|
88
|
-
declare class SubcommandEntry extends BaseCommandEntry {
|
|
89
|
-
options: BaseCommandEntryOptions;
|
|
90
|
-
parent: RootCommandEntry | CommandGroupEntry;
|
|
91
|
-
constructor(options: BaseCommandEntryOptions, parent: RootCommandEntry | CommandGroupEntry);
|
|
92
|
-
}
|
|
93
|
-
type CommandEntry = RootCommandEntry | CommandGroupEntry | SubcommandEntry;
|
|
94
|
-
|
|
95
|
-
declare enum ArgumentType {
|
|
96
|
-
String = "string",
|
|
97
|
-
Integer = "integer",
|
|
98
|
-
Number = "number",
|
|
99
|
-
User = "user",
|
|
100
|
-
Member = "member"
|
|
101
|
-
}
|
|
102
|
-
interface BaseArgumentOptions {
|
|
103
|
-
type: ArgumentType;
|
|
104
|
-
name: string;
|
|
105
|
-
description?: string;
|
|
106
|
-
required?: boolean;
|
|
107
|
-
tuple?: boolean;
|
|
108
|
-
}
|
|
109
|
-
interface StringArgumentOptions extends BaseArgumentOptions {
|
|
110
|
-
type: ArgumentType.String;
|
|
111
|
-
maxLength?: number;
|
|
112
|
-
minLength?: number;
|
|
113
|
-
}
|
|
114
|
-
interface IntegerArgumentOptions extends BaseArgumentOptions {
|
|
115
|
-
type: ArgumentType.Integer;
|
|
116
|
-
maxValue?: number;
|
|
117
|
-
minValue?: number;
|
|
118
|
-
}
|
|
119
|
-
interface NumberArgumentOptions extends BaseArgumentOptions {
|
|
120
|
-
type: ArgumentType.Number;
|
|
121
|
-
maxValue?: number;
|
|
122
|
-
minValue?: number;
|
|
123
|
-
}
|
|
124
|
-
interface UserArgumentOptions extends BaseArgumentOptions {
|
|
125
|
-
type: ArgumentType.User;
|
|
126
|
-
}
|
|
127
|
-
interface MemberArgumentOptions extends BaseArgumentOptions {
|
|
128
|
-
type: ArgumentType.Member;
|
|
129
|
-
}
|
|
130
|
-
type ArgumentOptions = StringArgumentOptions | IntegerArgumentOptions | NumberArgumentOptions | UserArgumentOptions | MemberArgumentOptions;
|
|
131
|
-
|
|
132
|
-
declare abstract class Arg {
|
|
133
|
-
private static cache;
|
|
134
|
-
static string: (options: string | Omit<StringArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
135
|
-
static integer: (options: string | Omit<IntegerArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
136
|
-
static number: (options: string | Omit<NumberArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
137
|
-
static user: (options: string | Omit<UserArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
138
|
-
static member: (options: string | Omit<MemberArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
139
|
-
static getMethodArguments(method: CommandHook["method"]): readonly ArgumentOptions[];
|
|
140
|
-
static getMethodArguments(method: CommandHook["method"], init: true): ArgumentOptions[];
|
|
141
|
-
static format(arg: ArgumentOptions): string;
|
|
142
|
-
static describeArgumentExpectation(arg: ArgumentOptions): string;
|
|
143
|
-
protected static createArgument<Options extends ArgumentOptions>(type: Options["type"]): (options: Omit<Options, "type"> | string) => (target: object, key: string | symbol, _index: number) => void;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
declare class CommandRegistry {
|
|
147
|
-
static constructors: Collection<string, CommandConstructor>;
|
|
148
|
-
static instances: Collection<string, object>;
|
|
149
|
-
static add(constructor: CommandConstructor): void;
|
|
150
|
-
static buildSlashCommand(constructor: CommandConstructor): RESTPostAPIApplicationCommandsJSONBody;
|
|
151
|
-
static loadDirectory(pattern: string, parallel?: boolean): Promise<CommandConstructor[]>;
|
|
152
|
-
private static buildSlashCommandOptions;
|
|
153
|
-
private static buildSubcommand;
|
|
154
|
-
private static buildSlashCommandOption;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
declare enum CommandSyntaxErrorType {
|
|
158
|
-
MissingRequireArgument = "MISSING_REQUIRE_ARGUMENT",
|
|
159
|
-
InvalidArgument = "INVALID_ARGUMENT",
|
|
160
|
-
InvalidVariadicArgumentValue = "INVALID_VARIADIC_ARGUMENT_VALUE"
|
|
161
|
-
}
|
|
162
|
-
interface CommandSyntaxErrorOptions {
|
|
163
|
-
arg: ArgumentOptions;
|
|
164
|
-
type: CommandSyntaxErrorType;
|
|
165
|
-
received: unknown;
|
|
166
|
-
}
|
|
167
|
-
declare class CommandSyntaxError extends Error {
|
|
168
|
-
readonly arg: ArgumentOptions;
|
|
169
|
-
readonly type: CommandSyntaxErrorType;
|
|
170
|
-
readonly expected: unknown;
|
|
171
|
-
readonly received: unknown;
|
|
172
|
-
constructor(options: CommandSyntaxErrorOptions);
|
|
173
|
-
get name(): string;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
type GetSyntaxErrorMessageFunction = (command: object, error: CommandSyntaxError, context: MessageContext, args: readonly ArgumentOptions[], prefix: string) => Awaitable<MessageCreateOptions | undefined>;
|
|
177
|
-
interface BakitClientOptions extends ClientOptions {
|
|
178
|
-
prefixes?: string[];
|
|
179
|
-
enableMentionPrefix?: boolean;
|
|
180
|
-
getSyntaxErrorMessage?: GetSyntaxErrorMessageFunction | null;
|
|
181
|
-
}
|
|
182
|
-
declare class BakitClient<Ready extends boolean = boolean> extends Client<Ready> {
|
|
183
|
-
options: Omit<BakitClientOptions, "intents"> & {
|
|
184
|
-
intents: IntentsBitField;
|
|
185
|
-
};
|
|
186
|
-
constructor(options: BakitClientOptions);
|
|
187
|
-
static getSyntaxErrorMessage: GetSyntaxErrorMessageFunction;
|
|
188
|
-
private registerApplicationCommands;
|
|
189
|
-
private handleMessage;
|
|
190
|
-
private handleInteraction;
|
|
191
|
-
private handleChatInputHooks;
|
|
192
|
-
private handleMessageHooks;
|
|
193
|
-
private runMessageHooks;
|
|
194
|
-
private runChatInputHooks;
|
|
195
|
-
private getChatInputTargetHooks;
|
|
196
|
-
private createHookRecord;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export { Arg as A, type BakitClientOptions as B, type CommandHookMethod as C, type GetSyntaxErrorMessageFunction as G, HookExecutionState as H, type IntegerArgumentOptions as I, type MemberArgumentOptions as M, type NumberArgumentOptions as N, RootCommandEntry as R, type StringArgumentOptions as S, type UserArgumentOptions as U, BakitClient as a, ArgumentType as b, type BaseArgumentOptions as c, type ArgumentOptions as d, type CommandHook as e, type BaseCommandEntryOptions as f, type CreateOptions as g, HOOKS_KEY as h, BaseCommandEntry as i, BaseCommandGroupEntry as j, CommandGroupEntry as k, SubcommandEntry as l, type CommandEntry as m, type CommandConstructor as n, Command as o, CommandRegistry as p, type ChatInputContextSendOptions as q, type MessageContextSendOptions as r, type ContextSendOptions as s, BaseContext as t, ChatInputContext as u, MessageContext as v, type Context as w, CommandSyntaxErrorType as x, type CommandSyntaxErrorOptions as y, CommandSyntaxError as z };
|