@discordjs/builders 1.3.0-dev.1662293019-8b3d006.0 → 1.3.0-dev.1663675483-5048a3d.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
@@ -539,6 +539,28 @@ declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSO
539
539
  */
540
540
  declare class SelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOption> {
541
541
  data: Partial<APISelectMenuOption>;
542
+ /**
543
+ * Creates a new select menu option from API data
544
+ *
545
+ * @param data - The API data to create this select menu option with
546
+ * @example
547
+ * Creating a select menu option from an API data object
548
+ * ```ts
549
+ * const selectMenuOption = new SelectMenuOptionBuilder({
550
+ * label: 'catchy label',
551
+ * value: '1',
552
+ * });
553
+ * ```
554
+ * @example
555
+ * Creating a select menu option using setters and API data
556
+ * ```ts
557
+ * const selectMenuOption = new SelectMenuOptionBuilder({
558
+ * default: true,
559
+ * value: '1',
560
+ * })
561
+ * .setLabel('woah')
562
+ * ```
563
+ */
542
564
  constructor(data?: Partial<APISelectMenuOption>);
543
565
  /**
544
566
  * Sets the label of this option
@@ -694,24 +716,24 @@ declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
694
716
  * Creating a button from an API data object
695
717
  * ```ts
696
718
  * const button = new ButtonBuilder({
697
- * style: 'primary',
719
+ * custom_id: 'a cool button',
720
+ * style: ButtonStyle.Primary,
698
721
  * label: 'Click Me',
699
722
  * emoji: {
700
- * name: ':smile:',
701
- * id: '12345678901234567890123456789012',
723
+ * name: 'smile',
724
+ * id: '123456789012345678',
702
725
  * },
703
- * custom_id: '12345678901234567890123456789012',
704
726
  * });
705
727
  * ```
706
728
  * @example
707
729
  * Creating a button using setters and API data
708
730
  * ```ts
709
731
  * const button = new ButtonBuilder({
710
- * style: 'primary',
732
+ * style: ButtonStyle.Secondary,
711
733
  * label: 'Click Me',
712
734
  * })
713
- * .setEmoji({ name: ':smile:', id: '12345678901234567890123456789012' })
714
- * .setCustomId('12345678901234567890123456789012');
735
+ * .setEmoji({ name: '🙂' })
736
+ * .setCustomId('another cool button');
715
737
  * ```
716
738
  */
717
739
  constructor(data?: Partial<APIButtonComponent>);
@@ -770,6 +792,37 @@ declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent>
770
792
  * The options within this select menu
771
793
  */
772
794
  readonly options: SelectMenuOptionBuilder[];
795
+ /**
796
+ * Creates a new select menu from API data
797
+ *
798
+ * @param data - The API data to create this select menu with
799
+ * @example
800
+ * Creating a select menu from an API data object
801
+ * ```ts
802
+ * const selectMenu = new SelectMenuBuilder({
803
+ * custom_id: 'a cool select menu',
804
+ * placeholder: 'select an option',
805
+ * max_values: 2,
806
+ * options: [
807
+ * { label: 'option 1', value: '1' },
808
+ * { label: 'option 2', value: '2' },
809
+ * { label: 'option 3', value: '3' },
810
+ * ],
811
+ * });
812
+ * ```
813
+ * @example
814
+ * Creating a select menu using setters and API data
815
+ * ```ts
816
+ * const selectMenu = new SelectMenuBuilder({
817
+ * custom_id: 'a cool select menu',
818
+ * })
819
+ * .setMinValues(1)
820
+ * .addOptions({
821
+ * label: 'Catchy',
822
+ * value: 'catch',
823
+ * });
824
+ * ```
825
+ */
773
826
  constructor(data?: Partial<APISelectMenuComponent>);
774
827
  /**
775
828
  * Sets the placeholder for this select menu
@@ -840,6 +893,29 @@ interface Equatable<T> {
840
893
  declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown>;
841
894
 
842
895
  declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>> {
896
+ /**
897
+ * Creates a new text input from API data
898
+ *
899
+ * @param data - The API data to create this text input with
900
+ * @example
901
+ * Creating a select menu option from an API data object
902
+ * ```ts
903
+ * const textInput = new TextInputBuilder({
904
+ * custom_id: 'a cool select menu',
905
+ * label: 'Type something',
906
+ * style: TextInputStyle.Short,
907
+ * });
908
+ * ```
909
+ * @example
910
+ * Creating a select menu option using setters and API data
911
+ * ```ts
912
+ * const textInput = new TextInputBuilder({
913
+ * label: 'Type something else',
914
+ * })
915
+ * .setCustomId('woah')
916
+ * .setStyle(TextInputStyle.Paragraph);
917
+ * ```
918
+ */
843
919
  constructor(data?: APITextInputComponent & {
844
920
  type?: ComponentType.TextInput;
845
921
  });
@@ -916,6 +992,40 @@ declare class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentB
916
992
  * The components within this action row
917
993
  */
918
994
  readonly components: T[];
995
+ /**
996
+ * Creates a new action row from API data
997
+ *
998
+ * @param data - The API data to create this action row with
999
+ * @example
1000
+ * Creating an action row from an API data object
1001
+ * ```ts
1002
+ * const actionRow = new ActionRowBuilder({
1003
+ * components: [
1004
+ * {
1005
+ * custom_id: "custom id",
1006
+ * label: "Type something",
1007
+ * style: TextInputStyle.Short,
1008
+ * type: ComponentType.TextInput,
1009
+ * },
1010
+ * ],
1011
+ * });
1012
+ * ```
1013
+ * @example
1014
+ * Creating an action row using setters and API data
1015
+ * ```ts
1016
+ * const actionRow = new ActionRowBuilder({
1017
+ * components: [
1018
+ * {
1019
+ * custom_id: "custom id",
1020
+ * label: "Click me",
1021
+ * style: ButtonStyle.Primary,
1022
+ * type: ComponentType.Button,
1023
+ * },
1024
+ * ],
1025
+ * })
1026
+ * .addComponents(button2, button3);
1027
+ * ```
1028
+ */
919
1029
  constructor({ components, ...data }?: Partial<APIActionRowComponent<APIActionRowComponentTypes>>);
920
1030
  /**
921
1031
  * Adds components to this action row.
@@ -1096,7 +1206,7 @@ declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
1096
1206
  toJSON(): APIApplicationCommandBooleanOption;
1097
1207
  }
1098
1208
 
1099
- declare const allowedChannelTypes: readonly [ChannelType.GuildText, ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildNews, ChannelType.GuildNewsThread, ChannelType.GuildPublicThread, ChannelType.GuildPrivateThread, ChannelType.GuildStageVoice];
1209
+ declare const allowedChannelTypes: readonly [ChannelType.GuildText, ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildAnnouncement, ChannelType.AnnouncementThread, ChannelType.PublicThread, ChannelType.PrivateThread, ChannelType.GuildStageVoice];
1100
1210
  declare type ApplicationCommandOptionAllowedChannelTypes = typeof allowedChannelTypes[number];
1101
1211
  declare class ApplicationCommandOptionChannelTypesMixin {
1102
1212
  readonly channel_types?: ApplicationCommandOptionAllowedChannelTypes[];
@@ -1367,14 +1477,16 @@ declare class SlashCommandBuilder {
1367
1477
  /**
1368
1478
  * Returns the final data that should be sent to Discord.
1369
1479
  *
1370
- * **Note:** Calling this function will validate required properties based on their conditions.
1480
+ * @remarks
1481
+ * This method runs validations on the data before serializing it.
1482
+ * As such, it may throw an error if the data is invalid.
1371
1483
  */
1372
1484
  toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody;
1373
1485
  /**
1374
1486
  * Sets whether the command is enabled by default when the application is added to a guild.
1375
1487
  *
1376
- * **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.
1377
- *
1488
+ * @remarks
1489
+ * If set to `false`, you will have to later `PUT` the permissions for this command.
1378
1490
  * @param value - Whether or not to enable this command by default
1379
1491
  * @see https://discord.com/developers/docs/interactions/application-commands#permissions
1380
1492
  * @deprecated Use {@link (SlashCommandBuilder:class).setDefaultMemberPermissions} or {@link (SlashCommandBuilder:class).setDMPermission} instead.
@@ -1383,8 +1495,8 @@ declare class SlashCommandBuilder {
1383
1495
  /**
1384
1496
  * Sets the default permissions a member should have in order to run the command.
1385
1497
  *
1386
- * **Note:** You can set this to `'0'` to disable the command by default.
1387
- *
1498
+ * @remarks
1499
+ * You can set this to `'0'` to disable the command by default.
1388
1500
  * @param permissions - The permissions bit field to set
1389
1501
  * @see https://discord.com/developers/docs/interactions/application-commands#permissions
1390
1502
  */
@@ -1412,7 +1524,7 @@ declare class SlashCommandBuilder {
1412
1524
  }
1413
1525
  interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
1414
1526
  }
1415
- interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup' | 'toJSON'> {
1527
+ interface SlashCommandSubcommandsOnlyBuilder extends Omit<SlashCommandBuilder, Exclude<keyof SharedSlashCommandOptions, 'options'>> {
1416
1528
  }
1417
1529
  interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {
1418
1530
  }
@@ -1504,8 +1616,8 @@ declare class ContextMenuCommandBuilder {
1504
1616
  /**
1505
1617
  * Sets whether the command is enabled by default when the application is added to a guild.
1506
1618
  *
1507
- * **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.
1508
- *
1619
+ * @remarks
1620
+ * If set to `false`, you will have to later `PUT` the permissions for this command.
1509
1621
  * @param value - Whether or not to enable this command by default
1510
1622
  * @see https://discord.com/developers/docs/interactions/application-commands#permissions
1511
1623
  * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
@@ -1514,8 +1626,8 @@ declare class ContextMenuCommandBuilder {
1514
1626
  /**
1515
1627
  * Sets the default permissions a member should have in order to run the command.
1516
1628
  *
1517
- * **Note:** You can set this to `'0'` to disable the command by default.
1518
- *
1629
+ * @remarks
1630
+ * You can set this to `'0'` to disable the command by default.
1519
1631
  * @param permissions - The permissions bit field to set
1520
1632
  * @see https://discord.com/developers/docs/interactions/application-commands#permissions
1521
1633
  */
@@ -1544,7 +1656,9 @@ declare class ContextMenuCommandBuilder {
1544
1656
  /**
1545
1657
  * Returns the final data that should be sent to Discord.
1546
1658
  *
1547
- * **Note:** Calling this function will validate required properties based on their conditions.
1659
+ * @remarks
1660
+ * This method runs validations on the data before serializing it.
1661
+ * As such, it may throw an error if the data is invalid.
1548
1662
  */
1549
1663
  toJSON(): RESTPostAPIContextMenuApplicationCommandsJSONBody;
1550
1664
  }
package/dist/index.js CHANGED
@@ -1009,10 +1009,10 @@ var allowedChannelTypes = [
1009
1009
  import_v1011.ChannelType.GuildText,
1010
1010
  import_v1011.ChannelType.GuildVoice,
1011
1011
  import_v1011.ChannelType.GuildCategory,
1012
- import_v1011.ChannelType.GuildNews,
1013
- import_v1011.ChannelType.GuildNewsThread,
1014
- import_v1011.ChannelType.GuildPublicThread,
1015
- import_v1011.ChannelType.GuildPrivateThread,
1012
+ import_v1011.ChannelType.GuildAnnouncement,
1013
+ import_v1011.ChannelType.AnnouncementThread,
1014
+ import_v1011.ChannelType.PublicThread,
1015
+ import_v1011.ChannelType.PrivateThread,
1016
1016
  import_v1011.ChannelType.GuildStageVoice
1017
1017
  ];
1018
1018
  var channelTypesPredicate = import_shapeshift6.s.array(import_shapeshift6.s.union(...allowedChannelTypes.map((type) => import_shapeshift6.s.literal(type))));