@ovencord/builders 1.11.3 → 1.11.5-dev.1

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.11.3",
4
+ "version": "1.11.5-dev.1",
5
5
  "description": "A set of builders that you can use when creating your bot",
6
6
  "scripts": {
7
7
  "test": "bun test",
@@ -42,7 +42,7 @@
42
42
  "discord-api-types": "^0.38.36",
43
43
  "ts-mixer": "^6.0.4",
44
44
  "tslib": "^2.8.1",
45
- "zod": "^4.1.13",
45
+ "zod": "^4.3.6",
46
46
  "@ovencord/util": "^1.1.1"
47
47
  },
48
48
  "devDependencies": {
@@ -180,6 +180,18 @@ export class ActionRowBuilder extends ComponentBuilder<APIActionRowComponent<API
180
180
  return this;
181
181
  }
182
182
 
183
+ /**
184
+ * Sets the components in this action row.
185
+ *
186
+ * @param input - The components to set
187
+ */
188
+ public setComponents(...input: RestOrArray<AnyActionRowComponentBuilder>): this {
189
+ const normalized = normalizeArray(input);
190
+ this.data.components = [...normalized];
191
+
192
+ return this;
193
+ }
194
+
183
195
  /**
184
196
  * Adds SKU id button components to this action row.
185
197
  *
@@ -133,6 +133,7 @@ export const selectMenuStringPredicate = selectMenuBasePredicate
133
133
  minimum,
134
134
  type: 'array',
135
135
  path: ['options'],
136
+ origin: 'value',
136
137
  });
137
138
 
138
139
  if (value.min_values !== undefined && value.options.length < value.min_values) {
@@ -151,6 +152,7 @@ export const selectMenuStringPredicate = selectMenuBasePredicate
151
152
  maximum: value.max_values,
152
153
  type: 'number',
153
154
  path: ['min_values'],
155
+ origin: 'value',
154
156
  });
155
157
  }
156
158
  });
@@ -70,6 +70,12 @@ export type ModalComponentBuilder =
70
70
  */
71
71
  export type MessageActionRowComponentBuilder =
72
72
  | ButtonBuilder
73
+ | PrimaryButtonBuilder
74
+ | SecondaryButtonBuilder
75
+ | SuccessButtonBuilder
76
+ | DangerButtonBuilder
77
+ | LinkButtonBuilder
78
+ | PremiumButtonBuilder
73
79
  | ChannelSelectMenuBuilder
74
80
  | MentionableSelectMenuBuilder
75
81
  | RoleSelectMenuBuilder
@@ -238,17 +244,17 @@ export function createComponentBuilder(
238
244
  function createButtonBuilder(data: APIButtonComponent): ButtonBuilder {
239
245
  switch (data.style) {
240
246
  case ButtonStyle.Primary:
241
- return new PrimaryButtonBuilder(data);
247
+ return new PrimaryButtonBuilder(data) as any;
242
248
  case ButtonStyle.Secondary:
243
- return new SecondaryButtonBuilder(data);
249
+ return new SecondaryButtonBuilder(data) as any;
244
250
  case ButtonStyle.Success:
245
- return new SuccessButtonBuilder(data);
251
+ return new SuccessButtonBuilder(data) as any;
246
252
  case ButtonStyle.Danger:
247
- return new DangerButtonBuilder(data);
253
+ return new DangerButtonBuilder(data) as any;
248
254
  case ButtonStyle.Link:
249
- return new LinkButtonBuilder(data);
255
+ return new LinkButtonBuilder(data) as any;
250
256
  case ButtonStyle.Premium:
251
- return new PremiumButtonBuilder(data);
257
+ return new PremiumButtonBuilder(data) as any;
252
258
  default:
253
259
  // @ts-expect-error This case can still occur if we get a newer unsupported button style
254
260
  throw new Error(`Cannot properly serialize button with style: ${data.style}`);
@@ -9,6 +9,7 @@ import { EmojiOrLabelButtonMixin } from './mixins/EmojiOrLabelButtonMixin.js';
9
9
  * @mixes {@link BaseButtonBuilder}\<{@link discord-api-types/v10#(APIButtonComponent:interface)}\>
10
10
  * @mixes {@link EmojiOrLabelButtonMixin}
11
11
  */
12
+ // @ts-ignore
12
13
  export interface ButtonBuilder extends BaseButtonBuilder<APIButtonComponent>, EmojiOrLabelButtonMixin {}
13
14
 
14
15
  export class ButtonBuilder extends Mixin(BaseButtonBuilder<APIButtonComponent>, EmojiOrLabelButtonMixin) {
@@ -33,7 +34,7 @@ export class ButtonBuilder extends Mixin(BaseButtonBuilder<APIButtonComponent>,
33
34
  * @param customId - The custom id to use
34
35
  */
35
36
  public setCustomId(customId: string) {
36
- this.data.custom_id = customId;
37
+ (this.data as any).custom_id = customId;
37
38
  return this;
38
39
  }
39
40
 
@@ -43,7 +44,7 @@ export class ButtonBuilder extends Mixin(BaseButtonBuilder<APIButtonComponent>,
43
44
  * @param style - The style to use
44
45
  */
45
46
  public setStyle(style: ButtonStyle) {
46
- this.data.style = style;
47
+ (this.data as any).style = style;
47
48
  return this;
48
49
  }
49
50
 
@@ -53,7 +54,17 @@ export class ButtonBuilder extends Mixin(BaseButtonBuilder<APIButtonComponent>,
53
54
  * @param url - The URL to use
54
55
  */
55
56
  public setURL(url: string) {
56
- this.data.url = url;
57
+ (this.data as any).url = url;
58
+ return this;
59
+ }
60
+
61
+ /**
62
+ * Sets the SKU id for this button.
63
+ *
64
+ * @param skuId - The SKU id to use
65
+ */
66
+ public setSKUId(skuId: string) {
67
+ (this.data as any).sku_id = skuId;
57
68
  return this;
58
69
  }
59
70
  }
@@ -19,8 +19,12 @@ export class EmojiOrLabelButtonMixin {
19
19
  *
20
20
  * @param emoji - The emoji to use
21
21
  */
22
- public setEmoji(emoji: APIMessageComponentEmoji) {
23
- this.data.emoji = emoji;
22
+ public setEmoji(emoji: APIMessageComponentEmoji | string) {
23
+ if (typeof emoji === 'string') {
24
+ this.data.emoji = { name: emoji };
25
+ } else {
26
+ this.data.emoji = emoji;
27
+ }
24
28
  return this;
25
29
  }
26
30
 
@@ -25,7 +25,15 @@ import { sectionPredicate } from './Assertions.js';
25
25
  import { TextDisplayBuilder } from './TextDisplay.js';
26
26
  import { ThumbnailBuilder } from './Thumbnail.js';
27
27
 
28
- export type SectionBuilderAccessory = ButtonBuilder | ThumbnailBuilder;
28
+ export type SectionBuilderAccessory =
29
+ | ButtonBuilder
30
+ | PrimaryButtonBuilder
31
+ | SecondaryButtonBuilder
32
+ | SuccessButtonBuilder
33
+ | DangerButtonBuilder
34
+ | LinkButtonBuilder
35
+ | PremiumButtonBuilder
36
+ | ThumbnailBuilder;
29
37
 
30
38
  export interface SectionBuilderData extends Partial<Omit<APISectionComponent, 'accessory' | 'components'>> {
31
39
  accessory?: SectionBuilderAccessory;
@@ -23,6 +23,13 @@ export class SharedName {
23
23
  return this;
24
24
  }
25
25
 
26
+ /**
27
+ * Returns the name of this command.
28
+ */
29
+ public get name(): string | undefined {
30
+ return this.data.name;
31
+ }
32
+
26
33
  /**
27
34
  * Sets a name localization for this command.
28
35
  *
@@ -24,6 +24,13 @@ export class SharedNameAndDescription extends SharedName {
24
24
  return this;
25
25
  }
26
26
 
27
+ /**
28
+ * Returns the description of this command.
29
+ */
30
+ public get description(): string | undefined {
31
+ return this.data.description;
32
+ }
33
+
27
34
  /**
28
35
  * Sets a description localization for this command.
29
36
  *