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.
@@ -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 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
- }
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 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
- }
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, 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 };
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 };
@@ -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, t as BaseContext, u as ChatInputContext, q as ChatInputContextSendOptions, o as Command, n as CommandConstructor, m as CommandEntry, k as CommandGroupEntry, e as CommandHook, C as CommandHookMethod, p as CommandRegistry, w as Context, s as ContextSendOptions, g as CreateOptions, h as HOOKS_KEY, H as HookExecutionState, I as IntegerArgumentOptions, M as MemberArgumentOptions, v as MessageContext, r as MessageContextSendOptions, N as NumberArgumentOptions, R as RootCommandEntry, S as StringArgumentOptions, l as SubcommandEntry, U as UserArgumentOptions } from '../BakitClient-BWxRFtSg.js';
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';
@@ -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 Arg = class _Arg {
17
- static cache = /* @__PURE__ */ new WeakMap();
18
- static string = _Arg.createArgument("string" /* String */);
19
- static integer = _Arg.createArgument("integer" /* Integer */);
20
- static number = _Arg.createArgument("number" /* Number */);
21
- static user = _Arg.createArgument("user" /* User */);
22
- static member = _Arg.createArgument("member" /* Member */);
23
- static getMethodArguments(method, init = false) {
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
- static format(arg) {
35
- const { name, required, tuple } = arg;
36
- const opening = required ? "<" : "[";
37
- const closing = required ? ">" : "]";
38
- const prefix = tuple ? "..." : "";
39
- return `${opening}${prefix}${name}: ${this.describeArgumentExpectation(arg)}${closing}`;
40
- }
41
- static describeArgumentExpectation(arg) {
42
- const parts = [arg.type];
43
- switch (arg.type) {
44
- case "string" /* String */: {
45
- if (arg.minLength && !arg.maxLength) {
46
- parts.push(`\u2265 ${String(arg.minLength)}`);
47
- }
48
- if (!arg.minLength && arg.maxLength) {
49
- parts.push(`\u2264 ${String(arg.maxLength)}`);
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
- case "number" /* Number */:
57
- case "integer" /* Integer */: {
58
- if (arg.minValue !== void 0 && arg.maxValue === void 0) {
59
- parts.push(`\u2265 ${String(arg.minValue)}`);
60
- }
61
- if (arg.minValue === void 0 && arg.maxValue !== void 0) {
62
- parts.push(`\u2264 ${String(arg.maxValue)}`);
63
- }
64
- if (arg.minValue !== void 0 && arg.maxValue !== void 0) {
65
- parts.push(`${String(arg.minValue)} - ${String(arg.maxValue)}`);
66
- }
67
- break;
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
- case "user" /* User */:
70
- case "member" /* Member */: {
71
- break;
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
- return parts.join(", ");
75
- }
76
- static createArgument(type) {
77
- return function(options) {
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 (!("required" in fullOptions)) {
84
- fullOptions.required = true;
73
+ if (arg.minValue === void 0 && arg.maxValue !== void 0) {
74
+ parts.push(`\u2264 ${String(arg.maxValue)}`);
85
75
  }
86
- return function(target, key, _index) {
87
- const method = Object.getOwnPropertyDescriptor(target, key)?.value;
88
- if (!method) {
89
- throw new Error("No method found");
90
- }
91
- const args = _Arg.getMethodArguments(method, true);
92
- args.unshift(fullOptions);
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
- var Command = class {
225
- static create(options) {
226
- if (typeof options === "string") {
227
- options = { name: options };
228
- }
229
- if (!options.description) {
230
- options.description = options.name;
231
- }
232
- return new RootCommandEntry(options);
233
- }
234
- static use(command) {
235
- return (target) => {
236
- Reflect.defineMetadata(ROOT_KEY, command, target);
237
- };
238
- }
239
- static getRoot(constructor) {
240
- return Reflect.getMetadata(ROOT_KEY, constructor);
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, t as BaseContext, u as ChatInputContext, q as ChatInputContextSendOptions, o as Command, n as CommandConstructor, m as CommandEntry, k as CommandGroupEntry, e as CommandHook, C as CommandHookMethod, p as CommandRegistry, z as CommandSyntaxError, y as CommandSyntaxErrorOptions, x as CommandSyntaxErrorType, w as Context, s as ContextSendOptions, g as CreateOptions, G as GetSyntaxErrorMessageFunction, h as HOOKS_KEY, H as HookExecutionState, I as IntegerArgumentOptions, M as MemberArgumentOptions, v as MessageContext, r as MessageContextSendOptions, N as NumberArgumentOptions, R as RootCommandEntry, S as StringArgumentOptions, l as SubcommandEntry, U as UserArgumentOptions } from './BakitClient-BWxRFtSg.js';
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 Arg = class _Arg {
34
- static cache = /* @__PURE__ */ new WeakMap();
35
- static string = _Arg.createArgument("string" /* String */);
36
- static integer = _Arg.createArgument("integer" /* Integer */);
37
- static number = _Arg.createArgument("number" /* Number */);
38
- static user = _Arg.createArgument("user" /* User */);
39
- static member = _Arg.createArgument("member" /* Member */);
40
- static getMethodArguments(method, init = false) {
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
- static format(arg) {
52
- const { name, required, tuple } = arg;
53
- const opening = required ? "<" : "[";
54
- const closing = required ? ">" : "]";
55
- const prefix = tuple ? "..." : "";
56
- return `${opening}${prefix}${name}: ${this.describeArgumentExpectation(arg)}${closing}`;
57
- }
58
- static describeArgumentExpectation(arg) {
59
- const parts = [arg.type];
60
- switch (arg.type) {
61
- case "string" /* String */: {
62
- if (arg.minLength && !arg.maxLength) {
63
- parts.push(`\u2265 ${String(arg.minLength)}`);
64
- }
65
- if (!arg.minLength && arg.maxLength) {
66
- parts.push(`\u2264 ${String(arg.maxLength)}`);
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
- case "number" /* Number */:
74
- case "integer" /* Integer */: {
75
- if (arg.minValue !== void 0 && arg.maxValue === void 0) {
76
- parts.push(`\u2265 ${String(arg.minValue)}`);
77
- }
78
- if (arg.minValue === void 0 && arg.maxValue !== void 0) {
79
- parts.push(`\u2264 ${String(arg.maxValue)}`);
80
- }
81
- if (arg.minValue !== void 0 && arg.maxValue !== void 0) {
82
- parts.push(`${String(arg.minValue)} - ${String(arg.maxValue)}`);
83
- }
84
- break;
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
- case "user" /* User */:
87
- case "member" /* Member */: {
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
- return parts.join(", ");
92
- }
93
- static createArgument(type) {
94
- return function(options) {
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 (!("required" in fullOptions)) {
101
- fullOptions.required = true;
90
+ if (arg.minValue === void 0 && arg.maxValue !== void 0) {
91
+ parts.push(`\u2264 ${String(arg.maxValue)}`);
102
92
  }
103
- return function(target, key, _index) {
104
- const method = Object.getOwnPropertyDescriptor(target, key)?.value;
105
- if (!method) {
106
- throw new Error("No method found");
107
- }
108
- const args = _Arg.getMethodArguments(method, true);
109
- args.unshift(fullOptions);
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
- var Command = class {
241
- static create(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
- static use(command) {
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
- static getRoot(constructor) {
256
- return Reflect.getMetadata(ROOT_KEY, constructor);
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 user = await this.client.users.fetch(userId).catch(() => null);
703
- if (!user) {
713
+ const user2 = await this.client.users.fetch(userId).catch(() => null);
714
+ if (!user2) {
704
715
  return null;
705
716
  }
706
- return user;
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.1",
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
@@ -1,2 +0,0 @@
1
- # bakit
2
- A discord.js framework