nexocord 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58316,30 +58316,30 @@ function getAttachmentName(attachment) {
58316
58316
  if (!attachment || typeof attachment !== "object") {
58317
58317
  throw new Error("Attachment must be an object with a valid file name.");
58318
58318
  }
58319
- const candidate = attachment;
58320
- const name = typeof candidate.name === "string" ? candidate.name : typeof candidate.data?.name === "string" ? candidate.data.name : undefined;
58319
+ const file = attachment;
58320
+ const name = typeof file.name === "string" ? file.name : typeof file.data?.name === "string" ? file.data.name : undefined;
58321
58321
  if (!name) {
58322
58322
  throw new Error("Attachment name was not found. Define a name in AttachmentBuilder options.");
58323
58323
  }
58324
58324
  return name;
58325
58325
  }
58326
58326
  // src/core/ui/utils/formatText.ts
58327
- function wrap(content, marker) {
58327
+ function surround(content, marker) {
58328
58328
  return `${marker}${content}${marker}`;
58329
58329
  }
58330
- function getInlineCodeDelimiter(content) {
58331
- let longestRun = 0;
58332
- let currentRun = 0;
58330
+ function getCodeFence(content) {
58331
+ let maxRun = 0;
58332
+ let run = 0;
58333
58333
  for (const character of content) {
58334
58334
  if (character === "`") {
58335
- currentRun += 1;
58336
- if (currentRun > longestRun)
58337
- longestRun = currentRun;
58335
+ run += 1;
58336
+ if (run > maxRun)
58337
+ maxRun = run;
58338
58338
  continue;
58339
58339
  }
58340
- currentRun = 0;
58340
+ run = 0;
58341
58341
  }
58342
- return "`".repeat(longestRun + 1);
58342
+ return "`".repeat(maxRun + 1);
58343
58343
  }
58344
58344
  function toLines(input) {
58345
58345
  return Array.isArray(input) ? input : [input];
@@ -58349,25 +58349,25 @@ function formatLines(input, formatter) {
58349
58349
  `);
58350
58350
  }
58351
58351
  function formatText(content, options = {}) {
58352
- let formatted = toLines(content).join(`
58352
+ let out = toLines(content).join(`
58353
58353
  `);
58354
58354
  if (options.underline)
58355
- formatted = wrap(formatted, "__");
58355
+ out = surround(out, "__");
58356
58356
  if (options.italic)
58357
- formatted = wrap(formatted, "*");
58357
+ out = surround(out, "*");
58358
58358
  if (options.bold)
58359
- formatted = wrap(formatted, "**");
58359
+ out = surround(out, "**");
58360
58360
  if (typeof options.size === "number") {
58361
58361
  const prefix = options.size === 4 ? "-#" : "#".repeat(options.size);
58362
- return `${prefix} ${formatted}`;
58362
+ return `${prefix} ${out}`;
58363
58363
  }
58364
- return formatted;
58364
+ return out;
58365
58365
  }
58366
58366
  function formatInlineCode(content) {
58367
58367
  const text = toLines(content).join(`
58368
58368
  `);
58369
- const delimiter = getInlineCodeDelimiter(text);
58370
- return `${delimiter}${text}${delimiter}`;
58369
+ const fence = getCodeFence(text);
58370
+ return `${fence}${text}${fence}`;
58371
58371
  }
58372
58372
  function formatQuote(input) {
58373
58373
  return formatLines(input, (line) => `> ${line}`);
@@ -58378,38 +58378,34 @@ function formatSpoiler(input) {
58378
58378
 
58379
58379
  // src/core/ui/utils/formatList.ts
58380
58380
  function formatList(items, options = {}) {
58381
- return formatLines(items, (item, index) => {
58382
- if (options.ordered) {
58383
- return `${index + 1}. ${item}`;
58384
- }
58385
- return `- ${item}`;
58386
- });
58381
+ return formatLines(items, (item, index) => options.ordered ? `${index + 1}. ${item}` : `- ${item}`);
58387
58382
  }
58388
58383
  // src/core/ui/utils/resolveSelectBase.ts
58389
58384
  function resolveSelectBase(customIdOrOpts, opts = {}) {
58390
58385
  if (typeof customIdOrOpts === "string") {
58391
58386
  return { id: customIdOrOpts, ...opts };
58392
58387
  }
58393
- const { customId, ...selectOptions } = customIdOrOpts;
58394
- return { id: customId, ...selectOptions };
58388
+ const { customId, ...select } = customIdOrOpts;
58389
+ return { id: customId, ...select };
58395
58390
  }
58396
58391
  // src/core/ui/utils/splitContainerArgs.ts
58397
- function isContainerOptions(value) {
58392
+ function isOptions(value) {
58398
58393
  if (!value || typeof value !== "object" || Array.isArray(value)) {
58399
58394
  return false;
58400
58395
  }
58401
58396
  return "color" in value;
58402
58397
  }
58403
58398
  function splitContainerArgs(args) {
58404
- if (isContainerOptions(args[0])) {
58399
+ const head = args[0];
58400
+ if (!isOptions(head)) {
58405
58401
  return {
58406
- options: args[0],
58407
- components: args.slice(1)
58402
+ options: {},
58403
+ components: args
58408
58404
  };
58409
58405
  }
58410
58406
  return {
58411
- options: {},
58412
- components: args
58407
+ options: head,
58408
+ components: args.slice(1)
58413
58409
  };
58414
58410
  }
58415
58411
  // src/core/ui/builders/primitives.ts
@@ -58460,12 +58456,12 @@ function row(...components) {
58460
58456
  return { type: "row", components };
58461
58457
  }
58462
58458
  function buildEasyFile(url, fileOrSpoiler, spoiler = false) {
58463
- const hasFile = typeof fileOrSpoiler !== "boolean";
58459
+ const hasAttachment = typeof fileOrSpoiler !== "boolean";
58464
58460
  return {
58465
58461
  type: "file",
58466
58462
  url,
58467
- spoiler: hasFile ? spoiler : fileOrSpoiler ?? false,
58468
- attachment: hasFile ? fileOrSpoiler : undefined
58463
+ spoiler: hasAttachment ? spoiler : fileOrSpoiler ?? false,
58464
+ attachment: hasAttachment ? fileOrSpoiler : undefined
58469
58465
  };
58470
58466
  }
58471
58467
  function buildFile(url, fileOrSpoiler, spoiler = false) {
@@ -58478,65 +58474,59 @@ function fromAttachment(attachment, spoiler = false) {
58478
58474
  var file = Object.assign(buildFile, { fromAttachment });
58479
58475
 
58480
58476
  // src/core/ui/builders/select.ts
58481
- function createSelect(type, customId, opts) {
58477
+ function mkSelect(type, input, opts) {
58478
+ const select = typeof input === "string" ? resolveSelectBase(input, opts) : resolveSelectBase(input);
58482
58479
  return {
58483
58480
  type,
58484
- ...resolveSelectBase(customId, opts)
58481
+ ...select
58485
58482
  };
58486
58483
  }
58487
- function createSelectFromObject(type, customIdOrOpts) {
58488
- const { customId, ...selectOptions } = customIdOrOpts;
58489
- return {
58490
- type,
58491
- ...resolveSelectBase({ customId, ...selectOptions })
58492
- };
58493
- }
58494
- function createSimpleSelectBuilder(type) {
58495
- function build(customIdOrOpts, opts) {
58496
- return typeof customIdOrOpts === "string" ? createSelect(type, customIdOrOpts, opts) : createSelectFromObject(type, customIdOrOpts);
58484
+ function mkSimpleBuilder(type) {
58485
+ function build(input, opts) {
58486
+ return mkSelect(type, input, opts);
58497
58487
  }
58498
58488
  return build;
58499
58489
  }
58500
- var userSelect = createSimpleSelectBuilder("select.user");
58501
- var roleSelect = createSimpleSelectBuilder("select.role");
58502
- var mentionableSelect = createSimpleSelectBuilder("select.mentionable");
58503
- function user(customIdOrOpts, opts) {
58504
- return typeof customIdOrOpts === "string" ? userSelect(customIdOrOpts, opts) : userSelect(customIdOrOpts);
58490
+ var userSelect = mkSimpleBuilder("select.user");
58491
+ var roleSelect = mkSimpleBuilder("select.role");
58492
+ var mentionableSelect = mkSimpleBuilder("select.mentionable");
58493
+ function user(input, opts) {
58494
+ return userSelect(input, opts);
58505
58495
  }
58506
- function role(customIdOrOpts, opts) {
58507
- return typeof customIdOrOpts === "string" ? roleSelect(customIdOrOpts, opts) : roleSelect(customIdOrOpts);
58496
+ function role(input, opts) {
58497
+ return roleSelect(input, opts);
58508
58498
  }
58509
- function mentionable(customIdOrOpts, opts) {
58510
- return typeof customIdOrOpts === "string" ? mentionableSelect(customIdOrOpts, opts) : mentionableSelect(customIdOrOpts);
58499
+ function mentionable(input, opts) {
58500
+ return mentionableSelect(input, opts);
58511
58501
  }
58512
- function channel(customIdOrOpts, channelTypes, opts = {}) {
58513
- if (typeof customIdOrOpts !== "string") {
58514
- const { channelTypes: resolvedChannelTypes, ...select } = customIdOrOpts;
58502
+ function channel(input, channelTypes, opts = {}) {
58503
+ if (typeof input !== "string") {
58504
+ const { channelTypes: chans, ...select } = input;
58515
58505
  return {
58516
58506
  type: "select.channel",
58517
58507
  ...resolveSelectBase(select),
58518
- channelTypes: resolvedChannelTypes
58508
+ channelTypes: chans
58519
58509
  };
58520
58510
  }
58521
- const resolvedOpts = Array.isArray(channelTypes) ? opts : channelTypes;
58522
58511
  return {
58523
58512
  type: "select.channel",
58524
- ...resolveSelectBase(customIdOrOpts, resolvedOpts),
58513
+ ...resolveSelectBase(input, Array.isArray(channelTypes) ? opts : channelTypes),
58525
58514
  channelTypes: Array.isArray(channelTypes) ? channelTypes : undefined
58526
58515
  };
58527
58516
  }
58528
- function string(customIdOrOpts, options, opts = {}) {
58529
- if (typeof customIdOrOpts !== "string") {
58530
- const { options: stringOptions, ...select } = customIdOrOpts;
58517
+ function string(input, options, opts = {}) {
58518
+ if (typeof input !== "string") {
58519
+ const { options: items, ...select } = input;
58531
58520
  return {
58532
58521
  type: "select.string",
58533
58522
  ...resolveSelectBase(select),
58534
- options: stringOptions
58523
+ options: items
58535
58524
  };
58536
58525
  }
58526
+ const base = Array.isArray(options) ? opts : {};
58537
58527
  return {
58538
58528
  type: "select.string",
58539
- ...resolveSelectBase(customIdOrOpts, Array.isArray(options) ? opts : {}),
58529
+ ...resolveSelectBase(input, base),
58540
58530
  options: Array.isArray(options) ? options : []
58541
58531
  };
58542
58532
  }
@@ -58563,6 +58553,9 @@ var ATTACHMENTS = Symbol("ui.display.attachments");
58563
58553
  var RENDERED = Symbol("ui.display.rendered");
58564
58554
  var RENDERED_ATTACHMENTS = Symbol("ui.display.rendered.attachments");
58565
58555
  // src/core/ui/validators/container.ts
58556
+ function isSelectComponent(component) {
58557
+ return !("label" in component);
58558
+ }
58566
58559
  function validateComponents(components) {
58567
58560
  if (components.length > MAX_MESSAGE_COMPONENTS) {
58568
58561
  throw new Error("A message cannot contain more than 40 components.");
@@ -58587,7 +58580,7 @@ function validateRow(components) {
58587
58580
  if (components.length < 1 || components.length > MAX_ROW_COMPONENTS) {
58588
58581
  throw new Error("Action row must contain between 1 and 5 components.");
58589
58582
  }
58590
- const selectCount = components.filter((component) => !("label" in component)).length;
58583
+ const selectCount = components.filter(isSelectComponent).length;
58591
58584
  if (selectCount > 0 && components.length > 1) {
58592
58585
  throw new Error("Select menus must be alone in an action row (max width layout rule).");
58593
58586
  }
@@ -58621,37 +58614,47 @@ function validateGallery(items) {
58621
58614
  }
58622
58615
 
58623
58616
  // src/core/ui/validators/button.ts
58624
- function hasLengthBetween(value, min, max) {
58617
+ function isLink(button2) {
58618
+ return "url" in button2 && typeof button2.url === "string";
58619
+ }
58620
+ function hasLen(value, min, max) {
58625
58621
  if (!value)
58626
58622
  return false;
58627
58623
  return value.length >= min && value.length <= max;
58628
58624
  }
58629
58625
  function validateButton(button2) {
58630
- if (!hasLengthBetween(button2.label, 1, MAX_BUTTON_LABEL_LENGTH)) {
58626
+ if (!hasLen(button2.label, 1, MAX_BUTTON_LABEL_LENGTH)) {
58631
58627
  throw new Error("Button label must have between 1 and 80 characters.");
58632
58628
  }
58633
- if (!hasLengthBetween(button2.customId, 1, MAX_BUTTON_CUSTOM_ID_LENGTH)) {
58629
+ if (isLink(button2)) {
58630
+ validateUrl(button2.url);
58631
+ return;
58632
+ }
58633
+ if (!hasLen(button2.customId, 1, MAX_BUTTON_CUSTOM_ID_LENGTH)) {
58634
58634
  throw new Error("Button custom id must have between 1 and 100 characters.");
58635
58635
  }
58636
58636
  }
58637
58637
 
58638
58638
  // src/core/ui/validators/select.ts
58639
- function hasLengthBetween2(value, min, max) {
58640
- if (!value)
58639
+ function hasLen2(value, min, max) {
58640
+ if (typeof value !== "string")
58641
58641
  return false;
58642
58642
  return value.length >= min && value.length <= max;
58643
58643
  }
58644
+ function checkStringSelect(select) {
58645
+ if (select.options.length < 1 || select.options.length > MAX_STRING_SELECT_OPTIONS) {
58646
+ throw new Error("String select must contain between 1 and 25 options.");
58647
+ }
58648
+ }
58644
58649
  function validateSelect(select) {
58645
- if (!hasLengthBetween2(select.id, 1, 100)) {
58650
+ if (!hasLen2(select.id, 1, 100)) {
58646
58651
  throw new Error("Select custom id must have between 1 and 100 characters.");
58647
58652
  }
58648
- if (select.placeholder && select.placeholder.length > MAX_SELECT_PLACEHOLDER_LENGTH) {
58653
+ if (typeof select.placeholder === "string" && select.placeholder.length > MAX_SELECT_PLACEHOLDER_LENGTH) {
58649
58654
  throw new Error("Select placeholder cannot exceed 150 characters.");
58650
58655
  }
58651
58656
  if (select.type === "select.string") {
58652
- if (select.options.length < 1 || select.options.length > MAX_STRING_SELECT_OPTIONS) {
58653
- throw new Error("String select must contain between 1 and 25 options.");
58654
- }
58657
+ checkStringSelect(select);
58655
58658
  }
58656
58659
  }
58657
58660
 
@@ -58671,16 +58674,29 @@ var validate = {
58671
58674
 
58672
58675
  // src/core/ui/normalizers/button.ts
58673
58676
  var import_discord2 = __toESM(require_src(), 1);
58677
+ function isLink2(button2) {
58678
+ return "url" in button2 && typeof button2.url === "string";
58679
+ }
58674
58680
  function normalizeButton(button2) {
58675
58681
  validateButton(button2);
58676
- const built = new import_discord2.ButtonBuilder().setLabel(button2.label).setCustomId(button2.customId).setStyle(button2.style ?? import_discord2.ButtonStyle.Primary);
58682
+ const btn = new import_discord2.ButtonBuilder().setLabel(button2.label);
58683
+ if (isLink2(button2)) {
58684
+ btn.setURL(button2.url).setStyle(button2.style ?? import_discord2.ButtonStyle.Link);
58685
+ } else {
58686
+ btn.setCustomId(button2.customId).setStyle(button2.style ?? import_discord2.ButtonStyle.Primary);
58687
+ }
58677
58688
  if (button2.emoji) {
58678
- built.setEmoji({ name: button2.emoji });
58689
+ btn.setEmoji({ name: button2.emoji });
58679
58690
  }
58680
- return built;
58691
+ return btn;
58681
58692
  }
58682
58693
  function applyButtonData(button2, data) {
58683
- button2.setLabel(data.label).setCustomId(data.customId).setStyle(data.style ?? import_discord2.ButtonStyle.Primary);
58694
+ button2.setLabel(data.label);
58695
+ if (isLink2(data)) {
58696
+ button2.setURL(data.url).setStyle(data.style ?? import_discord2.ButtonStyle.Link);
58697
+ } else {
58698
+ button2.setCustomId(data.customId).setStyle(data.style ?? import_discord2.ButtonStyle.Primary);
58699
+ }
58684
58700
  if (data.emoji) {
58685
58701
  button2.setEmoji({ name: data.emoji });
58686
58702
  }
@@ -58691,10 +58707,8 @@ var import_discord5 = __toESM(require_src(), 1);
58691
58707
 
58692
58708
  // src/core/ui/normalizers/media.ts
58693
58709
  var import_discord3 = __toESM(require_src(), 1);
58694
- function normalizeGallery(items) {
58695
- validateGallery(items);
58696
- const gallery2 = new import_discord3.MediaGalleryBuilder;
58697
- gallery2.addItems(...items.map((item) => (media) => {
58710
+ function toMediaItem(item) {
58711
+ return (media) => {
58698
58712
  validateUrl(item.url);
58699
58713
  media.setURL(item.url);
58700
58714
  if (item.description)
@@ -58702,7 +58716,12 @@ function normalizeGallery(items) {
58702
58716
  if (item.spoiler)
58703
58717
  media.setSpoiler(item.spoiler);
58704
58718
  return media;
58705
- }));
58719
+ };
58720
+ }
58721
+ function normalizeGallery(items) {
58722
+ validateGallery(items);
58723
+ const gallery2 = new import_discord3.MediaGalleryBuilder;
58724
+ gallery2.addItems(...items.map(toMediaItem));
58706
58725
  return gallery2;
58707
58726
  }
58708
58727
  function normalizeFile(fileInput) {
@@ -58715,34 +58734,40 @@ function normalizeFile(fileInput) {
58715
58734
 
58716
58735
  // src/core/ui/normalizers/select.ts
58717
58736
  var import_discord4 = __toESM(require_src(), 1);
58737
+ function baseSelect(type, select, builder) {
58738
+ validateSelect({ type, ...select });
58739
+ return applySelectBase(builder, select);
58740
+ }
58741
+ function withChannelTypes(builder, channelTypes) {
58742
+ if (channelTypes?.length)
58743
+ builder.setChannelTypes(...channelTypes);
58744
+ return builder;
58745
+ }
58746
+ function toStringOptions(select) {
58747
+ return select.options.map((option) => ({
58748
+ label: option.label,
58749
+ value: option.value,
58750
+ description: option.description,
58751
+ default: option.default
58752
+ }));
58753
+ }
58718
58754
  function normalizeUserSelect(select) {
58719
- validateSelect({ type: "select.user", ...select });
58720
- return applySelectBase(new import_discord4.UserSelectMenuBuilder, select);
58755
+ return baseSelect("select.user", select, new import_discord4.UserSelectMenuBuilder);
58721
58756
  }
58722
58757
  function normalizeRoleSelect(select) {
58723
- validateSelect({ type: "select.role", ...select });
58724
- return applySelectBase(new import_discord4.RoleSelectMenuBuilder, select);
58758
+ return baseSelect("select.role", select, new import_discord4.RoleSelectMenuBuilder);
58725
58759
  }
58726
58760
  function normalizeMentionableSelect(select) {
58727
- validateSelect({ type: "select.mentionable", ...select });
58728
- return applySelectBase(new import_discord4.MentionableSelectMenuBuilder, select);
58761
+ return baseSelect("select.mentionable", select, new import_discord4.MentionableSelectMenuBuilder);
58729
58762
  }
58730
58763
  function normalizeChannelSelect(select) {
58731
58764
  validateSelect(select);
58732
- const builder = applySelectBase(new import_discord4.ChannelSelectMenuBuilder, select);
58733
- if (select.channelTypes?.length)
58734
- builder.setChannelTypes(...select.channelTypes);
58735
- return builder;
58765
+ return applySelectBase(withChannelTypes(new import_discord4.ChannelSelectMenuBuilder, select.channelTypes), select);
58736
58766
  }
58737
58767
  function normalizeStringSelect(select) {
58738
58768
  validateSelect(select);
58739
58769
  const builder = applySelectBase(new import_discord4.StringSelectMenuBuilder, select);
58740
- builder.setOptions(...select.options.map((option) => ({
58741
- label: option.label,
58742
- value: option.value,
58743
- description: option.description,
58744
- default: option.default
58745
- })));
58770
+ builder.setOptions(...toStringOptions(select));
58746
58771
  return builder;
58747
58772
  }
58748
58773
  function normalizeSelect(select) {
@@ -58763,14 +58788,24 @@ function normalizeSelect(select) {
58763
58788
  }
58764
58789
 
58765
58790
  // src/core/ui/normalizers/container.ts
58766
- function isContainerChild(component) {
58791
+ function isChild(component) {
58767
58792
  return component instanceof import_discord5.TextDisplayBuilder || component instanceof import_discord5.SeparatorBuilder || component instanceof import_discord5.SectionBuilder || component instanceof import_discord5.MediaGalleryBuilder || component instanceof import_discord5.FileBuilder || component instanceof import_discord5.ActionRowBuilder;
58768
58793
  }
58769
- function isDisplayComponent(component) {
58770
- return component instanceof import_discord5.ContainerBuilder || isContainerChild(component);
58794
+ function isDisplay(component) {
58795
+ return component instanceof import_discord5.ContainerBuilder || isChild(component);
58796
+ }
58797
+ function isObject(value) {
58798
+ return !!value && typeof value === "object" && !Array.isArray(value);
58799
+ }
58800
+ function isButton(component) {
58801
+ if (!isObject(component)) {
58802
+ return false;
58803
+ }
58804
+ const candidate = component;
58805
+ return typeof candidate.label === "string" && (("customId" in candidate) || ("url" in candidate));
58771
58806
  }
58772
- function isContainerNode(component) {
58773
- return !isContainerChild(component);
58807
+ function toRow(component) {
58808
+ return new import_discord5.ActionRowBuilder().addComponents(normalizeButton(component));
58774
58809
  }
58775
58810
  function normalizeRowComponent(component) {
58776
58811
  return "label" in component ? normalizeButton(component) : normalizeSelect(component);
@@ -58789,6 +58824,20 @@ function normalizeSeparator(component) {
58789
58824
  }
58790
58825
  return separator2;
58791
58826
  }
58827
+ function setSectionButton(section, button2) {
58828
+ section.setButtonAccessory((target) => applyButtonData(target, button2));
58829
+ }
58830
+ function setSectionThumb(section, thumbnail2) {
58831
+ validateUrl(thumbnail2.url);
58832
+ section.setThumbnailAccessory((target) => {
58833
+ target.setURL(thumbnail2.url);
58834
+ if (thumbnail2.description)
58835
+ target.setDescription(thumbnail2.description);
58836
+ if (thumbnail2.spoiler)
58837
+ target.setSpoiler(thumbnail2.spoiler);
58838
+ return target;
58839
+ });
58840
+ }
58792
58841
  function normalizeSection(component) {
58793
58842
  validateSection(component);
58794
58843
  const section = new import_discord5.SectionBuilder;
@@ -58797,19 +58846,10 @@ function normalizeSection(component) {
58797
58846
  return (text2) => text2.setContent(content);
58798
58847
  }));
58799
58848
  if (component.button) {
58800
- section.setButtonAccessory((button2) => applyButtonData(button2, component.button));
58849
+ setSectionButton(section, component.button);
58801
58850
  }
58802
58851
  if (component.thumbnail) {
58803
- const thumbnail2 = component.thumbnail;
58804
- validateUrl(thumbnail2.url);
58805
- section.setThumbnailAccessory((thumb) => {
58806
- thumb.setURL(thumbnail2.url);
58807
- if (thumbnail2.description)
58808
- thumb.setDescription(thumbnail2.description);
58809
- if (thumbnail2.spoiler)
58810
- thumb.setSpoiler(thumbnail2.spoiler);
58811
- return thumb;
58812
- });
58852
+ setSectionThumb(section, component.thumbnail);
58813
58853
  }
58814
58854
  return section;
58815
58855
  }
@@ -58817,7 +58857,7 @@ function normalizeRow(component) {
58817
58857
  validateRow(component.components);
58818
58858
  return new import_discord5.ActionRowBuilder().addComponents(...component.components.map(normalizeRowComponent));
58819
58859
  }
58820
- function normalizeContainerNode(component) {
58860
+ function normalizeNode(component) {
58821
58861
  switch (component.type) {
58822
58862
  case "text":
58823
58863
  return normalizeText(component);
@@ -58836,16 +58876,18 @@ function normalizeContainerNode(component) {
58836
58876
  }
58837
58877
  }
58838
58878
  function toContainerChild(component) {
58839
- if (isContainerChild(component))
58879
+ if (isChild(component))
58840
58880
  return component;
58841
- if (isContainerNode(component))
58842
- return normalizeContainerNode(component);
58843
- return component;
58881
+ if (isButton(component))
58882
+ return toRow(component);
58883
+ return normalizeNode(component);
58844
58884
  }
58845
58885
  function toDisplayComponent(component) {
58846
- if (isDisplayComponent(component))
58886
+ if (isDisplay(component))
58847
58887
  return component;
58848
- return normalizeContainerNode(component);
58888
+ if (isButton(component))
58889
+ return toRow(component);
58890
+ return normalizeNode(component);
58849
58891
  }
58850
58892
  function toDisplayComponents(...components) {
58851
58893
  return components.map(toDisplayComponent);
@@ -58865,7 +58907,7 @@ function getRenderedComponentsAttachments(components) {
58865
58907
  return components[RENDERED_ATTACHMENTS] ?? [];
58866
58908
  }
58867
58909
  function isEasyFileInput(component) {
58868
- if (!component || typeof component !== "object" || Array.isArray(component)) {
58910
+ if (!isObject(component)) {
58869
58911
  return false;
58870
58912
  }
58871
58913
  const candidate = component;
@@ -58902,20 +58944,17 @@ function section(texts, opts = {}) {
58902
58944
  }
58903
58945
  function container(...args) {
58904
58946
  const { options, components } = splitContainerArgs(args);
58905
- const container2 = new import_discord6.ContainerBuilder;
58906
- container2.components.push(...components.map(toContainerChild));
58947
+ const out = new import_discord6.ContainerBuilder;
58948
+ out.components.push(...components.map(toContainerChild));
58907
58949
  if (options.color !== undefined) {
58908
- const accentColor = validate.color(options.color);
58909
- container2.setAccentColor(accentColor);
58950
+ out.setAccentColor(validate.color(options.color));
58910
58951
  }
58911
- const attachments = collectAttachmentsFromContainerInputs(components);
58912
- return attachContainerAttachments(container2, attachments);
58952
+ return attachContainerAttachments(out, collectAttachmentsFromContainerInputs(components));
58913
58953
  }
58914
58954
  function render(...components) {
58915
- const rendered = toDisplayComponents(...components);
58916
- validate.components(rendered);
58917
- const files = collectAttachmentsFromDisplayInputs(components);
58918
- return createRenderedComponents(rendered, files);
58955
+ const out = toDisplayComponents(...components);
58956
+ validate.components(out);
58957
+ return createRenderedComponents(out, collectAttachmentsFromDisplayInputs(components));
58919
58958
  }
58920
58959
  function send(interaction, payload) {
58921
58960
  if (!isRenderedComponents(payload.components)) {
@@ -58923,8 +58962,10 @@ function send(interaction, payload) {
58923
58962
  }
58924
58963
  validate.components(payload.components);
58925
58964
  const flags = payload.ephemeral ? [import_discord6.MessageFlags.IsComponentsV2, import_discord6.MessageFlags.Ephemeral] : [import_discord6.MessageFlags.IsComponentsV2];
58926
- const autoFiles = getRenderedComponentsAttachments(payload.components);
58927
- const files = [...autoFiles, ...payload.files ?? []];
58965
+ const files = [
58966
+ ...getRenderedComponentsAttachments(payload.components),
58967
+ ...payload.files ?? []
58968
+ ];
58928
58969
  return interaction.reply({
58929
58970
  flags,
58930
58971
  components: payload.components,
@@ -17,6 +17,7 @@ export declare function normalizeButton(button: Button): ButtonBuilder;
17
17
  export declare function applyButtonData<T extends {
18
18
  setLabel(label: string): T;
19
19
  setCustomId(id: string): T;
20
+ setURL(url: string): T;
20
21
  setStyle(style: ButtonStyle): T;
21
22
  setEmoji(emoji: {
22
23
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,iBAa7C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,CAAC,SAAS;IACR,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;IAC3B,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,CAAC,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,CAAC,CAAC;CACtC,EACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAW5B"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOvC;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,iBAgB7C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,CAAC,SAAS;IACR,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;IAC3B,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,WAAW,GAAG,CAAC,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,CAAC,CAAC;CACtC,EACD,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAc5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,EAMjB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,YAAY,EAQb,MAAM,UAAU,CAAC;AAiIlB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,CAI1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,YAAY,GAAG,gBAAgB,CAG5E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,UAAU,EAAE,YAAY,EAAE,sBAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,gBAAgB,EAAE,EAC9B,WAAW,EAAE,SAAS,OAAO,EAAE,GAUZ,OAAO,UAAU,EAAE,kBAAkB,CACzD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,OAAO,UAAU,EAAE,kBAAkB,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,OAAO,UAAU,EAAE,kBAAkB,GAChD,SAAS,OAAO,EAAE,CAEpB;AAeD;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,UAAU,EAAE,SAAS,cAAc,EAAE,GACpC,SAAS,OAAO,EAAE,CAKpB;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,gBAAgB,EAC3B,WAAW,EAAE,SAAS,OAAO,EAAE,GAC9B,gBAAgB,CAKlB;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CACjD,UAAU,EAAE,SAAS,YAAY,EAAE,GAClC,SAAS,OAAO,EAAE,CAepB"}
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,EAMjB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,YAAY,EASb,MAAM,UAAU,CAAC;AA6JlB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,cAAc,GAAG,cAAc,CAI1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,YAAY,GAAG,gBAAgB,CAI5E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,UAAU,EAAE,YAAY,EAAE,sBAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,gBAAgB,EAAE,EAC9B,WAAW,EAAE,SAAS,OAAO,EAAE,GAUZ,OAAO,UAAU,EAAE,kBAAkB,CACzD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,OAAO,UAAU,EAAE,kBAAkB,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,OAAO,UAAU,EAAE,kBAAkB,GAChD,SAAS,OAAO,EAAE,CAEpB;AAeD;;;;;GAKG;AACH,wBAAgB,qCAAqC,CACnD,UAAU,EAAE,SAAS,cAAc,EAAE,GACpC,SAAS,OAAO,EAAE,CAKpB;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,gBAAgB,EAC3B,WAAW,EAAE,SAAS,OAAO,EAAE,GAC9B,gBAAgB,CAKlB;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CACjD,UAAU,EAAE,SAAS,YAAY,EAAE,GAClC,SAAS,OAAO,EAAE,CAepB"}
@@ -1 +1 @@
1
- {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGzD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,uBAkB3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,aAAa,eAOrD"}
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/media.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAezD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,uBAQ3D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,aAAa,eAOrD"}
@@ -41,5 +41,5 @@ export declare function normalizeStringSelect(select: StringSelect): StringSelec
41
41
  * @param select Select descriptor.
42
42
  * @returns Discord select builder.
43
43
  */
44
- export declare function normalizeSelect(select: SelectMenu): UserSelectMenuBuilder | RoleSelectMenuBuilder | MentionableSelectMenuBuilder | ChannelSelectMenuBuilder | StringSelectMenuBuilder;
44
+ export declare function normalizeSelect(select: SelectMenu): ChannelSelectMenuBuilder | UserSelectMenuBuilder | RoleSelectMenuBuilder | MentionableSelectMenuBuilder | StringSelectMenuBuilder;
45
45
  //# sourceMappingURL=select.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/select.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,YAAY,EAEb,MAAM,UAAU,CAAC;AAIlB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,yBAGrD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,yBAGrD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,gCAG5D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,4BAM3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,2BAczD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,qIAoBjD"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/normalizers/select.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,UAAU,EACV,YAAY,EAEb,MAAM,UAAU,CAAC;AAkClB;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,yBAErD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,yBAErD;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,UAAU,gCAE5D;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,4BAM3D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,YAAY,2BAOzD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,qIAoBjD"}
@@ -1,11 +1,19 @@
1
1
  import { ButtonStyle } from 'discord.js';
2
2
  /** Branded type used for component custom ids. */
3
3
  export type ButtonID = string & {};
4
- /** Public button descriptor used by `ui.button(...)`. */
5
- export type Button = {
4
+ type CommonButton = {
6
5
  label: string;
7
- customId: ButtonID;
8
6
  emoji?: string;
9
- style?: ButtonStyle;
10
7
  };
8
+ /** Public button descriptor used by `ui.button(...)`. */
9
+ export type Button = (CommonButton & {
10
+ customId: ButtonID;
11
+ style?: Exclude<ButtonStyle, ButtonStyle.Link>;
12
+ url?: never;
13
+ }) | (CommonButton & {
14
+ url: string;
15
+ style?: ButtonStyle.Link;
16
+ customId?: never;
17
+ });
18
+ export {};
11
19
  //# sourceMappingURL=button.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/types/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,EAAE,CAAC;AAEnC,yDAAyD;AACzD,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,CAAC"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/types/button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,kDAAkD;AAClD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,EAAE,CAAC;AAEnC,KAAK,YAAY,GAAG;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,yDAAyD;AACzD,MAAM,MAAM,MAAM,GACd,CAAC,YAAY,GAAG;IACd,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;IAC/C,GAAG,CAAC,EAAE,KAAK,CAAC;CACb,CAAC,GACF,CAAC,YAAY,GAAG;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC;IACzB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB,CAAC,CAAC"}