@ovencord/builders 1.12.4 → 1.12.6
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.
|
|
4
|
+
"version": "1.12.6",
|
|
5
5
|
"description": "A set of builders that you can use when creating your bot",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "bun test",
|
|
@@ -46,8 +46,6 @@
|
|
|
46
46
|
"@ovencord/util": "^1.1.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@ovencord/api-extractor": "^7.52.7",
|
|
50
|
-
"@ovencord/scripts": "^0.1.0",
|
|
51
49
|
"@favware/cliff-jumper": "^6.0.0",
|
|
52
50
|
"@vitest/coverage-v8": "^4.0.15",
|
|
53
51
|
"cross-env": "^10.1.0",
|
|
@@ -34,25 +34,25 @@ import { StringSelectMenuBuilder } from './selectMenu/StringSelectMenu.js';
|
|
|
34
34
|
import { UserSelectMenuBuilder } from './selectMenu/UserSelectMenu.js';
|
|
35
35
|
import { TextInputBuilder } from './textInput/TextInput.js';
|
|
36
36
|
|
|
37
|
-
export interface ActionRowBuilderData<
|
|
37
|
+
export interface ActionRowBuilderData<T extends AnyActionRowComponentBuilder = AnyActionRowComponentBuilder> extends Partial<
|
|
38
38
|
Omit<APIActionRowComponent<APIComponentInActionRow>, 'components'>
|
|
39
39
|
> {
|
|
40
|
-
components:
|
|
40
|
+
components: T[];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* A builder that creates API-compatible JSON data for action rows.
|
|
45
45
|
*/
|
|
46
|
-
export class ActionRowBuilder<
|
|
46
|
+
export class ActionRowBuilder<T extends AnyActionRowComponentBuilder = AnyActionRowComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIComponentInActionRow>> {
|
|
47
47
|
/**
|
|
48
48
|
* @internal
|
|
49
49
|
*/
|
|
50
|
-
protected readonly data: ActionRowBuilderData<
|
|
50
|
+
protected readonly data: ActionRowBuilderData<T>;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* The components within this action row.
|
|
54
54
|
*/
|
|
55
|
-
public get components(): readonly
|
|
55
|
+
public get components(): readonly T[] {
|
|
56
56
|
return this.data.components;
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -97,7 +97,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
97
97
|
|
|
98
98
|
this.data = {
|
|
99
99
|
...structuredClone(rest),
|
|
100
|
-
components: components.map((component) => createComponentBuilder(component)) as
|
|
100
|
+
components: components.map((component) => createComponentBuilder(component)) as T[],
|
|
101
101
|
type: ComponentType.ActionRow,
|
|
102
102
|
};
|
|
103
103
|
}
|
|
@@ -115,7 +115,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
115
115
|
const normalized = normalizeArray(input);
|
|
116
116
|
const resolved = normalized.map((component) => resolveBuilder(component, PrimaryButtonBuilder));
|
|
117
117
|
|
|
118
|
-
this.data.components.push(...(resolved as
|
|
118
|
+
this.data.components.push(...(resolved as T[]));
|
|
119
119
|
return this;
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -134,7 +134,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
134
134
|
const normalized = normalizeArray(input);
|
|
135
135
|
const resolved = normalized.map((component) => resolveBuilder(component, SecondaryButtonBuilder));
|
|
136
136
|
|
|
137
|
-
this.data.components.push(...(resolved as
|
|
137
|
+
this.data.components.push(...(resolved as T[]));
|
|
138
138
|
return this;
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -151,7 +151,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
151
151
|
const normalized = normalizeArray(input);
|
|
152
152
|
const resolved = normalized.map((component) => resolveBuilder(component, SuccessButtonBuilder));
|
|
153
153
|
|
|
154
|
-
this.data.components.push(...(resolved as
|
|
154
|
+
this.data.components.push(...(resolved as T[]));
|
|
155
155
|
return this;
|
|
156
156
|
}
|
|
157
157
|
|
|
@@ -166,7 +166,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
166
166
|
const normalized = normalizeArray(input);
|
|
167
167
|
const resolved = normalized.map((component) => resolveBuilder(component, DangerButtonBuilder));
|
|
168
168
|
|
|
169
|
-
this.data.components.push(...(resolved as
|
|
169
|
+
this.data.components.push(...(resolved as T[]));
|
|
170
170
|
return this;
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -175,7 +175,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
175
175
|
*/
|
|
176
176
|
public addComponents(...input: RestOrArray<AnyActionRowComponentBuilder>): this {
|
|
177
177
|
const normalized = normalizeArray(input);
|
|
178
|
-
this.data.components.push(...(normalized as
|
|
178
|
+
this.data.components.push(...(normalized as T[]));
|
|
179
179
|
|
|
180
180
|
return this;
|
|
181
181
|
}
|
|
@@ -187,7 +187,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
187
187
|
*/
|
|
188
188
|
public setComponents(...input: RestOrArray<AnyActionRowComponentBuilder>): this {
|
|
189
189
|
const normalized = normalizeArray(input);
|
|
190
|
-
this.data.components = [...normalized] as
|
|
190
|
+
this.data.components = [...normalized] as T[];
|
|
191
191
|
|
|
192
192
|
return this;
|
|
193
193
|
}
|
|
@@ -205,7 +205,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
205
205
|
const normalized = normalizeArray(input);
|
|
206
206
|
const resolved = normalized.map((component) => resolveBuilder(component, PremiumButtonBuilder));
|
|
207
207
|
|
|
208
|
-
this.data.components.push(...(resolved as
|
|
208
|
+
this.data.components.push(...(resolved as T[]));
|
|
209
209
|
return this;
|
|
210
210
|
}
|
|
211
211
|
|
|
@@ -222,7 +222,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
222
222
|
const normalized = normalizeArray(input);
|
|
223
223
|
const resolved = normalized.map((component) => resolveBuilder(component, LinkButtonBuilder));
|
|
224
224
|
|
|
225
|
-
this.data.components.push(...(resolved as
|
|
225
|
+
this.data.components.push(...(resolved as T[]));
|
|
226
226
|
return this;
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -237,7 +237,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
237
237
|
| ChannelSelectMenuBuilder
|
|
238
238
|
| ((builder: ChannelSelectMenuBuilder) => ChannelSelectMenuBuilder),
|
|
239
239
|
): this {
|
|
240
|
-
this.data.components.push(resolveBuilder(input, ChannelSelectMenuBuilder) as
|
|
240
|
+
this.data.components.push(resolveBuilder(input, ChannelSelectMenuBuilder) as T);
|
|
241
241
|
return this;
|
|
242
242
|
}
|
|
243
243
|
|
|
@@ -252,7 +252,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
252
252
|
| MentionableSelectMenuBuilder
|
|
253
253
|
| ((builder: MentionableSelectMenuBuilder) => MentionableSelectMenuBuilder),
|
|
254
254
|
): this {
|
|
255
|
-
this.data.components.push(resolveBuilder(input, MentionableSelectMenuBuilder) as
|
|
255
|
+
this.data.components.push(resolveBuilder(input, MentionableSelectMenuBuilder) as T);
|
|
256
256
|
return this;
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -264,7 +264,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
264
264
|
public addRoleSelectMenuComponent(
|
|
265
265
|
input: APIRoleSelectComponent | RoleSelectMenuBuilder | ((builder: RoleSelectMenuBuilder) => RoleSelectMenuBuilder),
|
|
266
266
|
): this {
|
|
267
|
-
this.data.components.push(resolveBuilder(input, RoleSelectMenuBuilder) as
|
|
267
|
+
this.data.components.push(resolveBuilder(input, RoleSelectMenuBuilder) as T);
|
|
268
268
|
return this;
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -279,7 +279,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
279
279
|
| StringSelectMenuBuilder
|
|
280
280
|
| ((builder: StringSelectMenuBuilder) => StringSelectMenuBuilder),
|
|
281
281
|
): this {
|
|
282
|
-
this.data.components.push(resolveBuilder(input, StringSelectMenuBuilder) as
|
|
282
|
+
this.data.components.push(resolveBuilder(input, StringSelectMenuBuilder) as T);
|
|
283
283
|
return this;
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -291,7 +291,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
291
291
|
public addUserSelectMenuComponent(
|
|
292
292
|
input: APIUserSelectComponent | UserSelectMenuBuilder | ((builder: UserSelectMenuBuilder) => UserSelectMenuBuilder),
|
|
293
293
|
): this {
|
|
294
|
-
this.data.components.push(resolveBuilder(input, UserSelectMenuBuilder) as
|
|
294
|
+
this.data.components.push(resolveBuilder(input, UserSelectMenuBuilder) as T);
|
|
295
295
|
return this;
|
|
296
296
|
}
|
|
297
297
|
|
|
@@ -303,7 +303,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
303
303
|
public addTextInputComponent(
|
|
304
304
|
input: APITextInputComponent | TextInputBuilder | ((builder: TextInputBuilder) => TextInputBuilder),
|
|
305
305
|
): this {
|
|
306
|
-
this.data.components.push(resolveBuilder(input, TextInputBuilder) as
|
|
306
|
+
this.data.components.push(resolveBuilder(input, TextInputBuilder) as T);
|
|
307
307
|
return this;
|
|
308
308
|
}
|
|
309
309
|
|
|
@@ -336,7 +336,7 @@ export class ActionRowBuilder<ComponentType extends AnyActionRowComponentBuilder
|
|
|
336
336
|
* @param components - The replacing component objects
|
|
337
337
|
*/
|
|
338
338
|
public spliceComponents(index: number, deleteCount: number, ...components: AnyActionRowComponentBuilder[]): this {
|
|
339
|
-
this.data.components.splice(index, deleteCount, ...components);
|
|
339
|
+
this.data.components.splice(index, deleteCount, ...(components as unknown as T[]));
|
|
340
340
|
return this;
|
|
341
341
|
}
|
|
342
342
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Buffer } from 'node:buffer';
|
|
2
1
|
import { AllowedMentionsTypes, ComponentType, MessageFlags, MessageReferenceType } from 'discord-api-types/v10';
|
|
3
2
|
import { z } from 'zod';
|
|
4
3
|
import { snowflakePredicate } from '../Assertions.js';
|
|
@@ -8,7 +7,7 @@ import { pollPredicate } from './poll/Assertions.js';
|
|
|
8
7
|
const fileKeyRegex = /^files\[(?<placeholder>\d+?)]$/;
|
|
9
8
|
|
|
10
9
|
export const rawFilePredicate = z.object({
|
|
11
|
-
data: z.union([z.instanceof(
|
|
10
|
+
data: z.union([z.instanceof(Uint8Array), z.string()]),
|
|
12
11
|
name: z.string().min(1),
|
|
13
12
|
contentType: z.string().optional(),
|
|
14
13
|
key: z.string().regex(fileKeyRegex).optional(),
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Buffer } from 'node:buffer';
|
|
2
1
|
import type { JSONEncodable, RawFile } from '@ovencord/util';
|
|
3
2
|
import type { RESTAPIAttachment, Snowflake } from 'discord-api-types/v10';
|
|
4
3
|
import { validate } from '../util/validation.js';
|
|
@@ -109,7 +108,7 @@ export class AttachmentBuilder implements JSONEncodable<RESTAPIAttachment> {
|
|
|
109
108
|
* @param data - The file data
|
|
110
109
|
* @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
|
|
111
110
|
*/
|
|
112
|
-
public setFileData(data:
|
|
111
|
+
public setFileData(data: Uint8Array | string): this {
|
|
113
112
|
this.fileData.data = data as any;
|
|
114
113
|
return this;
|
|
115
114
|
}
|