@minesa-org/mini-interaction 0.3.6 → 0.3.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.
|
@@ -65,29 +65,54 @@ export function createModalSubmitInteraction(interaction, helpers) {
|
|
|
65
65
|
const getTextFieldValue = (customId) => {
|
|
66
66
|
for (const actionRow of interaction.data.components) {
|
|
67
67
|
if ("components" in actionRow && Array.isArray(actionRow.components)) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
const findValue = (components) => {
|
|
69
|
+
for (const component of components) {
|
|
70
|
+
if (component.custom_id === customId &&
|
|
71
|
+
typeof component.value === "string") {
|
|
72
|
+
return component.value;
|
|
73
|
+
}
|
|
74
|
+
// Check for nested component (e.g. Label wrapper)
|
|
75
|
+
if (component.component) {
|
|
76
|
+
const found = findValue([component.component]);
|
|
77
|
+
if (found)
|
|
78
|
+
return found;
|
|
79
|
+
}
|
|
74
80
|
}
|
|
75
|
-
|
|
81
|
+
return undefined;
|
|
82
|
+
};
|
|
83
|
+
const result = findValue(actionRow.components);
|
|
84
|
+
if (result)
|
|
85
|
+
return result;
|
|
76
86
|
}
|
|
77
87
|
}
|
|
78
88
|
return undefined;
|
|
79
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Helper method to get the value(s) of a select menu component by its custom ID.
|
|
92
|
+
* Handles the nested structure of modal components (Action Rows -> Components).
|
|
93
|
+
* Also handles nested components within wrappers (like Label components).
|
|
94
|
+
*/
|
|
80
95
|
const getSelectMenuValues = (customId) => {
|
|
81
96
|
for (const actionRow of interaction.data.components) {
|
|
82
97
|
if ("components" in actionRow && Array.isArray(actionRow.components)) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
98
|
+
const findValues = (components) => {
|
|
99
|
+
for (const component of components) {
|
|
100
|
+
if (component.custom_id === customId &&
|
|
101
|
+
Array.isArray(component.values)) {
|
|
102
|
+
return component.values;
|
|
103
|
+
}
|
|
104
|
+
// Check for nested component (e.g. Label wrapper)
|
|
105
|
+
if (component.component) {
|
|
106
|
+
const found = findValues([component.component]);
|
|
107
|
+
if (found)
|
|
108
|
+
return found;
|
|
109
|
+
}
|
|
89
110
|
}
|
|
90
|
-
|
|
111
|
+
return undefined;
|
|
112
|
+
};
|
|
113
|
+
const result = findValues(actionRow.components);
|
|
114
|
+
if (result)
|
|
115
|
+
return result;
|
|
91
116
|
}
|
|
92
117
|
}
|
|
93
118
|
return undefined;
|
package/package.json
CHANGED