@mostfeatured/dbi 0.2.17 → 0.2.18

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.
Files changed (77) hide show
  1. package/dist/src/types/Event.d.ts +21 -13
  2. package/dist/src/types/Event.d.ts.map +1 -1
  3. package/dist/src/types/Event.js.map +1 -1
  4. package/dist/test/index.js +1 -1
  5. package/dist/test/index.js.map +1 -1
  6. package/generated/namespaceData.d.ts +3 -1
  7. package/package.json +6 -2
  8. package/.gitattributes +0 -2
  9. package/.hintrc +0 -8
  10. package/.vscode/settings.json +0 -3
  11. package/docs/ADVANCED_FEATURES.md +0 -840
  12. package/docs/API_REFERENCE.md +0 -929
  13. package/docs/CHAT_INPUT.md +0 -811
  14. package/docs/COMPONENTS.md +0 -1039
  15. package/docs/EVENTS.md +0 -568
  16. package/docs/GETTING_STARTED.md +0 -398
  17. package/docs/LOCALIZATION.md +0 -777
  18. package/docs/README.md +0 -345
  19. package/docs/SVELTE_COMPONENTS.md +0 -1111
  20. package/docs/llm/ADVANCED_FEATURES.txt +0 -521
  21. package/docs/llm/API_REFERENCE.txt +0 -659
  22. package/docs/llm/CHAT_INPUT.txt +0 -514
  23. package/docs/llm/COMPONENTS.txt +0 -595
  24. package/docs/llm/EVENTS.txt +0 -449
  25. package/docs/llm/GETTING_STARTED.txt +0 -296
  26. package/docs/llm/LOCALIZATION.txt +0 -501
  27. package/docs/llm/README.txt +0 -193
  28. package/docs/llm/SVELTE_COMPONENTS.txt +0 -566
  29. package/src/DBI.ts +0 -1007
  30. package/src/Events.ts +0 -189
  31. package/src/data/eventMap.json +0 -248
  32. package/src/index.ts +0 -23
  33. package/src/methods/handleMessageCommands.ts +0 -482
  34. package/src/methods/hookEventListeners.ts +0 -119
  35. package/src/methods/hookInteractionListeners.ts +0 -314
  36. package/src/methods/publishInteractions.ts +0 -256
  37. package/src/types/ApplicationRoleConnectionMetadata.ts +0 -19
  38. package/src/types/Builders/ButtonBuilder.ts +0 -53
  39. package/src/types/Builders/ChannelSelectMenuBuilder.ts +0 -53
  40. package/src/types/Builders/MentionableSelectMenuBuilder.ts +0 -53
  41. package/src/types/Builders/ModalBuilder.ts +0 -53
  42. package/src/types/Builders/RoleSelectMenuBuilder.ts +0 -53
  43. package/src/types/Builders/StringSelectMenuBuilder.ts +0 -53
  44. package/src/types/Builders/UserSelectMenuBuilder.ts +0 -53
  45. package/src/types/ChatInput/ChatInput.ts +0 -28
  46. package/src/types/ChatInput/ChatInputOptions.ts +0 -388
  47. package/src/types/Components/Button.ts +0 -39
  48. package/src/types/Components/ChannelSelectMenu.ts +0 -43
  49. package/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.ts +0 -78
  50. package/src/types/Components/HTMLComponentsV2/index.ts +0 -800
  51. package/src/types/Components/HTMLComponentsV2/parser.ts +0 -649
  52. package/src/types/Components/HTMLComponentsV2/svelteParser.ts +0 -1503
  53. package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +0 -416
  54. package/src/types/Components/MentionableSelectMenu.ts +0 -43
  55. package/src/types/Components/Modal.ts +0 -46
  56. package/src/types/Components/RoleSelectMenu.ts +0 -43
  57. package/src/types/Components/StringSelectMenu.ts +0 -43
  58. package/src/types/Components/UserSelectMenu.ts +0 -43
  59. package/src/types/Event.ts +0 -145
  60. package/src/types/Interaction.ts +0 -100
  61. package/src/types/other/CustomEvent.ts +0 -19
  62. package/src/types/other/FakeMessageInteraction.ts +0 -408
  63. package/src/types/other/InteractionLocale.ts +0 -34
  64. package/src/types/other/Locale.ts +0 -70
  65. package/src/types/other/MessageContextMenu.ts +0 -27
  66. package/src/types/other/UserContextMenu.ts +0 -25
  67. package/src/utils/MemoryStore.ts +0 -28
  68. package/src/utils/UtilTypes.ts +0 -11
  69. package/src/utils/customId.ts +0 -49
  70. package/src/utils/permissions.ts +0 -5
  71. package/src/utils/recursiveImport.ts +0 -35
  72. package/src/utils/recursiveUnload.ts +0 -25
  73. package/src/utils/unloadModule.ts +0 -7
  74. package/test/index.ts +0 -176
  75. package/test/product-showcase.svelte +0 -558
  76. package/test/test.ts +0 -3
  77. package/tsconfig.json +0 -51
@@ -1,929 +0,0 @@
1
- # API Reference
2
-
3
- Complete API reference for DBI (Discord Bot Infrastructure).
4
-
5
- ---
6
-
7
- ## Table of Contents
8
-
9
- - [createDBI](#createdbi)
10
- - [DBI Class](#dbi-class)
11
- - [Register API](#register-api)
12
- - [Interaction Classes](#interaction-classes)
13
- - [Event Classes](#event-classes)
14
- - [Locale Classes](#locale-classes)
15
- - [Utility Functions](#utility-functions)
16
- - [Types](#types)
17
-
18
- ---
19
-
20
- ## createDBI
21
-
22
- Creates a new DBI instance.
23
-
24
- ```typescript
25
- function createDBI<TNamespace, TOtherType>(
26
- namespace: TNamespace,
27
- config: DBIConfigConstructor<TNamespace, TOtherType>
28
- ): DBI<TNamespace, TOtherType>
29
- ```
30
-
31
- ### Parameters
32
-
33
- | Parameter | Type | Description |
34
- |-----------|------|-------------|
35
- | `namespace` | `string` | Unique identifier for this bot instance |
36
- | `config` | `DBIConfigConstructor` | Configuration object |
37
-
38
- ### Config Options
39
-
40
- ```typescript
41
- interface DBIConfigConstructor {
42
- // Discord client configuration
43
- discord: {
44
- token: string;
45
- options: Discord.ClientOptions;
46
- } | Array<{
47
- namespace: string;
48
- token: string;
49
- options: Discord.ClientOptions;
50
- }>;
51
-
52
- // Default settings
53
- defaults?: {
54
- locale?: {
55
- name?: string;
56
- invalidPath?: string | ((ctx: { path: string; locale: DBILocale }) => string);
57
- };
58
- directMessages?: boolean;
59
- defaultMemberPermissions?: Discord.PermissionsString[];
60
- messageCommands?: {
61
- deferReplyContent?: string | ((ctx) => string | Promise<string>);
62
- };
63
- };
64
-
65
- // Sharding mode
66
- sharding?: "hybrid" | "default" | "off";
67
-
68
- // Persistent store
69
- store?: DBIStore;
70
-
71
- // Reference auto-cleanup
72
- references?: {
73
- autoClear?: {
74
- check: number; // Check interval in ms
75
- ttl: number; // Time-to-live in ms
76
- };
77
- };
78
-
79
- // Inline listener auto-cleanup
80
- inlineListeners?: {
81
- autoClear?: {
82
- check: number;
83
- ttl: number;
84
- };
85
- };
86
-
87
- // Initial data
88
- data?: {
89
- other?: Record<string, any>;
90
- refs?: Map<string, { at: number; value: any; ttl?: number }>;
91
- };
92
-
93
- // Strict mode (throws on duplicates)
94
- strict?: boolean;
95
-
96
- // Message command configuration
97
- messageCommands?: {
98
- prefixes: string[] | ((ctx: { message: Discord.Message }) => string[] | Promise<string[]>);
99
- typeAliases?: {
100
- booleans?: Record<string, boolean>;
101
- };
102
- };
103
- }
104
- ```
105
-
106
- ### Example
107
-
108
- ```javascript
109
- const dbi = createDBI("my-bot", {
110
- strict: true,
111
- discord: {
112
- token: process.env.DISCORD_TOKEN,
113
- options: { intents: ["Guilds"] }
114
- },
115
- defaults: {
116
- locale: { name: "en" },
117
- directMessages: false
118
- }
119
- });
120
- ```
121
-
122
- ---
123
-
124
- ## DBI Class
125
-
126
- Main DBI instance class.
127
-
128
- ### Properties
129
-
130
- | Property | Type | Description |
131
- |----------|------|-------------|
132
- | `namespace` | `string` | Bot namespace |
133
- | `config` | `DBIConfig` | Configuration object |
134
- | `data` | `DBIData` | Data storage |
135
- | `events` | `Events` | Event system |
136
- | `cluster` | `ClusterClient \| undefined` | Hybrid sharding cluster |
137
- | `loaded` | `boolean` | Whether DBI is loaded |
138
-
139
- ### data Object
140
-
141
- ```typescript
142
- interface DBIData {
143
- interactions: Discord.Collection<string, TDBIInteractions>;
144
- events: Discord.Collection<string, DBIEvent>;
145
- locales: Discord.Collection<string, DBILocale>;
146
- interactionLocales: Discord.Collection<string, DBIInteractionLocale>;
147
- other: Record<string, any>;
148
- eventMap: Record<string, string[]>;
149
- customEventNames: Set<string>;
150
- unloaders: Set<() => void>;
151
- registers: Set<Function>;
152
- registerUnloaders: Set<Function>;
153
- refs: Map<string, { at: number; value: any; ttl?: number }>;
154
- clients: ClientsArray;
155
- }
156
- ```
157
-
158
- ### Methods
159
-
160
- #### register(callback)
161
-
162
- Register bot features.
163
-
164
- ```typescript
165
- async register(
166
- callback: (api: DBIRegisterAPI) => void | Promise<void>
167
- ): Promise<void>
168
- ```
169
-
170
- #### load(...flags)
171
-
172
- Load all registered features.
173
-
174
- ```typescript
175
- async load(...flags: string[]): Promise<boolean>
176
- ```
177
-
178
- #### unload()
179
-
180
- Unload all features and cleanup.
181
-
182
- ```typescript
183
- async unload(): Promise<boolean>
184
- ```
185
-
186
- #### login()
187
-
188
- Connect to Discord.
189
-
190
- ```typescript
191
- async login(): Promise<void>
192
- ```
193
-
194
- #### publish(type, guildId?, clear?)
195
-
196
- Publish commands to Discord.
197
-
198
- ```typescript
199
- async publish(type: "Global", clear?: boolean): Promise<void>
200
- async publish(type: "Guild", guildId: string, clear?: boolean): Promise<void>
201
- ```
202
-
203
- #### interaction(name)
204
-
205
- Get a registered interaction.
206
-
207
- ```typescript
208
- interaction<T>(name: T): TDBIInteractions
209
- ```
210
-
211
- #### event(name)
212
-
213
- Get a registered event.
214
-
215
- ```typescript
216
- event(name: string): DBIEvent
217
- ```
218
-
219
- #### locale(name)
220
-
221
- Get a registered locale.
222
-
223
- ```typescript
224
- locale(name: string): DBILocale
225
- ```
226
-
227
- #### client(namespace?)
228
-
229
- Get a client.
230
-
231
- ```typescript
232
- client(namespace?: string): TDBIClientData
233
- ```
234
-
235
- #### emit(name, args)
236
-
237
- Emit a custom event.
238
-
239
- ```typescript
240
- emit(name: string, args: object): void
241
- ```
242
-
243
- #### get(key, defaultValue?)
244
-
245
- Get from `data.other`.
246
-
247
- ```typescript
248
- get<K>(key: K, defaultValue?: any): any
249
- ```
250
-
251
- #### set(key, value)
252
-
253
- Set in `data.other`.
254
-
255
- ```typescript
256
- set<K>(key: K, value: any): void
257
- ```
258
-
259
- #### has(key)
260
-
261
- Check if key exists in `data.other`.
262
-
263
- ```typescript
264
- has(key: string): boolean
265
- ```
266
-
267
- #### delete(key)
268
-
269
- Delete from `data.other`.
270
-
271
- ```typescript
272
- delete(key: string): boolean
273
- ```
274
-
275
- ---
276
-
277
- ## Register API
278
-
279
- Functions available in the register callback.
280
-
281
- ### ChatInput
282
-
283
- Create a slash command.
284
-
285
- ```typescript
286
- ChatInput(config: {
287
- name: string;
288
- description: string;
289
- options?: any[];
290
- directMessages?: boolean;
291
- defaultMemberPermissions?: Discord.PermissionsString[];
292
- rateLimits?: DBIRateLimit[];
293
- flag?: string;
294
- publish?: string;
295
- other?: {
296
- messageCommand?: {
297
- aliases?: string[];
298
- ignore?: boolean;
299
- };
300
- };
301
- onExecute: (ctx: IDBIChatInputExecuteCtx) => void | Promise<void>;
302
- }): DBIChatInput
303
- ```
304
-
305
- ### ChatInputOptions
306
-
307
- Option builders for ChatInput.
308
-
309
- ```typescript
310
- class ChatInputOptions {
311
- string(config): ApplicationCommandOption
312
- stringChoices(config): ApplicationCommandOption
313
- stringAutocomplete(config): ApplicationCommandOption
314
- integer(config): ApplicationCommandOption
315
- integerChoices(config): ApplicationCommandOption
316
- integerAutocomplete(config): ApplicationCommandOption
317
- number(config): ApplicationCommandOption
318
- numberChoices(config): ApplicationCommandOption
319
- numberAutocomplete(config): ApplicationCommandOption
320
- boolean(config): ApplicationCommandOption
321
- user(config): ApplicationCommandOption
322
- channel(config): ApplicationCommandOption
323
- role(config): ApplicationCommandOption
324
- mentionable(config): ApplicationCommandOption
325
- attachment(config): ApplicationCommandOption
326
- }
327
- ```
328
-
329
- ### Button
330
-
331
- Create a button component.
332
-
333
- ```typescript
334
- Button(config: {
335
- name: string;
336
- options?: {
337
- style: Discord.ButtonStyle;
338
- label?: string;
339
- emoji?: string;
340
- disabled?: boolean;
341
- url?: string;
342
- };
343
- rateLimits?: DBIRateLimit[];
344
- flag?: string;
345
- ttl?: number;
346
- onExecute: (ctx: IDBIButtonExecuteCtx) => void | Promise<void>;
347
- }): DBIButton
348
- ```
349
-
350
- ### StringSelectMenu
351
-
352
- Create a string select menu.
353
-
354
- ```typescript
355
- StringSelectMenu(config: {
356
- name: string;
357
- options?: {
358
- placeholder?: string;
359
- minValues?: number;
360
- maxValues?: number;
361
- disabled?: boolean;
362
- options: Array<{
363
- label: string;
364
- value: string;
365
- description?: string;
366
- emoji?: string;
367
- default?: boolean;
368
- }>;
369
- };
370
- rateLimits?: DBIRateLimit[];
371
- flag?: string;
372
- ttl?: number;
373
- onExecute: (ctx: IDBISelectMenuExecuteCtx) => void | Promise<void>;
374
- }): DBIStringSelectMenu
375
- ```
376
-
377
- ### UserSelectMenu, RoleSelectMenu, ChannelSelectMenu, MentionableSelectMenu
378
-
379
- Similar to StringSelectMenu but for user/role/channel/mentionable selection.
380
-
381
- ### Modal
382
-
383
- Create a modal dialog.
384
-
385
- ```typescript
386
- Modal(config: {
387
- name: string;
388
- options?: {
389
- title: string;
390
- components: Discord.ActionRowData<Discord.ModalActionRowComponentData>[];
391
- };
392
- rateLimits?: DBIRateLimit[];
393
- flag?: string;
394
- ttl?: number;
395
- onExecute: (ctx: IDBIModalExecuteCtx) => void | Promise<void>;
396
- }): DBIModal
397
- ```
398
-
399
- ### MessageContextMenu
400
-
401
- Create a message context menu command.
402
-
403
- ```typescript
404
- MessageContextMenu(config: {
405
- name: string;
406
- directMessages?: boolean;
407
- defaultMemberPermissions?: Discord.PermissionsString[];
408
- rateLimits?: DBIRateLimit[];
409
- flag?: string;
410
- publish?: string;
411
- onExecute: (ctx: IDBIMessageContextMenuExecuteCtx) => void | Promise<void>;
412
- }): DBIMessageContextMenu
413
- ```
414
-
415
- ### UserContextMenu
416
-
417
- Create a user context menu command.
418
-
419
- ```typescript
420
- UserContextMenu(config: {
421
- name: string;
422
- directMessages?: boolean;
423
- defaultMemberPermissions?: Discord.PermissionsString[];
424
- rateLimits?: DBIRateLimit[];
425
- flag?: string;
426
- publish?: string;
427
- onExecute: (ctx: IDBIUserContextMenuExecuteCtx) => void | Promise<void>;
428
- }): DBIUserContextMenu
429
- ```
430
-
431
- ### Event
432
-
433
- Create an event handler.
434
-
435
- ```typescript
436
- Event(config: {
437
- name: keyof ClientEvents;
438
- id?: string;
439
- disabled?: boolean;
440
- triggerType?: "OneByOne" | "OneByOneGlobal" | "Random" | "First";
441
- ordered?: {
442
- await?: boolean;
443
- delayBefore?: number;
444
- delayAfter?: number;
445
- };
446
- flag?: string;
447
- ttl?: number;
448
- onExecute: (ctx) => void | Promise<void>;
449
- }): DBIEvent
450
- ```
451
-
452
- ### Locale
453
-
454
- Create a content locale.
455
-
456
- ```typescript
457
- Locale(config: {
458
- name: TDBILocaleString;
459
- data: Record<string, any>;
460
- flag?: string;
461
- }): DBILocale
462
- ```
463
-
464
- ### InteractionLocale
465
-
466
- Create an interaction locale (command translation).
467
-
468
- ```typescript
469
- InteractionLocale(config: {
470
- name: string; // Name of the interaction to translate
471
- data: Record<string, {
472
- name: string;
473
- description: string;
474
- options?: Record<string, {
475
- name: string;
476
- description: string;
477
- choices?: Record<string, string>;
478
- }>;
479
- }>;
480
- flag?: string;
481
- }): DBIInteractionLocale
482
- ```
483
-
484
- ### CustomEvent
485
-
486
- Define a custom event.
487
-
488
- ```typescript
489
- CustomEvent(config: {
490
- name: string;
491
- map: Record<string, string>;
492
- }): DBICustomEvent
493
- ```
494
-
495
- ### HTMLComponentsV2
496
-
497
- Create a Svelte/Eta template component.
498
-
499
- ```typescript
500
- HTMLComponentsV2(config: {
501
- name: string;
502
- mode?: "svelte" | "eta";
503
- template?: string;
504
- file?: string;
505
- handlers?: any[];
506
- rateLimits?: DBIRateLimit[];
507
- flag?: string;
508
- onExecute?: (ctx) => void;
509
- }): DBIHTMLComponentsV2
510
- ```
511
-
512
- ### Inline Creators
513
-
514
- Create one-time use components.
515
-
516
- ```typescript
517
- createInlineButton(config): DBIButton
518
- createInlineStringSelectMenu(config): DBIStringSelectMenu
519
- createInlineUserSelectMenu(config): DBIUserSelectMenu
520
- createInlineRoleSelectMenu(config): DBIRoleSelectMenu
521
- createInlineChannelSelectMenu(config): DBIChannelSelectMenu
522
- createInlineMentionableSelectMenu(config): DBIMentionableSelectMenu
523
- createInlineModal(config): DBIModal
524
- createInlineEvent(config): DBIEvent
525
- ```
526
-
527
- ### onUnload
528
-
529
- Register a cleanup callback.
530
-
531
- ```typescript
532
- onUnload(callback: () => void | Promise<void>): void
533
- ```
534
-
535
- ---
536
-
537
- ## Interaction Classes
538
-
539
- ### DBIBaseInteraction
540
-
541
- Base class for all interactions.
542
-
543
- ```typescript
544
- class DBIBaseInteraction {
545
- dbi: DBI;
546
- name: string;
547
- description: string;
548
- type: TDBIInteractionTypes;
549
- options?: any;
550
- other?: Record<string, any>;
551
- rateLimits?: DBIRateLimit[];
552
- flag?: string;
553
- publish?: string;
554
- ttl?: number;
555
- at?: number;
556
-
557
- toJSON(args?: IDBIToJSONArgs): any;
558
- onExecute(ctx: IDBIBaseExecuteCtx): void | Promise<void>;
559
- }
560
- ```
561
-
562
- ### toJSON Options
563
-
564
- ```typescript
565
- interface IDBIToJSONArgs {
566
- overrides?: Record<string, any>;
567
- reference?: {
568
- data?: any[];
569
- ttl?: number;
570
- };
571
- }
572
- ```
573
-
574
- ### Execution Context
575
-
576
- ```typescript
577
- interface IDBIBaseExecuteCtx {
578
- interaction: Discord.Interaction;
579
- locale: {
580
- user: DBILocale;
581
- guild?: DBILocale;
582
- };
583
- dbi: DBI;
584
- dbiInteraction: TDBIInteractions;
585
- setRateLimit: (type: TDBIRateLimitTypes, duration: number) => Promise<void>;
586
- other: Record<string, any>;
587
- clientNamespace: string;
588
- v2: boolean;
589
- }
590
- ```
591
-
592
- ### Builder Methods
593
-
594
- Each component class has a `createBuilder()` method:
595
-
596
- ```typescript
597
- // Button
598
- const builder = dbi.interaction("my-btn").createBuilder();
599
- builder.setLabel("Label")
600
- .setEmoji("🎉")
601
- .setStyle(Discord.ButtonStyle.Primary)
602
- .setReference(["data"])
603
- .setTTL(60000)
604
- .toJSON();
605
-
606
- // Select Menu
607
- const builder = dbi.interaction("my-select").createBuilder();
608
- builder.setPlaceholder("Select...")
609
- .setMinValues(1)
610
- .setMaxValues(3)
611
- .setOptions([...])
612
- .toJSON();
613
- ```
614
-
615
- ---
616
-
617
- ## Event Classes
618
-
619
- ### DBIEvent
620
-
621
- Event handler class.
622
-
623
- ```typescript
624
- class DBIEvent {
625
- type: "Event";
626
- id?: string;
627
- name: string;
628
- other?: Record<string, any>;
629
- triggerType?: "OneByOne" | "OneByOneGlobal" | "Random" | "First";
630
- ordered?: TDBIEventOrder;
631
- dbi: DBI;
632
- disabled: boolean;
633
- flag?: string;
634
- ttl?: number;
635
- at?: number;
636
-
637
- toggle(disabled?: boolean): this;
638
- onExecute(ctx): void | Promise<void>;
639
- }
640
- ```
641
-
642
- ### Events Class
643
-
644
- DBI event system.
645
-
646
- ```typescript
647
- class Events {
648
- on(
649
- eventName: TDBIEventNames,
650
- handler: (data: any) => boolean | Promise<boolean>,
651
- options?: { once: boolean }
652
- ): () => void; // Returns unsubscribe function
653
-
654
- trigger(
655
- name: TDBIEventNames,
656
- data?: any,
657
- ignoreResponse?: boolean
658
- ): Promise<boolean>;
659
- }
660
- ```
661
-
662
- ### DBI Event Names
663
-
664
- ```typescript
665
- type TDBIEventNames =
666
- | "beforeInteraction"
667
- | "afterInteraction"
668
- | "interactionRateLimit"
669
- | "beforeEvent"
670
- | "afterEvent"
671
- | "interactionError"
672
- | "eventError"
673
- | "messageCommandArgumentError"
674
- | "messageCommandDirectMessageUsageError"
675
- | "messageCommandDefaultMemberPermissionsError"
676
- | "clientsReady";
677
- ```
678
-
679
- ---
680
-
681
- ## Locale Classes
682
-
683
- ### DBILocale
684
-
685
- Content locale class.
686
-
687
- ```typescript
688
- class DBILocale {
689
- name: TDBILocaleString;
690
- data: InfinitePathProxy; // Auto-callable nested object
691
- _data: Record<string, any>; // Raw data
692
- dbi: DBI;
693
- flag?: string;
694
-
695
- mergeLocale(locale: DBILocale): DBILocale;
696
- get(path: string): string | null;
697
- format(path: string, ...args: any[]): string;
698
- }
699
- ```
700
-
701
- ### Usage
702
-
703
- ```typescript
704
- // Function-style access with variables
705
- locale.data.greeting(); // "Hello!"
706
- locale.data.welcome("John"); // "Welcome, John!"
707
- locale.data.nested.path("a", "b"); // "a and b"
708
-
709
- // Direct access
710
- locale.get("greeting"); // "Hello!"
711
- locale.format("welcome", "John"); // "Welcome, John!"
712
- ```
713
-
714
- ---
715
-
716
- ## Utility Functions
717
-
718
- ### Utils
719
-
720
- ```typescript
721
- const { Utils } = require("@mostfeatured/dbi");
722
-
723
- // Recursively import all files
724
- await Utils.recursiveImport(path: string): Promise<void>
725
-
726
- // Parse a custom ID
727
- Utils.parseCustomId(dbi, customId: string): {
728
- name: string;
729
- data: any[];
730
- v2: boolean;
731
- }
732
-
733
- // Build a custom ID
734
- Utils.buildCustomId(
735
- dbi,
736
- name: string,
737
- data: any[],
738
- ttl?: number,
739
- v2?: boolean
740
- ): string
741
-
742
- // Unload a module from require cache
743
- Utils.unloadModule(path: string): void
744
-
745
- // Recursively unload modules
746
- Utils.recursiveUnload(path: string): void
747
- ```
748
-
749
- ### MemoryStore
750
-
751
- ```typescript
752
- class MemoryStore {
753
- async get(key: string, defaultValue?: any): Promise<any>
754
- async set(key: string, value: any): Promise<void>
755
- async delete(key: string): Promise<void>
756
- async has(key: string): Promise<boolean>
757
- }
758
- ```
759
-
760
- ---
761
-
762
- ## Types
763
-
764
- ### Rate Limit Types
765
-
766
- ```typescript
767
- type TDBIRateLimitTypes =
768
- | "User"
769
- | "Channel"
770
- | "Guild"
771
- | "Member"
772
- | "Message";
773
-
774
- interface DBIRateLimit {
775
- type: TDBIRateLimitTypes;
776
- duration: number; // milliseconds
777
- }
778
- ```
779
-
780
- ### Interaction Types
781
-
782
- ```typescript
783
- type TDBIInteractionTypes =
784
- | "ChatInput"
785
- | "UserContextMenu"
786
- | "MessageContextMenu"
787
- | "Modal"
788
- | "Autocomplete"
789
- | "StringSelectMenu"
790
- | "UserSelectMenu"
791
- | "ChannelSelectMenu"
792
- | "MentionableSelectMenu"
793
- | "RoleSelectMenu"
794
- | "Button"
795
- | "HTMLComponentsV2";
796
- ```
797
-
798
- ### Locale Strings
799
-
800
- ```typescript
801
- type TDBILocaleString =
802
- | "en" | "bg" | "zh" | "hr" | "cs" | "da" | "nl"
803
- | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it"
804
- | "ja" | "ko" | "no" | "pl" | "pt" | "ro" | "ru"
805
- | "es" | "sv" | "th" | "tr" | "uk" | "vi";
806
- ```
807
-
808
- ### Store Interface
809
-
810
- ```typescript
811
- interface DBIStore {
812
- get(key: string, defaultValue?: any): Promise<any>;
813
- set(key: string, value: any): Promise<void>;
814
- delete(key: string): Promise<void>;
815
- has(key: string): Promise<boolean>;
816
- }
817
- ```
818
-
819
- ### Client Data
820
-
821
- ```typescript
822
- interface TDBIClientData {
823
- namespace: string;
824
- token: string;
825
- options: Discord.ClientOptions;
826
- client: Discord.Client<true>;
827
- }
828
-
829
- interface ClientsArray extends Array<TDBIClientData> {
830
- next(key?: string): TDBIClientData;
831
- random(): TDBIClientData;
832
- random(size: number): TDBIClientData[];
833
- first(): TDBIClientData;
834
- get(namespace: string): TDBIClientData;
835
- indexes: Record<string, number>;
836
- }
837
- ```
838
-
839
- ### Referenced Data
840
-
841
- ```typescript
842
- type TDBIReferencedData =
843
- | string
844
- | number
845
- | {
846
- [key: string]: any;
847
- $ref: string;
848
- $unRef(): boolean;
849
- };
850
- ```
851
-
852
- ---
853
-
854
- ## HTMLComponentsV2 (Svelte)
855
-
856
- ### Component Methods
857
-
858
- ```typescript
859
- class DBIHTMLComponentsV2 {
860
- // Send component to interaction or channel
861
- async send(
862
- target: Discord.Interaction | Discord.TextChannel,
863
- options?: {
864
- data?: Record<string, any>;
865
- flags?: string[];
866
- content?: string;
867
- ephemeral?: boolean;
868
- reply?: boolean;
869
- followUp?: boolean;
870
- }
871
- ): Promise<void>
872
-
873
- // Destroy a specific instance
874
- destroy(refId: string): void
875
-
876
- // Destroy all active instances
877
- destroyAll(): void
878
-
879
- // Get JSON representation
880
- toJSON(args?: { data?: Record<string, any> }): object
881
- }
882
- ```
883
-
884
- ### Svelte Globals
885
-
886
- Available in Svelte component scripts:
887
-
888
- ```typescript
889
- // Props (Svelte 5 rune)
890
- let { prop1, prop2 } = $props();
891
-
892
- // Reactive data proxy
893
- const data: Record<string, any>;
894
-
895
- // Render control
896
- function render(): void;
897
- function update(): Promise<void>;
898
- function rerender(): Promise<void>;
899
- function noRender(): void;
900
- function setThrottle(ms: number): void;
901
-
902
- // Lifecycle
903
- function onMount(callback: () => void | (() => void)): void;
904
- function onDestroy(callback: () => void): void;
905
- function destroy(): void;
906
-
907
- // Handler context
908
- interface HandlerContext {
909
- interaction: Discord.ButtonInteraction | Discord.SelectMenuInteraction;
910
- dbi: DBI;
911
- locale: { user: DBILocale; guild?: DBILocale };
912
- }
913
- ```
914
-
915
- ---
916
-
917
- ## See Also
918
-
919
- - [Getting Started](./GETTING_STARTED.md)
920
- - [Chat Input Commands](./CHAT_INPUT.md)
921
- - [Components](./COMPONENTS.md)
922
- - [Events](./EVENTS.md)
923
- - [Localization](./LOCALIZATION.md)
924
- - [Svelte Components](./SVELTE_COMPONENTS.md)
925
- - [Advanced Features](./ADVANCED_FEATURES.md)
926
-
927
- ---
928
-
929
- > 📄 **LLM-optimized version:** [llm/API_REFERENCE.txt](./llm/API_REFERENCE.txt)