@minesa-org/mini-interaction 0.3.5 → 0.3.7

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.
@@ -1,4 +1,4 @@
1
- import { ComponentType, InteractionResponseType, } from "discord-api-types/v10";
1
+ import { InteractionResponseType, } from "discord-api-types/v10";
2
2
  import { normaliseInteractionMessageData, normaliseMessageFlags, } from "./interactionMessageHelpers.js";
3
3
  export const ModalSubmitInteraction = {};
4
4
  /**
@@ -65,9 +65,11 @@ 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 component of actionRow.components) {
69
- if (component.type === ComponentType.TextInput &&
70
- component.custom_id === customId) {
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") {
71
73
  return component.value;
72
74
  }
73
75
  }
@@ -75,23 +77,30 @@ export function createModalSubmitInteraction(interaction, helpers) {
75
77
  }
76
78
  return undefined;
77
79
  };
80
+ /**
81
+ * Helper method to get the value(s) of a select menu component by its custom ID.
82
+ * Handles the nested structure of modal components (Action Rows -> Components).
83
+ */
78
84
  const getSelectMenuValues = (customId) => {
85
+ // 1. Access this.interaction.data.components (Array of Action Rows)
79
86
  for (const actionRow of interaction.data.components) {
87
+ // 2. Iterate through these Action Rows
80
88
  if ("components" in actionRow && Array.isArray(actionRow.components)) {
89
+ // 3. Inside each row, look for a component
81
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
82
92
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
93
  const component = rawComponent;
84
- if ((component.type === ComponentType.StringSelect ||
85
- component.type === ComponentType.UserSelect ||
86
- component.type === ComponentType.RoleSelect ||
87
- component.type === ComponentType.MentionableSelect ||
88
- component.type === ComponentType.ChannelSelect) &&
89
- component.custom_id === customId) {
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
90
98
  return component.values;
91
99
  }
92
100
  }
93
101
  }
94
102
  }
103
+ // 6. If not found, return undefined
95
104
  return undefined;
96
105
  };
97
106
  const getComponentValue = (customId) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
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",