@ovencord/builders 1.12.0 → 1.12.2

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@ovencord/builders",
4
- "version": "1.12.0",
4
+ "version": "1.12.2",
5
5
  "description": "A set of builders that you can use when creating your bot",
6
6
  "scripts": {
7
7
  "test": "bun test",
@@ -6,6 +6,7 @@ export const textInputPredicate = z.object({
6
6
  id: idPredicate,
7
7
  type: z.literal(ComponentType.TextInput),
8
8
  custom_id: customIdPredicate,
9
+ label: z.string().min(1).max(45),
9
10
  style: z.nativeEnum(TextInputStyle),
10
11
  min_length: z.number().min(0).max(4_000).optional(),
11
12
  max_length: z.number().min(1).max(4_000).optional(),
@@ -50,6 +50,24 @@ export class TextInputBuilder extends ComponentBuilder<APITextInputComponent> {
50
50
  return this;
51
51
  }
52
52
 
53
+ /**
54
+ * Sets the label for this text input.
55
+ *
56
+ * @param label - The label to use
57
+ */
58
+ public setLabel(label: string) {
59
+ this.data.label = label;
60
+ return this;
61
+ }
62
+
63
+ /**
64
+ * Clears the label for this text input.
65
+ */
66
+ public clearLabel() {
67
+ this.data.label = undefined;
68
+ return this;
69
+ }
70
+
53
71
  /**
54
72
  * Sets the style for this text input.
55
73
  *
@@ -1,10 +1,12 @@
1
1
  import type { JSONEncodable } from '@ovencord/util';
2
2
  import type {
3
+ APIActionRowComponent,
4
+ APIComponentInActionRow,
3
5
  APILabelComponent,
4
6
  APIModalInteractionResponseCallbackData,
5
7
  APITextDisplayComponent,
6
8
  } from 'discord-api-types/v10';
7
- import type { ActionRowBuilder } from '../../components/ActionRow.js';
9
+ import { ActionRowBuilder } from '../../components/ActionRow.js';
8
10
  import type { AnyModalComponentBuilder } from '../../components/Components.js';
9
11
  import { createComponentBuilder } from '../../components/Components.js';
10
12
  import { LabelBuilder } from '../../components/label/Label.js';
@@ -102,6 +104,41 @@ export class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCa
102
104
  return this;
103
105
  }
104
106
 
107
+ /**
108
+ * Adds action row components to this modal (for TextInput fields).
109
+ *
110
+ * @param components - The action rows to add
111
+ */
112
+ public addActionRowComponents(
113
+ ...components: RestOrArray<
114
+ ActionRowBuilder | APIActionRowComponent<APIComponentInActionRow>
115
+ >
116
+ ) {
117
+ const normalized = normalizeArray(components);
118
+ const resolved = normalized.map((row) =>
119
+ row instanceof ActionRowBuilder ? row : new ActionRowBuilder(row),
120
+ );
121
+
122
+ this.data.components.push(...resolved);
123
+
124
+ return this;
125
+ }
126
+
127
+ /**
128
+ * Adds components to this modal. Accepts ActionRowBuilder instances,
129
+ * or any other valid modal component builder.
130
+ *
131
+ * @param components - The components to add
132
+ */
133
+ public addComponents(
134
+ ...components: RestOrArray<ActionRowBuilder | AnyModalComponentBuilder>
135
+ ) {
136
+ const normalized = normalizeArray(components);
137
+ this.data.components.push(...normalized);
138
+
139
+ return this;
140
+ }
141
+
105
142
  /**
106
143
  * Removes, replaces, or inserts components for this modal.
107
144
  *