@minesa-org/mini-interaction 0.0.4 → 0.0.6
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/builders/AutomodRuleBuilder.d.ts +45 -0
- package/dist/builders/AutomodRuleBuilder.js +151 -0
- package/dist/builders/EmbedBuilder.d.ts +33 -0
- package/dist/builders/EmbedBuilder.js +94 -0
- package/dist/builders/MiniContainerBuilder.d.ts +131 -0
- package/dist/builders/MiniContainerBuilder.js +347 -0
- package/dist/builders/TextInputBuilder.d.ts +57 -0
- package/dist/builders/TextInputBuilder.js +98 -0
- package/dist/builders/index.d.ts +8 -0
- package/dist/builders/index.js +4 -0
- package/dist/clients/MiniInteraction.d.ts +25 -0
- package/dist/clients/MiniInteraction.js +114 -4
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -0
- package/dist/types/Commands.d.ts +11 -0
- package/dist/types/PermissionFlags.d.ts +55 -0
- package/dist/types/PermissionFlags.js +5 -0
- package/dist/types/SeparatorSpacingSize.d.ts +2 -0
- package/dist/types/SeparatorSpacingSize.js +2 -0
- package/dist/utils/CommandInteractionOptions.d.ts +3 -1
- package/dist/utils/CommandInteractionOptions.js +6 -1
- package/dist/utils/MessageComponentInteraction.d.ts +13 -1
- package/dist/utils/MessageComponentInteraction.js +15 -0
- package/dist/utils/ModalSubmitInteraction.d.ts +28 -0
- package/dist/utils/ModalSubmitInteraction.js +74 -0
- package/dist/utils/interactionMessageHelpers.d.ts +5 -5
- package/dist/utils/interactionMessageHelpers.js +79 -9
- package/package.json +2 -1
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
import { ComponentType } from "discord-api-types/v10";
|
|
2
|
+
import { resolveJSONEncodable } from "./shared.js";
|
|
3
|
+
function cloneContainerComponent(component) {
|
|
4
|
+
const resolved = resolveJSONEncodable(component);
|
|
5
|
+
return { ...resolved };
|
|
6
|
+
}
|
|
7
|
+
function cloneAccessory(accessory) {
|
|
8
|
+
const resolved = resolveJSONEncodable(accessory);
|
|
9
|
+
return { ...resolved };
|
|
10
|
+
}
|
|
11
|
+
/** Builder for structured message container payloads. */
|
|
12
|
+
export class ContainerBuilder {
|
|
13
|
+
data;
|
|
14
|
+
constructor(data = {}) {
|
|
15
|
+
const components = data.components
|
|
16
|
+
? data.components.map((component) => cloneContainerComponent(component))
|
|
17
|
+
: [];
|
|
18
|
+
this.data = {
|
|
19
|
+
...data,
|
|
20
|
+
type: ComponentType.Container,
|
|
21
|
+
components,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Replaces the components contained in the container. */
|
|
25
|
+
setComponents(components) {
|
|
26
|
+
this.data.components = components.map((component) => cloneContainerComponent(component));
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/** Replaces the sections contained in the container. */
|
|
30
|
+
setSections(sections) {
|
|
31
|
+
return this.setComponents(sections);
|
|
32
|
+
}
|
|
33
|
+
/** Adds a component to the container. */
|
|
34
|
+
addComponent(component) {
|
|
35
|
+
this.data.components ??= [];
|
|
36
|
+
this.data.components.push(cloneContainerComponent(component));
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
/** Adds a section to the container. */
|
|
40
|
+
addSection(section) {
|
|
41
|
+
return this.addComponent(section);
|
|
42
|
+
}
|
|
43
|
+
/** Sets or clears the accent colour on the container. */
|
|
44
|
+
setAccentColor(color) {
|
|
45
|
+
if (color === undefined) {
|
|
46
|
+
delete this.data.accent_color;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.data.accent_color = color ?? null;
|
|
50
|
+
}
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/** Marks the container as a spoiler. */
|
|
54
|
+
setSpoiler(spoiler) {
|
|
55
|
+
if (spoiler === null || spoiler === undefined) {
|
|
56
|
+
delete this.data.spoiler;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.data.spoiler = spoiler;
|
|
60
|
+
}
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
/** Serialises the container into a structured message payload. */
|
|
64
|
+
toJSON() {
|
|
65
|
+
const components = this.data.components ?? [];
|
|
66
|
+
return {
|
|
67
|
+
...this.data,
|
|
68
|
+
type: ComponentType.Container,
|
|
69
|
+
components: components.map((component) => ({ ...component })),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/** Builder for structured message sections. */
|
|
74
|
+
export class SectionBuilder {
|
|
75
|
+
data;
|
|
76
|
+
constructor(data = {}) {
|
|
77
|
+
const components = data.components
|
|
78
|
+
? data.components.map((component) => cloneTextDisplayComponent(component))
|
|
79
|
+
: [];
|
|
80
|
+
const rawAccessory = data.accessory;
|
|
81
|
+
const accessory = rawAccessory === undefined || rawAccessory === null
|
|
82
|
+
? undefined
|
|
83
|
+
: cloneAccessory(rawAccessory);
|
|
84
|
+
this.data = {
|
|
85
|
+
...data,
|
|
86
|
+
type: ComponentType.Section,
|
|
87
|
+
components,
|
|
88
|
+
accessory,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Replaces the text components within the section. */
|
|
92
|
+
setComponents(components) {
|
|
93
|
+
this.data.components = components.map((component) => cloneTextDisplayComponent(component));
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
/** Adds a text component to the section. */
|
|
97
|
+
addComponent(component) {
|
|
98
|
+
this.data.components ??= [];
|
|
99
|
+
this.data.components.push(cloneTextDisplayComponent(component));
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
/** Sets or clears the accessory component. */
|
|
103
|
+
setAccessory(accessory) {
|
|
104
|
+
if (accessory === null || accessory === undefined) {
|
|
105
|
+
this.data.accessory = undefined;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
this.data.accessory = cloneAccessory(accessory);
|
|
109
|
+
}
|
|
110
|
+
return this;
|
|
111
|
+
}
|
|
112
|
+
/** Serialises the section into a structured message payload. */
|
|
113
|
+
toJSON() {
|
|
114
|
+
const components = this.data.components ?? [];
|
|
115
|
+
const accessory = this.data.accessory
|
|
116
|
+
? { ...this.data.accessory }
|
|
117
|
+
: undefined;
|
|
118
|
+
if (!accessory) {
|
|
119
|
+
throw new Error("[SectionBuilder] accessory is required for sections");
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
...this.data,
|
|
123
|
+
type: ComponentType.Section,
|
|
124
|
+
components: components.map((component) => ({ ...component })),
|
|
125
|
+
accessory,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function cloneTextDisplayComponent(component) {
|
|
130
|
+
const resolved = resolveJSONEncodable(component);
|
|
131
|
+
return { ...resolved };
|
|
132
|
+
}
|
|
133
|
+
/** Builder for structured message text display components. */
|
|
134
|
+
export class TextDisplayBuilder {
|
|
135
|
+
data;
|
|
136
|
+
constructor(data = {}) {
|
|
137
|
+
this.data = {
|
|
138
|
+
...data,
|
|
139
|
+
type: ComponentType.TextDisplay,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Sets or clears the primary text content. */
|
|
143
|
+
setContent(content) {
|
|
144
|
+
if (content === null || content === undefined) {
|
|
145
|
+
delete this.data.content;
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
this.data.content = content;
|
|
149
|
+
}
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
/** Serialises the component into a structured message payload. */
|
|
153
|
+
toJSON() {
|
|
154
|
+
if (!this.data.content) {
|
|
155
|
+
throw new Error("[TextDisplayBuilder] content is required for text displays");
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
...this.data,
|
|
159
|
+
type: ComponentType.TextDisplay,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** Builder for structured message separator components. */
|
|
164
|
+
export class SeparatorBuilder {
|
|
165
|
+
data;
|
|
166
|
+
constructor(data = {}) {
|
|
167
|
+
this.data = {
|
|
168
|
+
...data,
|
|
169
|
+
type: ComponentType.Separator,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
/** Sets whether the separator should render a divider. */
|
|
173
|
+
setDivider(divider) {
|
|
174
|
+
if (divider === null || divider === undefined) {
|
|
175
|
+
delete this.data.divider;
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
this.data.divider = divider;
|
|
179
|
+
}
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
/** Sets the separator spacing value. */
|
|
183
|
+
setSpacing(spacing) {
|
|
184
|
+
if (spacing === null || spacing === undefined) {
|
|
185
|
+
delete this.data.spacing;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
this.data.spacing = spacing;
|
|
189
|
+
}
|
|
190
|
+
return this;
|
|
191
|
+
}
|
|
192
|
+
/** Serialises the separator payload. */
|
|
193
|
+
toJSON() {
|
|
194
|
+
return {
|
|
195
|
+
...this.data,
|
|
196
|
+
type: ComponentType.Separator,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Builder for structured message thumbnails. */
|
|
201
|
+
export class ThumbnailBuilder {
|
|
202
|
+
data;
|
|
203
|
+
constructor(data = {}) {
|
|
204
|
+
this.data = {
|
|
205
|
+
...data,
|
|
206
|
+
type: ComponentType.Thumbnail,
|
|
207
|
+
media: data.media ? { ...data.media } : undefined,
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
/** Sets the media payload for the thumbnail. */
|
|
211
|
+
setMedia(media) {
|
|
212
|
+
if (media === null || media === undefined) {
|
|
213
|
+
delete this.data.media;
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
this.data.media = { ...media };
|
|
217
|
+
}
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/** Sets the thumbnail description. */
|
|
221
|
+
setDescription(description) {
|
|
222
|
+
if (description === null || description === undefined) {
|
|
223
|
+
delete this.data.description;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
this.data.description = description;
|
|
227
|
+
}
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
/** Marks the thumbnail as a spoiler. */
|
|
231
|
+
setSpoiler(spoiler) {
|
|
232
|
+
if (spoiler === null || spoiler === undefined) {
|
|
233
|
+
delete this.data.spoiler;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
this.data.spoiler = spoiler;
|
|
237
|
+
}
|
|
238
|
+
return this;
|
|
239
|
+
}
|
|
240
|
+
/** Serialises the thumbnail payload. */
|
|
241
|
+
toJSON() {
|
|
242
|
+
if (!this.data.media) {
|
|
243
|
+
throw new Error("[ThumbnailBuilder] media is required for thumbnails");
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
...this.data,
|
|
247
|
+
type: ComponentType.Thumbnail,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/** Builder for structured message gallery items. */
|
|
252
|
+
export class GalleryItemBuilder {
|
|
253
|
+
data;
|
|
254
|
+
constructor(data = {}) {
|
|
255
|
+
this.data = {
|
|
256
|
+
...data,
|
|
257
|
+
media: data.media ? { ...data.media } : undefined,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
/** Sets the media item payload. */
|
|
261
|
+
setMedia(media) {
|
|
262
|
+
if (media === null || media === undefined) {
|
|
263
|
+
delete this.data.media;
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
this.data.media = { ...media };
|
|
267
|
+
}
|
|
268
|
+
return this;
|
|
269
|
+
}
|
|
270
|
+
/** Sets the media description. */
|
|
271
|
+
setDescription(description) {
|
|
272
|
+
if (description === null || description === undefined) {
|
|
273
|
+
delete this.data.description;
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
this.data.description = description;
|
|
277
|
+
}
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
/** Marks the media item as a spoiler. */
|
|
281
|
+
setSpoiler(spoiler) {
|
|
282
|
+
if (spoiler === null || spoiler === undefined) {
|
|
283
|
+
delete this.data.spoiler;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
this.data.spoiler = spoiler;
|
|
287
|
+
}
|
|
288
|
+
return this;
|
|
289
|
+
}
|
|
290
|
+
/** Serialises the gallery item payload. */
|
|
291
|
+
toJSON() {
|
|
292
|
+
if (!this.data.media) {
|
|
293
|
+
throw new Error("[GalleryItemBuilder] media is required for gallery items");
|
|
294
|
+
}
|
|
295
|
+
return {
|
|
296
|
+
...this.data,
|
|
297
|
+
media: { ...this.data.media },
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/** Builder for structured message gallery components. */
|
|
302
|
+
export class GalleryBuilder {
|
|
303
|
+
data;
|
|
304
|
+
constructor(data = {}) {
|
|
305
|
+
const items = data.items
|
|
306
|
+
? data.items.map((item) => resolveGalleryItem(item))
|
|
307
|
+
: [];
|
|
308
|
+
this.data = {
|
|
309
|
+
...data,
|
|
310
|
+
type: ComponentType.MediaGallery,
|
|
311
|
+
items,
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/** Replaces the gallery items. */
|
|
315
|
+
setItems(items) {
|
|
316
|
+
this.data.items = items.map((item) => resolveGalleryItem(item));
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
/** Adds a gallery item to the payload. */
|
|
320
|
+
addItem(item) {
|
|
321
|
+
this.data.items ??= [];
|
|
322
|
+
this.data.items.push(resolveGalleryItem(item));
|
|
323
|
+
return this;
|
|
324
|
+
}
|
|
325
|
+
/** Serialises the gallery payload. */
|
|
326
|
+
toJSON() {
|
|
327
|
+
const items = this.data.items ?? [];
|
|
328
|
+
if (items.length === 0) {
|
|
329
|
+
throw new Error("[GalleryBuilder] at least one gallery item is required");
|
|
330
|
+
}
|
|
331
|
+
return {
|
|
332
|
+
...this.data,
|
|
333
|
+
type: ComponentType.MediaGallery,
|
|
334
|
+
items: items.map((item) => ({ ...item })),
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function resolveGalleryItem(item) {
|
|
339
|
+
const resolved = resolveJSONEncodable(item);
|
|
340
|
+
if (!resolved.media) {
|
|
341
|
+
throw new Error("[GalleryBuilder] gallery items require media");
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
...resolved,
|
|
345
|
+
media: { ...resolved.media },
|
|
346
|
+
};
|
|
347
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { TextInputStyle, type APITextInputComponent } from "discord-api-types/v10";
|
|
2
|
+
import type { JSONEncodable } from "./shared.js";
|
|
3
|
+
/** Shape describing initial text input data accepted by the builder. */
|
|
4
|
+
export type TextInputBuilderData = {
|
|
5
|
+
customId?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
style?: TextInputStyle;
|
|
8
|
+
minLength?: number;
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
value?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
};
|
|
14
|
+
/** Builder for Discord text input components used in modals. */
|
|
15
|
+
export declare class TextInputBuilder implements JSONEncodable<APITextInputComponent> {
|
|
16
|
+
private data;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new text input builder with optional seed data.
|
|
19
|
+
*/
|
|
20
|
+
constructor(data?: TextInputBuilderData);
|
|
21
|
+
/**
|
|
22
|
+
* Sets the custom identifier for this text input.
|
|
23
|
+
*/
|
|
24
|
+
setCustomId(customId: string): this;
|
|
25
|
+
/**
|
|
26
|
+
* Sets the label displayed above the text input.
|
|
27
|
+
*/
|
|
28
|
+
setLabel(label: string): this;
|
|
29
|
+
/**
|
|
30
|
+
* Sets the style of the text input (Short or Paragraph).
|
|
31
|
+
*/
|
|
32
|
+
setStyle(style: TextInputStyle): this;
|
|
33
|
+
/**
|
|
34
|
+
* Sets the minimum length of the input text.
|
|
35
|
+
*/
|
|
36
|
+
setMinLength(minLength: number): this;
|
|
37
|
+
/**
|
|
38
|
+
* Sets the maximum length of the input text.
|
|
39
|
+
*/
|
|
40
|
+
setMaxLength(maxLength: number): this;
|
|
41
|
+
/**
|
|
42
|
+
* Sets whether this text input is required.
|
|
43
|
+
*/
|
|
44
|
+
setRequired(required: boolean): this;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the pre-filled value for this text input.
|
|
47
|
+
*/
|
|
48
|
+
setValue(value: string): this;
|
|
49
|
+
/**
|
|
50
|
+
* Sets the placeholder text shown when the input is empty.
|
|
51
|
+
*/
|
|
52
|
+
setPlaceholder(placeholder: string): this;
|
|
53
|
+
/**
|
|
54
|
+
* Serialises the builder into an API compatible text input payload.
|
|
55
|
+
*/
|
|
56
|
+
toJSON(): APITextInputComponent;
|
|
57
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { ComponentType, TextInputStyle, } from "discord-api-types/v10";
|
|
2
|
+
/** Builder for Discord text input components used in modals. */
|
|
3
|
+
export class TextInputBuilder {
|
|
4
|
+
data;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a new text input builder with optional seed data.
|
|
7
|
+
*/
|
|
8
|
+
constructor(data = {}) {
|
|
9
|
+
this.data = {
|
|
10
|
+
customId: data.customId,
|
|
11
|
+
label: data.label,
|
|
12
|
+
style: data.style ?? TextInputStyle.Short,
|
|
13
|
+
minLength: data.minLength,
|
|
14
|
+
maxLength: data.maxLength,
|
|
15
|
+
required: data.required,
|
|
16
|
+
value: data.value,
|
|
17
|
+
placeholder: data.placeholder,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sets the custom identifier for this text input.
|
|
22
|
+
*/
|
|
23
|
+
setCustomId(customId) {
|
|
24
|
+
this.data.customId = customId;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Sets the label displayed above the text input.
|
|
29
|
+
*/
|
|
30
|
+
setLabel(label) {
|
|
31
|
+
this.data.label = label;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Sets the style of the text input (Short or Paragraph).
|
|
36
|
+
*/
|
|
37
|
+
setStyle(style) {
|
|
38
|
+
this.data.style = style;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Sets the minimum length of the input text.
|
|
43
|
+
*/
|
|
44
|
+
setMinLength(minLength) {
|
|
45
|
+
this.data.minLength = minLength;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Sets the maximum length of the input text.
|
|
50
|
+
*/
|
|
51
|
+
setMaxLength(maxLength) {
|
|
52
|
+
this.data.maxLength = maxLength;
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Sets whether this text input is required.
|
|
57
|
+
*/
|
|
58
|
+
setRequired(required) {
|
|
59
|
+
this.data.required = required;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Sets the pre-filled value for this text input.
|
|
64
|
+
*/
|
|
65
|
+
setValue(value) {
|
|
66
|
+
this.data.value = value;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Sets the placeholder text shown when the input is empty.
|
|
71
|
+
*/
|
|
72
|
+
setPlaceholder(placeholder) {
|
|
73
|
+
this.data.placeholder = placeholder;
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Serialises the builder into an API compatible text input payload.
|
|
78
|
+
*/
|
|
79
|
+
toJSON() {
|
|
80
|
+
if (!this.data.customId) {
|
|
81
|
+
throw new Error("[TextInputBuilder] custom_id is required.");
|
|
82
|
+
}
|
|
83
|
+
if (!this.data.label) {
|
|
84
|
+
throw new Error("[TextInputBuilder] label is required.");
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
type: ComponentType.TextInput,
|
|
88
|
+
custom_id: this.data.customId,
|
|
89
|
+
label: this.data.label,
|
|
90
|
+
style: this.data.style ?? TextInputStyle.Short,
|
|
91
|
+
min_length: this.data.minLength,
|
|
92
|
+
max_length: this.data.maxLength,
|
|
93
|
+
required: this.data.required,
|
|
94
|
+
value: this.data.value,
|
|
95
|
+
placeholder: this.data.placeholder,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
package/dist/builders/index.d.ts
CHANGED
|
@@ -11,4 +11,12 @@ export { ChannelSelectMenuBuilder } from "./ChannelSelectMenuBuilder.js";
|
|
|
11
11
|
export type { ChannelSelectMenuBuilderData } from "./ChannelSelectMenuBuilder.js";
|
|
12
12
|
export { ModalBuilder } from "./ModalBuilder.js";
|
|
13
13
|
export type { ModalBuilderData, ModalComponentLike } from "./ModalBuilder.js";
|
|
14
|
+
export { TextInputBuilder } from "./TextInputBuilder.js";
|
|
15
|
+
export type { TextInputBuilderData } from "./TextInputBuilder.js";
|
|
16
|
+
export { AutomodRuleBuilder } from "./AutomodRuleBuilder.js";
|
|
17
|
+
export type { AutomodRuleBuilderData } from "./AutomodRuleBuilder.js";
|
|
18
|
+
export { EmbedBuilder } from "./EmbedBuilder.js";
|
|
19
|
+
export type { EmbedBuilderData } from "./EmbedBuilder.js";
|
|
20
|
+
export { ContainerBuilder, SectionBuilder, TextDisplayBuilder, SeparatorBuilder, GalleryBuilder, GalleryItemBuilder, ThumbnailBuilder, } from "./MiniContainerBuilder.js";
|
|
21
|
+
export type { ContainerBuilderData, SectionBuilderData, TextDisplayBuilderData, SeparatorBuilderData, GalleryBuilderData, GalleryItemBuilderData, ThumbnailBuilderData, MiniContainerComponent, MiniSectionComponent, MiniTextDisplayComponent, MiniSeparatorComponent, MiniGalleryComponent, MiniGalleryItemComponent, MiniThumbnailComponent, MiniContentComponent, MiniSectionAccessoryComponent, } from "./MiniContainerBuilder.js";
|
|
14
22
|
export type { JSONEncodable } from "./shared.js";
|
package/dist/builders/index.js
CHANGED
|
@@ -5,3 +5,7 @@ export { StringSelectMenuBuilder } from "./StringSelectMenuBuilder.js";
|
|
|
5
5
|
export { RoleSelectMenuBuilder } from "./RoleSelectMenuBuilder.js";
|
|
6
6
|
export { ChannelSelectMenuBuilder } from "./ChannelSelectMenuBuilder.js";
|
|
7
7
|
export { ModalBuilder } from "./ModalBuilder.js";
|
|
8
|
+
export { TextInputBuilder } from "./TextInputBuilder.js";
|
|
9
|
+
export { AutomodRuleBuilder } from "./AutomodRuleBuilder.js";
|
|
10
|
+
export { EmbedBuilder } from "./EmbedBuilder.js";
|
|
11
|
+
export { ContainerBuilder, SectionBuilder, TextDisplayBuilder, SeparatorBuilder, GalleryBuilder, GalleryItemBuilder, ThumbnailBuilder, } from "./MiniContainerBuilder.js";
|
|
@@ -3,6 +3,7 @@ import { APIInteractionResponse, RESTPostAPIChatInputApplicationCommandsJSONBody
|
|
|
3
3
|
import type { MiniInteractionCommand } from "../types/Commands.js";
|
|
4
4
|
import { RoleConnectionMetadataTypes } from "../types/RoleConnectionMetadataTypes.js";
|
|
5
5
|
import { type MessageComponentInteraction } from "../utils/MessageComponentInteraction.js";
|
|
6
|
+
import { type ModalSubmitInteraction } from "../utils/ModalSubmitInteraction.js";
|
|
6
7
|
/** Configuration parameters for the MiniInteraction client. */
|
|
7
8
|
export type MiniInteractionOptions = {
|
|
8
9
|
applicationId: string;
|
|
@@ -41,6 +42,13 @@ export type MiniInteractionComponent = {
|
|
|
41
42
|
customId: string;
|
|
42
43
|
handler: MiniInteractionComponentHandler;
|
|
43
44
|
};
|
|
45
|
+
/** Handler signature invoked for Discord modal submit interactions. */
|
|
46
|
+
export type MiniInteractionModalHandler = (interaction: ModalSubmitInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
47
|
+
/** Structure describing a modal handler mapped to a custom id. */
|
|
48
|
+
export type MiniInteractionModal = {
|
|
49
|
+
customId: string;
|
|
50
|
+
handler: MiniInteractionModalHandler;
|
|
51
|
+
};
|
|
44
52
|
/** Node.js HTTP handler compatible with frameworks like Express or Next.js API routes. */
|
|
45
53
|
export type MiniInteractionNodeHandler = (request: IncomingMessage, response: ServerResponse) => void;
|
|
46
54
|
/** Web Fetch API compatible request handler for platforms such as Cloudflare Workers. */
|
|
@@ -62,6 +70,7 @@ export declare class MiniInteraction {
|
|
|
62
70
|
private readonly componentsDirectory;
|
|
63
71
|
private readonly commands;
|
|
64
72
|
private readonly componentHandlers;
|
|
73
|
+
private readonly modalHandlers;
|
|
65
74
|
private commandsLoaded;
|
|
66
75
|
private loadCommandsPromise;
|
|
67
76
|
private componentsLoaded;
|
|
@@ -94,6 +103,18 @@ export declare class MiniInteraction {
|
|
|
94
103
|
* @param components - The component definitions to register.
|
|
95
104
|
*/
|
|
96
105
|
useComponents(components: MiniInteractionComponent[]): this;
|
|
106
|
+
/**
|
|
107
|
+
* Registers a single modal handler mapped to a custom identifier.
|
|
108
|
+
*
|
|
109
|
+
* @param modal - The modal definition to register.
|
|
110
|
+
*/
|
|
111
|
+
useModal(modal: MiniInteractionModal): this;
|
|
112
|
+
/**
|
|
113
|
+
* Registers multiple modal handlers in a single call.
|
|
114
|
+
*
|
|
115
|
+
* @param modals - The modal definitions to register.
|
|
116
|
+
*/
|
|
117
|
+
useModals(modals: MiniInteractionModal[]): this;
|
|
97
118
|
/**
|
|
98
119
|
* Recursively loads components from the configured components directory.
|
|
99
120
|
*
|
|
@@ -194,6 +215,10 @@ export declare class MiniInteraction {
|
|
|
194
215
|
* Handles execution of a message component interaction.
|
|
195
216
|
*/
|
|
196
217
|
private handleMessageComponent;
|
|
218
|
+
/**
|
|
219
|
+
* Handles execution of a modal submit interaction.
|
|
220
|
+
*/
|
|
221
|
+
private handleModalSubmit;
|
|
197
222
|
/**
|
|
198
223
|
* Handles execution of an application command interaction.
|
|
199
224
|
*/
|