@discordjs/builders 1.3.0-dev.1664583462-3c231ae.0 → 1.3.0-dev.1664756095-b2ec865.0

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.ts CHANGED
@@ -2,6 +2,8 @@ import * as _sapphire_shapeshift from '@sapphire/shapeshift';
2
2
  import { APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, APIEmbed, APISelectMenuOption, APIMessageComponentEmoji, ButtonStyle, APIActionRowComponent, APIActionRowComponentTypes, APIBaseComponent, ComponentType, APIButtonComponent, APISelectMenuComponent, APITextInputComponent, TextInputStyle, APIMessageActionRowComponent, APIModalActionRowComponent, APIModalComponent, APIMessageComponent, APIModalInteractionResponseCallbackData, LocalizationMap, LocaleString, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandAttachmentOption, APIApplicationCommandBooleanOption, ChannelType, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, Permissions, RESTPostAPIChatInputApplicationCommandsJSONBody, APIApplicationCommandOption, Locale, RESTPostAPIContextMenuApplicationCommandsJSONBody, ApplicationCommandType } from 'discord-api-types/v10';
3
3
  import { URL } from 'node:url';
4
4
  import { Snowflake } from 'discord-api-types/globals';
5
+ import { JSONEncodable, Equatable } from '@discordjs/util';
6
+ export * from '@discordjs/util';
5
7
 
6
8
  declare const fieldNamePredicate: _sapphire_shapeshift.StringValidator<string>;
7
9
  declare const fieldValuePredicate: _sapphire_shapeshift.StringValidator<string>;
@@ -516,24 +518,6 @@ declare enum Faces {
516
518
  Unflip = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"
517
519
  }
518
520
 
519
- /**
520
- * Represents an object capable of representing itself as a JSON object
521
- *
522
- * @typeParam T - The JSON type corresponding to {@link JSONEncodable.toJSON} outputs.
523
- */
524
- interface JSONEncodable<T> {
525
- /**
526
- * Transforms this object to its JSON format
527
- */
528
- toJSON(): T;
529
- }
530
- /**
531
- * Indicates if an object is encodable or not.
532
- *
533
- * @param maybeEncodable - The object to check against
534
- */
535
- declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown>;
536
-
537
521
  /**
538
522
  * Represents a option within a select menu component
539
523
  */
@@ -873,25 +857,6 @@ declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent>
873
857
  toJSON(): APISelectMenuComponent;
874
858
  }
875
859
 
876
- /**
877
- * Represents a structure that can be checked against another
878
- * given structure for equality
879
- *
880
- * @typeParam T - The type of object to compare the current object to
881
- */
882
- interface Equatable<T> {
883
- /**
884
- * Whether or not this is equal to another structure
885
- */
886
- equals(other: T): boolean;
887
- }
888
- /**
889
- * Indicates if an object is equatable or not.
890
- *
891
- * @param maybeEquatable - The object to check against
892
- */
893
- declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown>;
894
-
895
860
  declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>> {
896
861
  /**
897
862
  * Creates a new text input from API data
@@ -1694,4 +1659,4 @@ declare const enableValidators: () => boolean;
1694
1659
  declare const disableValidators: () => boolean;
1695
1660
  declare const isValidationEnabled: () => boolean;
1696
1661
 
1697
- export { ActionRowBuilder, AnyAPIActionRowComponent, AnyComponentBuilder, ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionBase, ApplicationCommandOptionChannelTypesMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin, ButtonBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, Equatable, Faces, IconData, JSONEncodable, MappedComponentTypes, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, RestOrArray, SelectMenuBuilder, SelectMenuOptionBuilder, SharedNameAndDescription, SharedSlashCommandOptions, Assertions$1 as SlashCommandAssertions, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, Assertions$3 as TextInputAssertions, TextInputBuilder, TimestampStyles, TimestampStylesString, ToAPIApplicationCommandOptions, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, createComponentBuilder, disableValidators, embedLength, enableValidators, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, isEquatable, isJSONEncodable, isValidationEnabled, italic, messageLink, normalizeArray, quote, roleMention, spoiler, strikethrough, time, underscore, userMention };
1662
+ export { ActionRowBuilder, AnyAPIActionRowComponent, AnyComponentBuilder, ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionBase, ApplicationCommandOptionChannelTypesMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin, ButtonBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, Faces, IconData, MappedComponentTypes, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, RestOrArray, SelectMenuBuilder, SelectMenuOptionBuilder, SharedNameAndDescription, SharedSlashCommandOptions, Assertions$1 as SlashCommandAssertions, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, Assertions$3 as TextInputAssertions, TextInputBuilder, TimestampStyles, TimestampStylesString, ToAPIApplicationCommandOptions, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, createComponentBuilder, disableValidators, embedLength, enableValidators, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, isValidationEnabled, italic, messageLink, normalizeArray, quote, roleMention, spoiler, strikethrough, time, underscore, userMention };
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  }
19
19
  return to;
20
20
  };
21
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
21
22
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
23
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
24
  mod
@@ -85,8 +86,6 @@ __export(src_exports, {
85
86
  hideLinkEmbed: () => hideLinkEmbed,
86
87
  hyperlink: () => hyperlink,
87
88
  inlineCode: () => inlineCode,
88
- isEquatable: () => isEquatable,
89
- isJSONEncodable: () => isJSONEncodable,
90
89
  isValidationEnabled: () => isValidationEnabled,
91
90
  italic: () => italic,
92
91
  messageLink: () => messageLink,
@@ -612,15 +611,10 @@ var SelectMenuBuilder = class extends ComponentBuilder {
612
611
  __name(SelectMenuBuilder, "SelectMenuBuilder");
613
612
 
614
613
  // src/components/textInput/TextInput.ts
614
+ var import_util = require("@discordjs/util");
615
615
  var import_v105 = require("discord-api-types/v10");
616
616
  var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
617
617
 
618
- // src/util/jsonEncodable.ts
619
- function isJSONEncodable(maybeEncodable) {
620
- return maybeEncodable !== null && typeof maybeEncodable === "object" && "toJSON" in maybeEncodable;
621
- }
622
- __name(isJSONEncodable, "isJSONEncodable");
623
-
624
618
  // src/components/textInput/Assertions.ts
625
619
  var Assertions_exports3 = {};
626
620
  __export(Assertions_exports3, {
@@ -693,7 +687,7 @@ var TextInputBuilder = class extends ComponentBuilder {
693
687
  };
694
688
  }
695
689
  equals(other) {
696
- if (isJSONEncodable(other)) {
690
+ if ((0, import_util.isJSONEncodable)(other)) {
697
691
  return (0, import_fast_deep_equal.default)(other.toJSON(), this.data);
698
692
  }
699
693
  return (0, import_fast_deep_equal.default)(other, this.data);
@@ -1489,17 +1483,14 @@ var ContextMenuCommandBuilder = class {
1489
1483
  };
1490
1484
  __name(ContextMenuCommandBuilder, "ContextMenuCommandBuilder");
1491
1485
 
1492
- // src/util/equatable.ts
1493
- function isEquatable(maybeEquatable) {
1494
- return maybeEquatable !== null && typeof maybeEquatable === "object" && "equals" in maybeEquatable;
1495
- }
1496
- __name(isEquatable, "isEquatable");
1497
-
1498
1486
  // src/util/componentUtil.ts
1499
1487
  function embedLength(data) {
1500
1488
  return (data.title?.length ?? 0) + (data.description?.length ?? 0) + (data.fields?.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) ?? 0) + (data.footer?.text.length ?? 0) + (data.author?.name.length ?? 0);
1501
1489
  }
1502
1490
  __name(embedLength, "embedLength");
1491
+
1492
+ // src/index.ts
1493
+ __reExport(src_exports, require("@discordjs/util"), module.exports);
1503
1494
  // Annotate the CommonJS export names for ESM import in node:
1504
1495
  0 && (module.exports = {
1505
1496
  ActionRowBuilder,
@@ -1551,8 +1542,6 @@ __name(embedLength, "embedLength");
1551
1542
  hideLinkEmbed,
1552
1543
  hyperlink,
1553
1544
  inlineCode,
1554
- isEquatable,
1555
- isJSONEncodable,
1556
1545
  isValidationEnabled,
1557
1546
  italic,
1558
1547
  messageLink,