@minesa-org/mini-interaction 0.3.8 → 0.3.9

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.
@@ -51,5 +51,6 @@ export declare const MiniPermFlags: {
51
51
  readonly SendPolls: bigint;
52
52
  readonly UseExternalApps: bigint;
53
53
  readonly PinMessages: bigint;
54
+ readonly BypassSlowmode: bigint;
54
55
  };
55
56
  export type MiniPermFlag = (typeof MiniPermFlags)[keyof typeof MiniPermFlags];
@@ -63,24 +63,29 @@ export function createModalSubmitInteraction(interaction, helpers) {
63
63
  };
64
64
  const getResponse = () => capturedResponse;
65
65
  const getTextFieldValue = (customId) => {
66
- for (const actionRow of interaction.data.components) {
67
- if ("components" in actionRow && Array.isArray(actionRow.components)) {
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
- }
80
- }
81
- return undefined;
82
- };
83
- const result = findValue(actionRow.components);
66
+ const findValue = (components) => {
67
+ for (const component of components) {
68
+ if (component?.custom_id === customId &&
69
+ typeof component.value === "string") {
70
+ return component.value;
71
+ }
72
+ // Nested Label wrapper: single child in .component
73
+ if (component?.component) {
74
+ const found = findValue([component.component]);
75
+ if (found)
76
+ return found;
77
+ }
78
+ }
79
+ return undefined;
80
+ };
81
+ for (const top of interaction.data.components) {
82
+ if ("components" in top && Array.isArray(top.components)) {
83
+ const result = findValue(top.components);
84
+ if (result)
85
+ return result;
86
+ }
87
+ if ("component" in top && top.component) {
88
+ const result = findValue([top.component]);
84
89
  if (result)
85
90
  return result;
86
91
  }
@@ -89,28 +94,36 @@ export function createModalSubmitInteraction(interaction, helpers) {
89
94
  };
90
95
  /**
91
96
  * 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).
97
+ * Handles the nested structure of modal components (Action Rows -> Components,
98
+ * and Label -> single component). Select menus in modals are typically inside
99
+ * Label components, not Action Rows.
94
100
  */
95
101
  const getSelectMenuValues = (customId) => {
96
- for (const actionRow of interaction.data.components) {
97
- if ("components" in actionRow && Array.isArray(actionRow.components)) {
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
- }
110
- }
111
- return undefined;
112
- };
113
- const result = findValues(actionRow.components);
102
+ const findValues = (components) => {
103
+ for (const component of components) {
104
+ if (component?.custom_id === customId &&
105
+ Array.isArray(component.values)) {
106
+ return component.values;
107
+ }
108
+ // Nested Label wrapper: single child in .component
109
+ if (component?.component) {
110
+ const found = findValues([component.component]);
111
+ if (found)
112
+ return found;
113
+ }
114
+ }
115
+ return undefined;
116
+ };
117
+ for (const top of interaction.data.components) {
118
+ // Action Row: multiple components in .components
119
+ if ("components" in top && Array.isArray(top.components)) {
120
+ const result = findValues(top.components);
121
+ if (result)
122
+ return result;
123
+ }
124
+ // Label: select menu (and other modal components) wrapped in .component
125
+ if ("component" in top && top.component) {
126
+ const result = findValues([top.component]);
114
127
  if (result)
115
128
  return result;
116
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
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",