@discordjs/builders 2.0.0-dev.1757073695-ddf9f818e → 2.0.0-dev.1757160090-352c9819b
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 +436 -298
- package/dist/index.d.ts +436 -298
- package/dist/index.js +581 -464
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +533 -418
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -370,6 +370,44 @@ var PremiumButtonBuilder = class extends BaseButtonBuilder {
|
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
372
|
|
|
373
|
+
// src/components/label/Label.ts
|
|
374
|
+
import { ComponentType as ComponentType23 } from "discord-api-types/v10";
|
|
375
|
+
|
|
376
|
+
// src/util/resolveBuilder.ts
|
|
377
|
+
function isBuilder(builder, Constructor) {
|
|
378
|
+
return builder instanceof Constructor;
|
|
379
|
+
}
|
|
380
|
+
__name(isBuilder, "isBuilder");
|
|
381
|
+
function resolveBuilder(builder, Constructor) {
|
|
382
|
+
if (isBuilder(builder, Constructor)) {
|
|
383
|
+
return builder;
|
|
384
|
+
}
|
|
385
|
+
if (typeof builder === "function") {
|
|
386
|
+
return builder(new Constructor());
|
|
387
|
+
}
|
|
388
|
+
return new Constructor(builder);
|
|
389
|
+
}
|
|
390
|
+
__name(resolveBuilder, "resolveBuilder");
|
|
391
|
+
|
|
392
|
+
// src/components/Components.ts
|
|
393
|
+
import { ButtonStyle as ButtonStyle5, ComponentType as ComponentType21 } from "discord-api-types/v10";
|
|
394
|
+
|
|
395
|
+
// src/components/ActionRow.ts
|
|
396
|
+
import { ComponentType as ComponentType12 } from "discord-api-types/v10";
|
|
397
|
+
|
|
398
|
+
// src/util/normalizeArray.ts
|
|
399
|
+
function normalizeArray(arr) {
|
|
400
|
+
if (Array.isArray(arr[0])) return [...arr[0]];
|
|
401
|
+
return arr;
|
|
402
|
+
}
|
|
403
|
+
__name(normalizeArray, "normalizeArray");
|
|
404
|
+
|
|
405
|
+
// src/components/selectMenu/ChannelSelectMenu.ts
|
|
406
|
+
import {
|
|
407
|
+
ComponentType as ComponentType5,
|
|
408
|
+
SelectMenuDefaultValueType as SelectMenuDefaultValueType2
|
|
409
|
+
} from "discord-api-types/v10";
|
|
410
|
+
|
|
373
411
|
// src/components/selectMenu/BaseSelectMenu.ts
|
|
374
412
|
var BaseSelectMenuBuilder = class extends ComponentBuilder {
|
|
375
413
|
static {
|
|
@@ -429,19 +467,6 @@ var BaseSelectMenuBuilder = class extends ComponentBuilder {
|
|
|
429
467
|
}
|
|
430
468
|
};
|
|
431
469
|
|
|
432
|
-
// src/components/selectMenu/ChannelSelectMenu.ts
|
|
433
|
-
import {
|
|
434
|
-
ComponentType as ComponentType5,
|
|
435
|
-
SelectMenuDefaultValueType as SelectMenuDefaultValueType2
|
|
436
|
-
} from "discord-api-types/v10";
|
|
437
|
-
|
|
438
|
-
// src/util/normalizeArray.ts
|
|
439
|
-
function normalizeArray(arr) {
|
|
440
|
-
if (Array.isArray(arr[0])) return [...arr[0]];
|
|
441
|
-
return arr;
|
|
442
|
-
}
|
|
443
|
-
__name(normalizeArray, "normalizeArray");
|
|
444
|
-
|
|
445
470
|
// src/components/selectMenu/ChannelSelectMenu.ts
|
|
446
471
|
var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
447
472
|
static {
|
|
@@ -713,22 +738,6 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
713
738
|
// src/components/selectMenu/StringSelectMenu.ts
|
|
714
739
|
import { ComponentType as ComponentType8 } from "discord-api-types/v10";
|
|
715
740
|
|
|
716
|
-
// src/util/resolveBuilder.ts
|
|
717
|
-
function isBuilder(builder, Constructor) {
|
|
718
|
-
return builder instanceof Constructor;
|
|
719
|
-
}
|
|
720
|
-
__name(isBuilder, "isBuilder");
|
|
721
|
-
function resolveBuilder(builder, Constructor) {
|
|
722
|
-
if (isBuilder(builder, Constructor)) {
|
|
723
|
-
return builder;
|
|
724
|
-
}
|
|
725
|
-
if (typeof builder === "function") {
|
|
726
|
-
return builder(new Constructor());
|
|
727
|
-
}
|
|
728
|
-
return new Constructor(builder);
|
|
729
|
-
}
|
|
730
|
-
__name(resolveBuilder, "resolveBuilder");
|
|
731
|
-
|
|
732
741
|
// src/components/selectMenu/StringSelectMenuOption.ts
|
|
733
742
|
var StringSelectMenuOptionBuilder = class {
|
|
734
743
|
static {
|
|
@@ -933,6 +942,16 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
933
942
|
this.data.options.splice(index, deleteCount, ...resolved);
|
|
934
943
|
return this;
|
|
935
944
|
}
|
|
945
|
+
/**
|
|
946
|
+
* Sets whether this string select menu is required.
|
|
947
|
+
*
|
|
948
|
+
* @remarks Only for use in modals.
|
|
949
|
+
* @param required - Whether this string select menu is required
|
|
950
|
+
*/
|
|
951
|
+
setRequired(required = true) {
|
|
952
|
+
this.data.required = required;
|
|
953
|
+
return this;
|
|
954
|
+
}
|
|
936
955
|
/**
|
|
937
956
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
938
957
|
*/
|
|
@@ -1032,7 +1051,6 @@ import { z as z4 } from "zod";
|
|
|
1032
1051
|
var textInputPredicate = z4.object({
|
|
1033
1052
|
type: z4.literal(ComponentType10.TextInput),
|
|
1034
1053
|
custom_id: customIdPredicate,
|
|
1035
|
-
label: z4.string().min(1).max(45),
|
|
1036
1054
|
style: z4.enum(TextInputStyle),
|
|
1037
1055
|
min_length: z4.number().min(0).max(4e3).optional(),
|
|
1038
1056
|
max_length: z4.number().min(1).max(4e3).optional(),
|
|
@@ -1059,7 +1077,7 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1059
1077
|
* ```ts
|
|
1060
1078
|
* const textInput = new TextInputBuilder({
|
|
1061
1079
|
* custom_id: 'a cool text input',
|
|
1062
|
-
*
|
|
1080
|
+
* placeholder: 'Type something',
|
|
1063
1081
|
* style: TextInputStyle.Short,
|
|
1064
1082
|
* });
|
|
1065
1083
|
* ```
|
|
@@ -1067,7 +1085,7 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1067
1085
|
* Creating a text input using setters and API data:
|
|
1068
1086
|
* ```ts
|
|
1069
1087
|
* const textInput = new TextInputBuilder({
|
|
1070
|
-
*
|
|
1088
|
+
* placeholder: 'Type something else',
|
|
1071
1089
|
* })
|
|
1072
1090
|
* .setCustomId('woah')
|
|
1073
1091
|
* .setStyle(TextInputStyle.Paragraph);
|
|
@@ -1086,15 +1104,6 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1086
1104
|
this.data.custom_id = customId;
|
|
1087
1105
|
return this;
|
|
1088
1106
|
}
|
|
1089
|
-
/**
|
|
1090
|
-
* Sets the label for this text input.
|
|
1091
|
-
*
|
|
1092
|
-
* @param label - The label to use
|
|
1093
|
-
*/
|
|
1094
|
-
setLabel(label) {
|
|
1095
|
-
this.data.label = label;
|
|
1096
|
-
return this;
|
|
1097
|
-
}
|
|
1098
1107
|
/**
|
|
1099
1108
|
* Sets the style for this text input.
|
|
1100
1109
|
*
|
|
@@ -1164,42 +1173,266 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1164
1173
|
/**
|
|
1165
1174
|
* Clears the value for this text input.
|
|
1166
1175
|
*/
|
|
1167
|
-
clearValue() {
|
|
1168
|
-
this.data.value = void 0;
|
|
1176
|
+
clearValue() {
|
|
1177
|
+
this.data.value = void 0;
|
|
1178
|
+
return this;
|
|
1179
|
+
}
|
|
1180
|
+
/**
|
|
1181
|
+
* Sets whether this text input is required.
|
|
1182
|
+
*
|
|
1183
|
+
* @param required - Whether this text input is required
|
|
1184
|
+
*/
|
|
1185
|
+
setRequired(required = true) {
|
|
1186
|
+
this.data.required = required;
|
|
1187
|
+
return this;
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1191
|
+
*/
|
|
1192
|
+
toJSON(validationOverride) {
|
|
1193
|
+
const clone = structuredClone(this.data);
|
|
1194
|
+
validate(textInputPredicate, clone, validationOverride);
|
|
1195
|
+
return clone;
|
|
1196
|
+
}
|
|
1197
|
+
};
|
|
1198
|
+
|
|
1199
|
+
// src/components/ActionRow.ts
|
|
1200
|
+
var ActionRowBuilder = class extends ComponentBuilder {
|
|
1201
|
+
static {
|
|
1202
|
+
__name(this, "ActionRowBuilder");
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* @internal
|
|
1206
|
+
*/
|
|
1207
|
+
data;
|
|
1208
|
+
/**
|
|
1209
|
+
* The components within this action row.
|
|
1210
|
+
*/
|
|
1211
|
+
get components() {
|
|
1212
|
+
return this.data.components;
|
|
1213
|
+
}
|
|
1214
|
+
/**
|
|
1215
|
+
* Creates a new action row.
|
|
1216
|
+
*
|
|
1217
|
+
* @param data - The API data to create this action row with
|
|
1218
|
+
* @example
|
|
1219
|
+
* Creating an action row from an API data object:
|
|
1220
|
+
* ```ts
|
|
1221
|
+
* const actionRow = new ActionRowBuilder({
|
|
1222
|
+
* components: [
|
|
1223
|
+
* {
|
|
1224
|
+
* custom_id: "custom id",
|
|
1225
|
+
* label: "Type something",
|
|
1226
|
+
* style: TextInputStyle.Short,
|
|
1227
|
+
* type: ComponentType.TextInput,
|
|
1228
|
+
* },
|
|
1229
|
+
* ],
|
|
1230
|
+
* });
|
|
1231
|
+
* ```
|
|
1232
|
+
* @example
|
|
1233
|
+
* Creating an action row using setters and API data:
|
|
1234
|
+
* ```ts
|
|
1235
|
+
* const actionRow = new ActionRowBuilder({
|
|
1236
|
+
* components: [
|
|
1237
|
+
* {
|
|
1238
|
+
* custom_id: "custom id",
|
|
1239
|
+
* label: "Click me",
|
|
1240
|
+
* style: ButtonStyle.Primary,
|
|
1241
|
+
* type: ComponentType.Button,
|
|
1242
|
+
* },
|
|
1243
|
+
* ],
|
|
1244
|
+
* })
|
|
1245
|
+
* .addComponents(button2, button3);
|
|
1246
|
+
* ```
|
|
1247
|
+
*/
|
|
1248
|
+
constructor(data = {}) {
|
|
1249
|
+
super();
|
|
1250
|
+
const { components = [], ...rest } = data;
|
|
1251
|
+
this.data = {
|
|
1252
|
+
...structuredClone(rest),
|
|
1253
|
+
components: components.map((component) => createComponentBuilder(component)),
|
|
1254
|
+
type: ComponentType12.ActionRow
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
/**
|
|
1258
|
+
* Adds primary button components to this action row.
|
|
1259
|
+
*
|
|
1260
|
+
* @param input - The buttons to add
|
|
1261
|
+
*/
|
|
1262
|
+
addPrimaryButtonComponents(...input) {
|
|
1263
|
+
const normalized = normalizeArray(input);
|
|
1264
|
+
const resolved = normalized.map((component) => resolveBuilder(component, PrimaryButtonBuilder));
|
|
1265
|
+
this.data.components.push(...resolved);
|
|
1266
|
+
return this;
|
|
1267
|
+
}
|
|
1268
|
+
/**
|
|
1269
|
+
* Adds secondary button components to this action row.
|
|
1270
|
+
*
|
|
1271
|
+
* @param input - The buttons to add
|
|
1272
|
+
*/
|
|
1273
|
+
addSecondaryButtonComponents(...input) {
|
|
1274
|
+
const normalized = normalizeArray(input);
|
|
1275
|
+
const resolved = normalized.map((component) => resolveBuilder(component, SecondaryButtonBuilder));
|
|
1276
|
+
this.data.components.push(...resolved);
|
|
1277
|
+
return this;
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* Adds success button components to this action row.
|
|
1281
|
+
*
|
|
1282
|
+
* @param input - The buttons to add
|
|
1283
|
+
*/
|
|
1284
|
+
addSuccessButtonComponents(...input) {
|
|
1285
|
+
const normalized = normalizeArray(input);
|
|
1286
|
+
const resolved = normalized.map((component) => resolveBuilder(component, SuccessButtonBuilder));
|
|
1287
|
+
this.data.components.push(...resolved);
|
|
1288
|
+
return this;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* Adds danger button components to this action row.
|
|
1292
|
+
*/
|
|
1293
|
+
addDangerButtonComponents(...input) {
|
|
1294
|
+
const normalized = normalizeArray(input);
|
|
1295
|
+
const resolved = normalized.map((component) => resolveBuilder(component, DangerButtonBuilder));
|
|
1296
|
+
this.data.components.push(...resolved);
|
|
1297
|
+
return this;
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Generically add any type of component to this action row, only takes in an instance of a component builder.
|
|
1301
|
+
*/
|
|
1302
|
+
addComponents(...input) {
|
|
1303
|
+
const normalized = normalizeArray(input);
|
|
1304
|
+
this.data.components.push(...normalized);
|
|
1305
|
+
return this;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Adds SKU id button components to this action row.
|
|
1309
|
+
*
|
|
1310
|
+
* @param input - The buttons to add
|
|
1311
|
+
*/
|
|
1312
|
+
addPremiumButtonComponents(...input) {
|
|
1313
|
+
const normalized = normalizeArray(input);
|
|
1314
|
+
const resolved = normalized.map((component) => resolveBuilder(component, PremiumButtonBuilder));
|
|
1315
|
+
this.data.components.push(...resolved);
|
|
1316
|
+
return this;
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Adds URL button components to this action row.
|
|
1320
|
+
*
|
|
1321
|
+
* @param input - The buttons to add
|
|
1322
|
+
*/
|
|
1323
|
+
addLinkButtonComponents(...input) {
|
|
1324
|
+
const normalized = normalizeArray(input);
|
|
1325
|
+
const resolved = normalized.map((component) => resolveBuilder(component, LinkButtonBuilder));
|
|
1326
|
+
this.data.components.push(...resolved);
|
|
1327
|
+
return this;
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* Adds a channel select menu component to this action row.
|
|
1331
|
+
*
|
|
1332
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1333
|
+
*/
|
|
1334
|
+
addChannelSelectMenuComponent(input) {
|
|
1335
|
+
this.data.components.push(resolveBuilder(input, ChannelSelectMenuBuilder));
|
|
1336
|
+
return this;
|
|
1337
|
+
}
|
|
1338
|
+
/**
|
|
1339
|
+
* Adds a mentionable select menu component to this action row.
|
|
1340
|
+
*
|
|
1341
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1342
|
+
*/
|
|
1343
|
+
addMentionableSelectMenuComponent(input) {
|
|
1344
|
+
this.data.components.push(resolveBuilder(input, MentionableSelectMenuBuilder));
|
|
1345
|
+
return this;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Adds a role select menu component to this action row.
|
|
1349
|
+
*
|
|
1350
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1351
|
+
*/
|
|
1352
|
+
addRoleSelectMenuComponent(input) {
|
|
1353
|
+
this.data.components.push(resolveBuilder(input, RoleSelectMenuBuilder));
|
|
1354
|
+
return this;
|
|
1355
|
+
}
|
|
1356
|
+
/**
|
|
1357
|
+
* Adds a string select menu component to this action row.
|
|
1358
|
+
*
|
|
1359
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1360
|
+
*/
|
|
1361
|
+
addStringSelectMenuComponent(input) {
|
|
1362
|
+
this.data.components.push(resolveBuilder(input, StringSelectMenuBuilder));
|
|
1363
|
+
return this;
|
|
1364
|
+
}
|
|
1365
|
+
/**
|
|
1366
|
+
* Adds a user select menu component to this action row.
|
|
1367
|
+
*
|
|
1368
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1369
|
+
*/
|
|
1370
|
+
addUserSelectMenuComponent(input) {
|
|
1371
|
+
this.data.components.push(resolveBuilder(input, UserSelectMenuBuilder));
|
|
1372
|
+
return this;
|
|
1373
|
+
}
|
|
1374
|
+
/**
|
|
1375
|
+
* Adds a text input component to this action row.
|
|
1376
|
+
*
|
|
1377
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
1378
|
+
*/
|
|
1379
|
+
addTextInputComponent(input) {
|
|
1380
|
+
this.data.components.push(resolveBuilder(input, TextInputBuilder));
|
|
1169
1381
|
return this;
|
|
1170
1382
|
}
|
|
1171
1383
|
/**
|
|
1172
|
-
*
|
|
1384
|
+
* Removes, replaces, or inserts components for this action row.
|
|
1173
1385
|
*
|
|
1174
|
-
* @
|
|
1386
|
+
* @remarks
|
|
1387
|
+
* This method behaves similarly
|
|
1388
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
1389
|
+
*
|
|
1390
|
+
* It's useful for modifying and adjusting order of the already-existing components of an action row.
|
|
1391
|
+
* @example
|
|
1392
|
+
* Remove the first component:
|
|
1393
|
+
* ```ts
|
|
1394
|
+
* actionRow.spliceComponents(0, 1);
|
|
1395
|
+
* ```
|
|
1396
|
+
* @example
|
|
1397
|
+
* Remove the first n components:
|
|
1398
|
+
* ```ts
|
|
1399
|
+
* const n = 4;
|
|
1400
|
+
* actionRow.spliceComponents(0, n);
|
|
1401
|
+
* ```
|
|
1402
|
+
* @example
|
|
1403
|
+
* Remove the last component:
|
|
1404
|
+
* ```ts
|
|
1405
|
+
* actionRow.spliceComponents(-1, 1);
|
|
1406
|
+
* ```
|
|
1407
|
+
* @param index - The index to start at
|
|
1408
|
+
* @param deleteCount - The number of components to remove
|
|
1409
|
+
* @param components - The replacing component objects
|
|
1175
1410
|
*/
|
|
1176
|
-
|
|
1177
|
-
this.data.
|
|
1411
|
+
spliceComponents(index, deleteCount, ...components) {
|
|
1412
|
+
this.data.components.splice(index, deleteCount, ...components);
|
|
1178
1413
|
return this;
|
|
1179
1414
|
}
|
|
1180
1415
|
/**
|
|
1181
1416
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1182
1417
|
*/
|
|
1183
1418
|
toJSON(validationOverride) {
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1186
|
-
|
|
1419
|
+
const { components, ...rest } = this.data;
|
|
1420
|
+
const data = {
|
|
1421
|
+
...structuredClone(rest),
|
|
1422
|
+
components: components.map((component) => component.toJSON(validationOverride))
|
|
1423
|
+
};
|
|
1424
|
+
validate(actionRowPredicate, data, validationOverride);
|
|
1425
|
+
return data;
|
|
1187
1426
|
}
|
|
1188
1427
|
};
|
|
1189
1428
|
|
|
1190
|
-
// src/components/ActionRow.ts
|
|
1191
|
-
import { ComponentType as ComponentType21 } from "discord-api-types/v10";
|
|
1192
|
-
|
|
1193
|
-
// src/components/Components.ts
|
|
1194
|
-
import { ButtonStyle as ButtonStyle5, ComponentType as ComponentType20 } from "discord-api-types/v10";
|
|
1195
|
-
|
|
1196
1429
|
// src/components/v2/Container.ts
|
|
1197
1430
|
import {
|
|
1198
|
-
ComponentType as
|
|
1431
|
+
ComponentType as ComponentType20
|
|
1199
1432
|
} from "discord-api-types/v10";
|
|
1200
1433
|
|
|
1201
1434
|
// src/components/v2/Assertions.ts
|
|
1202
|
-
import { ComponentType as
|
|
1435
|
+
import { ComponentType as ComponentType13, SeparatorSpacingSize } from "discord-api-types/v10";
|
|
1203
1436
|
import { z as z5 } from "zod";
|
|
1204
1437
|
var unfurledMediaItemPredicate = z5.object({
|
|
1205
1438
|
url: z5.url({ protocol: /^(?:https?|attachment)$/ })
|
|
@@ -1234,8 +1467,8 @@ var mediaGalleryPredicate = z5.object({
|
|
|
1234
1467
|
var sectionPredicate = z5.object({
|
|
1235
1468
|
components: z5.array(textDisplayPredicate).min(1).max(3),
|
|
1236
1469
|
accessory: z5.union([
|
|
1237
|
-
z5.object({ type: z5.literal(
|
|
1238
|
-
z5.object({ type: z5.literal(
|
|
1470
|
+
z5.object({ type: z5.literal(ComponentType13.Button) }),
|
|
1471
|
+
z5.object({ type: z5.literal(ComponentType13.Thumbnail) })
|
|
1239
1472
|
])
|
|
1240
1473
|
});
|
|
1241
1474
|
var containerPredicate = z5.object({
|
|
@@ -1254,7 +1487,7 @@ var containerPredicate = z5.object({
|
|
|
1254
1487
|
});
|
|
1255
1488
|
|
|
1256
1489
|
// src/components/v2/File.ts
|
|
1257
|
-
import { ComponentType as
|
|
1490
|
+
import { ComponentType as ComponentType14 } from "discord-api-types/v10";
|
|
1258
1491
|
var FileBuilder = class extends ComponentBuilder {
|
|
1259
1492
|
static {
|
|
1260
1493
|
__name(this, "FileBuilder");
|
|
@@ -1294,7 +1527,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1294
1527
|
this.data = {
|
|
1295
1528
|
...structuredClone(rest),
|
|
1296
1529
|
file: file && { url: file.url },
|
|
1297
|
-
type:
|
|
1530
|
+
type: ComponentType14.File
|
|
1298
1531
|
};
|
|
1299
1532
|
}
|
|
1300
1533
|
/**
|
|
@@ -1326,7 +1559,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1326
1559
|
};
|
|
1327
1560
|
|
|
1328
1561
|
// src/components/v2/MediaGallery.ts
|
|
1329
|
-
import { ComponentType as
|
|
1562
|
+
import { ComponentType as ComponentType15 } from "discord-api-types/v10";
|
|
1330
1563
|
|
|
1331
1564
|
// src/components/v2/MediaGalleryItem.ts
|
|
1332
1565
|
var MediaGalleryItemBuilder = class {
|
|
@@ -1461,7 +1694,7 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
1461
1694
|
this.data = {
|
|
1462
1695
|
...structuredClone(rest),
|
|
1463
1696
|
items: items.map((item) => new MediaGalleryItemBuilder(item)),
|
|
1464
|
-
type:
|
|
1697
|
+
type: ComponentType15.MediaGallery
|
|
1465
1698
|
};
|
|
1466
1699
|
}
|
|
1467
1700
|
/**
|
|
@@ -1503,10 +1736,10 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
1503
1736
|
};
|
|
1504
1737
|
|
|
1505
1738
|
// src/components/v2/Section.ts
|
|
1506
|
-
import { ComponentType as
|
|
1739
|
+
import { ComponentType as ComponentType18 } from "discord-api-types/v10";
|
|
1507
1740
|
|
|
1508
1741
|
// src/components/v2/TextDisplay.ts
|
|
1509
|
-
import { ComponentType as
|
|
1742
|
+
import { ComponentType as ComponentType16 } from "discord-api-types/v10";
|
|
1510
1743
|
var TextDisplayBuilder = class extends ComponentBuilder {
|
|
1511
1744
|
static {
|
|
1512
1745
|
__name(this, "TextDisplayBuilder");
|
|
@@ -1539,7 +1772,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
|
|
|
1539
1772
|
super();
|
|
1540
1773
|
this.data = {
|
|
1541
1774
|
...structuredClone(data),
|
|
1542
|
-
type:
|
|
1775
|
+
type: ComponentType16.TextDisplay
|
|
1543
1776
|
};
|
|
1544
1777
|
}
|
|
1545
1778
|
/**
|
|
@@ -1562,7 +1795,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
|
|
|
1562
1795
|
};
|
|
1563
1796
|
|
|
1564
1797
|
// src/components/v2/Thumbnail.ts
|
|
1565
|
-
import { ComponentType as
|
|
1798
|
+
import { ComponentType as ComponentType17 } from "discord-api-types/v10";
|
|
1566
1799
|
var ThumbnailBuilder = class extends ComponentBuilder {
|
|
1567
1800
|
static {
|
|
1568
1801
|
__name(this, "ThumbnailBuilder");
|
|
@@ -1602,7 +1835,7 @@ var ThumbnailBuilder = class extends ComponentBuilder {
|
|
|
1602
1835
|
this.data = {
|
|
1603
1836
|
...structuredClone(rest),
|
|
1604
1837
|
media: media && { url: media.url },
|
|
1605
|
-
type:
|
|
1838
|
+
type: ComponentType17.Thumbnail
|
|
1606
1839
|
};
|
|
1607
1840
|
}
|
|
1608
1841
|
/**
|
|
@@ -1706,7 +1939,7 @@ var SectionBuilder = class extends ComponentBuilder {
|
|
|
1706
1939
|
...structuredClone(rest),
|
|
1707
1940
|
accessory: accessory && resolveAccessoryComponent(accessory),
|
|
1708
1941
|
components: components.map((component) => new TextDisplayBuilder(component)),
|
|
1709
|
-
type:
|
|
1942
|
+
type: ComponentType18.Section
|
|
1710
1943
|
};
|
|
1711
1944
|
}
|
|
1712
1945
|
/**
|
|
@@ -1819,7 +2052,7 @@ var SectionBuilder = class extends ComponentBuilder {
|
|
|
1819
2052
|
};
|
|
1820
2053
|
|
|
1821
2054
|
// src/components/v2/Separator.ts
|
|
1822
|
-
import { ComponentType as
|
|
2055
|
+
import { ComponentType as ComponentType19 } from "discord-api-types/v10";
|
|
1823
2056
|
var SeparatorBuilder = class extends ComponentBuilder {
|
|
1824
2057
|
static {
|
|
1825
2058
|
__name(this, "SeparatorBuilder");
|
|
@@ -1853,7 +2086,7 @@ var SeparatorBuilder = class extends ComponentBuilder {
|
|
|
1853
2086
|
super();
|
|
1854
2087
|
this.data = {
|
|
1855
2088
|
...structuredClone(data),
|
|
1856
|
-
type:
|
|
2089
|
+
type: ComponentType19.Separator
|
|
1857
2090
|
};
|
|
1858
2091
|
}
|
|
1859
2092
|
/**
|
|
@@ -1917,7 +2150,7 @@ var ContainerBuilder = class extends ComponentBuilder {
|
|
|
1917
2150
|
this.data = {
|
|
1918
2151
|
...structuredClone(rest),
|
|
1919
2152
|
components: components.map((component) => createComponentBuilder(component)),
|
|
1920
|
-
type:
|
|
2153
|
+
type: ComponentType20.Container
|
|
1921
2154
|
};
|
|
1922
2155
|
}
|
|
1923
2156
|
/**
|
|
@@ -2067,36 +2300,38 @@ function createComponentBuilder(data) {
|
|
|
2067
2300
|
return data;
|
|
2068
2301
|
}
|
|
2069
2302
|
switch (data.type) {
|
|
2070
|
-
case
|
|
2303
|
+
case ComponentType21.ActionRow:
|
|
2071
2304
|
return new ActionRowBuilder(data);
|
|
2072
|
-
case
|
|
2305
|
+
case ComponentType21.Button:
|
|
2073
2306
|
return createButtonBuilder(data);
|
|
2074
|
-
case
|
|
2307
|
+
case ComponentType21.StringSelect:
|
|
2075
2308
|
return new StringSelectMenuBuilder(data);
|
|
2076
|
-
case
|
|
2309
|
+
case ComponentType21.TextInput:
|
|
2077
2310
|
return new TextInputBuilder(data);
|
|
2078
|
-
case
|
|
2311
|
+
case ComponentType21.UserSelect:
|
|
2079
2312
|
return new UserSelectMenuBuilder(data);
|
|
2080
|
-
case
|
|
2313
|
+
case ComponentType21.RoleSelect:
|
|
2081
2314
|
return new RoleSelectMenuBuilder(data);
|
|
2082
|
-
case
|
|
2315
|
+
case ComponentType21.MentionableSelect:
|
|
2083
2316
|
return new MentionableSelectMenuBuilder(data);
|
|
2084
|
-
case
|
|
2317
|
+
case ComponentType21.ChannelSelect:
|
|
2085
2318
|
return new ChannelSelectMenuBuilder(data);
|
|
2086
|
-
case
|
|
2319
|
+
case ComponentType21.Thumbnail:
|
|
2087
2320
|
return new ThumbnailBuilder(data);
|
|
2088
|
-
case
|
|
2321
|
+
case ComponentType21.File:
|
|
2089
2322
|
return new FileBuilder(data);
|
|
2090
|
-
case
|
|
2323
|
+
case ComponentType21.Separator:
|
|
2091
2324
|
return new SeparatorBuilder(data);
|
|
2092
|
-
case
|
|
2325
|
+
case ComponentType21.TextDisplay:
|
|
2093
2326
|
return new TextDisplayBuilder(data);
|
|
2094
|
-
case
|
|
2327
|
+
case ComponentType21.MediaGallery:
|
|
2095
2328
|
return new MediaGalleryBuilder(data);
|
|
2096
|
-
case
|
|
2329
|
+
case ComponentType21.Section:
|
|
2097
2330
|
return new SectionBuilder(data);
|
|
2098
|
-
case
|
|
2331
|
+
case ComponentType21.Container:
|
|
2099
2332
|
return new ContainerBuilder(data);
|
|
2333
|
+
case ComponentType21.Label:
|
|
2334
|
+
return new LabelBuilder(data);
|
|
2100
2335
|
default:
|
|
2101
2336
|
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
2102
2337
|
}
|
|
@@ -2123,9 +2358,9 @@ function createButtonBuilder(data) {
|
|
|
2123
2358
|
__name(createButtonBuilder, "createButtonBuilder");
|
|
2124
2359
|
function resolveAccessoryComponent(component) {
|
|
2125
2360
|
switch (component.type) {
|
|
2126
|
-
case
|
|
2361
|
+
case ComponentType21.Button:
|
|
2127
2362
|
return createButtonBuilder(component);
|
|
2128
|
-
case
|
|
2363
|
+
case ComponentType21.Thumbnail:
|
|
2129
2364
|
return new ThumbnailBuilder(component);
|
|
2130
2365
|
default:
|
|
2131
2366
|
throw new Error(`Cannot properly serialize section accessory component: ${component.type}`);
|
|
@@ -2133,232 +2368,108 @@ function resolveAccessoryComponent(component) {
|
|
|
2133
2368
|
}
|
|
2134
2369
|
__name(resolveAccessoryComponent, "resolveAccessoryComponent");
|
|
2135
2370
|
|
|
2136
|
-
// src/components/
|
|
2137
|
-
|
|
2371
|
+
// src/components/label/Assertions.ts
|
|
2372
|
+
import { ComponentType as ComponentType22 } from "discord-api-types/v10";
|
|
2373
|
+
import { z as z6 } from "zod";
|
|
2374
|
+
var labelPredicate2 = z6.object({
|
|
2375
|
+
type: z6.literal(ComponentType22.Label),
|
|
2376
|
+
label: z6.string().min(1).max(45),
|
|
2377
|
+
description: z6.string().min(1).max(100).optional(),
|
|
2378
|
+
component: z6.union([selectMenuStringPredicate, textInputPredicate])
|
|
2379
|
+
});
|
|
2380
|
+
|
|
2381
|
+
// src/components/label/Label.ts
|
|
2382
|
+
var LabelBuilder = class extends ComponentBuilder {
|
|
2138
2383
|
static {
|
|
2139
|
-
__name(this, "
|
|
2384
|
+
__name(this, "LabelBuilder");
|
|
2140
2385
|
}
|
|
2141
2386
|
/**
|
|
2142
2387
|
* @internal
|
|
2143
2388
|
*/
|
|
2144
2389
|
data;
|
|
2145
2390
|
/**
|
|
2146
|
-
*
|
|
2147
|
-
*/
|
|
2148
|
-
get components() {
|
|
2149
|
-
return this.data.components;
|
|
2150
|
-
}
|
|
2151
|
-
/**
|
|
2152
|
-
* Creates a new action row.
|
|
2391
|
+
* Creates a new label.
|
|
2153
2392
|
*
|
|
2154
|
-
* @param data - The API data to create this
|
|
2393
|
+
* @param data - The API data to create this label with
|
|
2155
2394
|
* @example
|
|
2156
|
-
* Creating
|
|
2395
|
+
* Creating a label from an API data object:
|
|
2157
2396
|
* ```ts
|
|
2158
|
-
* const
|
|
2159
|
-
*
|
|
2160
|
-
*
|
|
2161
|
-
* custom_id: "custom id",
|
|
2162
|
-
* label: "Type something",
|
|
2163
|
-
* style: TextInputStyle.Short,
|
|
2164
|
-
* type: ComponentType.TextInput,
|
|
2165
|
-
* },
|
|
2166
|
-
* ],
|
|
2397
|
+
* const label = new LabelBuilder({
|
|
2398
|
+
* label: "label",
|
|
2399
|
+
* component,
|
|
2167
2400
|
* });
|
|
2168
2401
|
* ```
|
|
2169
2402
|
* @example
|
|
2170
|
-
* Creating
|
|
2403
|
+
* Creating a label using setters and API data:
|
|
2171
2404
|
* ```ts
|
|
2172
|
-
* const
|
|
2173
|
-
*
|
|
2174
|
-
*
|
|
2175
|
-
*
|
|
2176
|
-
* label: "Click me",
|
|
2177
|
-
* style: ButtonStyle.Primary,
|
|
2178
|
-
* type: ComponentType.Button,
|
|
2179
|
-
* },
|
|
2180
|
-
* ],
|
|
2181
|
-
* })
|
|
2182
|
-
* .addComponents(button2, button3);
|
|
2405
|
+
* const label = new LabelBuilder({
|
|
2406
|
+
* label: 'label',
|
|
2407
|
+
* component,
|
|
2408
|
+
* }).setContent('new text');
|
|
2183
2409
|
* ```
|
|
2184
2410
|
*/
|
|
2185
2411
|
constructor(data = {}) {
|
|
2186
2412
|
super();
|
|
2187
|
-
const {
|
|
2413
|
+
const { component, ...rest } = data;
|
|
2188
2414
|
this.data = {
|
|
2189
2415
|
...structuredClone(rest),
|
|
2190
|
-
|
|
2191
|
-
type:
|
|
2416
|
+
component: component ? createComponentBuilder(component) : void 0,
|
|
2417
|
+
type: ComponentType23.Label
|
|
2192
2418
|
};
|
|
2193
2419
|
}
|
|
2194
2420
|
/**
|
|
2195
|
-
*
|
|
2196
|
-
*
|
|
2197
|
-
* @param input - The buttons to add
|
|
2198
|
-
*/
|
|
2199
|
-
addPrimaryButtonComponents(...input) {
|
|
2200
|
-
const normalized = normalizeArray(input);
|
|
2201
|
-
const resolved = normalized.map((component) => resolveBuilder(component, PrimaryButtonBuilder));
|
|
2202
|
-
this.data.components.push(...resolved);
|
|
2203
|
-
return this;
|
|
2204
|
-
}
|
|
2205
|
-
/**
|
|
2206
|
-
* Adds secondary button components to this action row.
|
|
2207
|
-
*
|
|
2208
|
-
* @param input - The buttons to add
|
|
2209
|
-
*/
|
|
2210
|
-
addSecondaryButtonComponents(...input) {
|
|
2211
|
-
const normalized = normalizeArray(input);
|
|
2212
|
-
const resolved = normalized.map((component) => resolveBuilder(component, SecondaryButtonBuilder));
|
|
2213
|
-
this.data.components.push(...resolved);
|
|
2214
|
-
return this;
|
|
2215
|
-
}
|
|
2216
|
-
/**
|
|
2217
|
-
* Adds success button components to this action row.
|
|
2218
|
-
*
|
|
2219
|
-
* @param input - The buttons to add
|
|
2220
|
-
*/
|
|
2221
|
-
addSuccessButtonComponents(...input) {
|
|
2222
|
-
const normalized = normalizeArray(input);
|
|
2223
|
-
const resolved = normalized.map((component) => resolveBuilder(component, SuccessButtonBuilder));
|
|
2224
|
-
this.data.components.push(...resolved);
|
|
2225
|
-
return this;
|
|
2226
|
-
}
|
|
2227
|
-
/**
|
|
2228
|
-
* Adds danger button components to this action row.
|
|
2229
|
-
*/
|
|
2230
|
-
addDangerButtonComponents(...input) {
|
|
2231
|
-
const normalized = normalizeArray(input);
|
|
2232
|
-
const resolved = normalized.map((component) => resolveBuilder(component, DangerButtonBuilder));
|
|
2233
|
-
this.data.components.push(...resolved);
|
|
2234
|
-
return this;
|
|
2235
|
-
}
|
|
2236
|
-
/**
|
|
2237
|
-
* Generically add any type of component to this action row, only takes in an instance of a component builder.
|
|
2238
|
-
*/
|
|
2239
|
-
addComponents(...input) {
|
|
2240
|
-
const normalized = normalizeArray(input);
|
|
2241
|
-
this.data.components.push(...normalized);
|
|
2242
|
-
return this;
|
|
2243
|
-
}
|
|
2244
|
-
/**
|
|
2245
|
-
* Adds SKU id button components to this action row.
|
|
2246
|
-
*
|
|
2247
|
-
* @param input - The buttons to add
|
|
2248
|
-
*/
|
|
2249
|
-
addPremiumButtonComponents(...input) {
|
|
2250
|
-
const normalized = normalizeArray(input);
|
|
2251
|
-
const resolved = normalized.map((component) => resolveBuilder(component, PremiumButtonBuilder));
|
|
2252
|
-
this.data.components.push(...resolved);
|
|
2253
|
-
return this;
|
|
2254
|
-
}
|
|
2255
|
-
/**
|
|
2256
|
-
* Adds URL button components to this action row.
|
|
2257
|
-
*
|
|
2258
|
-
* @param input - The buttons to add
|
|
2259
|
-
*/
|
|
2260
|
-
addLinkButtonComponents(...input) {
|
|
2261
|
-
const normalized = normalizeArray(input);
|
|
2262
|
-
const resolved = normalized.map((component) => resolveBuilder(component, LinkButtonBuilder));
|
|
2263
|
-
this.data.components.push(...resolved);
|
|
2264
|
-
return this;
|
|
2265
|
-
}
|
|
2266
|
-
/**
|
|
2267
|
-
* Adds a channel select menu component to this action row.
|
|
2268
|
-
*
|
|
2269
|
-
* @param input - A function that returns a component builder or an already built builder
|
|
2270
|
-
*/
|
|
2271
|
-
addChannelSelectMenuComponent(input) {
|
|
2272
|
-
this.data.components.push(resolveBuilder(input, ChannelSelectMenuBuilder));
|
|
2273
|
-
return this;
|
|
2274
|
-
}
|
|
2275
|
-
/**
|
|
2276
|
-
* Adds a mentionable select menu component to this action row.
|
|
2421
|
+
* Sets the label for this label.
|
|
2277
2422
|
*
|
|
2278
|
-
* @param
|
|
2423
|
+
* @param label - The label to use
|
|
2279
2424
|
*/
|
|
2280
|
-
|
|
2281
|
-
this.data.
|
|
2425
|
+
setLabel(label) {
|
|
2426
|
+
this.data.label = label;
|
|
2282
2427
|
return this;
|
|
2283
2428
|
}
|
|
2284
2429
|
/**
|
|
2285
|
-
*
|
|
2430
|
+
* Sets the description for this label.
|
|
2286
2431
|
*
|
|
2287
|
-
* @param
|
|
2432
|
+
* @param description - The description to use
|
|
2288
2433
|
*/
|
|
2289
|
-
|
|
2290
|
-
this.data.
|
|
2434
|
+
setDescription(description) {
|
|
2435
|
+
this.data.description = description;
|
|
2291
2436
|
return this;
|
|
2292
2437
|
}
|
|
2293
2438
|
/**
|
|
2294
|
-
*
|
|
2295
|
-
*
|
|
2296
|
-
* @param input - A function that returns a component builder or an already built builder
|
|
2439
|
+
* Clears the description for this label.
|
|
2297
2440
|
*/
|
|
2298
|
-
|
|
2299
|
-
this.data.
|
|
2441
|
+
clearDescription() {
|
|
2442
|
+
this.data.description = void 0;
|
|
2300
2443
|
return this;
|
|
2301
2444
|
}
|
|
2302
2445
|
/**
|
|
2303
|
-
*
|
|
2446
|
+
* Sets a string select menu component to this label.
|
|
2304
2447
|
*
|
|
2305
2448
|
* @param input - A function that returns a component builder or an already built builder
|
|
2306
2449
|
*/
|
|
2307
|
-
|
|
2308
|
-
this.data.
|
|
2450
|
+
setStringSelectMenuComponent(input) {
|
|
2451
|
+
this.data.component = resolveBuilder(input, StringSelectMenuBuilder);
|
|
2309
2452
|
return this;
|
|
2310
2453
|
}
|
|
2311
2454
|
/**
|
|
2312
|
-
*
|
|
2455
|
+
* Sets a text input component to this label.
|
|
2313
2456
|
*
|
|
2314
2457
|
* @param input - A function that returns a component builder or an already built builder
|
|
2315
2458
|
*/
|
|
2316
|
-
|
|
2317
|
-
this.data.
|
|
2318
|
-
return this;
|
|
2319
|
-
}
|
|
2320
|
-
/**
|
|
2321
|
-
* Removes, replaces, or inserts components for this action row.
|
|
2322
|
-
*
|
|
2323
|
-
* @remarks
|
|
2324
|
-
* This method behaves similarly
|
|
2325
|
-
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
2326
|
-
*
|
|
2327
|
-
* It's useful for modifying and adjusting order of the already-existing components of an action row.
|
|
2328
|
-
* @example
|
|
2329
|
-
* Remove the first component:
|
|
2330
|
-
* ```ts
|
|
2331
|
-
* actionRow.spliceComponents(0, 1);
|
|
2332
|
-
* ```
|
|
2333
|
-
* @example
|
|
2334
|
-
* Remove the first n components:
|
|
2335
|
-
* ```ts
|
|
2336
|
-
* const n = 4;
|
|
2337
|
-
* actionRow.spliceComponents(0, n);
|
|
2338
|
-
* ```
|
|
2339
|
-
* @example
|
|
2340
|
-
* Remove the last component:
|
|
2341
|
-
* ```ts
|
|
2342
|
-
* actionRow.spliceComponents(-1, 1);
|
|
2343
|
-
* ```
|
|
2344
|
-
* @param index - The index to start at
|
|
2345
|
-
* @param deleteCount - The number of components to remove
|
|
2346
|
-
* @param components - The replacing component objects
|
|
2347
|
-
*/
|
|
2348
|
-
spliceComponents(index, deleteCount, ...components) {
|
|
2349
|
-
this.data.components.splice(index, deleteCount, ...components);
|
|
2459
|
+
setTextInputComponent(input) {
|
|
2460
|
+
this.data.component = resolveBuilder(input, TextInputBuilder);
|
|
2350
2461
|
return this;
|
|
2351
2462
|
}
|
|
2352
2463
|
/**
|
|
2353
2464
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
2354
2465
|
*/
|
|
2355
2466
|
toJSON(validationOverride) {
|
|
2356
|
-
const {
|
|
2467
|
+
const { component, ...rest } = this.data;
|
|
2357
2468
|
const data = {
|
|
2358
2469
|
...structuredClone(rest),
|
|
2359
|
-
|
|
2470
|
+
component: component?.toJSON(false)
|
|
2360
2471
|
};
|
|
2361
|
-
validate(
|
|
2472
|
+
validate(labelPredicate2, data, validationOverride);
|
|
2362
2473
|
return data;
|
|
2363
2474
|
}
|
|
2364
2475
|
};
|
|
@@ -2607,33 +2718,33 @@ import {
|
|
|
2607
2718
|
InteractionContextType,
|
|
2608
2719
|
ApplicationCommandOptionType
|
|
2609
2720
|
} from "discord-api-types/v10";
|
|
2610
|
-
import { z as
|
|
2611
|
-
var namePredicate =
|
|
2612
|
-
var descriptionPredicate =
|
|
2613
|
-
var sharedNameAndDescriptionPredicate =
|
|
2721
|
+
import { z as z7 } from "zod";
|
|
2722
|
+
var namePredicate = z7.string().min(1).max(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u);
|
|
2723
|
+
var descriptionPredicate = z7.string().min(1).max(100);
|
|
2724
|
+
var sharedNameAndDescriptionPredicate = z7.object({
|
|
2614
2725
|
name: namePredicate,
|
|
2615
2726
|
name_localizations: localeMapPredicate.optional(),
|
|
2616
2727
|
description: descriptionPredicate,
|
|
2617
2728
|
description_localizations: localeMapPredicate.optional()
|
|
2618
2729
|
});
|
|
2619
|
-
var numericMixinNumberOptionPredicate =
|
|
2620
|
-
max_value:
|
|
2621
|
-
min_value:
|
|
2730
|
+
var numericMixinNumberOptionPredicate = z7.object({
|
|
2731
|
+
max_value: z7.float32().optional(),
|
|
2732
|
+
min_value: z7.float32().optional()
|
|
2622
2733
|
});
|
|
2623
|
-
var numericMixinIntegerOptionPredicate =
|
|
2624
|
-
max_value:
|
|
2625
|
-
min_value:
|
|
2734
|
+
var numericMixinIntegerOptionPredicate = z7.object({
|
|
2735
|
+
max_value: z7.int().optional(),
|
|
2736
|
+
min_value: z7.int().optional()
|
|
2626
2737
|
});
|
|
2627
|
-
var channelMixinOptionPredicate =
|
|
2628
|
-
channel_types:
|
|
2738
|
+
var channelMixinOptionPredicate = z7.object({
|
|
2739
|
+
channel_types: z7.literal(ApplicationCommandOptionAllowedChannelTypes).array().optional()
|
|
2629
2740
|
});
|
|
2630
|
-
var autocompleteMixinOptionPredicate =
|
|
2631
|
-
autocomplete:
|
|
2632
|
-
choices:
|
|
2741
|
+
var autocompleteMixinOptionPredicate = z7.object({
|
|
2742
|
+
autocomplete: z7.literal(true),
|
|
2743
|
+
choices: z7.union([z7.never(), z7.never().array(), z7.undefined()])
|
|
2633
2744
|
});
|
|
2634
|
-
var choiceValueStringPredicate =
|
|
2635
|
-
var choiceValueNumberPredicate =
|
|
2636
|
-
var choiceBasePredicate =
|
|
2745
|
+
var choiceValueStringPredicate = z7.string().min(1).max(100);
|
|
2746
|
+
var choiceValueNumberPredicate = z7.number();
|
|
2747
|
+
var choiceBasePredicate = z7.object({
|
|
2637
2748
|
name: choiceValueStringPredicate,
|
|
2638
2749
|
name_localizations: localeMapPredicate.optional()
|
|
2639
2750
|
});
|
|
@@ -2643,8 +2754,8 @@ var choiceStringPredicate = choiceBasePredicate.extend({
|
|
|
2643
2754
|
var choiceNumberPredicate = choiceBasePredicate.extend({
|
|
2644
2755
|
value: choiceValueNumberPredicate
|
|
2645
2756
|
});
|
|
2646
|
-
var choiceBaseMixinPredicate =
|
|
2647
|
-
autocomplete:
|
|
2757
|
+
var choiceBaseMixinPredicate = z7.object({
|
|
2758
|
+
autocomplete: z7.literal(false).optional()
|
|
2648
2759
|
});
|
|
2649
2760
|
var choiceStringMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
2650
2761
|
choices: choiceStringPredicate.array().max(25).optional()
|
|
@@ -2652,7 +2763,7 @@ var choiceStringMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
|
2652
2763
|
var choiceNumberMixinPredicate = choiceBaseMixinPredicate.extend({
|
|
2653
2764
|
choices: choiceNumberPredicate.array().max(25).optional()
|
|
2654
2765
|
});
|
|
2655
|
-
var basicOptionTypesPredicate =
|
|
2766
|
+
var basicOptionTypesPredicate = z7.literal([
|
|
2656
2767
|
ApplicationCommandOptionType.Attachment,
|
|
2657
2768
|
ApplicationCommandOptionType.Boolean,
|
|
2658
2769
|
ApplicationCommandOptionType.Channel,
|
|
@@ -2664,54 +2775,54 @@ var basicOptionTypesPredicate = z6.literal([
|
|
|
2664
2775
|
ApplicationCommandOptionType.User
|
|
2665
2776
|
]);
|
|
2666
2777
|
var basicOptionPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2667
|
-
required:
|
|
2778
|
+
required: z7.boolean().optional(),
|
|
2668
2779
|
type: basicOptionTypesPredicate
|
|
2669
2780
|
});
|
|
2670
|
-
var autocompleteOrStringChoicesMixinOptionPredicate =
|
|
2781
|
+
var autocompleteOrStringChoicesMixinOptionPredicate = z7.discriminatedUnion("autocomplete", [
|
|
2671
2782
|
autocompleteMixinOptionPredicate,
|
|
2672
2783
|
choiceStringMixinPredicate
|
|
2673
2784
|
]);
|
|
2674
|
-
var autocompleteOrNumberChoicesMixinOptionPredicate =
|
|
2785
|
+
var autocompleteOrNumberChoicesMixinOptionPredicate = z7.discriminatedUnion("autocomplete", [
|
|
2675
2786
|
autocompleteMixinOptionPredicate,
|
|
2676
2787
|
choiceNumberMixinPredicate
|
|
2677
2788
|
]);
|
|
2678
|
-
var channelOptionPredicate =
|
|
2789
|
+
var channelOptionPredicate = z7.object({
|
|
2679
2790
|
...basicOptionPredicate.shape,
|
|
2680
2791
|
...channelMixinOptionPredicate.shape
|
|
2681
2792
|
});
|
|
2682
|
-
var integerOptionPredicate =
|
|
2793
|
+
var integerOptionPredicate = z7.object({
|
|
2683
2794
|
...basicOptionPredicate.shape,
|
|
2684
2795
|
...numericMixinIntegerOptionPredicate.shape
|
|
2685
2796
|
}).and(autocompleteOrNumberChoicesMixinOptionPredicate);
|
|
2686
|
-
var numberOptionPredicate =
|
|
2797
|
+
var numberOptionPredicate = z7.object({
|
|
2687
2798
|
...basicOptionPredicate.shape,
|
|
2688
2799
|
...numericMixinNumberOptionPredicate.shape
|
|
2689
2800
|
}).and(autocompleteOrNumberChoicesMixinOptionPredicate);
|
|
2690
2801
|
var stringOptionPredicate = basicOptionPredicate.extend({
|
|
2691
|
-
max_length:
|
|
2692
|
-
min_length:
|
|
2802
|
+
max_length: z7.number().min(0).max(6e3).optional(),
|
|
2803
|
+
min_length: z7.number().min(1).max(6e3).optional()
|
|
2693
2804
|
}).and(autocompleteOrStringChoicesMixinOptionPredicate);
|
|
2694
2805
|
var baseChatInputCommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2695
|
-
contexts:
|
|
2806
|
+
contexts: z7.array(z7.enum(InteractionContextType)).optional(),
|
|
2696
2807
|
default_member_permissions: memberPermissionsPredicate.optional(),
|
|
2697
|
-
integration_types:
|
|
2698
|
-
nsfw:
|
|
2808
|
+
integration_types: z7.array(z7.enum(ApplicationIntegrationType)).optional(),
|
|
2809
|
+
nsfw: z7.boolean().optional()
|
|
2699
2810
|
});
|
|
2700
|
-
var chatInputCommandOptionsPredicate =
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2811
|
+
var chatInputCommandOptionsPredicate = z7.union([
|
|
2812
|
+
z7.object({ type: basicOptionTypesPredicate }).array(),
|
|
2813
|
+
z7.object({ type: z7.literal(ApplicationCommandOptionType.Subcommand) }).array(),
|
|
2814
|
+
z7.object({ type: z7.literal(ApplicationCommandOptionType.SubcommandGroup) }).array()
|
|
2704
2815
|
]);
|
|
2705
2816
|
var chatInputCommandPredicate = baseChatInputCommandPredicate.extend({
|
|
2706
2817
|
options: chatInputCommandOptionsPredicate.optional()
|
|
2707
2818
|
});
|
|
2708
2819
|
var chatInputCommandSubcommandGroupPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2709
|
-
type:
|
|
2710
|
-
options:
|
|
2820
|
+
type: z7.literal(ApplicationCommandOptionType.SubcommandGroup),
|
|
2821
|
+
options: z7.array(z7.object({ type: z7.literal(ApplicationCommandOptionType.Subcommand) })).min(1).max(25)
|
|
2711
2822
|
});
|
|
2712
2823
|
var chatInputCommandSubcommandPredicate = sharedNameAndDescriptionPredicate.extend({
|
|
2713
|
-
type:
|
|
2714
|
-
options:
|
|
2824
|
+
type: z7.literal(ApplicationCommandOptionType.Subcommand),
|
|
2825
|
+
options: z7.array(z7.object({ type: basicOptionTypesPredicate })).max(25)
|
|
2715
2826
|
});
|
|
2716
2827
|
|
|
2717
2828
|
// src/interactions/commands/chatInput/options/ApplicationCommandOptionBase.ts
|
|
@@ -3260,25 +3371,25 @@ var ChatInputCommandBuilder = class extends Mixin8(
|
|
|
3260
3371
|
|
|
3261
3372
|
// src/interactions/commands/contextMenu/Assertions.ts
|
|
3262
3373
|
import { ApplicationCommandType as ApplicationCommandType2, ApplicationIntegrationType as ApplicationIntegrationType2, InteractionContextType as InteractionContextType2 } from "discord-api-types/v10";
|
|
3263
|
-
import { z as
|
|
3264
|
-
var namePredicate2 =
|
|
3374
|
+
import { z as z8 } from "zod";
|
|
3375
|
+
var namePredicate2 = z8.string().min(1).max(32).refine((val) => val.trim().length > 0, {
|
|
3265
3376
|
error: "Must not consist of only whitespace."
|
|
3266
3377
|
});
|
|
3267
|
-
var contextsPredicate =
|
|
3268
|
-
var integrationTypesPredicate =
|
|
3269
|
-
var baseContextMenuCommandPredicate =
|
|
3378
|
+
var contextsPredicate = z8.array(z8.enum(InteractionContextType2));
|
|
3379
|
+
var integrationTypesPredicate = z8.array(z8.enum(ApplicationIntegrationType2));
|
|
3380
|
+
var baseContextMenuCommandPredicate = z8.object({
|
|
3270
3381
|
contexts: contextsPredicate.optional(),
|
|
3271
3382
|
default_member_permissions: memberPermissionsPredicate.optional(),
|
|
3272
3383
|
name: namePredicate2,
|
|
3273
3384
|
name_localizations: localeMapPredicate.optional(),
|
|
3274
3385
|
integration_types: integrationTypesPredicate.optional(),
|
|
3275
|
-
nsfw:
|
|
3386
|
+
nsfw: z8.boolean().optional()
|
|
3276
3387
|
});
|
|
3277
3388
|
var userCommandPredicate = baseContextMenuCommandPredicate.extend({
|
|
3278
|
-
type:
|
|
3389
|
+
type: z8.literal(ApplicationCommandType2.User)
|
|
3279
3390
|
});
|
|
3280
3391
|
var messageCommandPredicate = baseContextMenuCommandPredicate.extend({
|
|
3281
|
-
type:
|
|
3392
|
+
type: z8.literal(ApplicationCommandType2.Message)
|
|
3282
3393
|
});
|
|
3283
3394
|
|
|
3284
3395
|
// src/interactions/commands/contextMenu/ContextMenuCommand.ts
|
|
@@ -3340,16 +3451,19 @@ var UserContextCommandBuilder = class extends ContextMenuCommandBuilder {
|
|
|
3340
3451
|
};
|
|
3341
3452
|
|
|
3342
3453
|
// src/interactions/modals/Assertions.ts
|
|
3343
|
-
import { ComponentType as
|
|
3344
|
-
import { z as
|
|
3345
|
-
var titlePredicate =
|
|
3346
|
-
var modalPredicate =
|
|
3454
|
+
import { ComponentType as ComponentType24 } from "discord-api-types/v10";
|
|
3455
|
+
import { z as z9 } from "zod";
|
|
3456
|
+
var titlePredicate = z9.string().min(1).max(45);
|
|
3457
|
+
var modalPredicate = z9.object({
|
|
3347
3458
|
title: titlePredicate,
|
|
3348
3459
|
custom_id: customIdPredicate,
|
|
3349
|
-
components:
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3460
|
+
components: z9.union([
|
|
3461
|
+
z9.object({
|
|
3462
|
+
type: z9.literal(ComponentType24.ActionRow),
|
|
3463
|
+
components: z9.object({ type: z9.literal(ComponentType24.TextInput) }).array().length(1)
|
|
3464
|
+
}),
|
|
3465
|
+
labelPredicate2
|
|
3466
|
+
]).array().min(1).max(5)
|
|
3353
3467
|
});
|
|
3354
3468
|
|
|
3355
3469
|
// src/interactions/modals/Modal.ts
|
|
@@ -3376,7 +3490,6 @@ var ModalBuilder = class {
|
|
|
3376
3490
|
const { components = [], ...rest } = data;
|
|
3377
3491
|
this.data = {
|
|
3378
3492
|
...structuredClone(rest),
|
|
3379
|
-
// @ts-expect-error https://github.com/discordjs/discord.js/pull/11034
|
|
3380
3493
|
components: components.map((component) => createComponentBuilder(component))
|
|
3381
3494
|
};
|
|
3382
3495
|
}
|
|
@@ -3399,57 +3512,57 @@ var ModalBuilder = class {
|
|
|
3399
3512
|
return this;
|
|
3400
3513
|
}
|
|
3401
3514
|
/**
|
|
3402
|
-
* Adds
|
|
3515
|
+
* Adds label components to this modal.
|
|
3403
3516
|
*
|
|
3404
3517
|
* @param components - The components to add
|
|
3405
3518
|
*/
|
|
3406
|
-
|
|
3519
|
+
addLabelComponents(...components) {
|
|
3407
3520
|
const normalized = normalizeArray(components);
|
|
3408
|
-
const resolved = normalized.map((
|
|
3521
|
+
const resolved = normalized.map((label) => resolveBuilder(label, LabelBuilder));
|
|
3409
3522
|
this.data.components.push(...resolved);
|
|
3410
3523
|
return this;
|
|
3411
3524
|
}
|
|
3412
3525
|
/**
|
|
3413
|
-
* Sets the
|
|
3526
|
+
* Sets the labels for this modal.
|
|
3414
3527
|
*
|
|
3415
3528
|
* @param components - The components to set
|
|
3416
3529
|
*/
|
|
3417
|
-
|
|
3530
|
+
setLabelComponents(...components) {
|
|
3418
3531
|
const normalized = normalizeArray(components);
|
|
3419
|
-
this.
|
|
3532
|
+
this.spliceLabelComponents(0, this.data.components.length, ...normalized);
|
|
3420
3533
|
return this;
|
|
3421
3534
|
}
|
|
3422
3535
|
/**
|
|
3423
|
-
* Removes, replaces, or inserts
|
|
3536
|
+
* Removes, replaces, or inserts labels for this modal.
|
|
3424
3537
|
*
|
|
3425
3538
|
* @remarks
|
|
3426
3539
|
* This method behaves similarly
|
|
3427
3540
|
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
3428
|
-
* The maximum amount of
|
|
3541
|
+
* The maximum amount of labels that can be added is 5.
|
|
3429
3542
|
*
|
|
3430
|
-
* It's useful for modifying and adjusting order of the already-existing
|
|
3543
|
+
* It's useful for modifying and adjusting order of the already-existing labels of a modal.
|
|
3431
3544
|
* @example
|
|
3432
|
-
* Remove the first
|
|
3545
|
+
* Remove the first label:
|
|
3433
3546
|
* ```ts
|
|
3434
|
-
*
|
|
3547
|
+
* modal.spliceLabelComponents(0, 1);
|
|
3435
3548
|
* ```
|
|
3436
3549
|
* @example
|
|
3437
|
-
* Remove the first n
|
|
3550
|
+
* Remove the first n labels:
|
|
3438
3551
|
* ```ts
|
|
3439
3552
|
* const n = 4;
|
|
3440
|
-
*
|
|
3553
|
+
* modal.spliceLabelComponents(0, n);
|
|
3441
3554
|
* ```
|
|
3442
3555
|
* @example
|
|
3443
|
-
* Remove the last
|
|
3556
|
+
* Remove the last label:
|
|
3444
3557
|
* ```ts
|
|
3445
|
-
*
|
|
3558
|
+
* modal.spliceLabelComponents(-1, 1);
|
|
3446
3559
|
* ```
|
|
3447
3560
|
* @param index - The index to start at
|
|
3448
|
-
* @param deleteCount - The number of
|
|
3449
|
-
* @param
|
|
3561
|
+
* @param deleteCount - The number of labels to remove
|
|
3562
|
+
* @param labels - The replacing label objects
|
|
3450
3563
|
*/
|
|
3451
|
-
|
|
3452
|
-
const resolved =
|
|
3564
|
+
spliceLabelComponents(index, deleteCount, ...labels) {
|
|
3565
|
+
const resolved = labels.map((label) => resolveBuilder(label, LabelBuilder));
|
|
3453
3566
|
this.data.components.splice(index, deleteCount, ...resolved);
|
|
3454
3567
|
return this;
|
|
3455
3568
|
}
|
|
@@ -3472,7 +3585,7 @@ var ModalBuilder = class {
|
|
|
3472
3585
|
};
|
|
3473
3586
|
|
|
3474
3587
|
// src/messages/embed/Assertions.ts
|
|
3475
|
-
import { z as
|
|
3588
|
+
import { z as z10 } from "zod";
|
|
3476
3589
|
|
|
3477
3590
|
// src/util/componentUtil.ts
|
|
3478
3591
|
function embedLength(data) {
|
|
@@ -3481,34 +3594,34 @@ function embedLength(data) {
|
|
|
3481
3594
|
__name(embedLength, "embedLength");
|
|
3482
3595
|
|
|
3483
3596
|
// src/messages/embed/Assertions.ts
|
|
3484
|
-
var namePredicate3 =
|
|
3485
|
-
var URLPredicate =
|
|
3486
|
-
var URLWithAttachmentProtocolPredicate =
|
|
3487
|
-
var embedFieldPredicate =
|
|
3597
|
+
var namePredicate3 = z10.string().max(256);
|
|
3598
|
+
var URLPredicate = z10.url({ protocol: /^https?$/ });
|
|
3599
|
+
var URLWithAttachmentProtocolPredicate = z10.url({ protocol: /^(?:https?|attachment)$/ });
|
|
3600
|
+
var embedFieldPredicate = z10.object({
|
|
3488
3601
|
name: namePredicate3,
|
|
3489
|
-
value:
|
|
3490
|
-
inline:
|
|
3602
|
+
value: z10.string().max(1024),
|
|
3603
|
+
inline: z10.boolean().optional()
|
|
3491
3604
|
});
|
|
3492
|
-
var embedAuthorPredicate =
|
|
3605
|
+
var embedAuthorPredicate = z10.object({
|
|
3493
3606
|
name: namePredicate3.min(1),
|
|
3494
3607
|
icon_url: URLWithAttachmentProtocolPredicate.optional(),
|
|
3495
3608
|
url: URLPredicate.optional()
|
|
3496
3609
|
});
|
|
3497
|
-
var embedFooterPredicate =
|
|
3498
|
-
text:
|
|
3610
|
+
var embedFooterPredicate = z10.object({
|
|
3611
|
+
text: z10.string().min(1).max(2048),
|
|
3499
3612
|
icon_url: URLWithAttachmentProtocolPredicate.optional()
|
|
3500
3613
|
});
|
|
3501
|
-
var embedPredicate =
|
|
3614
|
+
var embedPredicate = z10.object({
|
|
3502
3615
|
title: namePredicate3.min(1).optional(),
|
|
3503
|
-
description:
|
|
3616
|
+
description: z10.string().min(1).max(4096).optional(),
|
|
3504
3617
|
url: URLPredicate.optional(),
|
|
3505
|
-
timestamp:
|
|
3506
|
-
color:
|
|
3618
|
+
timestamp: z10.string().optional(),
|
|
3619
|
+
color: z10.int().min(0).max(16777215).optional(),
|
|
3507
3620
|
footer: embedFooterPredicate.optional(),
|
|
3508
|
-
image:
|
|
3509
|
-
thumbnail:
|
|
3621
|
+
image: z10.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
3622
|
+
thumbnail: z10.object({ url: URLWithAttachmentProtocolPredicate }).optional(),
|
|
3510
3623
|
author: embedAuthorPredicate.optional(),
|
|
3511
|
-
fields:
|
|
3624
|
+
fields: z10.array(embedFieldPredicate).max(25).optional()
|
|
3512
3625
|
}).refine(
|
|
3513
3626
|
(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,
|
|
3514
3627
|
{
|
|
@@ -3994,19 +4107,19 @@ var EmbedBuilder = class {
|
|
|
3994
4107
|
|
|
3995
4108
|
// src/messages/poll/Assertions.ts
|
|
3996
4109
|
import { PollLayoutType } from "discord-api-types/v10";
|
|
3997
|
-
import { z as
|
|
3998
|
-
var pollQuestionPredicate =
|
|
3999
|
-
var pollAnswerMediaPredicate =
|
|
4000
|
-
text:
|
|
4110
|
+
import { z as z11 } from "zod";
|
|
4111
|
+
var pollQuestionPredicate = z11.object({ text: z11.string().min(1).max(300) });
|
|
4112
|
+
var pollAnswerMediaPredicate = z11.object({
|
|
4113
|
+
text: z11.string().min(1).max(55),
|
|
4001
4114
|
emoji: emojiPredicate.optional()
|
|
4002
4115
|
});
|
|
4003
|
-
var pollAnswerPredicate =
|
|
4004
|
-
var pollPredicate =
|
|
4116
|
+
var pollAnswerPredicate = z11.object({ poll_media: pollAnswerMediaPredicate });
|
|
4117
|
+
var pollPredicate = z11.object({
|
|
4005
4118
|
question: pollQuestionPredicate,
|
|
4006
|
-
answers:
|
|
4007
|
-
duration:
|
|
4008
|
-
allow_multiselect:
|
|
4009
|
-
layout_type:
|
|
4119
|
+
answers: z11.array(pollAnswerPredicate).min(1).max(10),
|
|
4120
|
+
duration: z11.number().min(1).max(768).optional(),
|
|
4121
|
+
allow_multiselect: z11.boolean().optional(),
|
|
4122
|
+
layout_type: z11.enum(PollLayoutType).optional()
|
|
4010
4123
|
});
|
|
4011
4124
|
|
|
4012
4125
|
// src/messages/poll/PollMedia.ts
|
|
@@ -4335,95 +4448,95 @@ var PollBuilder = class {
|
|
|
4335
4448
|
};
|
|
4336
4449
|
|
|
4337
4450
|
// src/messages/Assertions.ts
|
|
4338
|
-
import { AllowedMentionsTypes, ComponentType as
|
|
4339
|
-
import { z as
|
|
4340
|
-
var attachmentPredicate =
|
|
4341
|
-
id:
|
|
4342
|
-
description:
|
|
4343
|
-
duration_secs:
|
|
4344
|
-
filename:
|
|
4345
|
-
title:
|
|
4346
|
-
waveform:
|
|
4451
|
+
import { AllowedMentionsTypes, ComponentType as ComponentType25, MessageFlags, MessageReferenceType } from "discord-api-types/v10";
|
|
4452
|
+
import { z as z12 } from "zod";
|
|
4453
|
+
var attachmentPredicate = z12.object({
|
|
4454
|
+
id: z12.union([z12.string(), z12.number()]),
|
|
4455
|
+
description: z12.string().max(1024).optional(),
|
|
4456
|
+
duration_secs: z12.number().max(2 ** 31 - 1).optional(),
|
|
4457
|
+
filename: z12.string().max(1024).optional(),
|
|
4458
|
+
title: z12.string().max(1024).optional(),
|
|
4459
|
+
waveform: z12.string().max(400).optional()
|
|
4347
4460
|
});
|
|
4348
|
-
var allowedMentionPredicate =
|
|
4349
|
-
parse:
|
|
4350
|
-
roles:
|
|
4351
|
-
users:
|
|
4352
|
-
replied_user:
|
|
4461
|
+
var allowedMentionPredicate = z12.object({
|
|
4462
|
+
parse: z12.enum(AllowedMentionsTypes).array().optional(),
|
|
4463
|
+
roles: z12.string().array().max(100).optional(),
|
|
4464
|
+
users: z12.string().array().max(100).optional(),
|
|
4465
|
+
replied_user: z12.boolean().optional()
|
|
4353
4466
|
}).refine(
|
|
4354
4467
|
(data) => !(data.parse?.includes(AllowedMentionsTypes.User) && data.users?.length || data.parse?.includes(AllowedMentionsTypes.Role) && data.roles?.length),
|
|
4355
4468
|
{
|
|
4356
4469
|
error: 'Cannot specify both parse: ["users"] and non-empty users array, or parse: ["roles"] and non-empty roles array. These are mutually exclusive'
|
|
4357
4470
|
}
|
|
4358
4471
|
);
|
|
4359
|
-
var messageReferencePredicate =
|
|
4360
|
-
channel_id:
|
|
4361
|
-
fail_if_not_exists:
|
|
4362
|
-
guild_id:
|
|
4363
|
-
message_id:
|
|
4364
|
-
type:
|
|
4472
|
+
var messageReferencePredicate = z12.object({
|
|
4473
|
+
channel_id: z12.string().optional(),
|
|
4474
|
+
fail_if_not_exists: z12.boolean().optional(),
|
|
4475
|
+
guild_id: z12.string().optional(),
|
|
4476
|
+
message_id: z12.string(),
|
|
4477
|
+
type: z12.enum(MessageReferenceType).optional()
|
|
4365
4478
|
});
|
|
4366
|
-
var baseMessagePredicate =
|
|
4367
|
-
nonce:
|
|
4368
|
-
tts:
|
|
4479
|
+
var baseMessagePredicate = z12.object({
|
|
4480
|
+
nonce: z12.union([z12.string().max(25), z12.number()]).optional(),
|
|
4481
|
+
tts: z12.boolean().optional(),
|
|
4369
4482
|
allowed_mentions: allowedMentionPredicate.optional(),
|
|
4370
4483
|
message_reference: messageReferencePredicate.optional(),
|
|
4371
4484
|
attachments: attachmentPredicate.array().max(10).optional(),
|
|
4372
|
-
enforce_nonce:
|
|
4485
|
+
enforce_nonce: z12.boolean().optional()
|
|
4373
4486
|
});
|
|
4374
|
-
var basicActionRowPredicate =
|
|
4375
|
-
type:
|
|
4376
|
-
components:
|
|
4377
|
-
type:
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4487
|
+
var basicActionRowPredicate = z12.object({
|
|
4488
|
+
type: z12.literal(ComponentType25.ActionRow),
|
|
4489
|
+
components: z12.object({
|
|
4490
|
+
type: z12.literal([
|
|
4491
|
+
ComponentType25.Button,
|
|
4492
|
+
ComponentType25.ChannelSelect,
|
|
4493
|
+
ComponentType25.MentionableSelect,
|
|
4494
|
+
ComponentType25.RoleSelect,
|
|
4495
|
+
ComponentType25.StringSelect,
|
|
4496
|
+
ComponentType25.UserSelect
|
|
4384
4497
|
])
|
|
4385
4498
|
}).array()
|
|
4386
4499
|
});
|
|
4387
4500
|
var messageNoComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4388
|
-
content:
|
|
4501
|
+
content: z12.string().max(2e3).optional(),
|
|
4389
4502
|
embeds: embedPredicate.array().max(10).optional(),
|
|
4390
|
-
sticker_ids:
|
|
4503
|
+
sticker_ids: z12.array(z12.string()).max(3).optional(),
|
|
4391
4504
|
poll: pollPredicate.optional(),
|
|
4392
4505
|
components: basicActionRowPredicate.array().max(5).optional(),
|
|
4393
|
-
flags:
|
|
4506
|
+
flags: z12.int().optional().refine((flags) => !flags || (flags & MessageFlags.IsComponentsV2) === 0, {
|
|
4394
4507
|
error: "Cannot set content, embeds, stickers, or poll with IsComponentsV2 flag set"
|
|
4395
4508
|
})
|
|
4396
4509
|
}).refine(
|
|
4397
4510
|
(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,
|
|
4398
4511
|
{ error: "Messages must have content, embeds, a poll, attachments, components or stickers" }
|
|
4399
4512
|
);
|
|
4400
|
-
var allTopLevelComponentsPredicate =
|
|
4513
|
+
var allTopLevelComponentsPredicate = z12.union([
|
|
4401
4514
|
basicActionRowPredicate,
|
|
4402
|
-
|
|
4403
|
-
type:
|
|
4515
|
+
z12.object({
|
|
4516
|
+
type: z12.literal([
|
|
4404
4517
|
// Components v2
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4518
|
+
ComponentType25.Container,
|
|
4519
|
+
ComponentType25.File,
|
|
4520
|
+
ComponentType25.MediaGallery,
|
|
4521
|
+
ComponentType25.Section,
|
|
4522
|
+
ComponentType25.Separator,
|
|
4523
|
+
ComponentType25.TextDisplay,
|
|
4524
|
+
ComponentType25.Thumbnail
|
|
4412
4525
|
])
|
|
4413
4526
|
})
|
|
4414
4527
|
]).array().min(1).max(10);
|
|
4415
4528
|
var messageComponentsV2Predicate = baseMessagePredicate.extend({
|
|
4416
4529
|
components: allTopLevelComponentsPredicate,
|
|
4417
|
-
flags:
|
|
4530
|
+
flags: z12.int().refine((flags) => (flags & MessageFlags.IsComponentsV2) === MessageFlags.IsComponentsV2, {
|
|
4418
4531
|
error: "Must set IsComponentsV2 flag to use Components V2"
|
|
4419
4532
|
}),
|
|
4420
4533
|
// These fields cannot be set
|
|
4421
|
-
content:
|
|
4422
|
-
embeds:
|
|
4423
|
-
sticker_ids:
|
|
4424
|
-
poll:
|
|
4534
|
+
content: z12.string().length(0).nullish(),
|
|
4535
|
+
embeds: z12.array(z12.never()).nullish(),
|
|
4536
|
+
sticker_ids: z12.array(z12.never()).nullish(),
|
|
4537
|
+
poll: z12.null().optional()
|
|
4425
4538
|
});
|
|
4426
|
-
var messagePredicate =
|
|
4539
|
+
var messagePredicate = z12.union([messageNoComponentsV2Predicate, messageComponentsV2Predicate]);
|
|
4427
4540
|
|
|
4428
4541
|
// src/messages/AllowedMentions.ts
|
|
4429
4542
|
var AllowedMentionsBuilder = class {
|
|
@@ -5313,7 +5426,7 @@ var MessageBuilder = class {
|
|
|
5313
5426
|
};
|
|
5314
5427
|
|
|
5315
5428
|
// src/index.ts
|
|
5316
|
-
var version = "2.0.0-dev.
|
|
5429
|
+
var version = "2.0.0-dev.1757160090-352c9819b";
|
|
5317
5430
|
export {
|
|
5318
5431
|
ActionRowBuilder,
|
|
5319
5432
|
AllowedMentionsBuilder,
|
|
@@ -5351,6 +5464,7 @@ export {
|
|
|
5351
5464
|
EmbedFooterBuilder,
|
|
5352
5465
|
EmojiOrLabelButtonMixin,
|
|
5353
5466
|
FileBuilder,
|
|
5467
|
+
LabelBuilder,
|
|
5354
5468
|
LinkButtonBuilder,
|
|
5355
5469
|
MediaGalleryBuilder,
|
|
5356
5470
|
MediaGalleryItemBuilder,
|
|
@@ -5406,6 +5520,7 @@ export {
|
|
|
5406
5520
|
filePredicate,
|
|
5407
5521
|
integerOptionPredicate,
|
|
5408
5522
|
isValidationEnabled,
|
|
5523
|
+
labelPredicate2 as labelPredicate,
|
|
5409
5524
|
localeMapPredicate,
|
|
5410
5525
|
mediaGalleryItemPredicate,
|
|
5411
5526
|
mediaGalleryPredicate,
|