@mostfeatured/dbi 0.2.13 → 0.2.15

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 (45) hide show
  1. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts +33 -1
  2. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts.map +1 -1
  3. package/dist/src/types/Components/HTMLComponentsV2/index.js +408 -82
  4. package/dist/src/types/Components/HTMLComponentsV2/index.js.map +1 -1
  5. package/dist/src/types/Components/HTMLComponentsV2/parser.d.ts +52 -0
  6. package/dist/src/types/Components/HTMLComponentsV2/parser.d.ts.map +1 -1
  7. package/dist/src/types/Components/HTMLComponentsV2/parser.js +275 -0
  8. package/dist/src/types/Components/HTMLComponentsV2/parser.js.map +1 -1
  9. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts +26 -0
  10. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts.map +1 -1
  11. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js +509 -34
  12. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js.map +1 -1
  13. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts +10 -0
  14. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts.map +1 -1
  15. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js +76 -11
  16. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js.map +1 -1
  17. package/dist/test/index.js +76 -3
  18. package/dist/test/index.js.map +1 -1
  19. package/docs/ADVANCED_FEATURES.md +4 -0
  20. package/docs/API_REFERENCE.md +4 -0
  21. package/docs/CHAT_INPUT.md +4 -0
  22. package/docs/COMPONENTS.md +4 -0
  23. package/docs/EVENTS.md +4 -0
  24. package/docs/GETTING_STARTED.md +4 -0
  25. package/docs/LOCALIZATION.md +4 -0
  26. package/docs/README.md +4 -0
  27. package/docs/SVELTE_COMPONENTS.md +162 -6
  28. package/docs/llm/ADVANCED_FEATURES.txt +521 -0
  29. package/docs/llm/API_REFERENCE.txt +659 -0
  30. package/docs/llm/CHAT_INPUT.txt +514 -0
  31. package/docs/llm/COMPONENTS.txt +595 -0
  32. package/docs/llm/EVENTS.txt +449 -0
  33. package/docs/llm/GETTING_STARTED.txt +296 -0
  34. package/docs/llm/LOCALIZATION.txt +501 -0
  35. package/docs/llm/README.txt +193 -0
  36. package/docs/llm/SVELTE_COMPONENTS.txt +566 -0
  37. package/generated/svelte-dbi.d.ts +122 -0
  38. package/package.json +1 -1
  39. package/src/types/Components/HTMLComponentsV2/index.ts +466 -94
  40. package/src/types/Components/HTMLComponentsV2/parser.ts +317 -0
  41. package/src/types/Components/HTMLComponentsV2/svelteParser.ts +567 -35
  42. package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +91 -13
  43. package/test/index.ts +76 -3
  44. package/test/product-showcase.svelte +380 -24
  45. package/llm.txt +0 -1088
@@ -0,0 +1,514 @@
1
+ ================================================================================
2
+ DBI - CHAT INPUT COMMANDS - LLM REFERENCE DOCUMENT
3
+ ================================================================================
4
+
5
+ DOCUMENT TYPE: Slash Commands Reference
6
+ PACKAGE: @mostfeatured/dbi
7
+
8
+ ================================================================================
9
+ SECTION 1: BASIC COMMAND STRUCTURE
10
+ ================================================================================
11
+
12
+ SIMPLE COMMAND:
13
+ ---------------
14
+ dbi.register(({ ChatInput }) => {
15
+ ChatInput({
16
+ name: "hello",
17
+ description: "Say hello!",
18
+ onExecute({ interaction }) {
19
+ interaction.reply("Hello, World!");
20
+ }
21
+ });
22
+ });
23
+
24
+ ASYNC COMMAND:
25
+ --------------
26
+ dbi.register(({ ChatInput }) => {
27
+ ChatInput({
28
+ name: "fetch-data",
29
+ description: "Fetch some data",
30
+ async onExecute({ interaction }) {
31
+ await interaction.deferReply();
32
+ const data = await fetchSomeData();
33
+ await interaction.editReply(`Data: ${data}`);
34
+ }
35
+ });
36
+ });
37
+
38
+ ================================================================================
39
+ SECTION 2: COMMAND OPTIONS (ChatInputOptions)
40
+ ================================================================================
41
+
42
+ OPTION TYPE | METHOD | KEY OPTIONS
43
+ ---------------------|---------------------------|---------------------------
44
+ String | string() | minLength, maxLength
45
+ String with Choices | stringChoices() | choices[]
46
+ String Autocomplete | stringAutocomplete() | onComplete()
47
+ Integer | integer() | minValue, maxValue
48
+ Integer with Choices | integerChoices() | choices[]
49
+ Integer Autocomplete | integerAutocomplete() | onComplete()
50
+ Number (decimal) | number() | minValue, maxValue
51
+ Number with Choices | numberChoices() | choices[]
52
+ Number Autocomplete | numberAutocomplete() | onComplete()
53
+ Boolean | boolean() | -
54
+ User | user() | -
55
+ Channel | channel() | channelTypes[]
56
+ Role | role() | -
57
+ Mentionable | mentionable() | -
58
+ Attachment | attachment() | -
59
+
60
+ ================================================================================
61
+ SECTION 3: STRING OPTIONS
62
+ ================================================================================
63
+
64
+ BASIC STRING:
65
+ -------------
66
+ ChatInputOptions.string({
67
+ name: "message",
68
+ description: "The message to echo",
69
+ required: true,
70
+ minLength: 1,
71
+ maxLength: 2000
72
+ })
73
+
74
+ USAGE:
75
+ const message = interaction.options.getString("message");
76
+
77
+ STRING WITH CHOICES:
78
+ --------------------
79
+ ChatInputOptions.stringChoices({
80
+ name: "color",
81
+ description: "Choose your favorite color",
82
+ required: true,
83
+ choices: [
84
+ { name: "Red", value: "red" },
85
+ { name: "Green", value: "green" },
86
+ { name: "Blue", value: "blue" }
87
+ ]
88
+ })
89
+
90
+ USAGE:
91
+ const color = interaction.options.getString("color");
92
+
93
+ ================================================================================
94
+ SECTION 4: NUMBER OPTIONS
95
+ ================================================================================
96
+
97
+ INTEGER:
98
+ --------
99
+ ChatInputOptions.integer({
100
+ name: "sides",
101
+ description: "Number of sides",
102
+ required: true,
103
+ minValue: 2,
104
+ maxValue: 100
105
+ })
106
+
107
+ USAGE:
108
+ const sides = interaction.options.getInteger("sides");
109
+
110
+ NUMBER (DECIMAL):
111
+ -----------------
112
+ ChatInputOptions.number({
113
+ name: "multiplier",
114
+ description: "Multiplier (decimal)",
115
+ required: false,
116
+ minValue: 0.1,
117
+ maxValue: 10.0
118
+ })
119
+
120
+ USAGE:
121
+ const multiplier = interaction.options.getNumber("multiplier") ?? 1;
122
+
123
+ ================================================================================
124
+ SECTION 5: BOOLEAN OPTIONS
125
+ ================================================================================
126
+
127
+ ChatInputOptions.boolean({
128
+ name: "mention-everyone",
129
+ description: "Ping @everyone?",
130
+ required: false
131
+ })
132
+
133
+ USAGE:
134
+ const mention = interaction.options.getBoolean("mention-everyone");
135
+
136
+ ================================================================================
137
+ SECTION 6: USER/ROLE/CHANNEL OPTIONS
138
+ ================================================================================
139
+
140
+ USER:
141
+ -----
142
+ ChatInputOptions.user({
143
+ name: "user",
144
+ description: "Target user",
145
+ required: true
146
+ })
147
+
148
+ USAGE:
149
+ const user = interaction.options.getUser("user");
150
+
151
+ ROLE:
152
+ -----
153
+ ChatInputOptions.role({
154
+ name: "role",
155
+ description: "Target role",
156
+ required: false
157
+ })
158
+
159
+ USAGE:
160
+ const role = interaction.options.getRole("role");
161
+
162
+ CHANNEL:
163
+ --------
164
+ ChatInputOptions.channel({
165
+ name: "channel",
166
+ description: "Target channel",
167
+ required: false,
168
+ channelTypes: ["GuildText", "GuildVoice"]
169
+ })
170
+
171
+ USAGE:
172
+ const channel = interaction.options.getChannel("channel");
173
+
174
+ MENTIONABLE:
175
+ ------------
176
+ ChatInputOptions.mentionable({
177
+ name: "target",
178
+ description: "User or role to mention",
179
+ required: true
180
+ })
181
+
182
+ USAGE:
183
+ const mentionable = interaction.options.getMentionable("target");
184
+
185
+ ================================================================================
186
+ SECTION 7: ATTACHMENT OPTIONS
187
+ ================================================================================
188
+
189
+ ChatInputOptions.attachment({
190
+ name: "file",
191
+ description: "The file to upload",
192
+ required: true
193
+ })
194
+
195
+ USAGE:
196
+ const file = interaction.options.getAttachment("file");
197
+ // file.name, file.size, file.url
198
+
199
+ ================================================================================
200
+ SECTION 8: AUTOCOMPLETE
201
+ ================================================================================
202
+
203
+ STRING AUTOCOMPLETE:
204
+ --------------------
205
+ ChatInputOptions.stringAutocomplete({
206
+ name: "query",
207
+ description: "Search query",
208
+ required: true,
209
+
210
+ async onComplete({ value, interaction }) {
211
+ const items = await searchDatabase(value);
212
+ return items.slice(0, 25).map(item => ({
213
+ name: item.displayName,
214
+ value: item.id
215
+ }));
216
+ },
217
+
218
+ async validate({ value, step }) {
219
+ if (step === "Autocomplete") return true;
220
+ const item = await getItemById(value);
221
+ return item !== null;
222
+ }
223
+ })
224
+
225
+ NUMBER AUTOCOMPLETE:
226
+ --------------------
227
+ ChatInputOptions.integerAutocomplete({
228
+ name: "amount",
229
+ description: "Amount to select",
230
+ required: true,
231
+
232
+ onComplete({ value }) {
233
+ const suggestions = [1, 5, 10, 25, 50, 100];
234
+ const typed = parseInt(value) || 0;
235
+ return suggestions
236
+ .filter(n => n.toString().startsWith(typed.toString()))
237
+ .map(n => ({ name: `${n} items`, value: n }));
238
+ }
239
+ })
240
+
241
+ ================================================================================
242
+ SECTION 9: SUBCOMMANDS
243
+ ================================================================================
244
+
245
+ BASIC SUBCOMMANDS:
246
+ ------------------
247
+ const Discord = require("discord.js");
248
+
249
+ ChatInput({
250
+ name: "config",
251
+ description: "Bot configuration",
252
+ options: [
253
+ {
254
+ type: Discord.ApplicationCommandOptionType.Subcommand,
255
+ name: "view",
256
+ description: "View current configuration"
257
+ },
258
+ {
259
+ type: Discord.ApplicationCommandOptionType.Subcommand,
260
+ name: "set",
261
+ description: "Change a setting",
262
+ options: [
263
+ ChatInputOptions.string({
264
+ name: "key",
265
+ description: "Setting name",
266
+ required: true
267
+ }),
268
+ ChatInputOptions.string({
269
+ name: "value",
270
+ description: "New value",
271
+ required: true
272
+ })
273
+ ]
274
+ }
275
+ ],
276
+
277
+ onExecute({ interaction }) {
278
+ const subcommand = interaction.options.getSubcommand();
279
+
280
+ switch (subcommand) {
281
+ case "view":
282
+ interaction.reply("Current config: ...");
283
+ break;
284
+ case "set":
285
+ const key = interaction.options.getString("key");
286
+ const value = interaction.options.getString("value");
287
+ interaction.reply(`Set ${key} = ${value}`);
288
+ break;
289
+ }
290
+ }
291
+ });
292
+
293
+ SUBCOMMAND GROUPS:
294
+ ------------------
295
+ options: [
296
+ {
297
+ type: Discord.ApplicationCommandOptionType.SubcommandGroup,
298
+ name: "user",
299
+ description: "User management",
300
+ options: [
301
+ {
302
+ type: Discord.ApplicationCommandOptionType.Subcommand,
303
+ name: "ban",
304
+ description: "Ban a user",
305
+ options: [/* ... */]
306
+ },
307
+ {
308
+ type: Discord.ApplicationCommandOptionType.Subcommand,
309
+ name: "kick",
310
+ description: "Kick a user",
311
+ options: [/* ... */]
312
+ }
313
+ ]
314
+ }
315
+ ]
316
+
317
+ HANDLING SUBCOMMAND GROUPS:
318
+ const group = interaction.options.getSubcommandGroup();
319
+ const subcommand = interaction.options.getSubcommand();
320
+
321
+ switch (`${group}/${subcommand}`) {
322
+ case "user/ban": /* ... */ break;
323
+ case "user/kick": /* ... */ break;
324
+ }
325
+
326
+ ================================================================================
327
+ SECTION 10: PERMISSIONS
328
+ ================================================================================
329
+
330
+ DEFAULT MEMBER PERMISSIONS:
331
+ ---------------------------
332
+ ChatInput({
333
+ name: "ban",
334
+ description: "Ban a user",
335
+ defaultMemberPermissions: ["BanMembers"],
336
+ async onExecute({ interaction }) {
337
+ // Only users with BanMembers can reach here
338
+ }
339
+ });
340
+
341
+ ALLOW DIRECT MESSAGES:
342
+ ----------------------
343
+ ChatInput({
344
+ name: "help",
345
+ description: "Get help",
346
+ directMessages: true,
347
+ onExecute({ interaction }) {
348
+ interaction.reply("Help information...");
349
+ }
350
+ });
351
+
352
+ ================================================================================
353
+ SECTION 11: CONTEXT MENUS
354
+ ================================================================================
355
+
356
+ MESSAGE CONTEXT MENU:
357
+ ---------------------
358
+ dbi.register(({ MessageContextMenu }) => {
359
+ MessageContextMenu({
360
+ name: "Report Message",
361
+ async onExecute({ interaction }) {
362
+ const message = interaction.targetMessage;
363
+ await interaction.reply({
364
+ content: `Reported message by ${message.author.tag}`,
365
+ ephemeral: true
366
+ });
367
+ }
368
+ });
369
+ });
370
+
371
+ USER CONTEXT MENU:
372
+ ------------------
373
+ dbi.register(({ UserContextMenu }) => {
374
+ UserContextMenu({
375
+ name: "View Profile",
376
+ async onExecute({ interaction }) {
377
+ const user = interaction.targetUser;
378
+ await interaction.reply({
379
+ content: `Profile: ${user.tag}\nID: ${user.id}`,
380
+ ephemeral: true
381
+ });
382
+ }
383
+ });
384
+ });
385
+
386
+ ================================================================================
387
+ SECTION 12: EXECUTION CONTEXT
388
+ ================================================================================
389
+
390
+ CONTEXT OBJECT PROPERTIES:
391
+ --------------------------
392
+ PROPERTY | TYPE | DESCRIPTION
393
+ ------------------|----------------------------|----------------------------
394
+ interaction | ChatInputCommandInteraction| Discord.js interaction
395
+ dbi | DBI | DBI instance
396
+ dbiInteraction | DBIChatInput | Registered interaction object
397
+ locale.user | DBILocale | User's preferred locale
398
+ locale.guild | DBILocale | undefined | Guild's preferred locale
399
+ setRateLimit | function | Set rate limit
400
+ other | object | Shared custom data
401
+ clientNamespace | string | Multi-client namespace
402
+ v2 | boolean | Components V2 enabled
403
+
404
+ USAGE EXAMPLE:
405
+ --------------
406
+ async onExecute(ctx) {
407
+ const {
408
+ interaction,
409
+ dbi,
410
+ dbiInteraction,
411
+ locale,
412
+ setRateLimit,
413
+ other,
414
+ clientNamespace,
415
+ v2
416
+ } = ctx;
417
+
418
+ const greeting = locale.user.data.greeting();
419
+ await setRateLimit("User", 60000);
420
+ const button = dbi.interaction("my-button");
421
+ await interaction.reply(greeting);
422
+ }
423
+
424
+ ================================================================================
425
+ SECTION 13: RATE LIMITING
426
+ ================================================================================
427
+
428
+ DECLARATIVE RATE LIMITS:
429
+ ------------------------
430
+ ChatInput({
431
+ name: "daily",
432
+ description: "Daily reward",
433
+ rateLimits: [
434
+ {
435
+ type: "User",
436
+ duration: 86400000 // 24 hours
437
+ }
438
+ ],
439
+ async onExecute({ interaction }) {
440
+ interaction.reply("Here's your daily reward!");
441
+ }
442
+ });
443
+
444
+ RATE LIMIT TYPES:
445
+ -----------------
446
+ TYPE | DESCRIPTION
447
+ --------|----------------------------------
448
+ User | Per-user rate limit
449
+ Channel | Per-channel rate limit
450
+ Guild | Per-guild rate limit
451
+ Member | Per-member (user+guild) rate limit
452
+ Message | Per-message rate limit
453
+
454
+ DYNAMIC RATE LIMITING:
455
+ ----------------------
456
+ async onExecute({ interaction, setRateLimit }) {
457
+ const isPremium = await checkPremium(interaction.user.id);
458
+ await setRateLimit("User", isPremium ? 60000 : 300000);
459
+ interaction.reply("Action performed!");
460
+ }
461
+
462
+ ================================================================================
463
+ SECTION 14: MESSAGE COMMAND ALIASES
464
+ ================================================================================
465
+
466
+ ChatInput({
467
+ name: "help",
468
+ description: "Get help",
469
+ other: {
470
+ messageCommand: {
471
+ aliases: ["h", "?", "commands"],
472
+ ignore: false
473
+ }
474
+ },
475
+ onExecute({ interaction }) {
476
+ interaction.reply("Help information...");
477
+ }
478
+ });
479
+
480
+ ================================================================================
481
+ SECTION 15: PUBLISHING OPTIONS
482
+ ================================================================================
483
+
484
+ PUBLISH TO SPECIFIC CLIENT:
485
+ ---------------------------
486
+ ChatInput({
487
+ name: "admin-only",
488
+ description: "Admin bot command",
489
+ publish: "admin",
490
+ onExecute({ interaction }) {
491
+ // Only available on admin bot
492
+ }
493
+ });
494
+
495
+ CONDITIONAL REGISTRATION WITH FLAGS:
496
+ ------------------------------------
497
+ ChatInput({
498
+ name: "debug",
499
+ description: "Debug command",
500
+ flag: "debug",
501
+ onExecute({ interaction }) {
502
+ // Debug info...
503
+ }
504
+ });
505
+
506
+ // Load with flag:
507
+ await dbi.load("debug");
508
+
509
+ // Load without debug commands:
510
+ await dbi.load();
511
+
512
+ ================================================================================
513
+ END OF DOCUMENT
514
+ ================================================================================