bakit 2.0.0-alpha.3 → 2.0.0-alpha.4

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/index.d.ts CHANGED
@@ -327,6 +327,28 @@ declare class BakitClient<Ready extends boolean = boolean> extends Client<Ready>
327
327
  [inspect.custom](): string;
328
328
  }
329
329
 
330
+ declare class Instance {
331
+ client: BakitClient;
332
+ start(): Promise<void>;
333
+ private loadModules;
334
+ private initIntents;
335
+ }
336
+ declare function useApp(): Instance;
337
+
338
+ declare const EVENT_INTENT_MAPPING: Record<string, number[]>;
339
+
340
+ declare function tokenize(content: string): string[];
341
+
342
+ declare class BakitError extends Error {
343
+ constructor(message: string);
344
+ }
345
+
346
+ declare class ArgumentError extends BakitError {
347
+ target: string;
348
+ reason: string;
349
+ constructor(target: string, reason: string);
350
+ }
351
+
330
352
  declare const Params: {
331
353
  readonly string: <Required extends boolean = true>(options: string | {
332
354
  name: string;
@@ -344,4 +366,4 @@ declare const Params: {
344
366
  }) => NumberParam<Required>;
345
367
  };
346
368
 
347
- export { type AnyParam, BakitClient, type BakitClientEvents, BaseCommandContext, BaseParam, type BaseParamOptions, BaseParamSchema, ChatInputContext, type ChatInputContextSendOptions, Command, type CommandContext, CommandManager, type CommandOptions, type CommandOptionsInput, CommandOptionsSchema, type ContextSendOptions, type GetPrefixFunction, type InferParamTuple, type InferParamValue, Listener, ListenerManager, type ListenerOptions, ListenerOptionsSchema, MessageContext, type MessageContextSendOptions, type NumberOptions, NumberParam, NumberParamSchema, type ParamResolvedOutputType, ParamUserType, Params, type ProjectConfig, type ProjectConfigInput, ProjectConfigSchema, type StringOptions, StringParam, StringParamSchema, defineCommand, defineConfig, defineListener, getConfig, loadConfig };
369
+ export { type AnyParam, ArgumentError, BakitClient, type BakitClientEvents, BakitError, BaseClientManager, BaseCommandContext, BaseParam, type BaseParamOptions, BaseParamSchema, ChatInputContext, type ChatInputContextSendOptions, Command, type CommandContext, CommandManager, type CommandOptions, type CommandOptionsInput, CommandOptionsSchema, Context, type ContextSendOptions, EVENT_INTENT_MAPPING, type ErrorHookCallback, type GetPrefixFunction, HookOrder, HookState, type InferParamTuple, type InferParamValue, Instance, LifecycleManager, Listener, ListenerManager, type ListenerOptions, ListenerOptionsSchema, type MainHookCallback, MessageContext, type MessageContextSendOptions, type NumberOptions, NumberParam, NumberParamSchema, type ParamResolvedOutputType, ParamUserType, Params, type ProjectConfig, type ProjectConfigInput, ProjectConfigSchema, type StringOptions, StringParam, StringParamSchema, defineCommand, defineConfig, defineListener, getConfig, loadConfig, tokenize, useApp };
package/dist/index.js CHANGED
@@ -130,7 +130,7 @@ var BaseCommandContext = class extends Context {
130
130
  return await channel.send(options);
131
131
  }
132
132
  };
133
- var LifecycleManager = class {
133
+ var HookState = /* @__PURE__ */ ((HookState2) => (HookState2.Pre = "PRE", HookState2.Main = "MAIN", HookState2.Post = "POST", HookState2.Error = "ERROR", HookState2))(HookState || {}), HookOrder = /* @__PURE__ */ ((HookOrder2) => (HookOrder2[HookOrder2.First = 0] = "First", HookOrder2[HookOrder2.Last = 1] = "Last", HookOrder2))(HookOrder || {}), LifecycleManager = class {
134
134
  constructor(id) {
135
135
  this.id = id;
136
136
  }
@@ -613,6 +613,47 @@ var BakitClient3 = class extends Client {
613
613
  return `${this.constructor.name} {}`;
614
614
  }
615
615
  };
616
+ var Instance = class {
617
+ client;
618
+ async start() {
619
+ await loadConfig();
620
+ let config = getConfig();
621
+ this.client = new BakitClient3({
622
+ intents: []
623
+ }), await this.loadModules(), this.initIntents(), await this.client.login(config.token);
624
+ }
625
+ loadModules() {
626
+ let { managers } = this.client, { commands, listeners } = managers;
627
+ return Promise.all([commands.loadModules(), listeners.loadModules()]);
628
+ }
629
+ initIntents() {
630
+ let config = getConfig(), { options, managers } = this.client, { listeners } = managers, intents;
631
+ config.intents === "auto" ? intents = listeners.getNeededIntents() : (intents = listeners.getBaseIntents(), typeof config.intents == "bigint" ? intents.bitfield = Number(config.intents) : intents.add(...config.intents)), options.intents = intents;
632
+ }
633
+ };
634
+ function useApp() {
635
+ return new Instance();
636
+ }
637
+
638
+ // src/utils/string.ts
639
+ function tokenize(content) {
640
+ let args = [], current = "", quoteChar = null, isEscaped = false;
641
+ for (let i = 0; i < content.length; i++) {
642
+ let char = content[i];
643
+ if (char === void 0)
644
+ break;
645
+ if (isEscaped) {
646
+ current += char, isEscaped = false;
647
+ continue;
648
+ }
649
+ if (char === "\\") {
650
+ isEscaped = true;
651
+ continue;
652
+ }
653
+ quoteChar ? char === quoteChar ? quoteChar = null : current += char : char === '"' ? quoteChar = char : /\s/.test(char) ? current.length > 0 && (args.push(current), current = "") : current += char;
654
+ }
655
+ return current.length > 0 && args.push(current), args;
656
+ }
616
657
  var ParamUserType = /* @__PURE__ */ ((ParamUserType2) => (ParamUserType2.Bot = "bot", ParamUserType2.Normal = "normal", ParamUserType2.Any = "any", ParamUserType2))(ParamUserType || {}), BaseParamSchema = z.object({
617
658
  name: z.string(),
618
659
  description: z.string().optional(),
@@ -634,4 +675,4 @@ var Params = {
634
675
  number: createFactory(NumberParam)
635
676
  };
636
677
 
637
- export { BakitClient3 as BakitClient, BaseCommandContext, BaseParam, BaseParamSchema, ChatInputContext, Command, CommandManager, CommandOptionsSchema, Listener, ListenerManager, ListenerOptionsSchema, MessageContext, NumberParam, NumberParamSchema, ParamUserType, Params, ProjectConfigSchema, StringParam, StringParamSchema, defineCommand, defineConfig, defineListener, getConfig, loadConfig };
678
+ export { ArgumentError, BakitClient3 as BakitClient, BakitError, BaseClientManager, BaseCommandContext, BaseParam, BaseParamSchema, ChatInputContext, Command, CommandManager, CommandOptionsSchema, Context, EVENT_INTENT_MAPPING, HookOrder, HookState, Instance, LifecycleManager, Listener, ListenerManager, ListenerOptionsSchema, MessageContext, NumberParam, NumberParamSchema, ParamUserType, Params, ProjectConfigSchema, StringParam, StringParamSchema, defineCommand, defineConfig, defineListener, getConfig, loadConfig, tokenize, useApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bakit",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-alpha.4",
4
4
  "description": "A framework for discord.js",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",