@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.
- package/dist/src/types/Components/HTMLComponentsV2/index.d.ts +33 -1
- package/dist/src/types/Components/HTMLComponentsV2/index.d.ts.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/index.js +408 -82
- package/dist/src/types/Components/HTMLComponentsV2/index.js.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/parser.d.ts +52 -0
- package/dist/src/types/Components/HTMLComponentsV2/parser.d.ts.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/parser.js +275 -0
- package/dist/src/types/Components/HTMLComponentsV2/parser.js.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts +26 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js +509 -34
- package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts +10 -0
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts.map +1 -1
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js +76 -11
- package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js.map +1 -1
- package/dist/test/index.js +76 -3
- package/dist/test/index.js.map +1 -1
- package/docs/ADVANCED_FEATURES.md +4 -0
- package/docs/API_REFERENCE.md +4 -0
- package/docs/CHAT_INPUT.md +4 -0
- package/docs/COMPONENTS.md +4 -0
- package/docs/EVENTS.md +4 -0
- package/docs/GETTING_STARTED.md +4 -0
- package/docs/LOCALIZATION.md +4 -0
- package/docs/README.md +4 -0
- package/docs/SVELTE_COMPONENTS.md +162 -6
- package/docs/llm/ADVANCED_FEATURES.txt +521 -0
- package/docs/llm/API_REFERENCE.txt +659 -0
- package/docs/llm/CHAT_INPUT.txt +514 -0
- package/docs/llm/COMPONENTS.txt +595 -0
- package/docs/llm/EVENTS.txt +449 -0
- package/docs/llm/GETTING_STARTED.txt +296 -0
- package/docs/llm/LOCALIZATION.txt +501 -0
- package/docs/llm/README.txt +193 -0
- package/docs/llm/SVELTE_COMPONENTS.txt +566 -0
- package/generated/svelte-dbi.d.ts +122 -0
- package/package.json +1 -1
- package/src/types/Components/HTMLComponentsV2/index.ts +466 -94
- package/src/types/Components/HTMLComponentsV2/parser.ts +317 -0
- package/src/types/Components/HTMLComponentsV2/svelteParser.ts +567 -35
- package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +91 -13
- package/test/index.ts +76 -3
- package/test/product-showcase.svelte +380 -24
- package/llm.txt +0 -1088
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
================================================================================
|
|
2
|
+
DBI - COMPONENTS GUIDE - LLM REFERENCE DOCUMENT
|
|
3
|
+
================================================================================
|
|
4
|
+
|
|
5
|
+
DOCUMENT TYPE: Interactive Components Reference
|
|
6
|
+
PACKAGE: @mostfeatured/dbi
|
|
7
|
+
|
|
8
|
+
================================================================================
|
|
9
|
+
SECTION 1: COMPONENT TYPES OVERVIEW
|
|
10
|
+
================================================================================
|
|
11
|
+
|
|
12
|
+
COMPONENT TYPE | DESCRIPTION
|
|
13
|
+
------------------------|--------------------------------------------------
|
|
14
|
+
Button | Clickable button with various styles
|
|
15
|
+
StringSelectMenu | Dropdown with custom string options
|
|
16
|
+
UserSelectMenu | Dropdown to select users
|
|
17
|
+
RoleSelectMenu | Dropdown to select roles
|
|
18
|
+
ChannelSelectMenu | Dropdown to select channels
|
|
19
|
+
MentionableSelectMenu | Dropdown to select users or roles
|
|
20
|
+
Modal | Popup form for user input
|
|
21
|
+
|
|
22
|
+
================================================================================
|
|
23
|
+
SECTION 2: BUTTONS
|
|
24
|
+
================================================================================
|
|
25
|
+
|
|
26
|
+
BASIC BUTTON STRUCTURE:
|
|
27
|
+
-----------------------
|
|
28
|
+
dbi.register(({ ChatInput, Button }) => {
|
|
29
|
+
Button({
|
|
30
|
+
name: "greet-button",
|
|
31
|
+
options: {
|
|
32
|
+
style: Discord.ButtonStyle.Primary,
|
|
33
|
+
label: "Click Me!",
|
|
34
|
+
emoji: "👋"
|
|
35
|
+
},
|
|
36
|
+
onExecute({ interaction }) {
|
|
37
|
+
interaction.reply({
|
|
38
|
+
content: "Hello! You clicked the button!",
|
|
39
|
+
ephemeral: true
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
ChatInput({
|
|
45
|
+
name: "greet",
|
|
46
|
+
description: "Get a greeting button",
|
|
47
|
+
onExecute({ interaction, dbi }) {
|
|
48
|
+
const button = dbi.interaction("greet-button").toJSON();
|
|
49
|
+
interaction.reply({
|
|
50
|
+
content: "Click the button below!",
|
|
51
|
+
components: [
|
|
52
|
+
{
|
|
53
|
+
type: Discord.ComponentType.ActionRow,
|
|
54
|
+
components: [button]
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
BUTTON STYLES:
|
|
63
|
+
--------------
|
|
64
|
+
STYLE | CONSTANT | COLOR/USE
|
|
65
|
+
----------|-----------------------------|--------------------------
|
|
66
|
+
Primary | ButtonStyle.Primary | Blue - Main action
|
|
67
|
+
Secondary | ButtonStyle.Secondary | Gray - Alternative action
|
|
68
|
+
Success | ButtonStyle.Success | Green - Positive action
|
|
69
|
+
Danger | ButtonStyle.Danger | Red - Destructive action
|
|
70
|
+
Link | ButtonStyle.Link | Gray - External URL
|
|
71
|
+
Premium | ButtonStyle.Premium | SKU-based button
|
|
72
|
+
|
|
73
|
+
BUTTON WITH OVERRIDES:
|
|
74
|
+
----------------------
|
|
75
|
+
const button = dbi.interaction("action-button");
|
|
76
|
+
|
|
77
|
+
interaction.reply({
|
|
78
|
+
content: "Choose an action:",
|
|
79
|
+
components: [
|
|
80
|
+
{
|
|
81
|
+
type: Discord.ComponentType.ActionRow,
|
|
82
|
+
components: [
|
|
83
|
+
button.toJSON({
|
|
84
|
+
overrides: {
|
|
85
|
+
label: "Accept",
|
|
86
|
+
style: Discord.ButtonStyle.Success,
|
|
87
|
+
emoji: "✅"
|
|
88
|
+
},
|
|
89
|
+
reference: { data: ["accept"] }
|
|
90
|
+
}),
|
|
91
|
+
button.toJSON({
|
|
92
|
+
overrides: {
|
|
93
|
+
label: "Decline",
|
|
94
|
+
style: Discord.ButtonStyle.Danger,
|
|
95
|
+
emoji: "❌"
|
|
96
|
+
},
|
|
97
|
+
reference: { data: ["decline"] }
|
|
98
|
+
})
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
LINK BUTTON (no handler needed):
|
|
105
|
+
--------------------------------
|
|
106
|
+
{
|
|
107
|
+
type: Discord.ComponentType.Button,
|
|
108
|
+
style: Discord.ButtonStyle.Link,
|
|
109
|
+
label: "Website",
|
|
110
|
+
url: "https://example.com",
|
|
111
|
+
emoji: "🌐"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
DISABLED BUTTON:
|
|
115
|
+
----------------
|
|
116
|
+
button.toJSON({
|
|
117
|
+
overrides: { disabled: true, label: "Clicked!" }
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
================================================================================
|
|
121
|
+
SECTION 3: SELECT MENUS
|
|
122
|
+
================================================================================
|
|
123
|
+
|
|
124
|
+
STRING SELECT MENU:
|
|
125
|
+
-------------------
|
|
126
|
+
StringSelectMenu({
|
|
127
|
+
name: "color-select",
|
|
128
|
+
options: {
|
|
129
|
+
placeholder: "Choose a color...",
|
|
130
|
+
minValues: 1,
|
|
131
|
+
maxValues: 1,
|
|
132
|
+
options: [
|
|
133
|
+
{ label: "Red", value: "red", emoji: "🔴", description: "A warm color" },
|
|
134
|
+
{ label: "Green", value: "green", emoji: "🟢", description: "Nature's color" },
|
|
135
|
+
{ label: "Blue", value: "blue", emoji: "🔵", description: "The sky's color" }
|
|
136
|
+
]
|
|
137
|
+
},
|
|
138
|
+
onExecute({ interaction }) {
|
|
139
|
+
const selected = interaction.values[0];
|
|
140
|
+
interaction.reply(`You selected: ${selected}`);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
MULTI-SELECT:
|
|
145
|
+
-------------
|
|
146
|
+
StringSelectMenu({
|
|
147
|
+
name: "toppings-select",
|
|
148
|
+
options: {
|
|
149
|
+
placeholder: "Select toppings...",
|
|
150
|
+
minValues: 1,
|
|
151
|
+
maxValues: 5,
|
|
152
|
+
options: [
|
|
153
|
+
{ label: "Cheese", value: "cheese", emoji: "🧀" },
|
|
154
|
+
{ label: "Pepperoni", value: "pepperoni", emoji: "🍕" },
|
|
155
|
+
{ label: "Mushrooms", value: "mushrooms", emoji: "🍄" }
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
onExecute({ interaction }) {
|
|
159
|
+
const selected = interaction.values;
|
|
160
|
+
interaction.reply(`Toppings: ${selected.join(", ")}`);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
USER SELECT MENU:
|
|
165
|
+
-----------------
|
|
166
|
+
UserSelectMenu({
|
|
167
|
+
name: "user-select",
|
|
168
|
+
options: {
|
|
169
|
+
placeholder: "Select a user...",
|
|
170
|
+
minValues: 1,
|
|
171
|
+
maxValues: 1
|
|
172
|
+
},
|
|
173
|
+
onExecute({ interaction }) {
|
|
174
|
+
const user = interaction.users.first();
|
|
175
|
+
interaction.reply(`You selected: ${user.tag}`);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
ROLE SELECT MENU:
|
|
180
|
+
-----------------
|
|
181
|
+
RoleSelectMenu({
|
|
182
|
+
name: "role-select",
|
|
183
|
+
options: {
|
|
184
|
+
placeholder: "Select roles...",
|
|
185
|
+
minValues: 1,
|
|
186
|
+
maxValues: 10
|
|
187
|
+
},
|
|
188
|
+
onExecute({ interaction }) {
|
|
189
|
+
const roles = interaction.roles;
|
|
190
|
+
const roleNames = roles.map(r => r.name).join(", ");
|
|
191
|
+
interaction.reply(`Selected roles: ${roleNames}`);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
CHANNEL SELECT MENU:
|
|
196
|
+
--------------------
|
|
197
|
+
ChannelSelectMenu({
|
|
198
|
+
name: "channel-select",
|
|
199
|
+
options: {
|
|
200
|
+
placeholder: "Select a channel...",
|
|
201
|
+
channelTypes: [
|
|
202
|
+
Discord.ChannelType.GuildText,
|
|
203
|
+
Discord.ChannelType.GuildVoice
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
onExecute({ interaction }) {
|
|
207
|
+
const channel = interaction.channels.first();
|
|
208
|
+
interaction.reply(`Selected: ${channel.name}`);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
MENTIONABLE SELECT MENU:
|
|
213
|
+
------------------------
|
|
214
|
+
MentionableSelectMenu({
|
|
215
|
+
name: "mentionable-select",
|
|
216
|
+
options: {
|
|
217
|
+
placeholder: "Select users or roles...",
|
|
218
|
+
minValues: 1,
|
|
219
|
+
maxValues: 5
|
|
220
|
+
},
|
|
221
|
+
onExecute({ interaction }) {
|
|
222
|
+
const users = interaction.users;
|
|
223
|
+
const roles = interaction.roles;
|
|
224
|
+
|
|
225
|
+
let response = "";
|
|
226
|
+
if (users.size) response += `Users: ${users.map(u => u.tag).join(", ")}\n`;
|
|
227
|
+
if (roles.size) response += `Roles: ${roles.map(r => r.name).join(", ")}`;
|
|
228
|
+
|
|
229
|
+
interaction.reply(response || "Nothing selected");
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
DYNAMIC SELECT OPTIONS:
|
|
234
|
+
-----------------------
|
|
235
|
+
const select = dbi.interaction("dynamic-select").toJSON({
|
|
236
|
+
overrides: {
|
|
237
|
+
placeholder: "Select an item to buy...",
|
|
238
|
+
options: items.map(item => ({
|
|
239
|
+
label: item.name,
|
|
240
|
+
value: item.id,
|
|
241
|
+
description: `$${item.price}`,
|
|
242
|
+
emoji: item.emoji
|
|
243
|
+
}))
|
|
244
|
+
},
|
|
245
|
+
reference: { data: ["shop"] }
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
================================================================================
|
|
249
|
+
SECTION 4: MODALS
|
|
250
|
+
================================================================================
|
|
251
|
+
|
|
252
|
+
BASIC MODAL:
|
|
253
|
+
------------
|
|
254
|
+
Modal({
|
|
255
|
+
name: "feedback-modal",
|
|
256
|
+
options: {
|
|
257
|
+
title: "Send Feedback",
|
|
258
|
+
components: [
|
|
259
|
+
{
|
|
260
|
+
type: Discord.ComponentType.ActionRow,
|
|
261
|
+
components: [
|
|
262
|
+
{
|
|
263
|
+
type: Discord.ComponentType.TextInput,
|
|
264
|
+
customId: "subject",
|
|
265
|
+
label: "Subject",
|
|
266
|
+
style: Discord.TextInputStyle.Short,
|
|
267
|
+
placeholder: "Brief description",
|
|
268
|
+
required: true,
|
|
269
|
+
minLength: 5,
|
|
270
|
+
maxLength: 100
|
|
271
|
+
}
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
type: Discord.ComponentType.ActionRow,
|
|
276
|
+
components: [
|
|
277
|
+
{
|
|
278
|
+
type: Discord.ComponentType.TextInput,
|
|
279
|
+
customId: "message",
|
|
280
|
+
label: "Message",
|
|
281
|
+
style: Discord.TextInputStyle.Paragraph,
|
|
282
|
+
placeholder: "Your detailed feedback...",
|
|
283
|
+
required: true,
|
|
284
|
+
minLength: 20,
|
|
285
|
+
maxLength: 2000
|
|
286
|
+
}
|
|
287
|
+
]
|
|
288
|
+
}
|
|
289
|
+
]
|
|
290
|
+
},
|
|
291
|
+
async onExecute({ interaction }) {
|
|
292
|
+
const subject = interaction.fields.getTextInputValue("subject");
|
|
293
|
+
const message = interaction.fields.getTextInputValue("message");
|
|
294
|
+
|
|
295
|
+
await saveFeedback({ subject, message, userId: interaction.user.id });
|
|
296
|
+
|
|
297
|
+
await interaction.reply({
|
|
298
|
+
content: "Thank you for your feedback!",
|
|
299
|
+
ephemeral: true
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
SHOWING A MODAL:
|
|
305
|
+
----------------
|
|
306
|
+
Button({
|
|
307
|
+
name: "feedback-button",
|
|
308
|
+
options: {
|
|
309
|
+
style: Discord.ButtonStyle.Primary,
|
|
310
|
+
label: "Send Feedback",
|
|
311
|
+
emoji: "📝"
|
|
312
|
+
},
|
|
313
|
+
async onExecute({ interaction, dbi }) {
|
|
314
|
+
const modal = dbi.interaction("feedback-modal").toJSON();
|
|
315
|
+
await interaction.showModal(modal);
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
MODAL WITH PRE-FILLED DATA:
|
|
320
|
+
---------------------------
|
|
321
|
+
const modal = dbi.interaction("edit-modal").toJSON({
|
|
322
|
+
overrides: {
|
|
323
|
+
components: [
|
|
324
|
+
{
|
|
325
|
+
type: Discord.ComponentType.ActionRow,
|
|
326
|
+
components: [{
|
|
327
|
+
type: Discord.ComponentType.TextInput,
|
|
328
|
+
customId: "name",
|
|
329
|
+
label: "Name",
|
|
330
|
+
style: Discord.TextInputStyle.Short,
|
|
331
|
+
value: item.name // Pre-filled!
|
|
332
|
+
}]
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
},
|
|
336
|
+
reference: { data: [itemId] }
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
await interaction.showModal(modal);
|
|
340
|
+
|
|
341
|
+
TEXT INPUT STYLES:
|
|
342
|
+
------------------
|
|
343
|
+
STYLE | CONSTANT | USE
|
|
344
|
+
----------|-----------------------------|--------------------------
|
|
345
|
+
Short | TextInputStyle.Short | Single line input
|
|
346
|
+
Paragraph | TextInputStyle.Paragraph | Multi-line textarea
|
|
347
|
+
|
|
348
|
+
================================================================================
|
|
349
|
+
SECTION 5: REFERENCE SYSTEM
|
|
350
|
+
================================================================================
|
|
351
|
+
|
|
352
|
+
PRIMITIVE REFERENCES (encoded in custom ID):
|
|
353
|
+
--------------------------------------------
|
|
354
|
+
DATA TYPE | EXAMPLE
|
|
355
|
+
-----------|----------------------------------
|
|
356
|
+
String | "123456789"
|
|
357
|
+
Number | 42
|
|
358
|
+
Boolean | true
|
|
359
|
+
Timestamp | Date.now()
|
|
360
|
+
|
|
361
|
+
USAGE:
|
|
362
|
+
const button = dbi.interaction("action-btn").toJSON({
|
|
363
|
+
reference: {
|
|
364
|
+
data: [
|
|
365
|
+
"123456789", // string
|
|
366
|
+
42, // number
|
|
367
|
+
true, // boolean
|
|
368
|
+
Date.now() // number
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
RECEIVING DATA:
|
|
374
|
+
onExecute({ interaction, data }) {
|
|
375
|
+
const [userId, actionType, isActive, timestamp] = data;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
OBJECT REFERENCES (stored in memory):
|
|
379
|
+
-------------------------------------
|
|
380
|
+
const cart = {
|
|
381
|
+
items: ["item1", "item2", "item3"],
|
|
382
|
+
total: 99.99,
|
|
383
|
+
userId: "123456789"
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
const button = dbi.interaction("cart-btn").toJSON({
|
|
387
|
+
reference: {
|
|
388
|
+
data: [cart], // Object stored in memory
|
|
389
|
+
ttl: 300000 // Auto-expire in 5 minutes
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
RECEIVING OBJECT DATA:
|
|
394
|
+
onExecute({ interaction, data }) {
|
|
395
|
+
const [cart] = data;
|
|
396
|
+
console.log(cart.items);
|
|
397
|
+
console.log(cart.total);
|
|
398
|
+
|
|
399
|
+
// Clean up when done
|
|
400
|
+
cart.$unRef();
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
REFERENCE TTL:
|
|
404
|
+
--------------
|
|
405
|
+
// Component-level TTL
|
|
406
|
+
reference: {
|
|
407
|
+
data: [myData],
|
|
408
|
+
ttl: 60000 // Expires in 1 minute
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// Global auto-clear in DBI config
|
|
412
|
+
references: {
|
|
413
|
+
autoClear: {
|
|
414
|
+
ttl: 3600000, // Default TTL: 1 hour
|
|
415
|
+
check: 60000 // Check every minute
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
================================================================================
|
|
420
|
+
SECTION 6: INLINE COMPONENTS
|
|
421
|
+
================================================================================
|
|
422
|
+
|
|
423
|
+
INLINE BUTTON:
|
|
424
|
+
--------------
|
|
425
|
+
dbi.register(({ ChatInput, createInlineButton }) => {
|
|
426
|
+
ChatInput({
|
|
427
|
+
name: "confirm",
|
|
428
|
+
description: "Confirm an action",
|
|
429
|
+
async onExecute({ interaction }) {
|
|
430
|
+
const confirmBtn = createInlineButton({
|
|
431
|
+
options: {
|
|
432
|
+
style: Discord.ButtonStyle.Success,
|
|
433
|
+
label: "Confirm"
|
|
434
|
+
},
|
|
435
|
+
onExecute({ interaction }) {
|
|
436
|
+
interaction.reply("Action confirmed!");
|
|
437
|
+
}
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
const cancelBtn = createInlineButton({
|
|
441
|
+
options: {
|
|
442
|
+
style: Discord.ButtonStyle.Danger,
|
|
443
|
+
label: "Cancel"
|
|
444
|
+
},
|
|
445
|
+
onExecute({ interaction }) {
|
|
446
|
+
interaction.reply("Action cancelled.");
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
await interaction.reply({
|
|
451
|
+
content: "Are you sure?",
|
|
452
|
+
components: [
|
|
453
|
+
{
|
|
454
|
+
type: Discord.ComponentType.ActionRow,
|
|
455
|
+
components: [
|
|
456
|
+
confirmBtn.toJSON(),
|
|
457
|
+
cancelBtn.toJSON()
|
|
458
|
+
]
|
|
459
|
+
}
|
|
460
|
+
]
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
INLINE SELECT MENU:
|
|
467
|
+
-------------------
|
|
468
|
+
const select = createInlineStringSelectMenu({
|
|
469
|
+
options: {
|
|
470
|
+
placeholder: "Cast your vote...",
|
|
471
|
+
options: [
|
|
472
|
+
{ label: "Option A", value: "a" },
|
|
473
|
+
{ label: "Option B", value: "b" },
|
|
474
|
+
{ label: "Option C", value: "c" }
|
|
475
|
+
]
|
|
476
|
+
},
|
|
477
|
+
onExecute({ interaction }) {
|
|
478
|
+
const vote = interaction.values[0];
|
|
479
|
+
interaction.reply({ content: `You voted for ${vote}!`, ephemeral: true });
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
INLINE MODAL:
|
|
484
|
+
-------------
|
|
485
|
+
const modal = createInlineModal({
|
|
486
|
+
options: {
|
|
487
|
+
title: "Enter Information",
|
|
488
|
+
components: [
|
|
489
|
+
{
|
|
490
|
+
type: Discord.ComponentType.ActionRow,
|
|
491
|
+
components: [{
|
|
492
|
+
type: Discord.ComponentType.TextInput,
|
|
493
|
+
customId: "input",
|
|
494
|
+
label: "Your Input",
|
|
495
|
+
style: Discord.TextInputStyle.Short,
|
|
496
|
+
required: true
|
|
497
|
+
}]
|
|
498
|
+
}
|
|
499
|
+
]
|
|
500
|
+
},
|
|
501
|
+
onExecute({ interaction }) {
|
|
502
|
+
const input = interaction.fields.getTextInputValue("input");
|
|
503
|
+
interaction.reply(`You entered: ${input}`);
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
await interaction.showModal(modal.toJSON());
|
|
508
|
+
|
|
509
|
+
AVAILABLE INLINE CREATORS:
|
|
510
|
+
--------------------------
|
|
511
|
+
FUNCTION | CREATES
|
|
512
|
+
-----------------------------------|---------------------------
|
|
513
|
+
createInlineButton() | Inline button
|
|
514
|
+
createInlineStringSelectMenu() | Inline string select
|
|
515
|
+
createInlineUserSelectMenu() | Inline user select
|
|
516
|
+
createInlineRoleSelectMenu() | Inline role select
|
|
517
|
+
createInlineChannelSelectMenu() | Inline channel select
|
|
518
|
+
createInlineMentionableSelectMenu()| Inline mentionable select
|
|
519
|
+
createInlineModal() | Inline modal
|
|
520
|
+
createInlineEvent() | Inline event listener
|
|
521
|
+
|
|
522
|
+
================================================================================
|
|
523
|
+
SECTION 7: BUILDER PATTERN
|
|
524
|
+
================================================================================
|
|
525
|
+
|
|
526
|
+
BUTTON BUILDER:
|
|
527
|
+
---------------
|
|
528
|
+
const btn = dbi.interaction("builder-btn");
|
|
529
|
+
|
|
530
|
+
const built = btn.createBuilder()
|
|
531
|
+
.setLabel("Custom Label")
|
|
532
|
+
.setEmoji("🎉")
|
|
533
|
+
.setStyle(Discord.ButtonStyle.Success)
|
|
534
|
+
.setReference(["data1", "data2"])
|
|
535
|
+
.setTTL(60000)
|
|
536
|
+
.toJSON();
|
|
537
|
+
|
|
538
|
+
SELECT MENU BUILDER:
|
|
539
|
+
--------------------
|
|
540
|
+
const select = dbi.interaction("builder-select");
|
|
541
|
+
|
|
542
|
+
const built = select.createBuilder()
|
|
543
|
+
.setPlaceholder("Choose items...")
|
|
544
|
+
.setMinValues(1)
|
|
545
|
+
.setMaxValues(3)
|
|
546
|
+
.setOptions([
|
|
547
|
+
{ label: "A", value: "a" },
|
|
548
|
+
{ label: "B", value: "b" },
|
|
549
|
+
{ label: "C", value: "c" }
|
|
550
|
+
])
|
|
551
|
+
.toJSON();
|
|
552
|
+
|
|
553
|
+
================================================================================
|
|
554
|
+
SECTION 8: COMPONENT EXECUTION CONTEXT
|
|
555
|
+
================================================================================
|
|
556
|
+
|
|
557
|
+
CONTEXT PROPERTIES:
|
|
558
|
+
-------------------
|
|
559
|
+
PROPERTY | TYPE | DESCRIPTION
|
|
560
|
+
------------------|-----------------------------------|------------------------
|
|
561
|
+
interaction | ButtonInteraction/SelectMenuInteraction | Discord.js interaction
|
|
562
|
+
data | any[] | Referenced data array
|
|
563
|
+
dbi | DBI | DBI instance
|
|
564
|
+
dbiInteraction | DBIButton/DBISelectMenu | Registered interaction
|
|
565
|
+
locale | { user, guild? } | Locale helpers
|
|
566
|
+
setRateLimit | function | Rate limit setter
|
|
567
|
+
other | object | Custom shared data
|
|
568
|
+
clientNamespace | string | Multi-client namespace
|
|
569
|
+
v2 | boolean | Components V2 enabled
|
|
570
|
+
|
|
571
|
+
EXAMPLE:
|
|
572
|
+
--------
|
|
573
|
+
Button({
|
|
574
|
+
name: "context-demo",
|
|
575
|
+
options: { style: Discord.ButtonStyle.Primary, label: "Demo" },
|
|
576
|
+
onExecute(ctx) {
|
|
577
|
+
const {
|
|
578
|
+
interaction,
|
|
579
|
+
data,
|
|
580
|
+
dbi,
|
|
581
|
+
dbiInteraction,
|
|
582
|
+
locale,
|
|
583
|
+
setRateLimit,
|
|
584
|
+
other,
|
|
585
|
+
clientNamespace,
|
|
586
|
+
v2
|
|
587
|
+
} = ctx;
|
|
588
|
+
|
|
589
|
+
interaction.reply("Demo!");
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
================================================================================
|
|
594
|
+
END OF DOCUMENT
|
|
595
|
+
================================================================================
|