@discordjs/builders 2.0.0-dev.1776730371-8ea7c7c7e → 2.0.0-dev.1779528402-e721e51b0

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/dist/index.js CHANGED
@@ -80,6 +80,7 @@ __export(index_exports, {
80
80
  SeparatorBuilder: () => SeparatorBuilder,
81
81
  SharedChatInputCommandOptions: () => SharedChatInputCommandOptions,
82
82
  SharedChatInputCommandSubcommands: () => SharedChatInputCommandSubcommands,
83
+ SharedClientThemeBuilder: () => SharedClientThemeBuilder,
83
84
  SharedName: () => SharedName,
84
85
  SharedNameAndDescription: () => SharedNameAndDescription,
85
86
  StringSelectMenuBuilder: () => StringSelectMenuBuilder,
@@ -146,6 +147,7 @@ __export(index_exports, {
146
147
  selectMenuStringPredicate: () => selectMenuStringPredicate,
147
148
  selectMenuUserPredicate: () => selectMenuUserPredicate,
148
149
  separatorPredicate: () => separatorPredicate,
150
+ sharedClientThemePredicate: () => sharedClientThemePredicate,
149
151
  snowflakePredicate: () => snowflakePredicate,
150
152
  stringOptionPredicate: () => stringOptionPredicate,
151
153
  textDisplayPredicate: () => textDisplayPredicate,
@@ -2963,7 +2965,7 @@ var channelMixinOptionPredicate = import_zod8.z.object({
2963
2965
  });
2964
2966
  var autocompleteMixinOptionPredicate = import_zod8.z.object({
2965
2967
  autocomplete: import_zod8.z.literal(true),
2966
- choices: import_zod8.z.union([import_zod8.z.never(), import_zod8.z.never().array(), import_zod8.z.undefined()])
2968
+ choices: import_zod8.z.array(import_zod8.z.any()).length(0).optional()
2967
2969
  });
2968
2970
  var choiceValueStringPredicate = import_zod8.z.string().min(1).max(100);
2969
2971
  var choiceValueNumberPredicate = import_zod8.z.number();
@@ -4886,18 +4888,27 @@ var basicActionRowPredicate = import_zod13.z.object({
4886
4888
  ])
4887
4889
  }).array()
4888
4890
  });
4891
+ var sharedClientThemePredicate = import_zod13.z.object({
4892
+ colors: import_zod13.z.array(import_zod13.z.string().regex(/^[\da-f]{6}$/i)).min(1).max(5),
4893
+ gradient_angle: import_zod13.z.int().min(0).max(360),
4894
+ base_mix: import_zod13.z.int().min(0).max(100),
4895
+ base_theme: import_zod13.z.enum(import_v1045.BaseThemeType).nullish()
4896
+ });
4889
4897
  var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
4890
4898
  content: import_zod13.z.string().max(2e3).optional(),
4891
4899
  embeds: embedPredicate.array().max(10).optional(),
4892
4900
  sticker_ids: import_zod13.z.array(import_zod13.z.string()).max(3).optional(),
4893
4901
  poll: pollPredicate.optional(),
4902
+ shared_client_theme: sharedClientThemePredicate.optional(),
4894
4903
  components: basicActionRowPredicate.array().max(5).optional(),
4895
4904
  flags: import_zod13.z.int().optional().refine((flags) => !flags || (flags & import_v1045.MessageFlags.IsComponentsV2) === 0, {
4896
- error: "Cannot set content, embeds, stickers, or poll with IsComponentsV2 flag set"
4905
+ error: "Cannot set content, embeds, stickers, poll, or shared client theme with IsComponentsV2 flag set"
4897
4906
  })
4898
4907
  }).refine(
4899
- (data) => data.content !== void 0 || data.embeds !== void 0 && data.embeds.length > 0 || data.poll !== void 0 || data.attachments !== void 0 && data.attachments.length > 0 || data.components !== void 0 && data.components.length > 0 || data.sticker_ids !== void 0 && data.sticker_ids.length > 0,
4900
- { error: "Messages must have content, embeds, a poll, attachments, components or stickers" }
4908
+ (data) => data.content !== void 0 || data.embeds !== void 0 && data.embeds.length > 0 || data.poll !== void 0 || data.attachments !== void 0 && data.attachments.length > 0 || data.components !== void 0 && data.components.length > 0 || data.sticker_ids !== void 0 && data.sticker_ids.length > 0 || data.shared_client_theme !== void 0,
4909
+ {
4910
+ error: "Messages must have content, embeds, a poll, attachments, components, stickers, or a shared client theme"
4911
+ }
4901
4912
  );
4902
4913
  var allTopLevelComponentsPredicate = import_zod13.z.union([
4903
4914
  basicActionRowPredicate,
@@ -4923,7 +4934,8 @@ var messageComponentsV2Predicate = baseMessagePredicate.extend({
4923
4934
  content: import_zod13.z.string().length(0).nullish(),
4924
4935
  embeds: import_zod13.z.array(import_zod13.z.never()).nullish(),
4925
4936
  sticker_ids: import_zod13.z.array(import_zod13.z.never()).nullish(),
4926
- poll: import_zod13.z.null().optional()
4937
+ poll: import_zod13.z.null().optional(),
4938
+ shared_client_theme: import_zod13.z.null().optional()
4927
4939
  });
4928
4940
  var messagePredicate = import_zod13.z.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
4929
4941
  var fileBodyMessagePredicate = import_zod13.z.object({
@@ -5118,7 +5130,7 @@ var AttachmentBuilder = class {
5118
5130
  /**
5119
5131
  * This data is not included in the output of `toJSON()`. For this class specifically, this refers to binary data
5120
5132
  * that will wind up being included in the multipart/form-data request, if used with the `MessageBuilder`.
5121
- * To retrieve this data, use {@link getRawFile}.
5133
+ * To retrieve this data, use {@link AttachmentBuilder.getRawFile}.
5122
5134
  *
5123
5135
  * @remarks This cannot be set via the constructor, primarily because of the behavior described
5124
5136
  * {@link https://discord.com/developers/docs/reference#editing-message-attachments | here}.
@@ -5200,7 +5212,7 @@ var AttachmentBuilder = class {
5200
5212
  * Sets the file data to upload with this attachment.
5201
5213
  *
5202
5214
  * @param data - The file data
5203
- * @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
5215
+ * @remarks Note that this data is NOT included in the {@link AttachmentBuilder.toJSON} output. To retrieve it, use {@link AttachmentBuilder.getRawFile}.
5204
5216
  */
5205
5217
  setFileData(data) {
5206
5218
  this.fileData.data = data;
@@ -5216,7 +5228,7 @@ var AttachmentBuilder = class {
5216
5228
  /**
5217
5229
  * Sets the content type of the file data to upload with this attachment.
5218
5230
  *
5219
- * @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
5231
+ * @remarks Note that this data is NOT included in the {@link AttachmentBuilder.toJSON} output. To retrieve it, use {@link AttachmentBuilder.getRawFile}.
5220
5232
  */
5221
5233
  setFileContentType(contentType) {
5222
5234
  this.fileData.contentType = contentType;
@@ -5230,9 +5242,9 @@ var AttachmentBuilder = class {
5230
5242
  return this;
5231
5243
  }
5232
5244
  /**
5233
- * Converts this attachment to a {@link RawFile} for uploading.
5245
+ * Converts this attachment to a {@link @discordjs/util#RawFile} for uploading.
5234
5246
  *
5235
- * @returns A {@link RawFile} object, or `undefined` if no file data is set
5247
+ * @returns A {@link @discordjs/util#RawFile} object, or `undefined` if no file data is set
5236
5248
  */
5237
5249
  getRawFile() {
5238
5250
  if (!this.fileData?.data) {
@@ -5387,6 +5399,86 @@ var MessageReferenceBuilder = class {
5387
5399
  }
5388
5400
  };
5389
5401
 
5402
+ // src/messages/SharedClientTheme.ts
5403
+ var SharedClientThemeBuilder = class {
5404
+ static {
5405
+ __name(this, "SharedClientThemeBuilder");
5406
+ }
5407
+ /**
5408
+ * The API data associated with this shared client theme.
5409
+ */
5410
+ data;
5411
+ /**
5412
+ * Creates a new shared client theme builder.
5413
+ *
5414
+ * @param data - The API data to create this shared client theme with
5415
+ */
5416
+ constructor(data = {}) {
5417
+ this.data = structuredClone(data);
5418
+ }
5419
+ /**
5420
+ * Sets the colors of this theme.
5421
+ *
5422
+ * @remarks
5423
+ * A maximum of 5 hexadecimal-encoded colors may be provided.
5424
+ * @param colors - The hexadecimal-encoded colors to set (e.g. `'5865F2'`)
5425
+ */
5426
+ setColors(...colors) {
5427
+ this.data.colors = normalizeArray(colors);
5428
+ return this;
5429
+ }
5430
+ /**
5431
+ * Sets the gradient angle of this theme.
5432
+ *
5433
+ * @remarks
5434
+ * The value must be between `0` and `360` (inclusive).
5435
+ * @param angle - The gradient angle (direction of theme colors)
5436
+ */
5437
+ setGradientAngle(angle) {
5438
+ this.data.gradient_angle = angle;
5439
+ return this;
5440
+ }
5441
+ /**
5442
+ * Sets the base mix (intensity) of this theme.
5443
+ *
5444
+ * @remarks
5445
+ * The value must be between `0` and `100` (inclusive).
5446
+ * @param baseMix - The base mix intensity
5447
+ */
5448
+ setBaseMix(baseMix) {
5449
+ this.data.base_mix = baseMix;
5450
+ return this;
5451
+ }
5452
+ /**
5453
+ * Sets the base theme (mode) of this theme.
5454
+ *
5455
+ * @param baseTheme - The base theme mode
5456
+ */
5457
+ setBaseTheme(baseTheme) {
5458
+ this.data.base_theme = baseTheme;
5459
+ return this;
5460
+ }
5461
+ /**
5462
+ * Clears the base theme of this theme.
5463
+ */
5464
+ clearBaseTheme() {
5465
+ this.data.base_theme = void 0;
5466
+ return this;
5467
+ }
5468
+ /**
5469
+ * Serializes this builder to API-compatible JSON data.
5470
+ *
5471
+ * Note that by disabling validation, there is no guarantee that the resulting object will be valid.
5472
+ *
5473
+ * @param validationOverride - Force validation to run/not run regardless of your global preference
5474
+ */
5475
+ toJSON(validationOverride) {
5476
+ const data = structuredClone(this.data);
5477
+ validate(sharedClientThemePredicate, data, validationOverride);
5478
+ return data;
5479
+ }
5480
+ };
5481
+
5390
5482
  // src/messages/Message.ts
5391
5483
  var MessageBuilder = class {
5392
5484
  static {
@@ -5420,7 +5512,16 @@ var MessageBuilder = class {
5420
5512
  * @param data - The API data to create this message with
5421
5513
  */
5422
5514
  constructor(data = {}) {
5423
- const { attachments = [], embeds = [], components = [], message_reference, poll, allowed_mentions, ...rest } = data;
5515
+ const {
5516
+ attachments = [],
5517
+ embeds = [],
5518
+ components = [],
5519
+ message_reference,
5520
+ poll,
5521
+ allowed_mentions,
5522
+ shared_client_theme,
5523
+ ...rest
5524
+ } = data;
5424
5525
  this.data = {
5425
5526
  ...structuredClone(rest),
5426
5527
  allowed_mentions: allowed_mentions && new AllowedMentionsBuilder(allowed_mentions),
@@ -5428,7 +5529,8 @@ var MessageBuilder = class {
5428
5529
  embeds: embeds.map((embed) => new EmbedBuilder(embed)),
5429
5530
  poll: poll && new PollBuilder(poll),
5430
5531
  components: components.map((component) => createComponentBuilder(component)),
5431
- message_reference: message_reference && new MessageReferenceBuilder(message_reference)
5532
+ message_reference: message_reference && new MessageReferenceBuilder(message_reference),
5533
+ shared_client_theme: shared_client_theme && new SharedClientThemeBuilder(shared_client_theme)
5432
5534
  };
5433
5535
  }
5434
5536
  /**
@@ -5858,6 +5960,31 @@ var MessageBuilder = class {
5858
5960
  this.data.poll = void 0;
5859
5961
  return this;
5860
5962
  }
5963
+ /**
5964
+ * Sets the shared client theme for this message.
5965
+ *
5966
+ * @param theme - The shared client theme to set
5967
+ */
5968
+ setSharedClientTheme(theme) {
5969
+ this.data.shared_client_theme = resolveBuilder(theme, SharedClientThemeBuilder);
5970
+ return this;
5971
+ }
5972
+ /**
5973
+ * Updates the shared client theme for this message (and creates it if it doesn't exist).
5974
+ *
5975
+ * @param updater - The function to update the shared client theme with
5976
+ */
5977
+ updateSharedClientTheme(updater) {
5978
+ updater(this.data.shared_client_theme ??= new SharedClientThemeBuilder());
5979
+ return this;
5980
+ }
5981
+ /**
5982
+ * Clears the shared client theme for this message.
5983
+ */
5984
+ clearSharedClientTheme() {
5985
+ this.data.shared_client_theme = void 0;
5986
+ return this;
5987
+ }
5861
5988
  /**
5862
5989
  * Serializes this builder to API-compatible JSON data.
5863
5990
  *
@@ -5866,7 +5993,7 @@ var MessageBuilder = class {
5866
5993
  * @param validationOverride - Force validation to run/not run regardless of your global preference
5867
5994
  */
5868
5995
  toJSON(validationOverride) {
5869
- const { poll, allowed_mentions, attachments, embeds, components, message_reference, ...rest } = this.data;
5996
+ const { poll, allowed_mentions, attachments, embeds, components, message_reference, shared_client_theme, ...rest } = this.data;
5870
5997
  const data = {
5871
5998
  ...structuredClone(rest),
5872
5999
  // Wherever we pass false, it's covered by the messagePredicate already
@@ -5876,7 +6003,8 @@ var MessageBuilder = class {
5876
6003
  embeds: embeds.map((embed) => embed.toJSON(false)),
5877
6004
  // Here, the messagePredicate does specific constraints rather than using the componentPredicate
5878
6005
  components: components.map((component) => component.toJSON(validationOverride)),
5879
- message_reference: message_reference?.toJSON(false)
6006
+ message_reference: message_reference?.toJSON(false),
6007
+ shared_client_theme: shared_client_theme?.toJSON(false)
5880
6008
  };
5881
6009
  validate(messagePredicate, data, validationOverride);
5882
6010
  return data;
@@ -5905,7 +6033,7 @@ var MessageBuilder = class {
5905
6033
  };
5906
6034
 
5907
6035
  // src/index.ts
5908
- var version = "2.0.0-dev.1776730371-8ea7c7c7e";
6036
+ var version = "2.0.0-dev.1779528402-e721e51b0";
5909
6037
  // Annotate the CommonJS export names for ESM import in node:
5910
6038
  0 && (module.exports = {
5911
6039
  ActionRowBuilder,
@@ -5967,6 +6095,7 @@ var version = "2.0.0-dev.1776730371-8ea7c7c7e";
5967
6095
  SeparatorBuilder,
5968
6096
  SharedChatInputCommandOptions,
5969
6097
  SharedChatInputCommandSubcommands,
6098
+ SharedClientThemeBuilder,
5970
6099
  SharedName,
5971
6100
  SharedNameAndDescription,
5972
6101
  StringSelectMenuBuilder,
@@ -6033,6 +6162,7 @@ var version = "2.0.0-dev.1776730371-8ea7c7c7e";
6033
6162
  selectMenuStringPredicate,
6034
6163
  selectMenuUserPredicate,
6035
6164
  separatorPredicate,
6165
+ sharedClientThemePredicate,
6036
6166
  snowflakePredicate,
6037
6167
  stringOptionPredicate,
6038
6168
  textDisplayPredicate,