bakit 1.0.0-beta.1 → 1.0.0-beta.2
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/dist/{BakitClient-BWxRFtSg.d.ts → BakitClient-Cvt3Nhoi.d.ts} +24 -19
- package/dist/command/index.d.ts +1 -1
- package/dist/command/index.js +105 -91
- package/dist/index.d.ts +1 -1
- package/dist/index.js +106 -92
- package/package.json +2 -22
- package/LICENSE +0 -21
- package/README.md +0 -2
|
@@ -31,11 +31,13 @@ declare class MessageContext<Cached extends boolean = boolean, InGuild extends b
|
|
|
31
31
|
type Context<Cached extends boolean = boolean, InGuild extends boolean = boolean> = ChatInputContext<Cached, InGuild> | MessageContext<Cached, InGuild>;
|
|
32
32
|
|
|
33
33
|
type CommandConstructor = new (...args: unknown[]) => object;
|
|
34
|
-
declare
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
declare function use(command: RootCommandEntry): (target: CommandConstructor) => void;
|
|
35
|
+
declare function getRoot(constructor: CommandConstructor): RootCommandEntry | undefined;
|
|
36
|
+
declare function CommandFactory(options: CreateOptions<BaseCommandEntryOptions> | string): RootCommandEntry;
|
|
37
|
+
declare const Command: typeof CommandFactory & {
|
|
38
|
+
use: typeof use;
|
|
39
|
+
getRoot: typeof getRoot;
|
|
40
|
+
};
|
|
39
41
|
|
|
40
42
|
declare enum HookExecutionState {
|
|
41
43
|
Main = "main",
|
|
@@ -129,19 +131,22 @@ interface MemberArgumentOptions extends BaseArgumentOptions {
|
|
|
129
131
|
}
|
|
130
132
|
type ArgumentOptions = StringArgumentOptions | IntegerArgumentOptions | NumberArgumentOptions | UserArgumentOptions | MemberArgumentOptions;
|
|
131
133
|
|
|
132
|
-
declare
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
134
|
+
declare function getMethodArguments(method: CommandHook["method"]): readonly ArgumentOptions[];
|
|
135
|
+
declare function getMethodArguments(method: CommandHook["method"], init: true): ArgumentOptions[];
|
|
136
|
+
declare function createArgument<Options extends ArgumentOptions>(type: Options["type"]): (options: Omit<Options, "type"> | string) => (target: object, key: string | symbol, _index: number) => void;
|
|
137
|
+
declare function describeArgumentExpectation(arg: ArgumentOptions): string;
|
|
138
|
+
declare function format(arg: ArgumentOptions): string;
|
|
139
|
+
declare const Arg: {
|
|
140
|
+
getMethodArguments: typeof getMethodArguments;
|
|
141
|
+
createArgument: typeof createArgument;
|
|
142
|
+
describeArgumentExpectation: typeof describeArgumentExpectation;
|
|
143
|
+
format: typeof format;
|
|
144
|
+
string: (options: string | Omit<StringArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
145
|
+
number: (options: string | Omit<NumberArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
146
|
+
integer: (options: string | Omit<IntegerArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
147
|
+
user: (options: string | Omit<UserArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
148
|
+
member: (options: string | Omit<MemberArgumentOptions, "type">) => (target: object, key: string | symbol, _index: number) => void;
|
|
149
|
+
};
|
|
145
150
|
|
|
146
151
|
declare class CommandRegistry {
|
|
147
152
|
static constructors: Collection<string, CommandConstructor>;
|
|
@@ -196,4 +201,4 @@ declare class BakitClient<Ready extends boolean = boolean> extends Client<Ready>
|
|
|
196
201
|
private createHookRecord;
|
|
197
202
|
}
|
|
198
203
|
|
|
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,
|
|
204
|
+
export { Arg as A, type BakitClientOptions as B, type CommandHookMethod as C, CommandSyntaxErrorType as D, type CommandSyntaxErrorOptions as E, CommandSyntaxError as F, 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, getRoot as o, CommandFactory as p, Command as q, CommandRegistry as r, type ChatInputContextSendOptions as s, type MessageContextSendOptions as t, use as u, type ContextSendOptions as v, BaseContext as w, ChatInputContext as x, MessageContext as y, type Context as z };
|
package/dist/command/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { A as Arg, d as ArgumentOptions, b as ArgumentType, c as BaseArgumentOptions, i as BaseCommandEntry, f as BaseCommandEntryOptions, j as BaseCommandGroupEntry,
|
|
1
|
+
export { A as Arg, d as ArgumentOptions, b as ArgumentType, c as BaseArgumentOptions, i as BaseCommandEntry, f as BaseCommandEntryOptions, j as BaseCommandGroupEntry, w as BaseContext, x as ChatInputContext, s as ChatInputContextSendOptions, q as Command, n as CommandConstructor, m as CommandEntry, p as CommandFactory, k as CommandGroupEntry, e as CommandHook, C as CommandHookMethod, r as CommandRegistry, z as Context, v as ContextSendOptions, g as CreateOptions, h as HOOKS_KEY, H as HookExecutionState, I as IntegerArgumentOptions, M as MemberArgumentOptions, y as MessageContext, t as MessageContextSendOptions, N as NumberArgumentOptions, R as RootCommandEntry, S as StringArgumentOptions, l as SubcommandEntry, U as UserArgumentOptions, o as getRoot, u as use } from '../BakitClient-Cvt3Nhoi.js';
|
|
2
2
|
import 'discord.js';
|
|
3
3
|
import 'type-fest';
|
package/dist/command/index.js
CHANGED
|
@@ -13,86 +13,95 @@ var ArgumentType = /* @__PURE__ */ ((ArgumentType2) => {
|
|
|
13
13
|
|
|
14
14
|
// src/command/argument/Arg.ts
|
|
15
15
|
var ARGS_KEY = Symbol("args");
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
let args = this.cache.get(method) ?? Reflect.getMetadata(ARGS_KEY, method);
|
|
25
|
-
if (!args) {
|
|
26
|
-
args = [];
|
|
27
|
-
if (init) {
|
|
28
|
-
Reflect.defineMetadata(ARGS_KEY, args, method);
|
|
29
|
-
this.cache.set(method, args);
|
|
30
|
-
}
|
|
16
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
17
|
+
function getMethodArguments(method, init = false) {
|
|
18
|
+
let args = cache.get(method) ?? Reflect.getMetadata(ARGS_KEY, method);
|
|
19
|
+
if (!args) {
|
|
20
|
+
args = [];
|
|
21
|
+
if (init) {
|
|
22
|
+
Reflect.defineMetadata(ARGS_KEY, args, method);
|
|
23
|
+
cache.set(method, args);
|
|
31
24
|
}
|
|
32
|
-
return init ? args : Object.freeze([...args]);
|
|
33
25
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
if (arg.minLength && arg.maxLength) {
|
|
52
|
-
parts.push(`${String(arg.minLength)} - ${String(arg.maxLength)}`);
|
|
53
|
-
}
|
|
54
|
-
break;
|
|
26
|
+
return init ? args : Object.freeze([...args]);
|
|
27
|
+
}
|
|
28
|
+
function createArgument(type) {
|
|
29
|
+
return function(options) {
|
|
30
|
+
const objOptions = typeof options === "string" ? { name: options } : options;
|
|
31
|
+
const fullOptions = { ...objOptions, type };
|
|
32
|
+
if (!fullOptions.description) {
|
|
33
|
+
fullOptions.description = fullOptions.name;
|
|
34
|
+
}
|
|
35
|
+
if (!("required" in fullOptions)) {
|
|
36
|
+
fullOptions.required = true;
|
|
37
|
+
}
|
|
38
|
+
return function(target, key, _index) {
|
|
39
|
+
const method = Object.getOwnPropertyDescriptor(target, key)?.value;
|
|
40
|
+
if (!method) {
|
|
41
|
+
throw new Error("No method found");
|
|
55
42
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
const args = getMethodArguments(method, true);
|
|
44
|
+
args.unshift(fullOptions);
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
var string = createArgument("string" /* String */);
|
|
49
|
+
var integer = createArgument("integer" /* Integer */);
|
|
50
|
+
var number = createArgument("number" /* Number */);
|
|
51
|
+
var user = createArgument("user" /* User */);
|
|
52
|
+
var member = createArgument("member" /* Member */);
|
|
53
|
+
function describeArgumentExpectation(arg) {
|
|
54
|
+
const parts = [arg.type];
|
|
55
|
+
switch (arg.type) {
|
|
56
|
+
case "string" /* String */: {
|
|
57
|
+
if (arg.minLength && !arg.maxLength) {
|
|
58
|
+
parts.push(`\u2265 ${String(arg.minLength)}`);
|
|
68
59
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
if (!arg.minLength && arg.maxLength) {
|
|
61
|
+
parts.push(`\u2264 ${String(arg.maxLength)}`);
|
|
62
|
+
}
|
|
63
|
+
if (arg.minLength && arg.maxLength) {
|
|
64
|
+
parts.push(`${String(arg.minLength)} - ${String(arg.maxLength)}`);
|
|
72
65
|
}
|
|
66
|
+
break;
|
|
73
67
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const objOptions = typeof options === "string" ? { name: options } : options;
|
|
79
|
-
const fullOptions = { ...objOptions, type };
|
|
80
|
-
if (!fullOptions.description) {
|
|
81
|
-
fullOptions.description = fullOptions.name;
|
|
68
|
+
case "number" /* Number */:
|
|
69
|
+
case "integer" /* Integer */: {
|
|
70
|
+
if (arg.minValue !== void 0 && arg.maxValue === void 0) {
|
|
71
|
+
parts.push(`\u2265 ${String(arg.minValue)}`);
|
|
82
72
|
}
|
|
83
|
-
if (
|
|
84
|
-
|
|
73
|
+
if (arg.minValue === void 0 && arg.maxValue !== void 0) {
|
|
74
|
+
parts.push(`\u2264 ${String(arg.maxValue)}`);
|
|
85
75
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
76
|
+
if (arg.minValue !== void 0 && arg.maxValue !== void 0) {
|
|
77
|
+
parts.push(`${String(arg.minValue)} - ${String(arg.maxValue)}`);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
case "user" /* User */:
|
|
82
|
+
case "member" /* Member */: {
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
95
85
|
}
|
|
86
|
+
return parts.join(", ");
|
|
87
|
+
}
|
|
88
|
+
function format(arg) {
|
|
89
|
+
const { name, required, tuple } = arg;
|
|
90
|
+
const opening = required ? "<" : "[";
|
|
91
|
+
const closing = required ? ">" : "]";
|
|
92
|
+
const prefix = tuple ? "..." : "";
|
|
93
|
+
return `${opening}${prefix}${name}: ${describeArgumentExpectation(arg)}${closing}`;
|
|
94
|
+
}
|
|
95
|
+
var Arg = {
|
|
96
|
+
getMethodArguments,
|
|
97
|
+
createArgument,
|
|
98
|
+
describeArgumentExpectation,
|
|
99
|
+
format,
|
|
100
|
+
string,
|
|
101
|
+
number,
|
|
102
|
+
integer,
|
|
103
|
+
user,
|
|
104
|
+
member
|
|
96
105
|
};
|
|
97
106
|
|
|
98
107
|
// src/command/CommandEntry.ts
|
|
@@ -221,25 +230,27 @@ var SubcommandEntry = class extends BaseCommandEntry {
|
|
|
221
230
|
|
|
222
231
|
// src/command/Command.ts
|
|
223
232
|
var ROOT_KEY = Symbol("root");
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
233
|
+
function use(command) {
|
|
234
|
+
return (target) => {
|
|
235
|
+
Reflect.defineMetadata(ROOT_KEY, command, target);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function getRoot(constructor) {
|
|
239
|
+
return Reflect.getMetadata(ROOT_KEY, constructor);
|
|
240
|
+
}
|
|
241
|
+
function CommandFactory(options) {
|
|
242
|
+
if (typeof options === "string") {
|
|
243
|
+
options = { name: options };
|
|
244
|
+
}
|
|
245
|
+
if (!options.description) {
|
|
246
|
+
options.description = options.name;
|
|
247
|
+
}
|
|
248
|
+
return new RootCommandEntry(options);
|
|
249
|
+
}
|
|
250
|
+
var Command = Object.assign(CommandFactory, {
|
|
251
|
+
use,
|
|
252
|
+
getRoot
|
|
253
|
+
});
|
|
243
254
|
|
|
244
255
|
// src/command/CommandRegistry.ts
|
|
245
256
|
import {
|
|
@@ -454,11 +465,14 @@ export {
|
|
|
454
465
|
BaseContext,
|
|
455
466
|
ChatInputContext,
|
|
456
467
|
Command,
|
|
468
|
+
CommandFactory,
|
|
457
469
|
CommandGroupEntry,
|
|
458
470
|
CommandRegistry,
|
|
459
471
|
HOOKS_KEY,
|
|
460
472
|
HookExecutionState,
|
|
461
473
|
MessageContext,
|
|
462
474
|
RootCommandEntry,
|
|
463
|
-
SubcommandEntry
|
|
475
|
+
SubcommandEntry,
|
|
476
|
+
getRoot,
|
|
477
|
+
use
|
|
464
478
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as Arg, d as ArgumentOptions, b as ArgumentType, a as BakitClient, B as BakitClientOptions, c as BaseArgumentOptions, i as BaseCommandEntry, f as BaseCommandEntryOptions, j as BaseCommandGroupEntry,
|
|
1
|
+
export { A as Arg, d as ArgumentOptions, b as ArgumentType, a as BakitClient, B as BakitClientOptions, c as BaseArgumentOptions, i as BaseCommandEntry, f as BaseCommandEntryOptions, j as BaseCommandGroupEntry, w as BaseContext, x as ChatInputContext, s as ChatInputContextSendOptions, q as Command, n as CommandConstructor, m as CommandEntry, p as CommandFactory, k as CommandGroupEntry, e as CommandHook, C as CommandHookMethod, r as CommandRegistry, F as CommandSyntaxError, E as CommandSyntaxErrorOptions, D as CommandSyntaxErrorType, z as Context, v as ContextSendOptions, g as CreateOptions, G as GetSyntaxErrorMessageFunction, h as HOOKS_KEY, H as HookExecutionState, I as IntegerArgumentOptions, M as MemberArgumentOptions, y as MessageContext, t as MessageContextSendOptions, N as NumberArgumentOptions, R as RootCommandEntry, S as StringArgumentOptions, l as SubcommandEntry, U as UserArgumentOptions, o as getRoot, u as use } from './BakitClient-Cvt3Nhoi.js';
|
|
2
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
import 'type-fest';
|
package/dist/index.js
CHANGED
|
@@ -30,86 +30,95 @@ var ArgumentType = /* @__PURE__ */ ((ArgumentType2) => {
|
|
|
30
30
|
|
|
31
31
|
// src/command/argument/Arg.ts
|
|
32
32
|
var ARGS_KEY = Symbol("args");
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
let args = this.cache.get(method) ?? Reflect.getMetadata(ARGS_KEY, method);
|
|
42
|
-
if (!args) {
|
|
43
|
-
args = [];
|
|
44
|
-
if (init) {
|
|
45
|
-
Reflect.defineMetadata(ARGS_KEY, args, method);
|
|
46
|
-
this.cache.set(method, args);
|
|
47
|
-
}
|
|
33
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
function getMethodArguments(method, init = false) {
|
|
35
|
+
let args = cache.get(method) ?? Reflect.getMetadata(ARGS_KEY, method);
|
|
36
|
+
if (!args) {
|
|
37
|
+
args = [];
|
|
38
|
+
if (init) {
|
|
39
|
+
Reflect.defineMetadata(ARGS_KEY, args, method);
|
|
40
|
+
cache.set(method, args);
|
|
48
41
|
}
|
|
49
|
-
return init ? args : Object.freeze([...args]);
|
|
50
42
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
if (arg.minLength && arg.maxLength) {
|
|
69
|
-
parts.push(`${String(arg.minLength)} - ${String(arg.maxLength)}`);
|
|
70
|
-
}
|
|
71
|
-
break;
|
|
43
|
+
return init ? args : Object.freeze([...args]);
|
|
44
|
+
}
|
|
45
|
+
function createArgument(type) {
|
|
46
|
+
return function(options) {
|
|
47
|
+
const objOptions = typeof options === "string" ? { name: options } : options;
|
|
48
|
+
const fullOptions = { ...objOptions, type };
|
|
49
|
+
if (!fullOptions.description) {
|
|
50
|
+
fullOptions.description = fullOptions.name;
|
|
51
|
+
}
|
|
52
|
+
if (!("required" in fullOptions)) {
|
|
53
|
+
fullOptions.required = true;
|
|
54
|
+
}
|
|
55
|
+
return function(target, key, _index) {
|
|
56
|
+
const method = Object.getOwnPropertyDescriptor(target, key)?.value;
|
|
57
|
+
if (!method) {
|
|
58
|
+
throw new Error("No method found");
|
|
72
59
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
60
|
+
const args = getMethodArguments(method, true);
|
|
61
|
+
args.unshift(fullOptions);
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
var string = createArgument("string" /* String */);
|
|
66
|
+
var integer = createArgument("integer" /* Integer */);
|
|
67
|
+
var number = createArgument("number" /* Number */);
|
|
68
|
+
var user = createArgument("user" /* User */);
|
|
69
|
+
var member = createArgument("member" /* Member */);
|
|
70
|
+
function describeArgumentExpectation(arg) {
|
|
71
|
+
const parts = [arg.type];
|
|
72
|
+
switch (arg.type) {
|
|
73
|
+
case "string" /* String */: {
|
|
74
|
+
if (arg.minLength && !arg.maxLength) {
|
|
75
|
+
parts.push(`\u2265 ${String(arg.minLength)}`);
|
|
85
76
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
break;
|
|
77
|
+
if (!arg.minLength && arg.maxLength) {
|
|
78
|
+
parts.push(`\u2264 ${String(arg.maxLength)}`);
|
|
89
79
|
}
|
|
80
|
+
if (arg.minLength && arg.maxLength) {
|
|
81
|
+
parts.push(`${String(arg.minLength)} - ${String(arg.maxLength)}`);
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
90
84
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const objOptions = typeof options === "string" ? { name: options } : options;
|
|
96
|
-
const fullOptions = { ...objOptions, type };
|
|
97
|
-
if (!fullOptions.description) {
|
|
98
|
-
fullOptions.description = fullOptions.name;
|
|
85
|
+
case "number" /* Number */:
|
|
86
|
+
case "integer" /* Integer */: {
|
|
87
|
+
if (arg.minValue !== void 0 && arg.maxValue === void 0) {
|
|
88
|
+
parts.push(`\u2265 ${String(arg.minValue)}`);
|
|
99
89
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
90
|
+
if (arg.minValue === void 0 && arg.maxValue !== void 0) {
|
|
91
|
+
parts.push(`\u2264 ${String(arg.maxValue)}`);
|
|
102
92
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
93
|
+
if (arg.minValue !== void 0 && arg.maxValue !== void 0) {
|
|
94
|
+
parts.push(`${String(arg.minValue)} - ${String(arg.maxValue)}`);
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case "user" /* User */:
|
|
99
|
+
case "member" /* Member */: {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
112
102
|
}
|
|
103
|
+
return parts.join(", ");
|
|
104
|
+
}
|
|
105
|
+
function format(arg) {
|
|
106
|
+
const { name, required, tuple } = arg;
|
|
107
|
+
const opening = required ? "<" : "[";
|
|
108
|
+
const closing = required ? ">" : "]";
|
|
109
|
+
const prefix = tuple ? "..." : "";
|
|
110
|
+
return `${opening}${prefix}${name}: ${describeArgumentExpectation(arg)}${closing}`;
|
|
111
|
+
}
|
|
112
|
+
var Arg = {
|
|
113
|
+
getMethodArguments,
|
|
114
|
+
createArgument,
|
|
115
|
+
describeArgumentExpectation,
|
|
116
|
+
format,
|
|
117
|
+
string,
|
|
118
|
+
number,
|
|
119
|
+
integer,
|
|
120
|
+
user,
|
|
121
|
+
member
|
|
113
122
|
};
|
|
114
123
|
|
|
115
124
|
// src/command/CommandEntry.ts
|
|
@@ -237,25 +246,27 @@ var SubcommandEntry = class extends BaseCommandEntry {
|
|
|
237
246
|
|
|
238
247
|
// src/command/Command.ts
|
|
239
248
|
var ROOT_KEY = Symbol("root");
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return (target) => {
|
|
252
|
-
Reflect.defineMetadata(ROOT_KEY, command, target);
|
|
253
|
-
};
|
|
249
|
+
function use(command) {
|
|
250
|
+
return (target) => {
|
|
251
|
+
Reflect.defineMetadata(ROOT_KEY, command, target);
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
function getRoot(constructor) {
|
|
255
|
+
return Reflect.getMetadata(ROOT_KEY, constructor);
|
|
256
|
+
}
|
|
257
|
+
function CommandFactory(options) {
|
|
258
|
+
if (typeof options === "string") {
|
|
259
|
+
options = { name: options };
|
|
254
260
|
}
|
|
255
|
-
|
|
256
|
-
|
|
261
|
+
if (!options.description) {
|
|
262
|
+
options.description = options.name;
|
|
257
263
|
}
|
|
258
|
-
|
|
264
|
+
return new RootCommandEntry(options);
|
|
265
|
+
}
|
|
266
|
+
var Command = Object.assign(CommandFactory, {
|
|
267
|
+
use,
|
|
268
|
+
getRoot
|
|
269
|
+
});
|
|
259
270
|
|
|
260
271
|
// src/command/CommandRegistry.ts
|
|
261
272
|
var CommandRegistry = class _CommandRegistry {
|
|
@@ -699,11 +710,11 @@ var ArgumentResolver = class _ArgumentResolver {
|
|
|
699
710
|
if (!userId) {
|
|
700
711
|
return null;
|
|
701
712
|
}
|
|
702
|
-
const
|
|
703
|
-
if (!
|
|
713
|
+
const user2 = await this.client.users.fetch(userId).catch(() => null);
|
|
714
|
+
if (!user2) {
|
|
704
715
|
return null;
|
|
705
716
|
}
|
|
706
|
-
return
|
|
717
|
+
return user2;
|
|
707
718
|
}
|
|
708
719
|
matchIntegerValue(arg, value) {
|
|
709
720
|
const intVal = parseInt(value, 10);
|
|
@@ -1006,6 +1017,7 @@ export {
|
|
|
1006
1017
|
BaseContext,
|
|
1007
1018
|
ChatInputContext,
|
|
1008
1019
|
Command,
|
|
1020
|
+
CommandFactory,
|
|
1009
1021
|
CommandGroupEntry,
|
|
1010
1022
|
CommandRegistry,
|
|
1011
1023
|
CommandSyntaxError,
|
|
@@ -1016,5 +1028,7 @@ export {
|
|
|
1016
1028
|
RootCommandEntry,
|
|
1017
1029
|
StateBox,
|
|
1018
1030
|
SubcommandEntry,
|
|
1019
|
-
extractId
|
|
1031
|
+
extractId,
|
|
1032
|
+
getRoot,
|
|
1033
|
+
use
|
|
1020
1034
|
};
|
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.2",
|
|
4
4
|
"description": "A framework for discord.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,8 +12,7 @@
|
|
|
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"
|
|
@@ -30,25 +29,6 @@
|
|
|
30
29
|
"peerDependencies": {
|
|
31
30
|
"discord.js": "^14.0.0"
|
|
32
31
|
},
|
|
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
32
|
"dependencies": {
|
|
53
33
|
"reflect-metadata": "^0.2.2",
|
|
54
34
|
"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.
|
package/README.md
DELETED