@discordjs/builders 2.0.0-dev.1745194448-8f35dfd03 → 2.0.0-dev.1745453588-abc5d99ce
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 +1516 -373
- package/dist/index.d.ts +1516 -373
- package/dist/index.js +1271 -274
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1238 -257
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -55,7 +55,10 @@ __export(index_exports, {
|
|
|
55
55
|
EmbedFieldBuilder: () => EmbedFieldBuilder,
|
|
56
56
|
EmbedFooterBuilder: () => EmbedFooterBuilder,
|
|
57
57
|
EmojiOrLabelButtonMixin: () => EmojiOrLabelButtonMixin,
|
|
58
|
+
FileBuilder: () => FileBuilder,
|
|
58
59
|
LinkButtonBuilder: () => LinkButtonBuilder,
|
|
60
|
+
MediaGalleryBuilder: () => MediaGalleryBuilder,
|
|
61
|
+
MediaGalleryItemBuilder: () => MediaGalleryItemBuilder,
|
|
59
62
|
MentionableSelectMenuBuilder: () => MentionableSelectMenuBuilder,
|
|
60
63
|
MessageBuilder: () => MessageBuilder,
|
|
61
64
|
MessageContextCommandBuilder: () => MessageContextCommandBuilder,
|
|
@@ -70,6 +73,8 @@ __export(index_exports, {
|
|
|
70
73
|
PrimaryButtonBuilder: () => PrimaryButtonBuilder,
|
|
71
74
|
RoleSelectMenuBuilder: () => RoleSelectMenuBuilder,
|
|
72
75
|
SecondaryButtonBuilder: () => SecondaryButtonBuilder,
|
|
76
|
+
SectionBuilder: () => SectionBuilder,
|
|
77
|
+
SeparatorBuilder: () => SeparatorBuilder,
|
|
73
78
|
SharedChatInputCommandOptions: () => SharedChatInputCommandOptions,
|
|
74
79
|
SharedChatInputCommandSubcommands: () => SharedChatInputCommandSubcommands,
|
|
75
80
|
SharedName: () => SharedName,
|
|
@@ -77,7 +82,9 @@ __export(index_exports, {
|
|
|
77
82
|
StringSelectMenuBuilder: () => StringSelectMenuBuilder,
|
|
78
83
|
StringSelectMenuOptionBuilder: () => StringSelectMenuOptionBuilder,
|
|
79
84
|
SuccessButtonBuilder: () => SuccessButtonBuilder,
|
|
85
|
+
TextDisplayBuilder: () => TextDisplayBuilder,
|
|
80
86
|
TextInputBuilder: () => TextInputBuilder,
|
|
87
|
+
ThumbnailBuilder: () => ThumbnailBuilder,
|
|
81
88
|
UserContextCommandBuilder: () => UserContextCommandBuilder,
|
|
82
89
|
UserSelectMenuBuilder: () => UserSelectMenuBuilder,
|
|
83
90
|
actionRowPredicate: () => actionRowPredicate,
|
|
@@ -89,6 +96,7 @@ __export(index_exports, {
|
|
|
89
96
|
chatInputCommandPredicate: () => chatInputCommandPredicate,
|
|
90
97
|
chatInputCommandSubcommandGroupPredicate: () => chatInputCommandSubcommandGroupPredicate,
|
|
91
98
|
chatInputCommandSubcommandPredicate: () => chatInputCommandSubcommandPredicate,
|
|
99
|
+
containerPredicate: () => containerPredicate,
|
|
92
100
|
createComponentBuilder: () => createComponentBuilder,
|
|
93
101
|
customIdPredicate: () => customIdPredicate,
|
|
94
102
|
disableValidators: () => disableValidators,
|
|
@@ -99,9 +107,12 @@ __export(index_exports, {
|
|
|
99
107
|
embedPredicate: () => embedPredicate,
|
|
100
108
|
emojiPredicate: () => emojiPredicate,
|
|
101
109
|
enableValidators: () => enableValidators,
|
|
110
|
+
filePredicate: () => filePredicate,
|
|
102
111
|
integerOptionPredicate: () => integerOptionPredicate,
|
|
103
112
|
isValidationEnabled: () => isValidationEnabled,
|
|
104
113
|
localeMapPredicate: () => localeMapPredicate,
|
|
114
|
+
mediaGalleryItemPredicate: () => mediaGalleryItemPredicate,
|
|
115
|
+
mediaGalleryPredicate: () => mediaGalleryPredicate,
|
|
105
116
|
memberPermissionsPredicate: () => memberPermissionsPredicate,
|
|
106
117
|
messageCommandPredicate: () => messageCommandPredicate,
|
|
107
118
|
messagePredicate: () => messagePredicate,
|
|
@@ -114,15 +125,20 @@ __export(index_exports, {
|
|
|
114
125
|
pollPredicate: () => pollPredicate,
|
|
115
126
|
pollQuestionPredicate: () => pollQuestionPredicate,
|
|
116
127
|
refineURLPredicate: () => refineURLPredicate,
|
|
128
|
+
resolveAccessoryComponent: () => resolveAccessoryComponent,
|
|
117
129
|
resolveBuilder: () => resolveBuilder,
|
|
130
|
+
sectionPredicate: () => sectionPredicate,
|
|
118
131
|
selectMenuChannelPredicate: () => selectMenuChannelPredicate,
|
|
119
132
|
selectMenuMentionablePredicate: () => selectMenuMentionablePredicate,
|
|
120
133
|
selectMenuRolePredicate: () => selectMenuRolePredicate,
|
|
121
134
|
selectMenuStringOptionPredicate: () => selectMenuStringOptionPredicate,
|
|
122
135
|
selectMenuStringPredicate: () => selectMenuStringPredicate,
|
|
123
136
|
selectMenuUserPredicate: () => selectMenuUserPredicate,
|
|
137
|
+
separatorPredicate: () => separatorPredicate,
|
|
124
138
|
stringOptionPredicate: () => stringOptionPredicate,
|
|
139
|
+
textDisplayPredicate: () => textDisplayPredicate,
|
|
125
140
|
textInputPredicate: () => textInputPredicate,
|
|
141
|
+
thumbnailPredicate: () => thumbnailPredicate,
|
|
126
142
|
userCommandPredicate: () => userCommandPredicate,
|
|
127
143
|
validate: () => validate,
|
|
128
144
|
version: () => version
|
|
@@ -328,6 +344,22 @@ var ComponentBuilder = class {
|
|
|
328
344
|
static {
|
|
329
345
|
__name(this, "ComponentBuilder");
|
|
330
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Sets the id of this component.
|
|
349
|
+
*
|
|
350
|
+
* @param id - The id to use
|
|
351
|
+
*/
|
|
352
|
+
setId(id) {
|
|
353
|
+
this.data.id = id;
|
|
354
|
+
return this;
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Clears the id of this component, defaulting to a default incremented id.
|
|
358
|
+
*/
|
|
359
|
+
clearId() {
|
|
360
|
+
this.data.id = void 0;
|
|
361
|
+
return this;
|
|
362
|
+
}
|
|
331
363
|
};
|
|
332
364
|
|
|
333
365
|
// src/components/button/Button.ts
|
|
@@ -1121,175 +1153,1023 @@ var textInputPredicate = import_zod3.z.object({
|
|
|
1121
1153
|
required: import_zod3.z.boolean().optional()
|
|
1122
1154
|
});
|
|
1123
1155
|
|
|
1124
|
-
// src/components/textInput/TextInput.ts
|
|
1125
|
-
var TextInputBuilder = class extends ComponentBuilder {
|
|
1156
|
+
// src/components/textInput/TextInput.ts
|
|
1157
|
+
var TextInputBuilder = class extends ComponentBuilder {
|
|
1158
|
+
static {
|
|
1159
|
+
__name(this, "TextInputBuilder");
|
|
1160
|
+
}
|
|
1161
|
+
data;
|
|
1162
|
+
/**
|
|
1163
|
+
* Creates a new text input from API data.
|
|
1164
|
+
*
|
|
1165
|
+
* @param data - The API data to create this text input with
|
|
1166
|
+
* @example
|
|
1167
|
+
* Creating a text input from an API data object:
|
|
1168
|
+
* ```ts
|
|
1169
|
+
* const textInput = new TextInputBuilder({
|
|
1170
|
+
* custom_id: 'a cool text input',
|
|
1171
|
+
* label: 'Type something',
|
|
1172
|
+
* style: TextInputStyle.Short,
|
|
1173
|
+
* });
|
|
1174
|
+
* ```
|
|
1175
|
+
* @example
|
|
1176
|
+
* Creating a text input using setters and API data:
|
|
1177
|
+
* ```ts
|
|
1178
|
+
* const textInput = new TextInputBuilder({
|
|
1179
|
+
* label: 'Type something else',
|
|
1180
|
+
* })
|
|
1181
|
+
* .setCustomId('woah')
|
|
1182
|
+
* .setStyle(TextInputStyle.Paragraph);
|
|
1183
|
+
* ```
|
|
1184
|
+
*/
|
|
1185
|
+
constructor(data = {}) {
|
|
1186
|
+
super();
|
|
1187
|
+
this.data = { ...structuredClone(data), type: import_v1012.ComponentType.TextInput };
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* Sets the custom id for this text input.
|
|
1191
|
+
*
|
|
1192
|
+
* @param customId - The custom id to use
|
|
1193
|
+
*/
|
|
1194
|
+
setCustomId(customId) {
|
|
1195
|
+
this.data.custom_id = customId;
|
|
1196
|
+
return this;
|
|
1197
|
+
}
|
|
1198
|
+
/**
|
|
1199
|
+
* Sets the label for this text input.
|
|
1200
|
+
*
|
|
1201
|
+
* @param label - The label to use
|
|
1202
|
+
*/
|
|
1203
|
+
setLabel(label) {
|
|
1204
|
+
this.data.label = label;
|
|
1205
|
+
return this;
|
|
1206
|
+
}
|
|
1207
|
+
/**
|
|
1208
|
+
* Sets the style for this text input.
|
|
1209
|
+
*
|
|
1210
|
+
* @param style - The style to use
|
|
1211
|
+
*/
|
|
1212
|
+
setStyle(style) {
|
|
1213
|
+
this.data.style = style;
|
|
1214
|
+
return this;
|
|
1215
|
+
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Sets the minimum length of text for this text input.
|
|
1218
|
+
*
|
|
1219
|
+
* @param minLength - The minimum length of text for this text input
|
|
1220
|
+
*/
|
|
1221
|
+
setMinLength(minLength) {
|
|
1222
|
+
this.data.min_length = minLength;
|
|
1223
|
+
return this;
|
|
1224
|
+
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Clears the minimum length of text for this text input.
|
|
1227
|
+
*/
|
|
1228
|
+
clearMinLength() {
|
|
1229
|
+
this.data.min_length = void 0;
|
|
1230
|
+
return this;
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* Sets the maximum length of text for this text input.
|
|
1234
|
+
*
|
|
1235
|
+
* @param maxLength - The maximum length of text for this text input
|
|
1236
|
+
*/
|
|
1237
|
+
setMaxLength(maxLength) {
|
|
1238
|
+
this.data.max_length = maxLength;
|
|
1239
|
+
return this;
|
|
1240
|
+
}
|
|
1241
|
+
/**
|
|
1242
|
+
* Clears the maximum length of text for this text input.
|
|
1243
|
+
*/
|
|
1244
|
+
clearMaxLength() {
|
|
1245
|
+
this.data.max_length = void 0;
|
|
1246
|
+
return this;
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1249
|
+
* Sets the placeholder for this text input.
|
|
1250
|
+
*
|
|
1251
|
+
* @param placeholder - The placeholder to use
|
|
1252
|
+
*/
|
|
1253
|
+
setPlaceholder(placeholder) {
|
|
1254
|
+
this.data.placeholder = placeholder;
|
|
1255
|
+
return this;
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Clears the placeholder for this text input.
|
|
1259
|
+
*/
|
|
1260
|
+
clearPlaceholder() {
|
|
1261
|
+
this.data.placeholder = void 0;
|
|
1262
|
+
return this;
|
|
1263
|
+
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Sets the value for this text input.
|
|
1266
|
+
*
|
|
1267
|
+
* @param value - The value to use
|
|
1268
|
+
*/
|
|
1269
|
+
setValue(value) {
|
|
1270
|
+
this.data.value = value;
|
|
1271
|
+
return this;
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Clears the value for this text input.
|
|
1275
|
+
*/
|
|
1276
|
+
clearValue() {
|
|
1277
|
+
this.data.value = void 0;
|
|
1278
|
+
return this;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Sets whether this text input is required.
|
|
1282
|
+
*
|
|
1283
|
+
* @param required - Whether this text input is required
|
|
1284
|
+
*/
|
|
1285
|
+
setRequired(required = true) {
|
|
1286
|
+
this.data.required = required;
|
|
1287
|
+
return this;
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1291
|
+
*/
|
|
1292
|
+
toJSON(validationOverride) {
|
|
1293
|
+
const clone = structuredClone(this.data);
|
|
1294
|
+
validate(textInputPredicate, clone, validationOverride);
|
|
1295
|
+
return clone;
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
// src/components/ActionRow.ts
|
|
1300
|
+
var import_v1022 = require("discord-api-types/v10");
|
|
1301
|
+
|
|
1302
|
+
// src/components/Components.ts
|
|
1303
|
+
var import_v1021 = require("discord-api-types/v10");
|
|
1304
|
+
|
|
1305
|
+
// src/components/v2/Container.ts
|
|
1306
|
+
var import_v1020 = require("discord-api-types/v10");
|
|
1307
|
+
|
|
1308
|
+
// src/components/v2/Assertions.ts
|
|
1309
|
+
var import_v1013 = require("discord-api-types/v10");
|
|
1310
|
+
var import_zod4 = require("zod");
|
|
1311
|
+
var unfurledMediaItemPredicate = import_zod4.z.object({
|
|
1312
|
+
url: import_zod4.z.string().url().refine(refineURLPredicate(["http:", "https:", "attachment:"]), {
|
|
1313
|
+
message: "Invalid protocol for media URL. Must be http:, https:, or attachment:"
|
|
1314
|
+
})
|
|
1315
|
+
});
|
|
1316
|
+
var thumbnailPredicate = import_zod4.z.object({
|
|
1317
|
+
media: unfurledMediaItemPredicate,
|
|
1318
|
+
description: import_zod4.z.string().min(1).max(1024).nullish(),
|
|
1319
|
+
spoiler: import_zod4.z.boolean().optional()
|
|
1320
|
+
});
|
|
1321
|
+
var unfurledMediaItemAttachmentOnlyPredicate = import_zod4.z.object({
|
|
1322
|
+
url: import_zod4.z.string().url().refine(refineURLPredicate(["attachment:"]), {
|
|
1323
|
+
message: "Invalid protocol for file URL. Must be attachment:"
|
|
1324
|
+
})
|
|
1325
|
+
});
|
|
1326
|
+
var filePredicate = import_zod4.z.object({
|
|
1327
|
+
file: unfurledMediaItemAttachmentOnlyPredicate,
|
|
1328
|
+
spoiler: import_zod4.z.boolean().optional()
|
|
1329
|
+
});
|
|
1330
|
+
var separatorPredicate = import_zod4.z.object({
|
|
1331
|
+
divider: import_zod4.z.boolean().optional(),
|
|
1332
|
+
spacing: import_zod4.z.nativeEnum(import_v1013.SeparatorSpacingSize).optional()
|
|
1333
|
+
});
|
|
1334
|
+
var textDisplayPredicate = import_zod4.z.object({
|
|
1335
|
+
content: import_zod4.z.string().min(1).max(4e3)
|
|
1336
|
+
});
|
|
1337
|
+
var mediaGalleryItemPredicate = import_zod4.z.object({
|
|
1338
|
+
media: unfurledMediaItemPredicate,
|
|
1339
|
+
description: import_zod4.z.string().min(1).max(1024).nullish(),
|
|
1340
|
+
spoiler: import_zod4.z.boolean().optional()
|
|
1341
|
+
});
|
|
1342
|
+
var mediaGalleryPredicate = import_zod4.z.object({
|
|
1343
|
+
items: import_zod4.z.array(mediaGalleryItemPredicate).min(1).max(10)
|
|
1344
|
+
});
|
|
1345
|
+
var sectionPredicate = import_zod4.z.object({
|
|
1346
|
+
components: import_zod4.z.array(textDisplayPredicate).min(1).max(3),
|
|
1347
|
+
accessory: import_zod4.z.union([
|
|
1348
|
+
import_zod4.z.object({ type: import_zod4.z.literal(import_v1013.ComponentType.Button) }),
|
|
1349
|
+
import_zod4.z.object({ type: import_zod4.z.literal(import_v1013.ComponentType.Thumbnail) })
|
|
1350
|
+
])
|
|
1351
|
+
});
|
|
1352
|
+
var containerPredicate = import_zod4.z.object({
|
|
1353
|
+
components: import_zod4.z.array(
|
|
1354
|
+
import_zod4.z.union([
|
|
1355
|
+
actionRowPredicate,
|
|
1356
|
+
filePredicate,
|
|
1357
|
+
mediaGalleryPredicate,
|
|
1358
|
+
sectionPredicate,
|
|
1359
|
+
separatorPredicate,
|
|
1360
|
+
textDisplayPredicate
|
|
1361
|
+
])
|
|
1362
|
+
).min(1).max(10),
|
|
1363
|
+
spoiler: import_zod4.z.boolean().optional(),
|
|
1364
|
+
accent_color: import_zod4.z.number().int().min(0).max(16777215).nullish()
|
|
1365
|
+
});
|
|
1366
|
+
|
|
1367
|
+
// src/components/v2/File.ts
|
|
1368
|
+
var import_v1014 = require("discord-api-types/v10");
|
|
1369
|
+
var FileBuilder = class extends ComponentBuilder {
|
|
1370
|
+
static {
|
|
1371
|
+
__name(this, "FileBuilder");
|
|
1372
|
+
}
|
|
1373
|
+
data;
|
|
1374
|
+
/**
|
|
1375
|
+
* Creates a new file from API data.
|
|
1376
|
+
*
|
|
1377
|
+
* @param data - The API data to create this file with
|
|
1378
|
+
* @example
|
|
1379
|
+
* Creating a file from an API data object:
|
|
1380
|
+
* ```ts
|
|
1381
|
+
* const file = new FileBuilder({
|
|
1382
|
+
* spoiler: true,
|
|
1383
|
+
* file: {
|
|
1384
|
+
* url: 'attachment://file.png',
|
|
1385
|
+
* },
|
|
1386
|
+
* });
|
|
1387
|
+
* ```
|
|
1388
|
+
* @example
|
|
1389
|
+
* Creating a file using setters and API data:
|
|
1390
|
+
* ```ts
|
|
1391
|
+
* const file = new FileBuilder({
|
|
1392
|
+
* file: {
|
|
1393
|
+
* url: 'attachment://image.jpg',
|
|
1394
|
+
* },
|
|
1395
|
+
* })
|
|
1396
|
+
* .setSpoiler(false);
|
|
1397
|
+
* ```
|
|
1398
|
+
*/
|
|
1399
|
+
constructor(data = {}) {
|
|
1400
|
+
super();
|
|
1401
|
+
this.data = {
|
|
1402
|
+
...structuredClone(data),
|
|
1403
|
+
file: data.file ? { url: data.file.url } : void 0,
|
|
1404
|
+
type: import_v1014.ComponentType.File
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Sets the spoiler status of this file.
|
|
1409
|
+
*
|
|
1410
|
+
* @param spoiler - The spoiler status to use
|
|
1411
|
+
*/
|
|
1412
|
+
setSpoiler(spoiler = true) {
|
|
1413
|
+
this.data.spoiler = spoiler;
|
|
1414
|
+
return this;
|
|
1415
|
+
}
|
|
1416
|
+
/**
|
|
1417
|
+
* Sets the media URL of this file.
|
|
1418
|
+
*
|
|
1419
|
+
* @param url - The URL to use
|
|
1420
|
+
*/
|
|
1421
|
+
setURL(url) {
|
|
1422
|
+
this.data.file = { url };
|
|
1423
|
+
return this;
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1427
|
+
*/
|
|
1428
|
+
toJSON(validationOverride) {
|
|
1429
|
+
const clone = structuredClone(this.data);
|
|
1430
|
+
validate(filePredicate, clone, validationOverride);
|
|
1431
|
+
return clone;
|
|
1432
|
+
}
|
|
1433
|
+
};
|
|
1434
|
+
|
|
1435
|
+
// src/components/v2/MediaGallery.ts
|
|
1436
|
+
var import_v1015 = require("discord-api-types/v10");
|
|
1437
|
+
|
|
1438
|
+
// src/components/v2/MediaGalleryItem.ts
|
|
1439
|
+
var MediaGalleryItemBuilder = class {
|
|
1440
|
+
static {
|
|
1441
|
+
__name(this, "MediaGalleryItemBuilder");
|
|
1442
|
+
}
|
|
1443
|
+
data;
|
|
1444
|
+
/**
|
|
1445
|
+
* Creates a new media gallery item from API data.
|
|
1446
|
+
*
|
|
1447
|
+
* @param data - The API data to create this media gallery item with
|
|
1448
|
+
* @example
|
|
1449
|
+
* Creating a media gallery item from an API data object:
|
|
1450
|
+
* ```ts
|
|
1451
|
+
* const item = new MediaGalleryItemBuilder({
|
|
1452
|
+
* description: "Some text here",
|
|
1453
|
+
* media: {
|
|
1454
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/2.png',
|
|
1455
|
+
* },
|
|
1456
|
+
* });
|
|
1457
|
+
* ```
|
|
1458
|
+
* @example
|
|
1459
|
+
* Creating a media gallery item using setters and API data:
|
|
1460
|
+
* ```ts
|
|
1461
|
+
* const item = new MediaGalleryItemBuilder({
|
|
1462
|
+
* media: {
|
|
1463
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/5.png',
|
|
1464
|
+
* },
|
|
1465
|
+
* })
|
|
1466
|
+
* .setDescription("alt text");
|
|
1467
|
+
* ```
|
|
1468
|
+
*/
|
|
1469
|
+
constructor(data = {}) {
|
|
1470
|
+
this.data = {
|
|
1471
|
+
...structuredClone(data)
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
/**
|
|
1475
|
+
* Sets the source URL of this media gallery item.
|
|
1476
|
+
*
|
|
1477
|
+
* @param url - The URL to use
|
|
1478
|
+
*/
|
|
1479
|
+
setURL(url) {
|
|
1480
|
+
this.data.media = { url };
|
|
1481
|
+
return this;
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Sets the description of this thumbnail.
|
|
1485
|
+
*
|
|
1486
|
+
* @param description - The description to use
|
|
1487
|
+
*/
|
|
1488
|
+
setDescription(description) {
|
|
1489
|
+
this.data.description = description;
|
|
1490
|
+
return this;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Clears the description of this thumbnail.
|
|
1494
|
+
*/
|
|
1495
|
+
clearDescription() {
|
|
1496
|
+
this.data.description = void 0;
|
|
1497
|
+
return this;
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Sets the spoiler status of this thumbnail.
|
|
1501
|
+
*
|
|
1502
|
+
* @param spoiler - The spoiler status to use
|
|
1503
|
+
*/
|
|
1504
|
+
setSpoiler(spoiler = true) {
|
|
1505
|
+
this.data.spoiler = spoiler;
|
|
1506
|
+
return this;
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Transforms this object to its JSON format
|
|
1510
|
+
*/
|
|
1511
|
+
toJSON(validationOverride) {
|
|
1512
|
+
const clone = structuredClone(this.data);
|
|
1513
|
+
validate(mediaGalleryItemPredicate, clone, validationOverride);
|
|
1514
|
+
return clone;
|
|
1515
|
+
}
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
// src/components/v2/MediaGallery.ts
|
|
1519
|
+
var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
1520
|
+
static {
|
|
1521
|
+
__name(this, "MediaGalleryBuilder");
|
|
1522
|
+
}
|
|
1523
|
+
data;
|
|
1524
|
+
/**
|
|
1525
|
+
* Creates a new media gallery from API data.
|
|
1526
|
+
*
|
|
1527
|
+
* @param data - The API data to create this container with
|
|
1528
|
+
* @example
|
|
1529
|
+
* Creating a media gallery from an API data object:
|
|
1530
|
+
* ```ts
|
|
1531
|
+
* const mediaGallery = new MediaGalleryBuilder({
|
|
1532
|
+
* items: [
|
|
1533
|
+
* {
|
|
1534
|
+
* description: "Some text here",
|
|
1535
|
+
* media: {
|
|
1536
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/2.png',
|
|
1537
|
+
* },
|
|
1538
|
+
* },
|
|
1539
|
+
* ],
|
|
1540
|
+
* });
|
|
1541
|
+
* ```
|
|
1542
|
+
* @example
|
|
1543
|
+
* Creating a media gallery using setters and API data:
|
|
1544
|
+
* ```ts
|
|
1545
|
+
* const mediaGallery = new MediaGalleryBuilder({
|
|
1546
|
+
* items: [
|
|
1547
|
+
* {
|
|
1548
|
+
* description: "alt text",
|
|
1549
|
+
* media: {
|
|
1550
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/5.png',
|
|
1551
|
+
* },
|
|
1552
|
+
* },
|
|
1553
|
+
* ],
|
|
1554
|
+
* })
|
|
1555
|
+
* .addItems(item2, item3);
|
|
1556
|
+
* ```
|
|
1557
|
+
*/
|
|
1558
|
+
constructor(data = {}) {
|
|
1559
|
+
super();
|
|
1560
|
+
this.data = {
|
|
1561
|
+
items: data?.items?.map((item) => new MediaGalleryItemBuilder(item)) ?? [],
|
|
1562
|
+
type: import_v1015.ComponentType.MediaGallery
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
/**
|
|
1566
|
+
* The items in this media gallery.
|
|
1567
|
+
*/
|
|
1568
|
+
get items() {
|
|
1569
|
+
return this.data.items;
|
|
1570
|
+
}
|
|
1571
|
+
/**
|
|
1572
|
+
* Adds a media gallery item to this media gallery.
|
|
1573
|
+
*
|
|
1574
|
+
* @param input - The items to add
|
|
1575
|
+
*/
|
|
1576
|
+
addItems(...input) {
|
|
1577
|
+
const normalized = normalizeArray(input);
|
|
1578
|
+
const resolved = normalized.map((item) => resolveBuilder(item, MediaGalleryItemBuilder));
|
|
1579
|
+
this.data.items.push(...resolved);
|
|
1580
|
+
return this;
|
|
1581
|
+
}
|
|
1582
|
+
/**
|
|
1583
|
+
* Removes, replaces, or inserts media gallery items for this media gallery.
|
|
1584
|
+
*
|
|
1585
|
+
* @param index - The index to start removing, replacing or inserting items
|
|
1586
|
+
* @param deleteCount - The amount of items to remove
|
|
1587
|
+
* @param items - The items to insert
|
|
1588
|
+
*/
|
|
1589
|
+
spliceItems(index, deleteCount, ...items) {
|
|
1590
|
+
const normalized = normalizeArray(items);
|
|
1591
|
+
const resolved = normalized.map((item) => resolveBuilder(item, MediaGalleryItemBuilder));
|
|
1592
|
+
this.data.items.splice(index, deleteCount, ...resolved);
|
|
1593
|
+
return this;
|
|
1594
|
+
}
|
|
1595
|
+
/**
|
|
1596
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1597
|
+
*/
|
|
1598
|
+
toJSON(validationOverride) {
|
|
1599
|
+
const { items, ...rest } = this.data;
|
|
1600
|
+
const data = {
|
|
1601
|
+
...structuredClone(rest),
|
|
1602
|
+
items: items.map((item) => item.toJSON(false))
|
|
1603
|
+
};
|
|
1604
|
+
validate(mediaGalleryPredicate, data, validationOverride);
|
|
1605
|
+
return data;
|
|
1606
|
+
}
|
|
1607
|
+
};
|
|
1608
|
+
|
|
1609
|
+
// src/components/v2/Section.ts
|
|
1610
|
+
var import_v1018 = require("discord-api-types/v10");
|
|
1611
|
+
|
|
1612
|
+
// src/components/v2/TextDisplay.ts
|
|
1613
|
+
var import_v1016 = require("discord-api-types/v10");
|
|
1614
|
+
var TextDisplayBuilder = class extends ComponentBuilder {
|
|
1615
|
+
static {
|
|
1616
|
+
__name(this, "TextDisplayBuilder");
|
|
1617
|
+
}
|
|
1618
|
+
data;
|
|
1619
|
+
/**
|
|
1620
|
+
* Creates a new text display from API data.
|
|
1621
|
+
*
|
|
1622
|
+
* @param data - The API data to create this text display with
|
|
1623
|
+
* @example
|
|
1624
|
+
* Creating a text display from an API data object:
|
|
1625
|
+
* ```ts
|
|
1626
|
+
* const textDisplay = new TextDisplayBuilder({
|
|
1627
|
+
* content: 'some text',
|
|
1628
|
+
* });
|
|
1629
|
+
* ```
|
|
1630
|
+
* @example
|
|
1631
|
+
* Creating a text display using setters and API data:
|
|
1632
|
+
* ```ts
|
|
1633
|
+
* const textDisplay = new TextDisplayBuilder({
|
|
1634
|
+
* content: 'old text',
|
|
1635
|
+
* })
|
|
1636
|
+
* .setContent('new text');
|
|
1637
|
+
* ```
|
|
1638
|
+
*/
|
|
1639
|
+
constructor(data = {}) {
|
|
1640
|
+
super();
|
|
1641
|
+
this.data = {
|
|
1642
|
+
...structuredClone(data),
|
|
1643
|
+
type: import_v1016.ComponentType.TextDisplay
|
|
1644
|
+
};
|
|
1645
|
+
}
|
|
1646
|
+
/**
|
|
1647
|
+
* Sets the text of this text display.
|
|
1648
|
+
*
|
|
1649
|
+
* @param content - The text to use
|
|
1650
|
+
*/
|
|
1651
|
+
setContent(content) {
|
|
1652
|
+
this.data.content = content;
|
|
1653
|
+
return this;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1657
|
+
*/
|
|
1658
|
+
toJSON(validationOverride) {
|
|
1659
|
+
const clone = structuredClone(this.data);
|
|
1660
|
+
validate(textDisplayPredicate, clone, validationOverride);
|
|
1661
|
+
return clone;
|
|
1662
|
+
}
|
|
1663
|
+
};
|
|
1664
|
+
|
|
1665
|
+
// src/components/v2/Thumbnail.ts
|
|
1666
|
+
var import_v1017 = require("discord-api-types/v10");
|
|
1667
|
+
var ThumbnailBuilder = class extends ComponentBuilder {
|
|
1668
|
+
static {
|
|
1669
|
+
__name(this, "ThumbnailBuilder");
|
|
1670
|
+
}
|
|
1671
|
+
data;
|
|
1672
|
+
/**
|
|
1673
|
+
* Creates a new thumbnail from API data.
|
|
1674
|
+
*
|
|
1675
|
+
* @param data - The API data to create this thumbnail with
|
|
1676
|
+
* @example
|
|
1677
|
+
* Creating a thumbnail from an API data object:
|
|
1678
|
+
* ```ts
|
|
1679
|
+
* const thumbnail = new ThumbnailBuilder({
|
|
1680
|
+
* description: 'some text',
|
|
1681
|
+
* media: {
|
|
1682
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/4.png',
|
|
1683
|
+
* },
|
|
1684
|
+
* });
|
|
1685
|
+
* ```
|
|
1686
|
+
* @example
|
|
1687
|
+
* Creating a thumbnail using setters and API data:
|
|
1688
|
+
* ```ts
|
|
1689
|
+
* const thumbnail = new ThumbnailBuilder({
|
|
1690
|
+
* media: {
|
|
1691
|
+
* url: 'attachment://image.png',
|
|
1692
|
+
* },
|
|
1693
|
+
* })
|
|
1694
|
+
* .setDescription('alt text');
|
|
1695
|
+
* ```
|
|
1696
|
+
*/
|
|
1697
|
+
constructor(data = {}) {
|
|
1698
|
+
super();
|
|
1699
|
+
this.data = {
|
|
1700
|
+
...structuredClone(data),
|
|
1701
|
+
media: data.media ? { url: data.media.url } : void 0,
|
|
1702
|
+
type: import_v1017.ComponentType.Thumbnail
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
/**
|
|
1706
|
+
* Sets the description of this thumbnail.
|
|
1707
|
+
*
|
|
1708
|
+
* @param description - The description to use
|
|
1709
|
+
*/
|
|
1710
|
+
setDescription(description) {
|
|
1711
|
+
this.data.description = description;
|
|
1712
|
+
return this;
|
|
1713
|
+
}
|
|
1714
|
+
/**
|
|
1715
|
+
* Clears the description of this thumbnail.
|
|
1716
|
+
*/
|
|
1717
|
+
clearDescription() {
|
|
1718
|
+
this.data.description = void 0;
|
|
1719
|
+
return this;
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Sets the spoiler status of this thumbnail.
|
|
1723
|
+
*
|
|
1724
|
+
* @param spoiler - The spoiler status to use
|
|
1725
|
+
*/
|
|
1726
|
+
setSpoiler(spoiler = true) {
|
|
1727
|
+
this.data.spoiler = spoiler;
|
|
1728
|
+
return this;
|
|
1729
|
+
}
|
|
1730
|
+
/**
|
|
1731
|
+
* Sets the media URL of this thumbnail.
|
|
1732
|
+
*
|
|
1733
|
+
* @param url - The URL to use
|
|
1734
|
+
*/
|
|
1735
|
+
setURL(url) {
|
|
1736
|
+
this.data.media = { url };
|
|
1737
|
+
return this;
|
|
1738
|
+
}
|
|
1739
|
+
/**
|
|
1740
|
+
* {@inheritdoc ComponentBuilder.toJSON}
|
|
1741
|
+
*/
|
|
1742
|
+
toJSON(validationOverride) {
|
|
1743
|
+
const clone = structuredClone(this.data);
|
|
1744
|
+
validate(thumbnailPredicate, clone, validationOverride);
|
|
1745
|
+
return clone;
|
|
1746
|
+
}
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
// src/components/v2/Section.ts
|
|
1750
|
+
var SectionBuilder = class extends ComponentBuilder {
|
|
1751
|
+
static {
|
|
1752
|
+
__name(this, "SectionBuilder");
|
|
1753
|
+
}
|
|
1754
|
+
data;
|
|
1755
|
+
get components() {
|
|
1756
|
+
return this.data.components;
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Creates a new section from API data.
|
|
1760
|
+
*
|
|
1761
|
+
* @param data - The API data to create this section with
|
|
1762
|
+
* @example
|
|
1763
|
+
* Creating a section from an API data object:
|
|
1764
|
+
* ```ts
|
|
1765
|
+
* const section = new SectionBuilder({
|
|
1766
|
+
* components: [
|
|
1767
|
+
* {
|
|
1768
|
+
* content: "Some text here",
|
|
1769
|
+
* type: ComponentType.TextDisplay,
|
|
1770
|
+
* },
|
|
1771
|
+
* ],
|
|
1772
|
+
* accessory: {
|
|
1773
|
+
* media: {
|
|
1774
|
+
* url: 'https://cdn.discordapp.com/embed/avatars/3.png',
|
|
1775
|
+
* },
|
|
1776
|
+
* }
|
|
1777
|
+
* });
|
|
1778
|
+
* ```
|
|
1779
|
+
* @example
|
|
1780
|
+
* Creating a section using setters and API data:
|
|
1781
|
+
* ```ts
|
|
1782
|
+
* const section = new SectionBuilder({
|
|
1783
|
+
* components: [
|
|
1784
|
+
* {
|
|
1785
|
+
* content: "# Heading",
|
|
1786
|
+
* type: ComponentType.TextDisplay,
|
|
1787
|
+
* },
|
|
1788
|
+
* ],
|
|
1789
|
+
* })
|
|
1790
|
+
* .setPrimaryButtonAccessory(button);
|
|
1791
|
+
* ```
|
|
1792
|
+
*/
|
|
1793
|
+
constructor(data = {}) {
|
|
1794
|
+
super();
|
|
1795
|
+
const { components = [], accessory, ...rest } = data;
|
|
1796
|
+
this.data = {
|
|
1797
|
+
...structuredClone(rest),
|
|
1798
|
+
accessory: accessory ? resolveAccessoryComponent(accessory) : void 0,
|
|
1799
|
+
components: components.map((component) => new TextDisplayBuilder(component)),
|
|
1800
|
+
type: import_v1018.ComponentType.Section
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
/**
|
|
1804
|
+
* Adds text display components to this section.
|
|
1805
|
+
*
|
|
1806
|
+
* @param input - The text display components to add
|
|
1807
|
+
*/
|
|
1808
|
+
addTextDisplayComponents(...input) {
|
|
1809
|
+
const normalized = normalizeArray(input);
|
|
1810
|
+
const resolved = normalized.map((component) => resolveBuilder(component, TextDisplayBuilder));
|
|
1811
|
+
this.data.components.push(...resolved);
|
|
1812
|
+
return this;
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Sets a primary button component to be the accessory of this section.
|
|
1816
|
+
*
|
|
1817
|
+
* @param input - The button to set as the accessory
|
|
1818
|
+
*/
|
|
1819
|
+
setPrimaryButtonAccessory(input) {
|
|
1820
|
+
const builder = resolveBuilder(input, PrimaryButtonBuilder);
|
|
1821
|
+
this.data.accessory = builder;
|
|
1822
|
+
return this;
|
|
1823
|
+
}
|
|
1824
|
+
/**
|
|
1825
|
+
* Sets a secondary button component to be the accessory of this section.
|
|
1826
|
+
*
|
|
1827
|
+
* @param input - The button to set as the accessory
|
|
1828
|
+
*/
|
|
1829
|
+
setSecondaryButtonAccessory(input) {
|
|
1830
|
+
const builder = resolveBuilder(input, SecondaryButtonBuilder);
|
|
1831
|
+
this.data.accessory = builder;
|
|
1832
|
+
return this;
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Sets a success button component to be the accessory of this section.
|
|
1836
|
+
*
|
|
1837
|
+
* @param input - The button to set as the accessory
|
|
1838
|
+
*/
|
|
1839
|
+
setSuccessButtonAccessory(input) {
|
|
1840
|
+
const builder = resolveBuilder(input, SuccessButtonBuilder);
|
|
1841
|
+
this.data.accessory = builder;
|
|
1842
|
+
return this;
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Sets a danger button component to be the accessory of this section.
|
|
1846
|
+
*
|
|
1847
|
+
* @param input - The button to set as the accessory
|
|
1848
|
+
*/
|
|
1849
|
+
setDangerButtonAccessory(input) {
|
|
1850
|
+
const builder = resolveBuilder(input, DangerButtonBuilder);
|
|
1851
|
+
this.data.accessory = builder;
|
|
1852
|
+
return this;
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Sets a SKU id button component to be the accessory of this section.
|
|
1856
|
+
*
|
|
1857
|
+
* @param input - The button to set as the accessory
|
|
1858
|
+
*/
|
|
1859
|
+
setPremiumButtonAccessory(input) {
|
|
1860
|
+
const builder = resolveBuilder(input, PremiumButtonBuilder);
|
|
1861
|
+
this.data.accessory = builder;
|
|
1862
|
+
return this;
|
|
1863
|
+
}
|
|
1864
|
+
/**
|
|
1865
|
+
* Sets a URL button component to be the accessory of this section.
|
|
1866
|
+
*
|
|
1867
|
+
* @param input - The button to set as the accessory
|
|
1868
|
+
*/
|
|
1869
|
+
setLinkButtonAccessory(input) {
|
|
1870
|
+
const builder = resolveBuilder(input, LinkButtonBuilder);
|
|
1871
|
+
this.data.accessory = builder;
|
|
1872
|
+
return this;
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Sets a thumbnail component to be the accessory of this section.
|
|
1876
|
+
*
|
|
1877
|
+
* @param input - The thumbnail to set as the accessory
|
|
1878
|
+
*/
|
|
1879
|
+
setThumbnailAccessory(input) {
|
|
1880
|
+
const builder = resolveBuilder(input, ThumbnailBuilder);
|
|
1881
|
+
this.data.accessory = builder;
|
|
1882
|
+
return this;
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* Removes, replaces, or inserts text display components for this section.
|
|
1886
|
+
*
|
|
1887
|
+
* @param index - The index to start removing, replacing or inserting text display components
|
|
1888
|
+
* @param deleteCount - The amount of text display components to remove
|
|
1889
|
+
* @param components - The text display components to insert
|
|
1890
|
+
*/
|
|
1891
|
+
spliceTextDisplayComponents(index, deleteCount, ...components) {
|
|
1892
|
+
const normalized = normalizeArray(components);
|
|
1893
|
+
const resolved = normalized.map((component) => resolveBuilder(component, TextDisplayBuilder));
|
|
1894
|
+
this.data.components.splice(index, deleteCount, ...resolved);
|
|
1895
|
+
return this;
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1899
|
+
*/
|
|
1900
|
+
toJSON(validationOverride) {
|
|
1901
|
+
const { components, accessory, ...rest } = this.data;
|
|
1902
|
+
const data = {
|
|
1903
|
+
...structuredClone(rest),
|
|
1904
|
+
components: components.map((component) => component.toJSON(false)),
|
|
1905
|
+
accessory: accessory?.toJSON(validationOverride)
|
|
1906
|
+
};
|
|
1907
|
+
validate(sectionPredicate, data, validationOverride);
|
|
1908
|
+
return data;
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
|
|
1912
|
+
// src/components/v2/Separator.ts
|
|
1913
|
+
var import_v1019 = require("discord-api-types/v10");
|
|
1914
|
+
var SeparatorBuilder = class extends ComponentBuilder {
|
|
1126
1915
|
static {
|
|
1127
|
-
__name(this, "
|
|
1916
|
+
__name(this, "SeparatorBuilder");
|
|
1128
1917
|
}
|
|
1129
1918
|
data;
|
|
1130
1919
|
/**
|
|
1131
|
-
* Creates a new
|
|
1920
|
+
* Creates a new separator from API data.
|
|
1132
1921
|
*
|
|
1133
|
-
* @param data - The API data to create this
|
|
1922
|
+
* @param data - The API data to create this separator with
|
|
1134
1923
|
* @example
|
|
1135
|
-
* Creating a
|
|
1924
|
+
* Creating a separator from an API data object:
|
|
1136
1925
|
* ```ts
|
|
1137
|
-
* const
|
|
1138
|
-
*
|
|
1139
|
-
*
|
|
1140
|
-
* style: TextInputStyle.Short,
|
|
1926
|
+
* const separator = new SeparatorBuilder({
|
|
1927
|
+
* spacing: SeparatorSpacingSize.Small,
|
|
1928
|
+
* divider: true,
|
|
1141
1929
|
* });
|
|
1142
1930
|
* ```
|
|
1143
1931
|
* @example
|
|
1144
|
-
* Creating a
|
|
1932
|
+
* Creating a separator using setters and API data:
|
|
1145
1933
|
* ```ts
|
|
1146
|
-
* const
|
|
1147
|
-
*
|
|
1934
|
+
* const separator = new SeparatorBuilder({
|
|
1935
|
+
* spacing: SeparatorSpacingSize.Large,
|
|
1148
1936
|
* })
|
|
1149
|
-
* .
|
|
1150
|
-
* .setStyle(TextInputStyle.Paragraph);
|
|
1937
|
+
* .setDivider(false);
|
|
1151
1938
|
* ```
|
|
1152
1939
|
*/
|
|
1153
1940
|
constructor(data = {}) {
|
|
1154
1941
|
super();
|
|
1155
|
-
this.data = {
|
|
1942
|
+
this.data = {
|
|
1943
|
+
...structuredClone(data),
|
|
1944
|
+
type: import_v1019.ComponentType.Separator
|
|
1945
|
+
};
|
|
1156
1946
|
}
|
|
1157
1947
|
/**
|
|
1158
|
-
* Sets
|
|
1948
|
+
* Sets whether this separator should show a divider line.
|
|
1159
1949
|
*
|
|
1160
|
-
* @param
|
|
1950
|
+
* @param divider - Whether to show a divider line
|
|
1161
1951
|
*/
|
|
1162
|
-
|
|
1163
|
-
this.data.
|
|
1952
|
+
setDivider(divider = true) {
|
|
1953
|
+
this.data.divider = divider;
|
|
1164
1954
|
return this;
|
|
1165
1955
|
}
|
|
1166
1956
|
/**
|
|
1167
|
-
* Sets the
|
|
1957
|
+
* Sets the spacing of this separator.
|
|
1168
1958
|
*
|
|
1169
|
-
* @param
|
|
1959
|
+
* @param spacing - The spacing to use
|
|
1170
1960
|
*/
|
|
1171
|
-
|
|
1172
|
-
this.data.
|
|
1961
|
+
setSpacing(spacing) {
|
|
1962
|
+
this.data.spacing = spacing;
|
|
1173
1963
|
return this;
|
|
1174
1964
|
}
|
|
1175
1965
|
/**
|
|
1176
|
-
*
|
|
1177
|
-
*
|
|
1178
|
-
* @param style - The style to use
|
|
1966
|
+
* Clears the spacing of this separator.
|
|
1179
1967
|
*/
|
|
1180
|
-
|
|
1181
|
-
this.data.
|
|
1968
|
+
clearSpacing() {
|
|
1969
|
+
this.data.spacing = void 0;
|
|
1182
1970
|
return this;
|
|
1183
1971
|
}
|
|
1184
1972
|
/**
|
|
1185
|
-
*
|
|
1973
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1974
|
+
*/
|
|
1975
|
+
toJSON(validationOverride) {
|
|
1976
|
+
const clone = structuredClone(this.data);
|
|
1977
|
+
validate(separatorPredicate, clone, validationOverride);
|
|
1978
|
+
return clone;
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
// src/components/v2/Container.ts
|
|
1983
|
+
var ContainerBuilder = class extends ComponentBuilder {
|
|
1984
|
+
static {
|
|
1985
|
+
__name(this, "ContainerBuilder");
|
|
1986
|
+
}
|
|
1987
|
+
data;
|
|
1988
|
+
constructor({ components = [], ...rest } = {}) {
|
|
1989
|
+
super();
|
|
1990
|
+
this.data = {
|
|
1991
|
+
...structuredClone(rest),
|
|
1992
|
+
components: components.map((component) => createComponentBuilder(component)),
|
|
1993
|
+
type: import_v1020.ComponentType.Container
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Sets the accent color of this container.
|
|
1186
1998
|
*
|
|
1187
|
-
* @param
|
|
1999
|
+
* @param color - The color to use
|
|
1188
2000
|
*/
|
|
1189
|
-
|
|
1190
|
-
this.data.
|
|
2001
|
+
setAccentColor(color) {
|
|
2002
|
+
this.data.accent_color = color;
|
|
1191
2003
|
return this;
|
|
1192
2004
|
}
|
|
1193
2005
|
/**
|
|
1194
|
-
* Clears the
|
|
2006
|
+
* Clears the accent color of this container.
|
|
1195
2007
|
*/
|
|
1196
|
-
|
|
1197
|
-
this.data.
|
|
2008
|
+
clearAccentColor() {
|
|
2009
|
+
this.data.accent_color = void 0;
|
|
1198
2010
|
return this;
|
|
1199
2011
|
}
|
|
1200
2012
|
/**
|
|
1201
|
-
* Sets the
|
|
2013
|
+
* Sets the spoiler status of this container.
|
|
1202
2014
|
*
|
|
1203
|
-
* @param
|
|
2015
|
+
* @param spoiler - The spoiler status to use
|
|
1204
2016
|
*/
|
|
1205
|
-
|
|
1206
|
-
this.data.
|
|
2017
|
+
setSpoiler(spoiler = true) {
|
|
2018
|
+
this.data.spoiler = spoiler;
|
|
1207
2019
|
return this;
|
|
1208
2020
|
}
|
|
1209
2021
|
/**
|
|
1210
|
-
*
|
|
2022
|
+
* Adds action row components to this container.
|
|
2023
|
+
*
|
|
2024
|
+
* @param input - The action row to add
|
|
1211
2025
|
*/
|
|
1212
|
-
|
|
1213
|
-
|
|
2026
|
+
addActionRowComponents(...input) {
|
|
2027
|
+
const normalized = normalizeArray(input);
|
|
2028
|
+
const resolved = normalized.map((component) => resolveBuilder(component, ActionRowBuilder));
|
|
2029
|
+
this.data.components.push(...resolved);
|
|
1214
2030
|
return this;
|
|
1215
2031
|
}
|
|
1216
2032
|
/**
|
|
1217
|
-
*
|
|
2033
|
+
* Adds file components to this container.
|
|
1218
2034
|
*
|
|
1219
|
-
* @param
|
|
2035
|
+
* @param input - The file components to add
|
|
1220
2036
|
*/
|
|
1221
|
-
|
|
1222
|
-
|
|
2037
|
+
addFileComponents(...input) {
|
|
2038
|
+
const normalized = normalizeArray(input);
|
|
2039
|
+
const resolved = normalized.map((component) => resolveBuilder(component, FileBuilder));
|
|
2040
|
+
this.data.components.push(...resolved);
|
|
1223
2041
|
return this;
|
|
1224
2042
|
}
|
|
1225
2043
|
/**
|
|
1226
|
-
*
|
|
2044
|
+
* Adds media gallery components to this container.
|
|
2045
|
+
*
|
|
2046
|
+
* @param input - The media gallery components to add
|
|
1227
2047
|
*/
|
|
1228
|
-
|
|
1229
|
-
|
|
2048
|
+
addMediaGalleryComponents(...input) {
|
|
2049
|
+
const normalized = normalizeArray(input);
|
|
2050
|
+
const resolved = normalized.map((component) => resolveBuilder(component, MediaGalleryBuilder));
|
|
2051
|
+
this.data.components.push(...resolved);
|
|
1230
2052
|
return this;
|
|
1231
2053
|
}
|
|
1232
2054
|
/**
|
|
1233
|
-
*
|
|
2055
|
+
* Adds section components to this container.
|
|
1234
2056
|
*
|
|
1235
|
-
* @param
|
|
2057
|
+
* @param input - The section components to add
|
|
1236
2058
|
*/
|
|
1237
|
-
|
|
1238
|
-
|
|
2059
|
+
addSectionComponents(...input) {
|
|
2060
|
+
const normalized = normalizeArray(input);
|
|
2061
|
+
const resolved = normalized.map((component) => resolveBuilder(component, SectionBuilder));
|
|
2062
|
+
this.data.components.push(...resolved);
|
|
1239
2063
|
return this;
|
|
1240
2064
|
}
|
|
1241
2065
|
/**
|
|
1242
|
-
*
|
|
2066
|
+
* Adds separator components to this container.
|
|
2067
|
+
*
|
|
2068
|
+
* @param input - The separator components to add
|
|
1243
2069
|
*/
|
|
1244
|
-
|
|
1245
|
-
|
|
2070
|
+
addSeparatorComponents(...input) {
|
|
2071
|
+
const normalized = normalizeArray(input);
|
|
2072
|
+
const resolved = normalized.map((component) => resolveBuilder(component, SeparatorBuilder));
|
|
2073
|
+
this.data.components.push(...resolved);
|
|
1246
2074
|
return this;
|
|
1247
2075
|
}
|
|
1248
2076
|
/**
|
|
1249
|
-
*
|
|
2077
|
+
* Adds text display components to this container.
|
|
1250
2078
|
*
|
|
1251
|
-
* @param
|
|
2079
|
+
* @param input - The text display components to add
|
|
1252
2080
|
*/
|
|
1253
|
-
|
|
1254
|
-
|
|
2081
|
+
addTextDisplayComponents(...input) {
|
|
2082
|
+
const normalized = normalizeArray(input);
|
|
2083
|
+
const resolved = normalized.map((component) => resolveBuilder(component, TextDisplayBuilder));
|
|
2084
|
+
this.data.components.push(...resolved);
|
|
2085
|
+
return this;
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
2088
|
+
* Removes, replaces, or inserts components for this container
|
|
2089
|
+
*
|
|
2090
|
+
* @remarks
|
|
2091
|
+
* This method behaves similarly
|
|
2092
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
2093
|
+
*
|
|
2094
|
+
* It's useful for modifying and adjusting order of the already-existing components of a container.
|
|
2095
|
+
* @example
|
|
2096
|
+
* Remove the first component:
|
|
2097
|
+
* ```ts
|
|
2098
|
+
* container.spliceComponents(0, 1);
|
|
2099
|
+
* ```
|
|
2100
|
+
* @example
|
|
2101
|
+
* Remove the first n components:
|
|
2102
|
+
* ```ts
|
|
2103
|
+
* const n = 4;
|
|
2104
|
+
* container.spliceComponents(0, n);
|
|
2105
|
+
* ```
|
|
2106
|
+
* @example
|
|
2107
|
+
* Remove the last component:
|
|
2108
|
+
* ```ts
|
|
2109
|
+
* container.spliceComponents(-1, 1);
|
|
2110
|
+
* ```
|
|
2111
|
+
* @param index - The index to start at
|
|
2112
|
+
* @param deleteCount - The number of components to remove
|
|
2113
|
+
* @param components - The replacing component objects
|
|
2114
|
+
*/
|
|
2115
|
+
spliceComponents(index, deleteCount, ...components) {
|
|
2116
|
+
const normalized = normalizeArray(components);
|
|
2117
|
+
const resolved = normalized.map(
|
|
2118
|
+
(component) => component instanceof ComponentBuilder ? component : createComponentBuilder(component)
|
|
2119
|
+
);
|
|
2120
|
+
this.data.components.splice(index, deleteCount, ...resolved);
|
|
1255
2121
|
return this;
|
|
1256
2122
|
}
|
|
1257
2123
|
/**
|
|
1258
2124
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1259
2125
|
*/
|
|
1260
2126
|
toJSON(validationOverride) {
|
|
1261
|
-
const
|
|
1262
|
-
|
|
1263
|
-
|
|
2127
|
+
const { components, ...rest } = this.data;
|
|
2128
|
+
const data = {
|
|
2129
|
+
...structuredClone(rest),
|
|
2130
|
+
components: components.map((component) => component.toJSON(false))
|
|
2131
|
+
};
|
|
2132
|
+
validate(containerPredicate, data, validationOverride);
|
|
2133
|
+
return data;
|
|
1264
2134
|
}
|
|
1265
2135
|
};
|
|
1266
2136
|
|
|
1267
|
-
// src/components/ActionRow.ts
|
|
1268
|
-
var import_v1014 = require("discord-api-types/v10");
|
|
1269
|
-
|
|
1270
2137
|
// src/components/Components.ts
|
|
1271
|
-
var import_v1013 = require("discord-api-types/v10");
|
|
1272
2138
|
function createComponentBuilder(data) {
|
|
1273
2139
|
if (data instanceof ComponentBuilder) {
|
|
1274
2140
|
return data;
|
|
1275
2141
|
}
|
|
1276
2142
|
switch (data.type) {
|
|
1277
|
-
case
|
|
2143
|
+
case import_v1021.ComponentType.ActionRow:
|
|
1278
2144
|
return new ActionRowBuilder(data);
|
|
1279
|
-
case
|
|
2145
|
+
case import_v1021.ComponentType.Button:
|
|
1280
2146
|
return createButtonBuilder(data);
|
|
1281
|
-
case
|
|
2147
|
+
case import_v1021.ComponentType.StringSelect:
|
|
1282
2148
|
return new StringSelectMenuBuilder(data);
|
|
1283
|
-
case
|
|
2149
|
+
case import_v1021.ComponentType.TextInput:
|
|
1284
2150
|
return new TextInputBuilder(data);
|
|
1285
|
-
case
|
|
2151
|
+
case import_v1021.ComponentType.UserSelect:
|
|
1286
2152
|
return new UserSelectMenuBuilder(data);
|
|
1287
|
-
case
|
|
2153
|
+
case import_v1021.ComponentType.RoleSelect:
|
|
1288
2154
|
return new RoleSelectMenuBuilder(data);
|
|
1289
|
-
case
|
|
2155
|
+
case import_v1021.ComponentType.MentionableSelect:
|
|
1290
2156
|
return new MentionableSelectMenuBuilder(data);
|
|
1291
|
-
case
|
|
2157
|
+
case import_v1021.ComponentType.ChannelSelect:
|
|
1292
2158
|
return new ChannelSelectMenuBuilder(data);
|
|
2159
|
+
case import_v1021.ComponentType.Thumbnail:
|
|
2160
|
+
return new ThumbnailBuilder(data);
|
|
2161
|
+
case import_v1021.ComponentType.File:
|
|
2162
|
+
return new FileBuilder(data);
|
|
2163
|
+
case import_v1021.ComponentType.Separator:
|
|
2164
|
+
return new SeparatorBuilder(data);
|
|
2165
|
+
case import_v1021.ComponentType.TextDisplay:
|
|
2166
|
+
return new TextDisplayBuilder(data);
|
|
2167
|
+
case import_v1021.ComponentType.MediaGallery:
|
|
2168
|
+
return new MediaGalleryBuilder(data);
|
|
2169
|
+
case import_v1021.ComponentType.Section:
|
|
2170
|
+
return new SectionBuilder(data);
|
|
2171
|
+
case import_v1021.ComponentType.Container:
|
|
2172
|
+
return new ContainerBuilder(data);
|
|
1293
2173
|
default:
|
|
1294
2174
|
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
1295
2175
|
}
|
|
@@ -1297,23 +2177,34 @@ function createComponentBuilder(data) {
|
|
|
1297
2177
|
__name(createComponentBuilder, "createComponentBuilder");
|
|
1298
2178
|
function createButtonBuilder(data) {
|
|
1299
2179
|
switch (data.style) {
|
|
1300
|
-
case
|
|
2180
|
+
case import_v1021.ButtonStyle.Primary:
|
|
1301
2181
|
return new PrimaryButtonBuilder(data);
|
|
1302
|
-
case
|
|
2182
|
+
case import_v1021.ButtonStyle.Secondary:
|
|
1303
2183
|
return new SecondaryButtonBuilder(data);
|
|
1304
|
-
case
|
|
2184
|
+
case import_v1021.ButtonStyle.Success:
|
|
1305
2185
|
return new SuccessButtonBuilder(data);
|
|
1306
|
-
case
|
|
2186
|
+
case import_v1021.ButtonStyle.Danger:
|
|
1307
2187
|
return new DangerButtonBuilder(data);
|
|
1308
|
-
case
|
|
2188
|
+
case import_v1021.ButtonStyle.Link:
|
|
1309
2189
|
return new LinkButtonBuilder(data);
|
|
1310
|
-
case
|
|
2190
|
+
case import_v1021.ButtonStyle.Premium:
|
|
1311
2191
|
return new PremiumButtonBuilder(data);
|
|
1312
2192
|
default:
|
|
1313
2193
|
throw new Error(`Cannot properly serialize button with style: ${data.style}`);
|
|
1314
2194
|
}
|
|
1315
2195
|
}
|
|
1316
2196
|
__name(createButtonBuilder, "createButtonBuilder");
|
|
2197
|
+
function resolveAccessoryComponent(component) {
|
|
2198
|
+
switch (component.type) {
|
|
2199
|
+
case import_v1021.ComponentType.Button:
|
|
2200
|
+
return createButtonBuilder(component);
|
|
2201
|
+
case import_v1021.ComponentType.Thumbnail:
|
|
2202
|
+
return new ThumbnailBuilder(component);
|
|
2203
|
+
default:
|
|
2204
|
+
throw new Error(`Cannot properly serialize section accessory component: ${component.type}`);
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
__name(resolveAccessoryComponent, "resolveAccessoryComponent");
|
|
1317
2208
|
|
|
1318
2209
|
// src/components/ActionRow.ts
|
|
1319
2210
|
var ActionRowBuilder = class extends ComponentBuilder {
|
|
@@ -1365,7 +2256,7 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
1365
2256
|
super();
|
|
1366
2257
|
this.data = {
|
|
1367
2258
|
...structuredClone(data),
|
|
1368
|
-
type:
|
|
2259
|
+
type: import_v1022.ComponentType.ActionRow,
|
|
1369
2260
|
components: components.map((component) => createComponentBuilder(component))
|
|
1370
2261
|
};
|
|
1371
2262
|
}
|
|
@@ -1581,18 +2472,18 @@ var ApplicationCommandNumericOptionMinMaxValueMixin = class {
|
|
|
1581
2472
|
};
|
|
1582
2473
|
|
|
1583
2474
|
// src/interactions/commands/chatInput/mixins/ApplicationCommandOptionChannelTypesMixin.ts
|
|
1584
|
-
var
|
|
2475
|
+
var import_v1023 = require("discord-api-types/v10");
|
|
1585
2476
|
var ApplicationCommandOptionAllowedChannelTypes = [
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
2477
|
+
import_v1023.ChannelType.GuildText,
|
|
2478
|
+
import_v1023.ChannelType.GuildVoice,
|
|
2479
|
+
import_v1023.ChannelType.GuildCategory,
|
|
2480
|
+
import_v1023.ChannelType.GuildAnnouncement,
|
|
2481
|
+
import_v1023.ChannelType.AnnouncementThread,
|
|
2482
|
+
import_v1023.ChannelType.PublicThread,
|
|
2483
|
+
import_v1023.ChannelType.PrivateThread,
|
|
2484
|
+
import_v1023.ChannelType.GuildStageVoice,
|
|
2485
|
+
import_v1023.ChannelType.GuildForum,
|
|
2486
|
+
import_v1023.ChannelType.GuildMedia
|
|
1596
2487
|
];
|
|
1597
2488
|
var ApplicationCommandOptionChannelTypesMixin = class {
|
|
1598
2489
|
static {
|
|
@@ -1663,7 +2554,7 @@ var ApplicationCommandOptionWithChoicesMixin = class {
|
|
|
1663
2554
|
};
|
|
1664
2555
|
|
|
1665
2556
|
// src/interactions/commands/chatInput/options/attachment.ts
|
|
1666
|
-
var
|
|
2557
|
+
var import_v1025 = require("discord-api-types/v10");
|
|
1667
2558
|
|
|
1668
2559
|
// src/interactions/commands/SharedName.ts
|
|
1669
2560
|
var SharedName = class {
|
|
@@ -1774,36 +2665,36 @@ var SharedNameAndDescription = class extends SharedName {
|
|
|
1774
2665
|
};
|
|
1775
2666
|
|
|
1776
2667
|
// src/interactions/commands/chatInput/Assertions.ts
|
|
1777
|
-
var
|
|
1778
|
-
var
|
|
1779
|
-
var namePredicate =
|
|
1780
|
-
var descriptionPredicate =
|
|
1781
|
-
var sharedNameAndDescriptionPredicate =
|
|
2668
|
+
var import_v1024 = require("discord-api-types/v10");
|
|
2669
|
+
var import_zod5 = require("zod");
|
|
2670
|
+
var namePredicate = import_zod5.z.string().min(1).max(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u);
|
|
2671
|
+
var descriptionPredicate = import_zod5.z.string().min(1).max(100);
|
|
2672
|
+
var sharedNameAndDescriptionPredicate = import_zod5.z.object({
|
|
1782
2673
|
name: namePredicate,
|
|
1783
2674
|
name_localizations: localeMapPredicate.optional(),
|
|
1784
2675
|
description: descriptionPredicate,
|
|
1785
2676
|
description_localizations: localeMapPredicate.optional()
|
|
1786
2677
|
});
|
|
1787
|
-
var numericMixinNumberOptionPredicate =
|
|
1788
|
-
max_value:
|
|
1789
|
-
min_value:
|
|
2678
|
+
var numericMixinNumberOptionPredicate = import_zod5.z.object({
|
|
2679
|
+
max_value: import_zod5.z.number().safe().optional(),
|
|
2680
|
+
min_value: import_zod5.z.number().safe().optional()
|
|
1790
2681
|
});
|
|
1791
|
-
var numericMixinIntegerOptionPredicate =
|
|
1792
|
-
max_value:
|
|
1793
|
-
min_value:
|
|
2682
|
+
var numericMixinIntegerOptionPredicate = import_zod5.z.object({
|
|
2683
|
+
max_value: import_zod5.z.number().safe().int().optional(),
|
|
2684
|
+
min_value: import_zod5.z.number().safe().int().optional()
|
|
1794
2685
|
});
|
|
1795
|
-
var channelMixinOptionPredicate =
|
|
1796
|
-
channel_types:
|
|
1797
|
-
ApplicationCommandOptionAllowedChannelTypes.map((type) =>
|
|
2686
|
+
var channelMixinOptionPredicate = import_zod5.z.object({
|
|
2687
|
+
channel_types: import_zod5.z.union(
|
|
2688
|
+
ApplicationCommandOptionAllowedChannelTypes.map((type) => import_zod5.z.literal(type))
|
|
1798
2689
|
).array().optional()
|
|
1799
2690
|
});
|
|
1800
|
-
var autocompleteMixinOptionPredicate =
|
|
1801
|
-
autocomplete:
|
|
1802
|
-
choices:
|
|
2691
|
+
var autocompleteMixinOptionPredicate = import_zod5.z.object({
|
|
2692
|
+
autocomplete: import_zod5.z.literal(true),
|
|
2693
|
+
choices: import_zod5.z.union([import_zod5.z.never(), import_zod5.z.never().array(), import_zod5.z.undefined()])
|
|
1803
2694
|
});
|
|
1804
|
-
var choiceValueStringPredicate =
|
|
1805
|
-
var choiceValueNumberPredicate =
|
|
1806
|
-
var choiceBasePredicate =
|
|
2695
|
+
var choiceValueStringPredicate = import_zod5.z.string().min(1).max(100);
|
|
2696
|
+
var choiceValueNumberPredicate = import_zod5.z.number().safe();
|
|
2697
|
+
var choiceBasePredicate = import_zod5.z.object({
|
|
1807
2698
|
name: choiceValueStringPredicate,
|
|
1808
2699
|
name_localizations: localeMapPredicate.optional()
|
|
1809
2700
|
});
|
|
@@ -1813,8 +2704,8 @@ var choiceStringPredicate = choiceBasePredicate.extend({
|
|
|
1813
2704
|
var choiceNumberPredicate = choiceBasePredicate.extend({
|
|
1814
2705
|
value: choiceValueNumberPredicate
|
|
1815
2706
|
});
|
|
1816
|
-
var choiceBaseMixinPredicate =
|
|
1817
|
-
autocomplete:
|
|
2707
|
+
var choiceBaseMixinPredicate = import_zod5.z.object({
|
|
2708
|
+
autocomplete: import_zod5.z.literal(false).optional()
|
|
1818
2709
|
});
|
|
1819
2710
|
var choiceStringMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
1820
2711
|
choices: choiceStringPredicate.array().max(25).optional()
|
|
@@ -1823,28 +2714,28 @@ var choiceNumberMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
|
1823
2714
|
choices: choiceNumberPredicate.array().max(25).optional()
|
|
1824
2715
|
});
|
|
1825
2716
|
var basicOptionTypes = [
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
2717
|
+
import_v1024.ApplicationCommandOptionType.Attachment,
|
|
2718
|
+
import_v1024.ApplicationCommandOptionType.Boolean,
|
|
2719
|
+
import_v1024.ApplicationCommandOptionType.Channel,
|
|
2720
|
+
import_v1024.ApplicationCommandOptionType.Integer,
|
|
2721
|
+
import_v1024.ApplicationCommandOptionType.Mentionable,
|
|
2722
|
+
import_v1024.ApplicationCommandOptionType.Number,
|
|
2723
|
+
import_v1024.ApplicationCommandOptionType.Role,
|
|
2724
|
+
import_v1024.ApplicationCommandOptionType.String,
|
|
2725
|
+
import_v1024.ApplicationCommandOptionType.User
|
|
1835
2726
|
];
|
|
1836
|
-
var basicOptionTypesPredicate =
|
|
1837
|
-
basicOptionTypes.map((type) =>
|
|
2727
|
+
var basicOptionTypesPredicate = import_zod5.z.union(
|
|
2728
|
+
basicOptionTypes.map((type) => import_zod5.z.literal(type))
|
|
1838
2729
|
);
|
|
1839
2730
|
var basicOptionPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
1840
|
-
required:
|
|
2731
|
+
required: import_zod5.z.boolean().optional(),
|
|
1841
2732
|
type: basicOptionTypesPredicate
|
|
1842
2733
|
});
|
|
1843
|
-
var autocompleteOrStringChoicesMixinOptionPredicate =
|
|
2734
|
+
var autocompleteOrStringChoicesMixinOptionPredicate = import_zod5.z.discriminatedUnion("autocomplete", [
|
|
1844
2735
|
autocompleteMixinOptionPredicate,
|
|
1845
2736
|
choiceStringMixinPredicate
|
|
1846
2737
|
]);
|
|
1847
|
-
var autocompleteOrNumberChoicesMixinOptionPredicate =
|
|
2738
|
+
var autocompleteOrNumberChoicesMixinOptionPredicate = import_zod5.z.discriminatedUnion("autocomplete", [
|
|
1848
2739
|
autocompleteMixinOptionPredicate,
|
|
1849
2740
|
choiceNumberMixinPredicate
|
|
1850
2741
|
]);
|
|
@@ -1852,30 +2743,30 @@ var channelOptionPredicate = basicOptionPredicate.merge(channelMixinOptionPredic
|
|
|
1852
2743
|
var integerOptionPredicate = basicOptionPredicate.merge(numericMixinIntegerOptionPredicate).and(autocompleteOrNumberChoicesMixinOptionPredicate);
|
|
1853
2744
|
var numberOptionPredicate = basicOptionPredicate.merge(numericMixinNumberOptionPredicate).and(autocompleteOrNumberChoicesMixinOptionPredicate);
|
|
1854
2745
|
var stringOptionPredicate = basicOptionPredicate.extend({
|
|
1855
|
-
max_length:
|
|
1856
|
-
min_length:
|
|
2746
|
+
max_length: import_zod5.z.number().min(0).max(6e3).optional(),
|
|
2747
|
+
min_length: import_zod5.z.number().min(1).max(6e3).optional()
|
|
1857
2748
|
}).and(autocompleteOrStringChoicesMixinOptionPredicate);
|
|
1858
2749
|
var baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
1859
|
-
contexts:
|
|
2750
|
+
contexts: import_zod5.z.array(import_zod5.z.nativeEnum(import_v1024.InteractionContextType)).optional(),
|
|
1860
2751
|
default_member_permissions: memberPermissionsPredicate.optional(),
|
|
1861
|
-
integration_types:
|
|
1862
|
-
nsfw:
|
|
2752
|
+
integration_types: import_zod5.z.array(import_zod5.z.nativeEnum(import_v1024.ApplicationIntegrationType)).optional(),
|
|
2753
|
+
nsfw: import_zod5.z.boolean().optional()
|
|
1863
2754
|
});
|
|
1864
|
-
var chatInputCommandOptionsPredicate =
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
2755
|
+
var chatInputCommandOptionsPredicate = import_zod5.z.union([
|
|
2756
|
+
import_zod5.z.object({ type: basicOptionTypesPredicate }).array(),
|
|
2757
|
+
import_zod5.z.object({ type: import_zod5.z.literal(import_v1024.ApplicationCommandOptionType.Subcommand) }).array(),
|
|
2758
|
+
import_zod5.z.object({ type: import_zod5.z.literal(import_v1024.ApplicationCommandOptionType.SubcommandGroup) }).array()
|
|
1868
2759
|
]);
|
|
1869
2760
|
var chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
|
|
1870
2761
|
options: chatInputCommandOptionsPredicate.optional()
|
|
1871
2762
|
});
|
|
1872
2763
|
var chatInputCommandSubcommandGroupPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
1873
|
-
type:
|
|
1874
|
-
options:
|
|
2764
|
+
type: import_zod5.z.literal(import_v1024.ApplicationCommandOptionType.SubcommandGroup),
|
|
2765
|
+
options: import_zod5.z.array(import_zod5.z.object({ type: import_zod5.z.literal(import_v1024.ApplicationCommandOptionType.Subcommand) })).min(1).max(25)
|
|
1875
2766
|
});
|
|
1876
2767
|
var chatInputCommandSubcommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
1877
|
-
type:
|
|
1878
|
-
options:
|
|
2768
|
+
type: import_zod5.z.literal(import_v1024.ApplicationCommandOptionType.Subcommand),
|
|
2769
|
+
options: import_zod5.z.array(import_zod5.z.object({ type: basicOptionTypesPredicate })).max(25)
|
|
1879
2770
|
});
|
|
1880
2771
|
|
|
1881
2772
|
// src/interactions/commands/chatInput/options/ApplicationCommandOptionBase.ts
|
|
@@ -1917,23 +2808,23 @@ var ChatInputCommandAttachmentOption = class extends ApplicationCommandOptionBas
|
|
|
1917
2808
|
__name(this, "ChatInputCommandAttachmentOption");
|
|
1918
2809
|
}
|
|
1919
2810
|
constructor() {
|
|
1920
|
-
super(
|
|
2811
|
+
super(import_v1025.ApplicationCommandOptionType.Attachment);
|
|
1921
2812
|
}
|
|
1922
2813
|
};
|
|
1923
2814
|
|
|
1924
2815
|
// src/interactions/commands/chatInput/options/boolean.ts
|
|
1925
|
-
var
|
|
2816
|
+
var import_v1026 = require("discord-api-types/v10");
|
|
1926
2817
|
var ChatInputCommandBooleanOption = class extends ApplicationCommandOptionBase {
|
|
1927
2818
|
static {
|
|
1928
2819
|
__name(this, "ChatInputCommandBooleanOption");
|
|
1929
2820
|
}
|
|
1930
2821
|
constructor() {
|
|
1931
|
-
super(
|
|
2822
|
+
super(import_v1026.ApplicationCommandOptionType.Boolean);
|
|
1932
2823
|
}
|
|
1933
2824
|
};
|
|
1934
2825
|
|
|
1935
2826
|
// src/interactions/commands/chatInput/options/channel.ts
|
|
1936
|
-
var
|
|
2827
|
+
var import_v1027 = require("discord-api-types/v10");
|
|
1937
2828
|
var import_ts_mixer3 = require("ts-mixer");
|
|
1938
2829
|
var ChatInputCommandChannelOption = class extends (0, import_ts_mixer3.Mixin)(
|
|
1939
2830
|
ApplicationCommandOptionBase,
|
|
@@ -1944,12 +2835,12 @@ var ChatInputCommandChannelOption = class extends (0, import_ts_mixer3.Mixin)(
|
|
|
1944
2835
|
}
|
|
1945
2836
|
static predicate = channelOptionPredicate;
|
|
1946
2837
|
constructor() {
|
|
1947
|
-
super(
|
|
2838
|
+
super(import_v1027.ApplicationCommandOptionType.Channel);
|
|
1948
2839
|
}
|
|
1949
2840
|
};
|
|
1950
2841
|
|
|
1951
2842
|
// src/interactions/commands/chatInput/options/integer.ts
|
|
1952
|
-
var
|
|
2843
|
+
var import_v1028 = require("discord-api-types/v10");
|
|
1953
2844
|
var import_ts_mixer4 = require("ts-mixer");
|
|
1954
2845
|
var ChatInputCommandIntegerOption = class extends (0, import_ts_mixer4.Mixin)(
|
|
1955
2846
|
ApplicationCommandOptionBase,
|
|
@@ -1962,23 +2853,23 @@ var ChatInputCommandIntegerOption = class extends (0, import_ts_mixer4.Mixin)(
|
|
|
1962
2853
|
}
|
|
1963
2854
|
static predicate = integerOptionPredicate;
|
|
1964
2855
|
constructor() {
|
|
1965
|
-
super(
|
|
2856
|
+
super(import_v1028.ApplicationCommandOptionType.Integer);
|
|
1966
2857
|
}
|
|
1967
2858
|
};
|
|
1968
2859
|
|
|
1969
2860
|
// src/interactions/commands/chatInput/options/mentionable.ts
|
|
1970
|
-
var
|
|
2861
|
+
var import_v1029 = require("discord-api-types/v10");
|
|
1971
2862
|
var ChatInputCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
|
1972
2863
|
static {
|
|
1973
2864
|
__name(this, "ChatInputCommandMentionableOption");
|
|
1974
2865
|
}
|
|
1975
2866
|
constructor() {
|
|
1976
|
-
super(
|
|
2867
|
+
super(import_v1029.ApplicationCommandOptionType.Mentionable);
|
|
1977
2868
|
}
|
|
1978
2869
|
};
|
|
1979
2870
|
|
|
1980
2871
|
// src/interactions/commands/chatInput/options/number.ts
|
|
1981
|
-
var
|
|
2872
|
+
var import_v1030 = require("discord-api-types/v10");
|
|
1982
2873
|
var import_ts_mixer5 = require("ts-mixer");
|
|
1983
2874
|
var ChatInputCommandNumberOption = class extends (0, import_ts_mixer5.Mixin)(
|
|
1984
2875
|
ApplicationCommandOptionBase,
|
|
@@ -1991,23 +2882,23 @@ var ChatInputCommandNumberOption = class extends (0, import_ts_mixer5.Mixin)(
|
|
|
1991
2882
|
}
|
|
1992
2883
|
static predicate = numberOptionPredicate;
|
|
1993
2884
|
constructor() {
|
|
1994
|
-
super(
|
|
2885
|
+
super(import_v1030.ApplicationCommandOptionType.Number);
|
|
1995
2886
|
}
|
|
1996
2887
|
};
|
|
1997
2888
|
|
|
1998
2889
|
// src/interactions/commands/chatInput/options/role.ts
|
|
1999
|
-
var
|
|
2890
|
+
var import_v1031 = require("discord-api-types/v10");
|
|
2000
2891
|
var ChatInputCommandRoleOption = class extends ApplicationCommandOptionBase {
|
|
2001
2892
|
static {
|
|
2002
2893
|
__name(this, "ChatInputCommandRoleOption");
|
|
2003
2894
|
}
|
|
2004
2895
|
constructor() {
|
|
2005
|
-
super(
|
|
2896
|
+
super(import_v1031.ApplicationCommandOptionType.Role);
|
|
2006
2897
|
}
|
|
2007
2898
|
};
|
|
2008
2899
|
|
|
2009
2900
|
// src/interactions/commands/chatInput/options/string.ts
|
|
2010
|
-
var
|
|
2901
|
+
var import_v1032 = require("discord-api-types/v10");
|
|
2011
2902
|
var import_ts_mixer6 = require("ts-mixer");
|
|
2012
2903
|
var ChatInputCommandStringOption = class extends (0, import_ts_mixer6.Mixin)(
|
|
2013
2904
|
ApplicationCommandOptionBase,
|
|
@@ -2019,7 +2910,7 @@ var ChatInputCommandStringOption = class extends (0, import_ts_mixer6.Mixin)(
|
|
|
2019
2910
|
}
|
|
2020
2911
|
static predicate = stringOptionPredicate;
|
|
2021
2912
|
constructor() {
|
|
2022
|
-
super(
|
|
2913
|
+
super(import_v1032.ApplicationCommandOptionType.String);
|
|
2023
2914
|
}
|
|
2024
2915
|
/**
|
|
2025
2916
|
* Sets the maximum length of this string option.
|
|
@@ -2056,13 +2947,13 @@ var ChatInputCommandStringOption = class extends (0, import_ts_mixer6.Mixin)(
|
|
|
2056
2947
|
};
|
|
2057
2948
|
|
|
2058
2949
|
// src/interactions/commands/chatInput/options/user.ts
|
|
2059
|
-
var
|
|
2950
|
+
var import_v1033 = require("discord-api-types/v10");
|
|
2060
2951
|
var ChatInputCommandUserOption = class extends ApplicationCommandOptionBase {
|
|
2061
2952
|
static {
|
|
2062
2953
|
__name(this, "ChatInputCommandUserOption");
|
|
2063
2954
|
}
|
|
2064
2955
|
constructor() {
|
|
2065
|
-
super(
|
|
2956
|
+
super(import_v1033.ApplicationCommandOptionType.User);
|
|
2066
2957
|
}
|
|
2067
2958
|
};
|
|
2068
2959
|
|
|
@@ -2194,7 +3085,7 @@ var SharedChatInputCommandOptions = class {
|
|
|
2194
3085
|
};
|
|
2195
3086
|
|
|
2196
3087
|
// src/interactions/commands/chatInput/ChatInputCommandSubcommands.ts
|
|
2197
|
-
var
|
|
3088
|
+
var import_v1034 = require("discord-api-types/v10");
|
|
2198
3089
|
var import_ts_mixer7 = require("ts-mixer");
|
|
2199
3090
|
var ChatInputCommandSubcommandGroupBuilder = class extends SharedNameAndDescription {
|
|
2200
3091
|
static {
|
|
@@ -2226,7 +3117,7 @@ var ChatInputCommandSubcommandGroupBuilder = class extends SharedNameAndDescript
|
|
|
2226
3117
|
const { options, ...rest } = this.data;
|
|
2227
3118
|
const data = {
|
|
2228
3119
|
...structuredClone(rest),
|
|
2229
|
-
type:
|
|
3120
|
+
type: import_v1034.ApplicationCommandOptionType.SubcommandGroup,
|
|
2230
3121
|
options: options?.map((option) => option.toJSON(validationOverride)) ?? []
|
|
2231
3122
|
};
|
|
2232
3123
|
validate(chatInputCommandSubcommandGroupPredicate, data, validationOverride);
|
|
@@ -2248,7 +3139,7 @@ var ChatInputCommandSubcommandBuilder = class extends (0, import_ts_mixer7.Mixin
|
|
|
2248
3139
|
const { options, ...rest } = this.data;
|
|
2249
3140
|
const data = {
|
|
2250
3141
|
...structuredClone(rest),
|
|
2251
|
-
type:
|
|
3142
|
+
type: import_v1034.ApplicationCommandOptionType.Subcommand,
|
|
2252
3143
|
options: options?.map((option) => option.toJSON(validationOverride)) ?? []
|
|
2253
3144
|
};
|
|
2254
3145
|
validate(chatInputCommandSubcommandPredicate, data, validationOverride);
|
|
@@ -2288,7 +3179,7 @@ var SharedChatInputCommandSubcommands = class {
|
|
|
2288
3179
|
};
|
|
2289
3180
|
|
|
2290
3181
|
// src/interactions/commands/chatInput/ChatInputCommand.ts
|
|
2291
|
-
var
|
|
3182
|
+
var import_v1035 = require("discord-api-types/v10");
|
|
2292
3183
|
var import_ts_mixer8 = require("ts-mixer");
|
|
2293
3184
|
|
|
2294
3185
|
// src/interactions/commands/Command.ts
|
|
@@ -2361,7 +3252,7 @@ var ChatInputCommandBuilder = class extends (0, import_ts_mixer8.Mixin)(
|
|
|
2361
3252
|
const { options, ...rest } = this.data;
|
|
2362
3253
|
const data = {
|
|
2363
3254
|
...structuredClone(rest),
|
|
2364
|
-
type:
|
|
3255
|
+
type: import_v1035.ApplicationCommandType.ChatInput,
|
|
2365
3256
|
options: options?.map((option) => option.toJSON(validationOverride))
|
|
2366
3257
|
};
|
|
2367
3258
|
validate(chatInputCommandPredicate, data, validationOverride);
|
|
@@ -2370,24 +3261,24 @@ var ChatInputCommandBuilder = class extends (0, import_ts_mixer8.Mixin)(
|
|
|
2370
3261
|
};
|
|
2371
3262
|
|
|
2372
3263
|
// src/interactions/commands/contextMenu/Assertions.ts
|
|
2373
|
-
var
|
|
2374
|
-
var
|
|
2375
|
-
var namePredicate2 =
|
|
2376
|
-
var contextsPredicate =
|
|
2377
|
-
var integrationTypesPredicate =
|
|
2378
|
-
var baseContextMenuCommandPredicate =
|
|
3264
|
+
var import_v1036 = require("discord-api-types/v10");
|
|
3265
|
+
var import_zod6 = require("zod");
|
|
3266
|
+
var namePredicate2 = import_zod6.z.string().min(1).max(32).regex(/^(?:(?: *[\p{P}\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}\p{Extended_Pictographic}\p{Emoji_Component}]) *)+$/u);
|
|
3267
|
+
var contextsPredicate = import_zod6.z.array(import_zod6.z.nativeEnum(import_v1036.InteractionContextType));
|
|
3268
|
+
var integrationTypesPredicate = import_zod6.z.array(import_zod6.z.nativeEnum(import_v1036.ApplicationIntegrationType));
|
|
3269
|
+
var baseContextMenuCommandPredicate = import_zod6.z.object({
|
|
2379
3270
|
contexts: contextsPredicate.optional(),
|
|
2380
3271
|
default_member_permissions: memberPermissionsPredicate.optional(),
|
|
2381
3272
|
name: namePredicate2,
|
|
2382
3273
|
name_localizations: localeMapPredicate.optional(),
|
|
2383
3274
|
integration_types: integrationTypesPredicate.optional(),
|
|
2384
|
-
nsfw:
|
|
3275
|
+
nsfw: import_zod6.z.boolean().optional()
|
|
2385
3276
|
});
|
|
2386
3277
|
var userCommandPredicate = baseContextMenuCommandPredicate.extend({
|
|
2387
|
-
type:
|
|
3278
|
+
type: import_zod6.z.literal(import_v1036.ApplicationCommandType.User)
|
|
2388
3279
|
});
|
|
2389
3280
|
var messageCommandPredicate = baseContextMenuCommandPredicate.extend({
|
|
2390
|
-
type:
|
|
3281
|
+
type: import_zod6.z.literal(import_v1036.ApplicationCommandType.Message)
|
|
2391
3282
|
});
|
|
2392
3283
|
|
|
2393
3284
|
// src/interactions/commands/contextMenu/ContextMenuCommand.ts
|
|
@@ -2407,7 +3298,7 @@ var ContextMenuCommandBuilder = class extends (0, import_ts_mixer9.Mixin)(
|
|
|
2407
3298
|
};
|
|
2408
3299
|
|
|
2409
3300
|
// src/interactions/commands/contextMenu/MessageCommand.ts
|
|
2410
|
-
var
|
|
3301
|
+
var import_v1037 = require("discord-api-types/v10");
|
|
2411
3302
|
var MessageContextCommandBuilder = class extends ContextMenuCommandBuilder {
|
|
2412
3303
|
static {
|
|
2413
3304
|
__name(this, "MessageContextCommandBuilder");
|
|
@@ -2416,14 +3307,14 @@ var MessageContextCommandBuilder = class extends ContextMenuCommandBuilder {
|
|
|
2416
3307
|
* {@inheritDoc CommandBuilder.toJSON}
|
|
2417
3308
|
*/
|
|
2418
3309
|
toJSON(validationOverride) {
|
|
2419
|
-
const data = { ...structuredClone(this.data), type:
|
|
3310
|
+
const data = { ...structuredClone(this.data), type: import_v1037.ApplicationCommandType.Message };
|
|
2420
3311
|
validate(messageCommandPredicate, data, validationOverride);
|
|
2421
3312
|
return data;
|
|
2422
3313
|
}
|
|
2423
3314
|
};
|
|
2424
3315
|
|
|
2425
3316
|
// src/interactions/commands/contextMenu/UserCommand.ts
|
|
2426
|
-
var
|
|
3317
|
+
var import_v1038 = require("discord-api-types/v10");
|
|
2427
3318
|
var UserContextCommandBuilder = class extends ContextMenuCommandBuilder {
|
|
2428
3319
|
static {
|
|
2429
3320
|
__name(this, "UserContextCommandBuilder");
|
|
@@ -2432,22 +3323,22 @@ var UserContextCommandBuilder = class extends ContextMenuCommandBuilder {
|
|
|
2432
3323
|
* {@inheritDoc CommandBuilder.toJSON}
|
|
2433
3324
|
*/
|
|
2434
3325
|
toJSON(validationOverride) {
|
|
2435
|
-
const data = { ...structuredClone(this.data), type:
|
|
3326
|
+
const data = { ...structuredClone(this.data), type: import_v1038.ApplicationCommandType.User };
|
|
2436
3327
|
validate(userCommandPredicate, data, validationOverride);
|
|
2437
3328
|
return data;
|
|
2438
3329
|
}
|
|
2439
3330
|
};
|
|
2440
3331
|
|
|
2441
3332
|
// src/interactions/modals/Assertions.ts
|
|
2442
|
-
var
|
|
2443
|
-
var
|
|
2444
|
-
var titlePredicate =
|
|
2445
|
-
var modalPredicate =
|
|
3333
|
+
var import_v1039 = require("discord-api-types/v10");
|
|
3334
|
+
var import_zod7 = require("zod");
|
|
3335
|
+
var titlePredicate = import_zod7.z.string().min(1).max(45);
|
|
3336
|
+
var modalPredicate = import_zod7.z.object({
|
|
2446
3337
|
title: titlePredicate,
|
|
2447
3338
|
custom_id: customIdPredicate,
|
|
2448
|
-
components:
|
|
2449
|
-
type:
|
|
2450
|
-
components:
|
|
3339
|
+
components: import_zod7.z.object({
|
|
3340
|
+
type: import_zod7.z.literal(import_v1039.ComponentType.ActionRow),
|
|
3341
|
+
components: import_zod7.z.object({ type: import_zod7.z.literal(import_v1039.ComponentType.TextInput) }).array().length(1)
|
|
2451
3342
|
}).array().min(1).max(5)
|
|
2452
3343
|
});
|
|
2453
3344
|
|
|
@@ -2569,7 +3460,7 @@ var ModalBuilder = class {
|
|
|
2569
3460
|
};
|
|
2570
3461
|
|
|
2571
3462
|
// src/messages/embed/Assertions.ts
|
|
2572
|
-
var
|
|
3463
|
+
var import_zod8 = require("zod");
|
|
2573
3464
|
|
|
2574
3465
|
// src/util/componentUtil.ts
|
|
2575
3466
|
function embedLength(data) {
|
|
@@ -2578,36 +3469,36 @@ function embedLength(data) {
|
|
|
2578
3469
|
__name(embedLength, "embedLength");
|
|
2579
3470
|
|
|
2580
3471
|
// src/messages/embed/Assertions.ts
|
|
2581
|
-
var namePredicate3 =
|
|
2582
|
-
var URLPredicate =
|
|
2583
|
-
var URLWithAttachmentProtocolPredicate =
|
|
3472
|
+
var namePredicate3 = import_zod8.z.string().max(256);
|
|
3473
|
+
var URLPredicate = import_zod8.z.string().url().refine(refineURLPredicate(["http:", "https:"]), { message: "Invalid protocol for URL. Must be http: or https:" });
|
|
3474
|
+
var URLWithAttachmentProtocolPredicate = import_zod8.z.string().url().refine(refineURLPredicate(["http:", "https:", "attachment:"]), {
|
|
2584
3475
|
message: "Invalid protocol for URL. Must be http:, https:, or attachment:"
|
|
2585
3476
|
});
|
|
2586
|
-
var embedFieldPredicate =
|
|
3477
|
+
var embedFieldPredicate = import_zod8.z.object({
|
|
2587
3478
|
name: namePredicate3,
|
|
2588
|
-
value:
|
|
2589
|
-
inline:
|
|
3479
|
+
value: import_zod8.z.string().max(1024),
|
|
3480
|
+
inline: import_zod8.z.boolean().optional()
|
|
2590
3481
|
});
|
|
2591
|
-
var embedAuthorPredicate =
|
|
3482
|
+
var embedAuthorPredicate = import_zod8.z.object({
|
|
2592
3483
|
name: namePredicate3.min(1),
|
|
2593
3484
|
icon_url: URLWithAttachmentProtocolPredicate.optional(),
|
|
2594
3485
|
url: URLPredicate.optional()
|
|
2595
3486
|
});
|
|
2596
|
-
var embedFooterPredicate =
|
|
2597
|
-
text:
|
|
3487
|
+
var embedFooterPredicate = import_zod8.z.object({
|
|
3488
|
+
text: import_zod8.z.string().min(1).max(2048),
|
|
2598
3489
|
icon_url: URLWithAttachmentProtocolPredicate.optional()
|
|
2599
3490
|
});
|
|
2600
|
-
var embedPredicate =
|
|
3491
|
+
var embedPredicate = import_zod8.z.object({
|
|
2601
3492
|
title: namePredicate3.min(1).optional(),
|
|
2602
|
-
description:
|
|
3493
|
+
description: import_zod8.z.string().min(1).max(4096).optional(),
|
|
2603
3494
|
url: URLPredicate.optional(),
|
|
2604
|
-
timestamp:
|
|
2605
|
-
color:
|
|
3495
|
+
timestamp: import_zod8.z.string().optional(),
|
|
3496
|
+
color: import_zod8.z.number().int().min(0).max(16777215).optional(),
|
|
2606
3497
|
footer: embedFooterPredicate.optional(),
|
|
2607
|
-
image:
|
|
2608
|
-
thumbnail:
|
|
3498
|
+
image: import_zod8.z.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
3499
|
+
thumbnail: import_zod8.z.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
2609
3500
|
author: embedAuthorPredicate.optional(),
|
|
2610
|
-
fields:
|
|
3501
|
+
fields: import_zod8.z.array(embedFieldPredicate).max(25).optional()
|
|
2611
3502
|
}).refine(
|
|
2612
3503
|
(embed) => embed.title !== void 0 || embed.description !== void 0 || embed.fields !== void 0 && embed.fields.length > 0 || embed.footer !== void 0 || embed.author !== void 0 || embed.image !== void 0 || embed.thumbnail !== void 0,
|
|
2613
3504
|
{
|
|
@@ -3082,20 +3973,20 @@ var EmbedBuilder = class {
|
|
|
3082
3973
|
};
|
|
3083
3974
|
|
|
3084
3975
|
// src/messages/poll/Assertions.ts
|
|
3085
|
-
var
|
|
3086
|
-
var
|
|
3087
|
-
var pollQuestionPredicate =
|
|
3088
|
-
var pollAnswerMediaPredicate =
|
|
3089
|
-
text:
|
|
3976
|
+
var import_v1040 = require("discord-api-types/v10");
|
|
3977
|
+
var import_zod9 = require("zod");
|
|
3978
|
+
var pollQuestionPredicate = import_zod9.z.object({ text: import_zod9.z.string().min(1).max(300) });
|
|
3979
|
+
var pollAnswerMediaPredicate = import_zod9.z.object({
|
|
3980
|
+
text: import_zod9.z.string().min(1).max(55),
|
|
3090
3981
|
emoji: emojiPredicate.optional()
|
|
3091
3982
|
});
|
|
3092
|
-
var pollAnswerPredicate =
|
|
3093
|
-
var pollPredicate =
|
|
3983
|
+
var pollAnswerPredicate = import_zod9.z.object({ poll_media: pollAnswerMediaPredicate });
|
|
3984
|
+
var pollPredicate = import_zod9.z.object({
|
|
3094
3985
|
question: pollQuestionPredicate,
|
|
3095
|
-
answers:
|
|
3096
|
-
duration:
|
|
3097
|
-
allow_multiselect:
|
|
3098
|
-
layout_type:
|
|
3986
|
+
answers: import_zod9.z.array(pollAnswerPredicate).min(1).max(10),
|
|
3987
|
+
duration: import_zod9.z.number().min(1).max(768).optional(),
|
|
3988
|
+
allow_multiselect: import_zod9.z.boolean().optional(),
|
|
3989
|
+
layout_type: import_zod9.z.nativeEnum(import_v1040.PollLayoutType).optional()
|
|
3099
3990
|
});
|
|
3100
3991
|
|
|
3101
3992
|
// src/messages/poll/PollMedia.ts
|
|
@@ -3420,60 +4311,91 @@ var PollBuilder = class {
|
|
|
3420
4311
|
};
|
|
3421
4312
|
|
|
3422
4313
|
// src/messages/Assertions.ts
|
|
3423
|
-
var
|
|
3424
|
-
var
|
|
3425
|
-
var attachmentPredicate =
|
|
3426
|
-
id:
|
|
3427
|
-
description:
|
|
3428
|
-
duration_secs:
|
|
3429
|
-
filename:
|
|
3430
|
-
title:
|
|
3431
|
-
waveform:
|
|
4314
|
+
var import_v1041 = require("discord-api-types/v10");
|
|
4315
|
+
var import_zod10 = require("zod");
|
|
4316
|
+
var attachmentPredicate = import_zod10.z.object({
|
|
4317
|
+
id: import_zod10.z.union([import_zod10.z.string(), import_zod10.z.number()]),
|
|
4318
|
+
description: import_zod10.z.string().optional(),
|
|
4319
|
+
duration_secs: import_zod10.z.number().optional(),
|
|
4320
|
+
filename: import_zod10.z.string().optional(),
|
|
4321
|
+
title: import_zod10.z.string().optional(),
|
|
4322
|
+
waveform: import_zod10.z.string().optional()
|
|
3432
4323
|
});
|
|
3433
|
-
var allowedMentionPredicate =
|
|
3434
|
-
parse:
|
|
3435
|
-
roles:
|
|
3436
|
-
users:
|
|
3437
|
-
replied_user:
|
|
4324
|
+
var allowedMentionPredicate = import_zod10.z.object({
|
|
4325
|
+
parse: import_zod10.z.nativeEnum(import_v1041.AllowedMentionsTypes).array().optional(),
|
|
4326
|
+
roles: import_zod10.z.string().array().optional(),
|
|
4327
|
+
users: import_zod10.z.string().array().optional(),
|
|
4328
|
+
replied_user: import_zod10.z.boolean().optional()
|
|
3438
4329
|
});
|
|
3439
|
-
var messageReferencePredicate =
|
|
3440
|
-
channel_id:
|
|
3441
|
-
fail_if_not_exists:
|
|
3442
|
-
guild_id:
|
|
3443
|
-
message_id:
|
|
3444
|
-
type:
|
|
4330
|
+
var messageReferencePredicate = import_zod10.z.object({
|
|
4331
|
+
channel_id: import_zod10.z.string().optional(),
|
|
4332
|
+
fail_if_not_exists: import_zod10.z.boolean().optional(),
|
|
4333
|
+
guild_id: import_zod10.z.string().optional(),
|
|
4334
|
+
message_id: import_zod10.z.string(),
|
|
4335
|
+
type: import_zod10.z.nativeEnum(import_v1041.MessageReferenceType).optional()
|
|
3445
4336
|
});
|
|
3446
|
-
var
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
tts: import_zod9.z.boolean().optional(),
|
|
3450
|
-
embeds: embedPredicate.array().max(10).optional(),
|
|
4337
|
+
var baseMessagePredicate = import_zod10.z.object({
|
|
4338
|
+
nonce: import_zod10.z.union([import_zod10.z.string().max(25), import_zod10.z.number()]).optional(),
|
|
4339
|
+
tts: import_zod10.z.boolean().optional(),
|
|
3451
4340
|
allowed_mentions: allowedMentionPredicate.optional(),
|
|
3452
4341
|
message_reference: messageReferencePredicate.optional(),
|
|
3453
|
-
// Partial validation here to ensure the components are valid,
|
|
3454
|
-
// rest of the validation is done in the action row predicate
|
|
3455
|
-
components: import_zod9.z.object({
|
|
3456
|
-
type: import_zod9.z.literal(import_v1033.ComponentType.ActionRow),
|
|
3457
|
-
components: import_zod9.z.object({
|
|
3458
|
-
type: import_zod9.z.union([
|
|
3459
|
-
import_zod9.z.literal(import_v1033.ComponentType.Button),
|
|
3460
|
-
import_zod9.z.literal(import_v1033.ComponentType.ChannelSelect),
|
|
3461
|
-
import_zod9.z.literal(import_v1033.ComponentType.MentionableSelect),
|
|
3462
|
-
import_zod9.z.literal(import_v1033.ComponentType.RoleSelect),
|
|
3463
|
-
import_zod9.z.literal(import_v1033.ComponentType.StringSelect),
|
|
3464
|
-
import_zod9.z.literal(import_v1033.ComponentType.UserSelect)
|
|
3465
|
-
])
|
|
3466
|
-
}).array()
|
|
3467
|
-
}).array().max(5).optional(),
|
|
3468
|
-
sticker_ids: import_zod9.z.array(import_zod9.z.string()).min(0).max(3).optional(),
|
|
3469
4342
|
attachments: attachmentPredicate.array().max(10).optional(),
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
4343
|
+
enforce_nonce: import_zod10.z.boolean().optional()
|
|
4344
|
+
});
|
|
4345
|
+
var basicActionRowPredicate = import_zod10.z.object({
|
|
4346
|
+
type: import_zod10.z.literal(import_v1041.ComponentType.ActionRow),
|
|
4347
|
+
components: import_zod10.z.object({
|
|
4348
|
+
type: import_zod10.z.union([
|
|
4349
|
+
import_zod10.z.literal(import_v1041.ComponentType.Button),
|
|
4350
|
+
import_zod10.z.literal(import_v1041.ComponentType.ChannelSelect),
|
|
4351
|
+
import_zod10.z.literal(import_v1041.ComponentType.MentionableSelect),
|
|
4352
|
+
import_zod10.z.literal(import_v1041.ComponentType.RoleSelect),
|
|
4353
|
+
import_zod10.z.literal(import_v1041.ComponentType.StringSelect),
|
|
4354
|
+
import_zod10.z.literal(import_v1041.ComponentType.UserSelect)
|
|
4355
|
+
])
|
|
4356
|
+
}).array()
|
|
4357
|
+
});
|
|
4358
|
+
var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4359
|
+
content: import_zod10.z.string().optional(),
|
|
4360
|
+
embeds: embedPredicate.array().max(10).optional(),
|
|
4361
|
+
sticker_ids: import_zod10.z.array(import_zod10.z.string()).min(0).max(3).optional(),
|
|
4362
|
+
poll: pollPredicate.optional(),
|
|
4363
|
+
components: basicActionRowPredicate.array().max(5).optional(),
|
|
4364
|
+
flags: import_zod10.z.number().optional().refine((flags) => {
|
|
4365
|
+
if (flags) {
|
|
4366
|
+
return (flags & import_v1041.MessageFlags.IsComponentsV2) === 0;
|
|
4367
|
+
}
|
|
4368
|
+
return true;
|
|
4369
|
+
})
|
|
3473
4370
|
}).refine(
|
|
3474
4371
|
(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,
|
|
3475
|
-
{ message: "Messages must have content, embeds, a poll, attachments, components
|
|
4372
|
+
{ message: "Messages must have content, embeds, a poll, attachments, components or stickers" }
|
|
3476
4373
|
);
|
|
4374
|
+
var allTopLevelComponentsPredicate = import_zod10.z.union([
|
|
4375
|
+
basicActionRowPredicate,
|
|
4376
|
+
import_zod10.z.object({
|
|
4377
|
+
type: import_zod10.z.union([
|
|
4378
|
+
// Components v2
|
|
4379
|
+
import_zod10.z.literal(import_v1041.ComponentType.Container),
|
|
4380
|
+
import_zod10.z.literal(import_v1041.ComponentType.File),
|
|
4381
|
+
import_zod10.z.literal(import_v1041.ComponentType.MediaGallery),
|
|
4382
|
+
import_zod10.z.literal(import_v1041.ComponentType.Section),
|
|
4383
|
+
import_zod10.z.literal(import_v1041.ComponentType.Separator),
|
|
4384
|
+
import_zod10.z.literal(import_v1041.ComponentType.TextDisplay),
|
|
4385
|
+
import_zod10.z.literal(import_v1041.ComponentType.Thumbnail)
|
|
4386
|
+
])
|
|
4387
|
+
})
|
|
4388
|
+
]).array().min(1).max(10);
|
|
4389
|
+
var messageComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4390
|
+
components: allTopLevelComponentsPredicate,
|
|
4391
|
+
flags: import_zod10.z.number().refine((flags) => (flags & import_v1041.MessageFlags.IsComponentsV2) === import_v1041.MessageFlags.IsComponentsV2),
|
|
4392
|
+
// These fields cannot be set
|
|
4393
|
+
content: import_zod10.z.string().length(0).nullish(),
|
|
4394
|
+
embeds: import_zod10.z.array(import_zod10.z.never()).nullish(),
|
|
4395
|
+
sticker_ids: import_zod10.z.array(import_zod10.z.never()).nullish(),
|
|
4396
|
+
poll: import_zod10.z.null().optional()
|
|
4397
|
+
});
|
|
4398
|
+
var messagePredicate = import_zod10.z.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
|
|
3477
4399
|
|
|
3478
4400
|
// src/messages/AllowedMentions.ts
|
|
3479
4401
|
var AllowedMentionsBuilder = class {
|
|
@@ -3867,7 +4789,7 @@ var MessageBuilder = class {
|
|
|
3867
4789
|
attachments: data.attachments?.map((attachment) => new AttachmentBuilder(attachment)) ?? [],
|
|
3868
4790
|
embeds: data.embeds?.map((embed) => new EmbedBuilder(embed)) ?? [],
|
|
3869
4791
|
poll: data.poll ? new PollBuilder(data.poll) : void 0,
|
|
3870
|
-
components: data.components?.map((component) =>
|
|
4792
|
+
components: data.components?.map((component) => createComponentBuilder(component)) ?? [],
|
|
3871
4793
|
message_reference: data.message_reference ? new MessageReferenceBuilder(data.message_reference) : void 0
|
|
3872
4794
|
};
|
|
3873
4795
|
}
|
|
@@ -4024,16 +4946,82 @@ var MessageBuilder = class {
|
|
|
4024
4946
|
return this;
|
|
4025
4947
|
}
|
|
4026
4948
|
/**
|
|
4027
|
-
* Adds components to this message.
|
|
4949
|
+
* Adds action row components to this message.
|
|
4028
4950
|
*
|
|
4029
|
-
* @param components - The components to add
|
|
4951
|
+
* @param components - The action row components to add
|
|
4030
4952
|
*/
|
|
4031
|
-
|
|
4953
|
+
addActionRowComponents(...components) {
|
|
4032
4954
|
this.data.components ??= [];
|
|
4033
4955
|
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, ActionRowBuilder));
|
|
4034
4956
|
this.data.components.push(...resolved);
|
|
4035
4957
|
return this;
|
|
4036
4958
|
}
|
|
4959
|
+
/**
|
|
4960
|
+
* Adds container components to this message.
|
|
4961
|
+
*
|
|
4962
|
+
* @param components - The container components to add
|
|
4963
|
+
*/
|
|
4964
|
+
addContainerComponents(...components) {
|
|
4965
|
+
this.data.components ??= [];
|
|
4966
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, ContainerBuilder));
|
|
4967
|
+
this.data.components.push(...resolved);
|
|
4968
|
+
return this;
|
|
4969
|
+
}
|
|
4970
|
+
/**
|
|
4971
|
+
* Adds file components to this message.
|
|
4972
|
+
*
|
|
4973
|
+
* @param components - The file components to add
|
|
4974
|
+
*/
|
|
4975
|
+
addFileComponents(...components) {
|
|
4976
|
+
this.data.components ??= [];
|
|
4977
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, FileBuilder));
|
|
4978
|
+
this.data.components.push(...resolved);
|
|
4979
|
+
return this;
|
|
4980
|
+
}
|
|
4981
|
+
/**
|
|
4982
|
+
* Adds media gallery components to this message.
|
|
4983
|
+
*
|
|
4984
|
+
* @param components - The media gallery components to add
|
|
4985
|
+
*/
|
|
4986
|
+
addMediaGalleryComponents(...components) {
|
|
4987
|
+
this.data.components ??= [];
|
|
4988
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, MediaGalleryBuilder));
|
|
4989
|
+
this.data.components.push(...resolved);
|
|
4990
|
+
return this;
|
|
4991
|
+
}
|
|
4992
|
+
/**
|
|
4993
|
+
* Adds section components to this message.
|
|
4994
|
+
*
|
|
4995
|
+
* @param components - The section components to add
|
|
4996
|
+
*/
|
|
4997
|
+
addSectionComponents(...components) {
|
|
4998
|
+
this.data.components ??= [];
|
|
4999
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, SectionBuilder));
|
|
5000
|
+
this.data.components.push(...resolved);
|
|
5001
|
+
return this;
|
|
5002
|
+
}
|
|
5003
|
+
/**
|
|
5004
|
+
* Adds separator components to this message.
|
|
5005
|
+
*
|
|
5006
|
+
* @param components - The separator components to add
|
|
5007
|
+
*/
|
|
5008
|
+
addSeparatorComponents(...components) {
|
|
5009
|
+
this.data.components ??= [];
|
|
5010
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, SeparatorBuilder));
|
|
5011
|
+
this.data.components.push(...resolved);
|
|
5012
|
+
return this;
|
|
5013
|
+
}
|
|
5014
|
+
/**
|
|
5015
|
+
* Adds text display components to this message.
|
|
5016
|
+
*
|
|
5017
|
+
* @param components - The text display components to add
|
|
5018
|
+
*/
|
|
5019
|
+
addTextDisplayComponents(...components) {
|
|
5020
|
+
this.data.components ??= [];
|
|
5021
|
+
const resolved = normalizeArray(components).map((component) => resolveBuilder(component, TextDisplayBuilder));
|
|
5022
|
+
this.data.components.push(...resolved);
|
|
5023
|
+
return this;
|
|
5024
|
+
}
|
|
4037
5025
|
/**
|
|
4038
5026
|
* Removes, replaces, or inserts components for this message.
|
|
4039
5027
|
*
|
|
@@ -4064,19 +5052,12 @@ var MessageBuilder = class {
|
|
|
4064
5052
|
*/
|
|
4065
5053
|
spliceComponents(start, deleteCount, ...components) {
|
|
4066
5054
|
this.data.components ??= [];
|
|
4067
|
-
const resolved = normalizeArray(components).map(
|
|
5055
|
+
const resolved = normalizeArray(components).map(
|
|
5056
|
+
(component) => component instanceof ComponentBuilder ? component : createComponentBuilder(component)
|
|
5057
|
+
);
|
|
4068
5058
|
this.data.components.splice(start, deleteCount, ...resolved);
|
|
4069
5059
|
return this;
|
|
4070
5060
|
}
|
|
4071
|
-
/**
|
|
4072
|
-
* Sets the components of this message.
|
|
4073
|
-
*
|
|
4074
|
-
* @param components - The components to set
|
|
4075
|
-
*/
|
|
4076
|
-
setComponents(...components) {
|
|
4077
|
-
this.data.components = normalizeArray(components).map((component) => resolveBuilder(component, ActionRowBuilder));
|
|
4078
|
-
return this;
|
|
4079
|
-
}
|
|
4080
5061
|
/**
|
|
4081
5062
|
* Sets the sticker ids of this message.
|
|
4082
5063
|
*
|
|
@@ -4254,7 +5235,7 @@ var MessageBuilder = class {
|
|
|
4254
5235
|
};
|
|
4255
5236
|
|
|
4256
5237
|
// src/index.ts
|
|
4257
|
-
var version = "2.0.0-dev.
|
|
5238
|
+
var version = "2.0.0-dev.1745453588-abc5d99ce";
|
|
4258
5239
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4259
5240
|
0 && (module.exports = {
|
|
4260
5241
|
ActionRowBuilder,
|
|
@@ -4291,7 +5272,10 @@ var version = "2.0.0-dev.1745194448-8f35dfd03";
|
|
|
4291
5272
|
EmbedFieldBuilder,
|
|
4292
5273
|
EmbedFooterBuilder,
|
|
4293
5274
|
EmojiOrLabelButtonMixin,
|
|
5275
|
+
FileBuilder,
|
|
4294
5276
|
LinkButtonBuilder,
|
|
5277
|
+
MediaGalleryBuilder,
|
|
5278
|
+
MediaGalleryItemBuilder,
|
|
4295
5279
|
MentionableSelectMenuBuilder,
|
|
4296
5280
|
MessageBuilder,
|
|
4297
5281
|
MessageContextCommandBuilder,
|
|
@@ -4306,6 +5290,8 @@ var version = "2.0.0-dev.1745194448-8f35dfd03";
|
|
|
4306
5290
|
PrimaryButtonBuilder,
|
|
4307
5291
|
RoleSelectMenuBuilder,
|
|
4308
5292
|
SecondaryButtonBuilder,
|
|
5293
|
+
SectionBuilder,
|
|
5294
|
+
SeparatorBuilder,
|
|
4309
5295
|
SharedChatInputCommandOptions,
|
|
4310
5296
|
SharedChatInputCommandSubcommands,
|
|
4311
5297
|
SharedName,
|
|
@@ -4313,7 +5299,9 @@ var version = "2.0.0-dev.1745194448-8f35dfd03";
|
|
|
4313
5299
|
StringSelectMenuBuilder,
|
|
4314
5300
|
StringSelectMenuOptionBuilder,
|
|
4315
5301
|
SuccessButtonBuilder,
|
|
5302
|
+
TextDisplayBuilder,
|
|
4316
5303
|
TextInputBuilder,
|
|
5304
|
+
ThumbnailBuilder,
|
|
4317
5305
|
UserContextCommandBuilder,
|
|
4318
5306
|
UserSelectMenuBuilder,
|
|
4319
5307
|
actionRowPredicate,
|
|
@@ -4325,6 +5313,7 @@ var version = "2.0.0-dev.1745194448-8f35dfd03";
|
|
|
4325
5313
|
chatInputCommandPredicate,
|
|
4326
5314
|
chatInputCommandSubcommandGroupPredicate,
|
|
4327
5315
|
chatInputCommandSubcommandPredicate,
|
|
5316
|
+
containerPredicate,
|
|
4328
5317
|
createComponentBuilder,
|
|
4329
5318
|
customIdPredicate,
|
|
4330
5319
|
disableValidators,
|
|
@@ -4335,9 +5324,12 @@ var version = "2.0.0-dev.1745194448-8f35dfd03";
|
|
|
4335
5324
|
embedPredicate,
|
|
4336
5325
|
emojiPredicate,
|
|
4337
5326
|
enableValidators,
|
|
5327
|
+
filePredicate,
|
|
4338
5328
|
integerOptionPredicate,
|
|
4339
5329
|
isValidationEnabled,
|
|
4340
5330
|
localeMapPredicate,
|
|
5331
|
+
mediaGalleryItemPredicate,
|
|
5332
|
+
mediaGalleryPredicate,
|
|
4341
5333
|
memberPermissionsPredicate,
|
|
4342
5334
|
messageCommandPredicate,
|
|
4343
5335
|
messagePredicate,
|
|
@@ -4350,15 +5342,20 @@ var version = "2.0.0-dev.1745194448-8f35dfd03";
|
|
|
4350
5342
|
pollPredicate,
|
|
4351
5343
|
pollQuestionPredicate,
|
|
4352
5344
|
refineURLPredicate,
|
|
5345
|
+
resolveAccessoryComponent,
|
|
4353
5346
|
resolveBuilder,
|
|
5347
|
+
sectionPredicate,
|
|
4354
5348
|
selectMenuChannelPredicate,
|
|
4355
5349
|
selectMenuMentionablePredicate,
|
|
4356
5350
|
selectMenuRolePredicate,
|
|
4357
5351
|
selectMenuStringOptionPredicate,
|
|
4358
5352
|
selectMenuStringPredicate,
|
|
4359
5353
|
selectMenuUserPredicate,
|
|
5354
|
+
separatorPredicate,
|
|
4360
5355
|
stringOptionPredicate,
|
|
5356
|
+
textDisplayPredicate,
|
|
4361
5357
|
textInputPredicate,
|
|
5358
|
+
thumbnailPredicate,
|
|
4362
5359
|
userCommandPredicate,
|
|
4363
5360
|
validate,
|
|
4364
5361
|
version
|