@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.d.mts +124 -29
- package/dist/index.d.ts +124 -29
- package/dist/index.js +145 -15
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +150 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -2831,7 +2831,7 @@ var channelMixinOptionPredicate = z8.object({
|
|
|
2831
2831
|
});
|
|
2832
2832
|
var autocompleteMixinOptionPredicate = z8.object({
|
|
2833
2833
|
autocomplete: z8.literal(true),
|
|
2834
|
-
choices: z8.
|
|
2834
|
+
choices: z8.array(z8.any()).length(0).optional()
|
|
2835
2835
|
});
|
|
2836
2836
|
var choiceValueStringPredicate = z8.string().min(1).max(100);
|
|
2837
2837
|
var choiceValueNumberPredicate = z8.number();
|
|
@@ -4697,7 +4697,13 @@ var PollBuilder = class {
|
|
|
4697
4697
|
|
|
4698
4698
|
// src/messages/Assertions.ts
|
|
4699
4699
|
import { Buffer as Buffer2 } from "buffer";
|
|
4700
|
-
import {
|
|
4700
|
+
import {
|
|
4701
|
+
AllowedMentionsTypes,
|
|
4702
|
+
BaseThemeType,
|
|
4703
|
+
ComponentType as ComponentType27,
|
|
4704
|
+
MessageFlags,
|
|
4705
|
+
MessageReferenceType
|
|
4706
|
+
} from "discord-api-types/v10";
|
|
4701
4707
|
import { z as z13 } from "zod";
|
|
4702
4708
|
var fileKeyRegex = /^files\[(?<placeholder>\d+?)]$/;
|
|
4703
4709
|
var rawFilePredicate = z13.object({
|
|
@@ -4754,18 +4760,27 @@ var basicActionRowPredicate = z13.object({
|
|
|
4754
4760
|
])
|
|
4755
4761
|
}).array()
|
|
4756
4762
|
});
|
|
4763
|
+
var sharedClientThemePredicate = z13.object({
|
|
4764
|
+
colors: z13.array(z13.string().regex(/^[\da-f]{6}$/i)).min(1).max(5),
|
|
4765
|
+
gradient_angle: z13.int().min(0).max(360),
|
|
4766
|
+
base_mix: z13.int().min(0).max(100),
|
|
4767
|
+
base_theme: z13.enum(BaseThemeType).nullish()
|
|
4768
|
+
});
|
|
4757
4769
|
var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4758
4770
|
content: z13.string().max(2e3).optional(),
|
|
4759
4771
|
embeds: embedPredicate.array().max(10).optional(),
|
|
4760
4772
|
sticker_ids: z13.array(z13.string()).max(3).optional(),
|
|
4761
4773
|
poll: pollPredicate.optional(),
|
|
4774
|
+
shared_client_theme: sharedClientThemePredicate.optional(),
|
|
4762
4775
|
components: basicActionRowPredicate.array().max(5).optional(),
|
|
4763
4776
|
flags: z13.int().optional().refine((flags) => !flags || (flags & MessageFlags.IsComponentsV2) === 0, {
|
|
4764
|
-
error: "Cannot set content, embeds, stickers, or
|
|
4777
|
+
error: "Cannot set content, embeds, stickers, poll, or shared client theme with IsComponentsV2 flag set"
|
|
4765
4778
|
})
|
|
4766
4779
|
}).refine(
|
|
4767
|
-
(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,
|
|
4768
|
-
{
|
|
4780
|
+
(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,
|
|
4781
|
+
{
|
|
4782
|
+
error: "Messages must have content, embeds, a poll, attachments, components, stickers, or a shared client theme"
|
|
4783
|
+
}
|
|
4769
4784
|
);
|
|
4770
4785
|
var allTopLevelComponentsPredicate = z13.union([
|
|
4771
4786
|
basicActionRowPredicate,
|
|
@@ -4791,7 +4806,8 @@ var messageComponentsV2Predicate = baseMessagePredicate.extend({
|
|
|
4791
4806
|
content: z13.string().length(0).nullish(),
|
|
4792
4807
|
embeds: z13.array(z13.never()).nullish(),
|
|
4793
4808
|
sticker_ids: z13.array(z13.never()).nullish(),
|
|
4794
|
-
poll: z13.null().optional()
|
|
4809
|
+
poll: z13.null().optional(),
|
|
4810
|
+
shared_client_theme: z13.null().optional()
|
|
4795
4811
|
});
|
|
4796
4812
|
var messagePredicate = z13.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
|
|
4797
4813
|
var fileBodyMessagePredicate = z13.object({
|
|
@@ -4986,7 +5002,7 @@ var AttachmentBuilder = class {
|
|
|
4986
5002
|
/**
|
|
4987
5003
|
* This data is not included in the output of `toJSON()`. For this class specifically, this refers to binary data
|
|
4988
5004
|
* that will wind up being included in the multipart/form-data request, if used with the `MessageBuilder`.
|
|
4989
|
-
* To retrieve this data, use {@link getRawFile}.
|
|
5005
|
+
* To retrieve this data, use {@link AttachmentBuilder.getRawFile}.
|
|
4990
5006
|
*
|
|
4991
5007
|
* @remarks This cannot be set via the constructor, primarily because of the behavior described
|
|
4992
5008
|
* {@link https://discord.com/developers/docs/reference#editing-message-attachments | here}.
|
|
@@ -5068,7 +5084,7 @@ var AttachmentBuilder = class {
|
|
|
5068
5084
|
* Sets the file data to upload with this attachment.
|
|
5069
5085
|
*
|
|
5070
5086
|
* @param data - The file data
|
|
5071
|
-
* @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
|
|
5087
|
+
* @remarks Note that this data is NOT included in the {@link AttachmentBuilder.toJSON} output. To retrieve it, use {@link AttachmentBuilder.getRawFile}.
|
|
5072
5088
|
*/
|
|
5073
5089
|
setFileData(data) {
|
|
5074
5090
|
this.fileData.data = data;
|
|
@@ -5084,7 +5100,7 @@ var AttachmentBuilder = class {
|
|
|
5084
5100
|
/**
|
|
5085
5101
|
* Sets the content type of the file data to upload with this attachment.
|
|
5086
5102
|
*
|
|
5087
|
-
* @remarks Note that this data is NOT included in the {@link toJSON} output. To retrieve it, use {@link getRawFile}.
|
|
5103
|
+
* @remarks Note that this data is NOT included in the {@link AttachmentBuilder.toJSON} output. To retrieve it, use {@link AttachmentBuilder.getRawFile}.
|
|
5088
5104
|
*/
|
|
5089
5105
|
setFileContentType(contentType) {
|
|
5090
5106
|
this.fileData.contentType = contentType;
|
|
@@ -5098,9 +5114,9 @@ var AttachmentBuilder = class {
|
|
|
5098
5114
|
return this;
|
|
5099
5115
|
}
|
|
5100
5116
|
/**
|
|
5101
|
-
* Converts this attachment to a {@link RawFile} for uploading.
|
|
5117
|
+
* Converts this attachment to a {@link @discordjs/util#RawFile} for uploading.
|
|
5102
5118
|
*
|
|
5103
|
-
* @returns A {@link RawFile} object, or `undefined` if no file data is set
|
|
5119
|
+
* @returns A {@link @discordjs/util#RawFile} object, or `undefined` if no file data is set
|
|
5104
5120
|
*/
|
|
5105
5121
|
getRawFile() {
|
|
5106
5122
|
if (!this.fileData?.data) {
|
|
@@ -5255,6 +5271,86 @@ var MessageReferenceBuilder = class {
|
|
|
5255
5271
|
}
|
|
5256
5272
|
};
|
|
5257
5273
|
|
|
5274
|
+
// src/messages/SharedClientTheme.ts
|
|
5275
|
+
var SharedClientThemeBuilder = class {
|
|
5276
|
+
static {
|
|
5277
|
+
__name(this, "SharedClientThemeBuilder");
|
|
5278
|
+
}
|
|
5279
|
+
/**
|
|
5280
|
+
* The API data associated with this shared client theme.
|
|
5281
|
+
*/
|
|
5282
|
+
data;
|
|
5283
|
+
/**
|
|
5284
|
+
* Creates a new shared client theme builder.
|
|
5285
|
+
*
|
|
5286
|
+
* @param data - The API data to create this shared client theme with
|
|
5287
|
+
*/
|
|
5288
|
+
constructor(data = {}) {
|
|
5289
|
+
this.data = structuredClone(data);
|
|
5290
|
+
}
|
|
5291
|
+
/**
|
|
5292
|
+
* Sets the colors of this theme.
|
|
5293
|
+
*
|
|
5294
|
+
* @remarks
|
|
5295
|
+
* A maximum of 5 hexadecimal-encoded colors may be provided.
|
|
5296
|
+
* @param colors - The hexadecimal-encoded colors to set (e.g. `'5865F2'`)
|
|
5297
|
+
*/
|
|
5298
|
+
setColors(...colors) {
|
|
5299
|
+
this.data.colors = normalizeArray(colors);
|
|
5300
|
+
return this;
|
|
5301
|
+
}
|
|
5302
|
+
/**
|
|
5303
|
+
* Sets the gradient angle of this theme.
|
|
5304
|
+
*
|
|
5305
|
+
* @remarks
|
|
5306
|
+
* The value must be between `0` and `360` (inclusive).
|
|
5307
|
+
* @param angle - The gradient angle (direction of theme colors)
|
|
5308
|
+
*/
|
|
5309
|
+
setGradientAngle(angle) {
|
|
5310
|
+
this.data.gradient_angle = angle;
|
|
5311
|
+
return this;
|
|
5312
|
+
}
|
|
5313
|
+
/**
|
|
5314
|
+
* Sets the base mix (intensity) of this theme.
|
|
5315
|
+
*
|
|
5316
|
+
* @remarks
|
|
5317
|
+
* The value must be between `0` and `100` (inclusive).
|
|
5318
|
+
* @param baseMix - The base mix intensity
|
|
5319
|
+
*/
|
|
5320
|
+
setBaseMix(baseMix) {
|
|
5321
|
+
this.data.base_mix = baseMix;
|
|
5322
|
+
return this;
|
|
5323
|
+
}
|
|
5324
|
+
/**
|
|
5325
|
+
* Sets the base theme (mode) of this theme.
|
|
5326
|
+
*
|
|
5327
|
+
* @param baseTheme - The base theme mode
|
|
5328
|
+
*/
|
|
5329
|
+
setBaseTheme(baseTheme) {
|
|
5330
|
+
this.data.base_theme = baseTheme;
|
|
5331
|
+
return this;
|
|
5332
|
+
}
|
|
5333
|
+
/**
|
|
5334
|
+
* Clears the base theme of this theme.
|
|
5335
|
+
*/
|
|
5336
|
+
clearBaseTheme() {
|
|
5337
|
+
this.data.base_theme = void 0;
|
|
5338
|
+
return this;
|
|
5339
|
+
}
|
|
5340
|
+
/**
|
|
5341
|
+
* Serializes this builder to API-compatible JSON data.
|
|
5342
|
+
*
|
|
5343
|
+
* Note that by disabling validation, there is no guarantee that the resulting object will be valid.
|
|
5344
|
+
*
|
|
5345
|
+
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
5346
|
+
*/
|
|
5347
|
+
toJSON(validationOverride) {
|
|
5348
|
+
const data = structuredClone(this.data);
|
|
5349
|
+
validate(sharedClientThemePredicate, data, validationOverride);
|
|
5350
|
+
return data;
|
|
5351
|
+
}
|
|
5352
|
+
};
|
|
5353
|
+
|
|
5258
5354
|
// src/messages/Message.ts
|
|
5259
5355
|
var MessageBuilder = class {
|
|
5260
5356
|
static {
|
|
@@ -5288,7 +5384,16 @@ var MessageBuilder = class {
|
|
|
5288
5384
|
* @param data - The API data to create this message with
|
|
5289
5385
|
*/
|
|
5290
5386
|
constructor(data = {}) {
|
|
5291
|
-
const {
|
|
5387
|
+
const {
|
|
5388
|
+
attachments = [],
|
|
5389
|
+
embeds = [],
|
|
5390
|
+
components = [],
|
|
5391
|
+
message_reference,
|
|
5392
|
+
poll,
|
|
5393
|
+
allowed_mentions,
|
|
5394
|
+
shared_client_theme,
|
|
5395
|
+
...rest
|
|
5396
|
+
} = data;
|
|
5292
5397
|
this.data = {
|
|
5293
5398
|
...structuredClone(rest),
|
|
5294
5399
|
allowed_mentions: allowed_mentions && new AllowedMentionsBuilder(allowed_mentions),
|
|
@@ -5296,7 +5401,8 @@ var MessageBuilder = class {
|
|
|
5296
5401
|
embeds: embeds.map((embed) => new EmbedBuilder(embed)),
|
|
5297
5402
|
poll: poll && new PollBuilder(poll),
|
|
5298
5403
|
components: components.map((component) => createComponentBuilder(component)),
|
|
5299
|
-
message_reference: message_reference && new MessageReferenceBuilder(message_reference)
|
|
5404
|
+
message_reference: message_reference && new MessageReferenceBuilder(message_reference),
|
|
5405
|
+
shared_client_theme: shared_client_theme && new SharedClientThemeBuilder(shared_client_theme)
|
|
5300
5406
|
};
|
|
5301
5407
|
}
|
|
5302
5408
|
/**
|
|
@@ -5726,6 +5832,31 @@ var MessageBuilder = class {
|
|
|
5726
5832
|
this.data.poll = void 0;
|
|
5727
5833
|
return this;
|
|
5728
5834
|
}
|
|
5835
|
+
/**
|
|
5836
|
+
* Sets the shared client theme for this message.
|
|
5837
|
+
*
|
|
5838
|
+
* @param theme - The shared client theme to set
|
|
5839
|
+
*/
|
|
5840
|
+
setSharedClientTheme(theme) {
|
|
5841
|
+
this.data.shared_client_theme = resolveBuilder(theme, SharedClientThemeBuilder);
|
|
5842
|
+
return this;
|
|
5843
|
+
}
|
|
5844
|
+
/**
|
|
5845
|
+
* Updates the shared client theme for this message (and creates it if it doesn't exist).
|
|
5846
|
+
*
|
|
5847
|
+
* @param updater - The function to update the shared client theme with
|
|
5848
|
+
*/
|
|
5849
|
+
updateSharedClientTheme(updater) {
|
|
5850
|
+
updater(this.data.shared_client_theme ??= new SharedClientThemeBuilder());
|
|
5851
|
+
return this;
|
|
5852
|
+
}
|
|
5853
|
+
/**
|
|
5854
|
+
* Clears the shared client theme for this message.
|
|
5855
|
+
*/
|
|
5856
|
+
clearSharedClientTheme() {
|
|
5857
|
+
this.data.shared_client_theme = void 0;
|
|
5858
|
+
return this;
|
|
5859
|
+
}
|
|
5729
5860
|
/**
|
|
5730
5861
|
* Serializes this builder to API-compatible JSON data.
|
|
5731
5862
|
*
|
|
@@ -5734,7 +5865,7 @@ var MessageBuilder = class {
|
|
|
5734
5865
|
* @param validationOverride - Force validation to run/not run regardless of your global preference
|
|
5735
5866
|
*/
|
|
5736
5867
|
toJSON(validationOverride) {
|
|
5737
|
-
const { poll, allowed_mentions, attachments, embeds, components, message_reference, ...rest } = this.data;
|
|
5868
|
+
const { poll, allowed_mentions, attachments, embeds, components, message_reference, shared_client_theme, ...rest } = this.data;
|
|
5738
5869
|
const data = {
|
|
5739
5870
|
...structuredClone(rest),
|
|
5740
5871
|
// Wherever we pass false, it's covered by the messagePredicate already
|
|
@@ -5744,7 +5875,8 @@ var MessageBuilder = class {
|
|
|
5744
5875
|
embeds: embeds.map((embed) => embed.toJSON(false)),
|
|
5745
5876
|
// Here, the messagePredicate does specific constraints rather than using the componentPredicate
|
|
5746
5877
|
components: components.map((component) => component.toJSON(validationOverride)),
|
|
5747
|
-
message_reference: message_reference?.toJSON(false)
|
|
5878
|
+
message_reference: message_reference?.toJSON(false),
|
|
5879
|
+
shared_client_theme: shared_client_theme?.toJSON(false)
|
|
5748
5880
|
};
|
|
5749
5881
|
validate(messagePredicate, data, validationOverride);
|
|
5750
5882
|
return data;
|
|
@@ -5773,7 +5905,7 @@ var MessageBuilder = class {
|
|
|
5773
5905
|
};
|
|
5774
5906
|
|
|
5775
5907
|
// src/index.ts
|
|
5776
|
-
var version = "2.0.0-dev.
|
|
5908
|
+
var version = "2.0.0-dev.1779528402-e721e51b0";
|
|
5777
5909
|
export {
|
|
5778
5910
|
ActionRowBuilder,
|
|
5779
5911
|
AllowedMentionsBuilder,
|
|
@@ -5834,6 +5966,7 @@ export {
|
|
|
5834
5966
|
SeparatorBuilder,
|
|
5835
5967
|
SharedChatInputCommandOptions,
|
|
5836
5968
|
SharedChatInputCommandSubcommands,
|
|
5969
|
+
SharedClientThemeBuilder,
|
|
5837
5970
|
SharedName,
|
|
5838
5971
|
SharedNameAndDescription,
|
|
5839
5972
|
StringSelectMenuBuilder,
|
|
@@ -5900,6 +6033,7 @@ export {
|
|
|
5900
6033
|
selectMenuStringPredicate,
|
|
5901
6034
|
selectMenuUserPredicate,
|
|
5902
6035
|
separatorPredicate,
|
|
6036
|
+
sharedClientThemePredicate,
|
|
5903
6037
|
snowflakePredicate,
|
|
5904
6038
|
stringOptionPredicate,
|
|
5905
6039
|
textDisplayPredicate,
|