@minesa-org/mini-interaction 0.3.7 → 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,14 +65,24 @@ 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;
|
|
@@ -80,27 +90,31 @@ export function createModalSubmitInteraction(interaction, helpers) {
|
|
|
80
90
|
/**
|
|
81
91
|
* Helper method to get the value(s) of a select menu component by its custom ID.
|
|
82
92
|
* Handles the nested structure of modal components (Action Rows -> Components).
|
|
93
|
+
* Also handles nested components within wrappers (like Label components).
|
|
83
94
|
*/
|
|
84
95
|
const getSelectMenuValues = (customId) => {
|
|
85
|
-
// 1. Access this.interaction.data.components (Array of Action Rows)
|
|
86
96
|
for (const actionRow of interaction.data.components) {
|
|
87
|
-
// 2. Iterate through these Action Rows
|
|
88
97
|
if ("components" in actionRow && Array.isArray(actionRow.components)) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
+
}
|
|
99
110
|
}
|
|
100
|
-
|
|
111
|
+
return undefined;
|
|
112
|
+
};
|
|
113
|
+
const result = findValues(actionRow.components);
|
|
114
|
+
if (result)
|
|
115
|
+
return result;
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
|
-
// 6. If not found, return undefined
|
|
104
118
|
return undefined;
|
|
105
119
|
};
|
|
106
120
|
const getComponentValue = (customId) => {
|
package/package.json
CHANGED