@minesa-org/mini-interaction 0.0.7 → 0.0.8
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.
|
@@ -80,9 +80,8 @@ export class TextInputBuilder {
|
|
|
80
80
|
if (!this.data.customId) {
|
|
81
81
|
throw new Error("[TextInputBuilder] custom_id is required.");
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
83
|
+
// Note: label is optional when used inside a LabelComponent
|
|
84
|
+
// but required when used standalone in an ActionRow
|
|
86
85
|
return {
|
|
87
86
|
type: ComponentType.TextInput,
|
|
88
87
|
custom_id: this.data.customId,
|
|
@@ -185,6 +185,7 @@ export declare class MiniInteraction {
|
|
|
185
185
|
private importCommandModule;
|
|
186
186
|
/**
|
|
187
187
|
* Dynamically imports and validates a component module from disk.
|
|
188
|
+
* Also handles modal components if they're in a "modals" subdirectory.
|
|
188
189
|
*/
|
|
189
190
|
private importComponentModule;
|
|
190
191
|
/**
|
|
@@ -545,6 +545,7 @@ export class MiniInteraction {
|
|
|
545
545
|
}
|
|
546
546
|
/**
|
|
547
547
|
* Dynamically imports and validates a component module from disk.
|
|
548
|
+
* Also handles modal components if they're in a "modals" subdirectory.
|
|
548
549
|
*/
|
|
549
550
|
async importComponentModule(absolutePath) {
|
|
550
551
|
try {
|
|
@@ -554,11 +555,16 @@ export class MiniInteraction {
|
|
|
554
555
|
imported.component ??
|
|
555
556
|
imported.components ??
|
|
556
557
|
imported.componentDefinition ??
|
|
558
|
+
imported.modal ??
|
|
559
|
+
imported.modals ??
|
|
557
560
|
imported;
|
|
558
561
|
const candidates = Array.isArray(candidate)
|
|
559
562
|
? candidate
|
|
560
563
|
: [candidate];
|
|
561
564
|
const components = [];
|
|
565
|
+
// Check if this file is in a "modals" subdirectory
|
|
566
|
+
const isModalFile = absolutePath.includes(path.sep + "modals" + path.sep) ||
|
|
567
|
+
absolutePath.includes("/modals/");
|
|
562
568
|
for (const item of candidates) {
|
|
563
569
|
if (!item || typeof item !== "object") {
|
|
564
570
|
continue;
|
|
@@ -572,9 +578,18 @@ export class MiniInteraction {
|
|
|
572
578
|
console.warn(`[MiniInteraction] Component module "${absolutePath}" is missing a "handler" function. Skipping.`);
|
|
573
579
|
continue;
|
|
574
580
|
}
|
|
575
|
-
|
|
581
|
+
// If it's in a modals directory, register it as a modal
|
|
582
|
+
if (isModalFile) {
|
|
583
|
+
this.useModal({
|
|
584
|
+
customId,
|
|
585
|
+
handler: handler,
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
else {
|
|
589
|
+
components.push({ customId, handler });
|
|
590
|
+
}
|
|
576
591
|
}
|
|
577
|
-
if (components.length === 0) {
|
|
592
|
+
if (components.length === 0 && !isModalFile) {
|
|
578
593
|
console.warn(`[MiniInteraction] Component module "${absolutePath}" did not export any valid components. Skipping.`);
|
|
579
594
|
}
|
|
580
595
|
return components;
|
|
@@ -755,6 +770,7 @@ export class MiniInteraction {
|
|
|
755
770
|
},
|
|
756
771
|
};
|
|
757
772
|
}
|
|
773
|
+
await this.ensureComponentsLoaded();
|
|
758
774
|
const handler = this.modalHandlers.get(customId);
|
|
759
775
|
if (!handler) {
|
|
760
776
|
return {
|
package/package.json
CHANGED