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.
@@ -43,11 +43,11 @@ export type SectionComponent = {
43
43
  /** Public container node used by `ui.container(...)`. */
44
44
  export type ContainerNode = TextComponent | SeparatorComponent | SectionComponent | Row | MediaGallery | FileComponent;
45
45
  /** Allowed container input passed to `ui.container(...)`. */
46
- export type ContainerInput = ContainerChild | ContainerNode;
46
+ export type ContainerInput = ContainerChild | ContainerNode | Button;
47
47
  /** Optional container configuration. */
48
48
  export type ContainerOptions = {
49
49
  color?: number | string;
50
50
  };
51
51
  /** Any component accepted by `ui.render(...)`. */
52
- export type DisplayInput = DisplayComponent | ContainerNode;
52
+ export type DisplayInput = DisplayComponent | ContainerNode | Button;
53
53
  //# sourceMappingURL=container.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/types/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,iEAAiE;AACjE,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,kBAAkB,GAClB,gBAAgB,GAChB,cAAc,GACd,mBAAmB,GACnB,WAAW,GACX,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;AAE1C,4DAA4D;AAC5D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;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/formatList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,SAAS,EAChB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,UASpC"}
1
+ {"version":3,"file":"formatList.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/utils/formatList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,UAI/E"}
@@ -1 +1 @@
1
- {"version":3,"file":"splitContainerArgs.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/utils/splitContainerArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAUjE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,CAAC,gBAAgB,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE;;gBAK/B,cAAc,EAAE;EAQlD"}
1
+ {"version":3,"file":"splitContainerArgs.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/utils/splitContainerArgs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAUjE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,CAAC,gBAAgB,EAAE,GAAG,cAAc,EAAE,CAAC,GAAG,cAAc,EAAE;aAM7C,gBAAgB;gBACX,cAAc,EAAE;EAQzC"}
@@ -1 +1 @@
1
- {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/validators/button.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAOvC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,QAQ5C"}
1
+ {"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/validators/button.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAYvC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,QAa5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/validators/container.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAOlB;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,QAIzE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,QAI3C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,QAItC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,QAIhD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,QAY9D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,QAIxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,UA0BnD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,QAI1D"}
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/validators/container.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,gBAAgB,EACjB,MAAM,UAAU,CAAC;AAWlB;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,gBAAgB,EAAE,QAIzE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,QAI3C;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,QAItC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,QAIhD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,QAY9D;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,QAIxD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,UA0BnD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,QAI1D"}
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/validators/select.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAO3C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,QAchD"}
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../../../src/core/ui/validators/select.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAa3C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,QAehD"}
package/dist/index.cjs CHANGED
@@ -65583,30 +65583,30 @@ function getAttachmentName(attachment) {
65583
65583
  if (!attachment || typeof attachment !== "object") {
65584
65584
  throw new Error("Attachment must be an object with a valid file name.");
65585
65585
  }
65586
- const candidate = attachment;
65587
- const name = typeof candidate.name === "string" ? candidate.name : typeof candidate.data?.name === "string" ? candidate.data.name : undefined;
65586
+ const file = attachment;
65587
+ const name = typeof file.name === "string" ? file.name : typeof file.data?.name === "string" ? file.data.name : undefined;
65588
65588
  if (!name) {
65589
65589
  throw new Error("Attachment name was not found. Define a name in AttachmentBuilder options.");
65590
65590
  }
65591
65591
  return name;
65592
65592
  }
65593
65593
  // src/core/ui/utils/formatText.ts
65594
- function wrap(content, marker) {
65594
+ function surround(content, marker) {
65595
65595
  return `${marker}${content}${marker}`;
65596
65596
  }
65597
- function getInlineCodeDelimiter(content) {
65598
- let longestRun = 0;
65599
- let currentRun = 0;
65597
+ function getCodeFence(content) {
65598
+ let maxRun = 0;
65599
+ let run = 0;
65600
65600
  for (const character of content) {
65601
65601
  if (character === "`") {
65602
- currentRun += 1;
65603
- if (currentRun > longestRun)
65604
- longestRun = currentRun;
65602
+ run += 1;
65603
+ if (run > maxRun)
65604
+ maxRun = run;
65605
65605
  continue;
65606
65606
  }
65607
- currentRun = 0;
65607
+ run = 0;
65608
65608
  }
65609
- return "`".repeat(longestRun + 1);
65609
+ return "`".repeat(maxRun + 1);
65610
65610
  }
65611
65611
  function toLines(input) {
65612
65612
  return Array.isArray(input) ? input : [input];
@@ -65616,25 +65616,25 @@ function formatLines(input, formatter) {
65616
65616
  `);
65617
65617
  }
65618
65618
  function formatText(content, options = {}) {
65619
- let formatted = toLines(content).join(`
65619
+ let out = toLines(content).join(`
65620
65620
  `);
65621
65621
  if (options.underline)
65622
- formatted = wrap(formatted, "__");
65622
+ out = surround(out, "__");
65623
65623
  if (options.italic)
65624
- formatted = wrap(formatted, "*");
65624
+ out = surround(out, "*");
65625
65625
  if (options.bold)
65626
- formatted = wrap(formatted, "**");
65626
+ out = surround(out, "**");
65627
65627
  if (typeof options.size === "number") {
65628
65628
  const prefix = options.size === 4 ? "-#" : "#".repeat(options.size);
65629
- return `${prefix} ${formatted}`;
65629
+ return `${prefix} ${out}`;
65630
65630
  }
65631
- return formatted;
65631
+ return out;
65632
65632
  }
65633
65633
  function formatInlineCode(content) {
65634
65634
  const text = toLines(content).join(`
65635
65635
  `);
65636
- const delimiter = getInlineCodeDelimiter(text);
65637
- return `${delimiter}${text}${delimiter}`;
65636
+ const fence = getCodeFence(text);
65637
+ return `${fence}${text}${fence}`;
65638
65638
  }
65639
65639
  function formatQuote(input) {
65640
65640
  return formatLines(input, (line) => `> ${line}`);
@@ -65645,38 +65645,34 @@ function formatSpoiler(input) {
65645
65645
 
65646
65646
  // src/core/ui/utils/formatList.ts
65647
65647
  function formatList(items, options = {}) {
65648
- return formatLines(items, (item, index) => {
65649
- if (options.ordered) {
65650
- return `${index + 1}. ${item}`;
65651
- }
65652
- return `- ${item}`;
65653
- });
65648
+ return formatLines(items, (item, index) => options.ordered ? `${index + 1}. ${item}` : `- ${item}`);
65654
65649
  }
65655
65650
  // src/core/ui/utils/resolveSelectBase.ts
65656
65651
  function resolveSelectBase(customIdOrOpts, opts = {}) {
65657
65652
  if (typeof customIdOrOpts === "string") {
65658
65653
  return { id: customIdOrOpts, ...opts };
65659
65654
  }
65660
- const { customId, ...selectOptions } = customIdOrOpts;
65661
- return { id: customId, ...selectOptions };
65655
+ const { customId, ...select } = customIdOrOpts;
65656
+ return { id: customId, ...select };
65662
65657
  }
65663
65658
  // src/core/ui/utils/splitContainerArgs.ts
65664
- function isContainerOptions(value) {
65659
+ function isOptions(value) {
65665
65660
  if (!value || typeof value !== "object" || Array.isArray(value)) {
65666
65661
  return false;
65667
65662
  }
65668
65663
  return "color" in value;
65669
65664
  }
65670
65665
  function splitContainerArgs(args) {
65671
- if (isContainerOptions(args[0])) {
65666
+ const head = args[0];
65667
+ if (!isOptions(head)) {
65672
65668
  return {
65673
- options: args[0],
65674
- components: args.slice(1)
65669
+ options: {},
65670
+ components: args
65675
65671
  };
65676
65672
  }
65677
65673
  return {
65678
- options: {},
65679
- components: args
65674
+ options: head,
65675
+ components: args.slice(1)
65680
65676
  };
65681
65677
  }
65682
65678
  // src/core/ui/builders/primitives.ts
@@ -65727,12 +65723,12 @@ function row(...components) {
65727
65723
  return { type: "row", components };
65728
65724
  }
65729
65725
  function buildEasyFile(url, fileOrSpoiler, spoiler = false) {
65730
- const hasFile = typeof fileOrSpoiler !== "boolean";
65726
+ const hasAttachment = typeof fileOrSpoiler !== "boolean";
65731
65727
  return {
65732
65728
  type: "file",
65733
65729
  url,
65734
- spoiler: hasFile ? spoiler : fileOrSpoiler ?? false,
65735
- attachment: hasFile ? fileOrSpoiler : undefined
65730
+ spoiler: hasAttachment ? spoiler : fileOrSpoiler ?? false,
65731
+ attachment: hasAttachment ? fileOrSpoiler : undefined
65736
65732
  };
65737
65733
  }
65738
65734
  function buildFile(url, fileOrSpoiler, spoiler = false) {
@@ -65745,65 +65741,59 @@ function fromAttachment(attachment, spoiler = false) {
65745
65741
  var file = Object.assign(buildFile, { fromAttachment });
65746
65742
 
65747
65743
  // src/core/ui/builders/select.ts
65748
- function createSelect(type, customId, opts) {
65744
+ function mkSelect(type, input, opts) {
65745
+ const select = typeof input === "string" ? resolveSelectBase(input, opts) : resolveSelectBase(input);
65749
65746
  return {
65750
65747
  type,
65751
- ...resolveSelectBase(customId, opts)
65748
+ ...select
65752
65749
  };
65753
65750
  }
65754
- function createSelectFromObject(type, customIdOrOpts) {
65755
- const { customId, ...selectOptions } = customIdOrOpts;
65756
- return {
65757
- type,
65758
- ...resolveSelectBase({ customId, ...selectOptions })
65759
- };
65760
- }
65761
- function createSimpleSelectBuilder(type) {
65762
- function build(customIdOrOpts, opts) {
65763
- return typeof customIdOrOpts === "string" ? createSelect(type, customIdOrOpts, opts) : createSelectFromObject(type, customIdOrOpts);
65751
+ function mkSimpleBuilder(type) {
65752
+ function build(input, opts) {
65753
+ return mkSelect(type, input, opts);
65764
65754
  }
65765
65755
  return build;
65766
65756
  }
65767
- var userSelect = createSimpleSelectBuilder("select.user");
65768
- var roleSelect = createSimpleSelectBuilder("select.role");
65769
- var mentionableSelect = createSimpleSelectBuilder("select.mentionable");
65770
- function user(customIdOrOpts, opts) {
65771
- return typeof customIdOrOpts === "string" ? userSelect(customIdOrOpts, opts) : userSelect(customIdOrOpts);
65757
+ var userSelect = mkSimpleBuilder("select.user");
65758
+ var roleSelect = mkSimpleBuilder("select.role");
65759
+ var mentionableSelect = mkSimpleBuilder("select.mentionable");
65760
+ function user(input, opts) {
65761
+ return userSelect(input, opts);
65772
65762
  }
65773
- function role(customIdOrOpts, opts) {
65774
- return typeof customIdOrOpts === "string" ? roleSelect(customIdOrOpts, opts) : roleSelect(customIdOrOpts);
65763
+ function role(input, opts) {
65764
+ return roleSelect(input, opts);
65775
65765
  }
65776
- function mentionable(customIdOrOpts, opts) {
65777
- return typeof customIdOrOpts === "string" ? mentionableSelect(customIdOrOpts, opts) : mentionableSelect(customIdOrOpts);
65766
+ function mentionable(input, opts) {
65767
+ return mentionableSelect(input, opts);
65778
65768
  }
65779
- function channel(customIdOrOpts, channelTypes, opts = {}) {
65780
- if (typeof customIdOrOpts !== "string") {
65781
- const { channelTypes: resolvedChannelTypes, ...select } = customIdOrOpts;
65769
+ function channel(input, channelTypes, opts = {}) {
65770
+ if (typeof input !== "string") {
65771
+ const { channelTypes: chans, ...select } = input;
65782
65772
  return {
65783
65773
  type: "select.channel",
65784
65774
  ...resolveSelectBase(select),
65785
- channelTypes: resolvedChannelTypes
65775
+ channelTypes: chans
65786
65776
  };
65787
65777
  }
65788
- const resolvedOpts = Array.isArray(channelTypes) ? opts : channelTypes;
65789
65778
  return {
65790
65779
  type: "select.channel",
65791
- ...resolveSelectBase(customIdOrOpts, resolvedOpts),
65780
+ ...resolveSelectBase(input, Array.isArray(channelTypes) ? opts : channelTypes),
65792
65781
  channelTypes: Array.isArray(channelTypes) ? channelTypes : undefined
65793
65782
  };
65794
65783
  }
65795
- function string(customIdOrOpts, options, opts = {}) {
65796
- if (typeof customIdOrOpts !== "string") {
65797
- const { options: stringOptions, ...select } = customIdOrOpts;
65784
+ function string(input, options, opts = {}) {
65785
+ if (typeof input !== "string") {
65786
+ const { options: items, ...select } = input;
65798
65787
  return {
65799
65788
  type: "select.string",
65800
65789
  ...resolveSelectBase(select),
65801
- options: stringOptions
65790
+ options: items
65802
65791
  };
65803
65792
  }
65793
+ const base = Array.isArray(options) ? opts : {};
65804
65794
  return {
65805
65795
  type: "select.string",
65806
- ...resolveSelectBase(customIdOrOpts, Array.isArray(options) ? opts : {}),
65796
+ ...resolveSelectBase(input, base),
65807
65797
  options: Array.isArray(options) ? options : []
65808
65798
  };
65809
65799
  }
@@ -65830,6 +65820,9 @@ var ATTACHMENTS = Symbol("ui.display.attachments");
65830
65820
  var RENDERED = Symbol("ui.display.rendered");
65831
65821
  var RENDERED_ATTACHMENTS = Symbol("ui.display.rendered.attachments");
65832
65822
  // src/core/ui/validators/container.ts
65823
+ function isSelectComponent(component) {
65824
+ return !("label" in component);
65825
+ }
65833
65826
  function validateComponents(components) {
65834
65827
  if (components.length > MAX_MESSAGE_COMPONENTS) {
65835
65828
  throw new Error("A message cannot contain more than 40 components.");
@@ -65854,7 +65847,7 @@ function validateRow(components) {
65854
65847
  if (components.length < 1 || components.length > MAX_ROW_COMPONENTS) {
65855
65848
  throw new Error("Action row must contain between 1 and 5 components.");
65856
65849
  }
65857
- const selectCount = components.filter((component) => !("label" in component)).length;
65850
+ const selectCount = components.filter(isSelectComponent).length;
65858
65851
  if (selectCount > 0 && components.length > 1) {
65859
65852
  throw new Error("Select menus must be alone in an action row (max width layout rule).");
65860
65853
  }
@@ -65888,37 +65881,47 @@ function validateGallery(items) {
65888
65881
  }
65889
65882
 
65890
65883
  // src/core/ui/validators/button.ts
65891
- function hasLengthBetween(value, min, max) {
65884
+ function isLink(button2) {
65885
+ return "url" in button2 && typeof button2.url === "string";
65886
+ }
65887
+ function hasLen(value, min, max) {
65892
65888
  if (!value)
65893
65889
  return false;
65894
65890
  return value.length >= min && value.length <= max;
65895
65891
  }
65896
65892
  function validateButton(button2) {
65897
- if (!hasLengthBetween(button2.label, 1, MAX_BUTTON_LABEL_LENGTH)) {
65893
+ if (!hasLen(button2.label, 1, MAX_BUTTON_LABEL_LENGTH)) {
65898
65894
  throw new Error("Button label must have between 1 and 80 characters.");
65899
65895
  }
65900
- if (!hasLengthBetween(button2.customId, 1, MAX_BUTTON_CUSTOM_ID_LENGTH)) {
65896
+ if (isLink(button2)) {
65897
+ validateUrl(button2.url);
65898
+ return;
65899
+ }
65900
+ if (!hasLen(button2.customId, 1, MAX_BUTTON_CUSTOM_ID_LENGTH)) {
65901
65901
  throw new Error("Button custom id must have between 1 and 100 characters.");
65902
65902
  }
65903
65903
  }
65904
65904
 
65905
65905
  // src/core/ui/validators/select.ts
65906
- function hasLengthBetween2(value, min, max) {
65907
- if (!value)
65906
+ function hasLen2(value, min, max) {
65907
+ if (typeof value !== "string")
65908
65908
  return false;
65909
65909
  return value.length >= min && value.length <= max;
65910
65910
  }
65911
+ function checkStringSelect(select) {
65912
+ if (select.options.length < 1 || select.options.length > MAX_STRING_SELECT_OPTIONS) {
65913
+ throw new Error("String select must contain between 1 and 25 options.");
65914
+ }
65915
+ }
65911
65916
  function validateSelect(select) {
65912
- if (!hasLengthBetween2(select.id, 1, 100)) {
65917
+ if (!hasLen2(select.id, 1, 100)) {
65913
65918
  throw new Error("Select custom id must have between 1 and 100 characters.");
65914
65919
  }
65915
- if (select.placeholder && select.placeholder.length > MAX_SELECT_PLACEHOLDER_LENGTH) {
65920
+ if (typeof select.placeholder === "string" && select.placeholder.length > MAX_SELECT_PLACEHOLDER_LENGTH) {
65916
65921
  throw new Error("Select placeholder cannot exceed 150 characters.");
65917
65922
  }
65918
65923
  if (select.type === "select.string") {
65919
- if (select.options.length < 1 || select.options.length > MAX_STRING_SELECT_OPTIONS) {
65920
- throw new Error("String select must contain between 1 and 25 options.");
65921
- }
65924
+ checkStringSelect(select);
65922
65925
  }
65923
65926
  }
65924
65927
 
@@ -65938,16 +65941,29 @@ var validate = {
65938
65941
 
65939
65942
  // src/core/ui/normalizers/button.ts
65940
65943
  var import_discord10 = __toESM(require_src(), 1);
65944
+ function isLink2(button2) {
65945
+ return "url" in button2 && typeof button2.url === "string";
65946
+ }
65941
65947
  function normalizeButton(button2) {
65942
65948
  validateButton(button2);
65943
- const built = new import_discord10.ButtonBuilder().setLabel(button2.label).setCustomId(button2.customId).setStyle(button2.style ?? import_discord10.ButtonStyle.Primary);
65949
+ const btn = new import_discord10.ButtonBuilder().setLabel(button2.label);
65950
+ if (isLink2(button2)) {
65951
+ btn.setURL(button2.url).setStyle(button2.style ?? import_discord10.ButtonStyle.Link);
65952
+ } else {
65953
+ btn.setCustomId(button2.customId).setStyle(button2.style ?? import_discord10.ButtonStyle.Primary);
65954
+ }
65944
65955
  if (button2.emoji) {
65945
- built.setEmoji({ name: button2.emoji });
65956
+ btn.setEmoji({ name: button2.emoji });
65946
65957
  }
65947
- return built;
65958
+ return btn;
65948
65959
  }
65949
65960
  function applyButtonData(button2, data) {
65950
- button2.setLabel(data.label).setCustomId(data.customId).setStyle(data.style ?? import_discord10.ButtonStyle.Primary);
65961
+ button2.setLabel(data.label);
65962
+ if (isLink2(data)) {
65963
+ button2.setURL(data.url).setStyle(data.style ?? import_discord10.ButtonStyle.Link);
65964
+ } else {
65965
+ button2.setCustomId(data.customId).setStyle(data.style ?? import_discord10.ButtonStyle.Primary);
65966
+ }
65951
65967
  if (data.emoji) {
65952
65968
  button2.setEmoji({ name: data.emoji });
65953
65969
  }
@@ -65958,10 +65974,8 @@ var import_discord13 = __toESM(require_src(), 1);
65958
65974
 
65959
65975
  // src/core/ui/normalizers/media.ts
65960
65976
  var import_discord11 = __toESM(require_src(), 1);
65961
- function normalizeGallery(items) {
65962
- validateGallery(items);
65963
- const gallery2 = new import_discord11.MediaGalleryBuilder;
65964
- gallery2.addItems(...items.map((item) => (media) => {
65977
+ function toMediaItem(item) {
65978
+ return (media) => {
65965
65979
  validateUrl(item.url);
65966
65980
  media.setURL(item.url);
65967
65981
  if (item.description)
@@ -65969,7 +65983,12 @@ function normalizeGallery(items) {
65969
65983
  if (item.spoiler)
65970
65984
  media.setSpoiler(item.spoiler);
65971
65985
  return media;
65972
- }));
65986
+ };
65987
+ }
65988
+ function normalizeGallery(items) {
65989
+ validateGallery(items);
65990
+ const gallery2 = new import_discord11.MediaGalleryBuilder;
65991
+ gallery2.addItems(...items.map(toMediaItem));
65973
65992
  return gallery2;
65974
65993
  }
65975
65994
  function normalizeFile(fileInput) {
@@ -65982,34 +66001,40 @@ function normalizeFile(fileInput) {
65982
66001
 
65983
66002
  // src/core/ui/normalizers/select.ts
65984
66003
  var import_discord12 = __toESM(require_src(), 1);
66004
+ function baseSelect(type, select, builder) {
66005
+ validateSelect({ type, ...select });
66006
+ return applySelectBase(builder, select);
66007
+ }
66008
+ function withChannelTypes(builder, channelTypes) {
66009
+ if (channelTypes?.length)
66010
+ builder.setChannelTypes(...channelTypes);
66011
+ return builder;
66012
+ }
66013
+ function toStringOptions(select) {
66014
+ return select.options.map((option) => ({
66015
+ label: option.label,
66016
+ value: option.value,
66017
+ description: option.description,
66018
+ default: option.default
66019
+ }));
66020
+ }
65985
66021
  function normalizeUserSelect(select) {
65986
- validateSelect({ type: "select.user", ...select });
65987
- return applySelectBase(new import_discord12.UserSelectMenuBuilder, select);
66022
+ return baseSelect("select.user", select, new import_discord12.UserSelectMenuBuilder);
65988
66023
  }
65989
66024
  function normalizeRoleSelect(select) {
65990
- validateSelect({ type: "select.role", ...select });
65991
- return applySelectBase(new import_discord12.RoleSelectMenuBuilder, select);
66025
+ return baseSelect("select.role", select, new import_discord12.RoleSelectMenuBuilder);
65992
66026
  }
65993
66027
  function normalizeMentionableSelect(select) {
65994
- validateSelect({ type: "select.mentionable", ...select });
65995
- return applySelectBase(new import_discord12.MentionableSelectMenuBuilder, select);
66028
+ return baseSelect("select.mentionable", select, new import_discord12.MentionableSelectMenuBuilder);
65996
66029
  }
65997
66030
  function normalizeChannelSelect(select) {
65998
66031
  validateSelect(select);
65999
- const builder = applySelectBase(new import_discord12.ChannelSelectMenuBuilder, select);
66000
- if (select.channelTypes?.length)
66001
- builder.setChannelTypes(...select.channelTypes);
66002
- return builder;
66032
+ return applySelectBase(withChannelTypes(new import_discord12.ChannelSelectMenuBuilder, select.channelTypes), select);
66003
66033
  }
66004
66034
  function normalizeStringSelect(select) {
66005
66035
  validateSelect(select);
66006
66036
  const builder = applySelectBase(new import_discord12.StringSelectMenuBuilder, select);
66007
- builder.setOptions(...select.options.map((option) => ({
66008
- label: option.label,
66009
- value: option.value,
66010
- description: option.description,
66011
- default: option.default
66012
- })));
66037
+ builder.setOptions(...toStringOptions(select));
66013
66038
  return builder;
66014
66039
  }
66015
66040
  function normalizeSelect(select) {
@@ -66030,14 +66055,24 @@ function normalizeSelect(select) {
66030
66055
  }
66031
66056
 
66032
66057
  // src/core/ui/normalizers/container.ts
66033
- function isContainerChild(component) {
66058
+ function isChild(component) {
66034
66059
  return component instanceof import_discord13.TextDisplayBuilder || component instanceof import_discord13.SeparatorBuilder || component instanceof import_discord13.SectionBuilder || component instanceof import_discord13.MediaGalleryBuilder || component instanceof import_discord13.FileBuilder || component instanceof import_discord13.ActionRowBuilder;
66035
66060
  }
66036
- function isDisplayComponent(component) {
66037
- return component instanceof import_discord13.ContainerBuilder || isContainerChild(component);
66061
+ function isDisplay(component) {
66062
+ return component instanceof import_discord13.ContainerBuilder || isChild(component);
66063
+ }
66064
+ function isObject2(value) {
66065
+ return !!value && typeof value === "object" && !Array.isArray(value);
66066
+ }
66067
+ function isButton(component) {
66068
+ if (!isObject2(component)) {
66069
+ return false;
66070
+ }
66071
+ const candidate = component;
66072
+ return typeof candidate.label === "string" && (("customId" in candidate) || ("url" in candidate));
66038
66073
  }
66039
- function isContainerNode(component) {
66040
- return !isContainerChild(component);
66074
+ function toRow(component) {
66075
+ return new import_discord13.ActionRowBuilder().addComponents(normalizeButton(component));
66041
66076
  }
66042
66077
  function normalizeRowComponent(component) {
66043
66078
  return "label" in component ? normalizeButton(component) : normalizeSelect(component);
@@ -66056,6 +66091,20 @@ function normalizeSeparator(component) {
66056
66091
  }
66057
66092
  return separator2;
66058
66093
  }
66094
+ function setSectionButton(section, button2) {
66095
+ section.setButtonAccessory((target) => applyButtonData(target, button2));
66096
+ }
66097
+ function setSectionThumb(section, thumbnail2) {
66098
+ validateUrl(thumbnail2.url);
66099
+ section.setThumbnailAccessory((target) => {
66100
+ target.setURL(thumbnail2.url);
66101
+ if (thumbnail2.description)
66102
+ target.setDescription(thumbnail2.description);
66103
+ if (thumbnail2.spoiler)
66104
+ target.setSpoiler(thumbnail2.spoiler);
66105
+ return target;
66106
+ });
66107
+ }
66059
66108
  function normalizeSection(component) {
66060
66109
  validateSection(component);
66061
66110
  const section = new import_discord13.SectionBuilder;
@@ -66064,19 +66113,10 @@ function normalizeSection(component) {
66064
66113
  return (text2) => text2.setContent(content);
66065
66114
  }));
66066
66115
  if (component.button) {
66067
- section.setButtonAccessory((button2) => applyButtonData(button2, component.button));
66116
+ setSectionButton(section, component.button);
66068
66117
  }
66069
66118
  if (component.thumbnail) {
66070
- const thumbnail2 = component.thumbnail;
66071
- validateUrl(thumbnail2.url);
66072
- section.setThumbnailAccessory((thumb) => {
66073
- thumb.setURL(thumbnail2.url);
66074
- if (thumbnail2.description)
66075
- thumb.setDescription(thumbnail2.description);
66076
- if (thumbnail2.spoiler)
66077
- thumb.setSpoiler(thumbnail2.spoiler);
66078
- return thumb;
66079
- });
66119
+ setSectionThumb(section, component.thumbnail);
66080
66120
  }
66081
66121
  return section;
66082
66122
  }
@@ -66084,7 +66124,7 @@ function normalizeRow(component) {
66084
66124
  validateRow(component.components);
66085
66125
  return new import_discord13.ActionRowBuilder().addComponents(...component.components.map(normalizeRowComponent));
66086
66126
  }
66087
- function normalizeContainerNode(component) {
66127
+ function normalizeNode(component) {
66088
66128
  switch (component.type) {
66089
66129
  case "text":
66090
66130
  return normalizeText(component);
@@ -66103,16 +66143,18 @@ function normalizeContainerNode(component) {
66103
66143
  }
66104
66144
  }
66105
66145
  function toContainerChild(component) {
66106
- if (isContainerChild(component))
66146
+ if (isChild(component))
66107
66147
  return component;
66108
- if (isContainerNode(component))
66109
- return normalizeContainerNode(component);
66110
- return component;
66148
+ if (isButton(component))
66149
+ return toRow(component);
66150
+ return normalizeNode(component);
66111
66151
  }
66112
66152
  function toDisplayComponent(component) {
66113
- if (isDisplayComponent(component))
66153
+ if (isDisplay(component))
66114
66154
  return component;
66115
- return normalizeContainerNode(component);
66155
+ if (isButton(component))
66156
+ return toRow(component);
66157
+ return normalizeNode(component);
66116
66158
  }
66117
66159
  function toDisplayComponents(...components) {
66118
66160
  return components.map(toDisplayComponent);
@@ -66132,7 +66174,7 @@ function getRenderedComponentsAttachments(components) {
66132
66174
  return components[RENDERED_ATTACHMENTS] ?? [];
66133
66175
  }
66134
66176
  function isEasyFileInput(component) {
66135
- if (!component || typeof component !== "object" || Array.isArray(component)) {
66177
+ if (!isObject2(component)) {
66136
66178
  return false;
66137
66179
  }
66138
66180
  const candidate = component;
@@ -66169,20 +66211,17 @@ function section(texts, opts = {}) {
66169
66211
  }
66170
66212
  function container(...args) {
66171
66213
  const { options, components } = splitContainerArgs(args);
66172
- const container2 = new import_discord14.ContainerBuilder;
66173
- container2.components.push(...components.map(toContainerChild));
66214
+ const out = new import_discord14.ContainerBuilder;
66215
+ out.components.push(...components.map(toContainerChild));
66174
66216
  if (options.color !== undefined) {
66175
- const accentColor = validate.color(options.color);
66176
- container2.setAccentColor(accentColor);
66217
+ out.setAccentColor(validate.color(options.color));
66177
66218
  }
66178
- const attachments = collectAttachmentsFromContainerInputs(components);
66179
- return attachContainerAttachments(container2, attachments);
66219
+ return attachContainerAttachments(out, collectAttachmentsFromContainerInputs(components));
66180
66220
  }
66181
66221
  function render(...components) {
66182
- const rendered = toDisplayComponents(...components);
66183
- validate.components(rendered);
66184
- const files = collectAttachmentsFromDisplayInputs(components);
66185
- return createRenderedComponents(rendered, files);
66222
+ const out = toDisplayComponents(...components);
66223
+ validate.components(out);
66224
+ return createRenderedComponents(out, collectAttachmentsFromDisplayInputs(components));
66186
66225
  }
66187
66226
  function send(interaction, payload) {
66188
66227
  if (!isRenderedComponents(payload.components)) {
@@ -66190,8 +66229,10 @@ function send(interaction, payload) {
66190
66229
  }
66191
66230
  validate.components(payload.components);
66192
66231
  const flags = payload.ephemeral ? [import_discord14.MessageFlags.IsComponentsV2, import_discord14.MessageFlags.Ephemeral] : [import_discord14.MessageFlags.IsComponentsV2];
66193
- const autoFiles = getRenderedComponentsAttachments(payload.components);
66194
- const files = [...autoFiles, ...payload.files ?? []];
66232
+ const files = [
66233
+ ...getRenderedComponentsAttachments(payload.components),
66234
+ ...payload.files ?? []
66235
+ ];
66195
66236
  return interaction.reply({
66196
66237
  flags,
66197
66238
  components: payload.components,