@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
- for (const rawComponent of actionRow.components) {
69
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
70
- const component = rawComponent;
71
- if (component.custom_id === customId &&
72
- typeof component.value === "string") {
73
- return component.value;
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
- // 3. Inside each row, look for a component
90
- for (const rawComponent of actionRow.components) {
91
- // Cast to any to handle potential type definitions that might not fully support Select Menus in Modals yet
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
- const component = rawComponent;
94
- // 4. Match customId and check for 'values' property (specific to Select Menus)
95
- if (component.custom_id === customId &&
96
- Array.isArray(component.values)) {
97
- // 5. Return its values property
98
- return component.values;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "Mini interaction, connecting your app with Discord via HTTP-interaction (Vercel support).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",