@discordjs/builders 0.13.0-dev.1649937819-b01f414 → 0.13.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.mjs CHANGED
@@ -308,8 +308,8 @@ __export(Assertions_exports2, {
308
308
  validateRequiredSelectMenuOptionParameters: () => validateRequiredSelectMenuOptionParameters,
309
309
  validateRequiredSelectMenuParameters: () => validateRequiredSelectMenuParameters
310
310
  });
311
- import { ButtonStyle } from "discord-api-types/v10";
312
311
  import { s as s2 } from "@sapphire/shapeshift";
312
+ import { ButtonStyle } from "discord-api-types/v10";
313
313
 
314
314
  // src/components/selectMenu/UnsafeSelectMenuOption.ts
315
315
  var UnsafeSelectMenuOptionBuilder = class {
@@ -435,10 +435,7 @@ __name(createComponentBuilder, "createComponentBuilder");
435
435
 
436
436
  // src/components/ActionRow.ts
437
437
  var ActionRowBuilder = class extends ComponentBuilder {
438
- constructor({
439
- components,
440
- ...data
441
- } = {}) {
438
+ constructor({ components, ...data } = {}) {
442
439
  super({ type: ComponentType2.ActionRow, ...data });
443
440
  __publicField(this, "components");
444
441
  this.components = components?.map((c) => createComponentBuilder(c)) ?? [];
@@ -539,8 +536,8 @@ __export(Assertions_exports3, {
539
536
  validateRequiredParameters: () => validateRequiredParameters,
540
537
  valueValidator: () => valueValidator
541
538
  });
542
- import { TextInputStyle } from "discord-api-types/v10";
543
539
  import { s as s3 } from "@sapphire/shapeshift";
540
+ import { TextInputStyle } from "discord-api-types/v10";
544
541
  var textInputStyleValidator = s3.nativeEnum(TextInputStyle);
545
542
  var minLengthValidator = s3.number.int.ge(0).le(4e3);
546
543
  var maxLengthValidator = s3.number.int.ge(1).le(4e3);
@@ -802,24 +799,31 @@ __export(Assertions_exports5, {
802
799
  validateChoicesLength: () => validateChoicesLength,
803
800
  validateDefaultPermission: () => validateDefaultPermission,
804
801
  validateDescription: () => validateDescription,
802
+ validateLocale: () => validateLocale,
805
803
  validateMaxOptionsLength: () => validateMaxOptionsLength,
806
804
  validateName: () => validateName,
807
805
  validateRequired: () => validateRequired,
808
806
  validateRequiredParameters: () => validateRequiredParameters3
809
807
  });
810
- import is from "@sindresorhus/is";
811
808
  import { s as s5 } from "@sapphire/shapeshift";
809
+ import is from "@sindresorhus/is";
810
+ import { Locale } from "discord-api-types/v10";
812
811
  var namePredicate = s5.string.lengthGe(1).lengthLe(32).regex(/^[\P{Lu}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u);
813
812
  function validateName(name) {
814
813
  namePredicate.parse(name);
815
814
  }
816
815
  __name(validateName, "validateName");
817
816
  var descriptionPredicate2 = s5.string.lengthGe(1).lengthLe(100);
817
+ var localePredicate = s5.nativeEnum(Locale);
818
818
  function validateDescription(description) {
819
819
  descriptionPredicate2.parse(description);
820
820
  }
821
821
  __name(validateDescription, "validateDescription");
822
822
  var maxArrayLengthPredicate = s5.unknown.array.lengthLe(25);
823
+ function validateLocale(locale) {
824
+ return localePredicate.parse(locale);
825
+ }
826
+ __name(validateLocale, "validateLocale");
823
827
  function validateMaxOptionsLength(options) {
824
828
  maxArrayLengthPredicate.parse(options);
825
829
  }
@@ -865,14 +869,19 @@ __name(assertReturnOfBuilder, "assertReturnOfBuilder");
865
869
  // src/interactions/slashCommands/SlashCommandBuilder.ts
866
870
  import { mix as mix6 } from "ts-mixer";
867
871
 
868
- // src/interactions/slashCommands/options/boolean.ts
869
- import { ApplicationCommandOptionType } from "discord-api-types/v10";
872
+ // src/interactions/slashCommands/SlashCommandSubcommands.ts
873
+ import {
874
+ ApplicationCommandOptionType as ApplicationCommandOptionType11
875
+ } from "discord-api-types/v10";
876
+ import { mix as mix5 } from "ts-mixer";
870
877
 
871
878
  // src/interactions/slashCommands/mixins/NameAndDescription.ts
872
879
  var SharedNameAndDescription = class {
873
880
  constructor() {
874
881
  __publicField(this, "name");
882
+ __publicField(this, "name_localizations");
875
883
  __publicField(this, "description");
884
+ __publicField(this, "description_localizations");
876
885
  }
877
886
  setName(name) {
878
887
  validateName(name);
@@ -884,9 +893,54 @@ var SharedNameAndDescription = class {
884
893
  Reflect.set(this, "description", description);
885
894
  return this;
886
895
  }
896
+ setNameLocalization(locale, localizedName) {
897
+ if (!this.name_localizations) {
898
+ Reflect.set(this, "name_localizations", {});
899
+ }
900
+ if (localizedName === null) {
901
+ this.name_localizations[locale] = null;
902
+ return this;
903
+ }
904
+ validateName(localizedName);
905
+ this.name_localizations[validateLocale(locale)] = localizedName;
906
+ return this;
907
+ }
908
+ setNameLocalizations(localizedNames) {
909
+ if (localizedNames === null) {
910
+ Reflect.set(this, "name_localizations", null);
911
+ return this;
912
+ }
913
+ Reflect.set(this, "name_localizations", {});
914
+ Object.entries(localizedNames).forEach((args) => this.setNameLocalization(...args));
915
+ return this;
916
+ }
917
+ setDescriptionLocalization(locale, localizedDescription) {
918
+ if (!this.description_localizations) {
919
+ Reflect.set(this, "description_localizations", {});
920
+ }
921
+ if (localizedDescription === null) {
922
+ this.description_localizations[locale] = null;
923
+ return this;
924
+ }
925
+ validateDescription(localizedDescription);
926
+ this.description_localizations[validateLocale(locale)] = localizedDescription;
927
+ return this;
928
+ }
929
+ setDescriptionLocalizations(localizedDescriptions) {
930
+ if (localizedDescriptions === null) {
931
+ Reflect.set(this, "description_localizations", null);
932
+ return this;
933
+ }
934
+ Reflect.set(this, "description_localizations", {});
935
+ Object.entries(localizedDescriptions).forEach((args) => this.setDescriptionLocalization(...args));
936
+ return this;
937
+ }
887
938
  };
888
939
  __name(SharedNameAndDescription, "SharedNameAndDescription");
889
940
 
941
+ // src/interactions/slashCommands/options/attachment.ts
942
+ import { ApplicationCommandOptionType } from "discord-api-types/v10";
943
+
890
944
  // src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
891
945
  var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
892
946
  constructor() {
@@ -905,11 +959,25 @@ var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
905
959
  };
906
960
  __name(ApplicationCommandOptionBase, "ApplicationCommandOptionBase");
907
961
 
962
+ // src/interactions/slashCommands/options/attachment.ts
963
+ var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
964
+ constructor() {
965
+ super(...arguments);
966
+ __publicField(this, "type", ApplicationCommandOptionType.Attachment);
967
+ }
968
+ toJSON() {
969
+ this.runRequiredValidations();
970
+ return { ...this };
971
+ }
972
+ };
973
+ __name(SlashCommandAttachmentOption, "SlashCommandAttachmentOption");
974
+
908
975
  // src/interactions/slashCommands/options/boolean.ts
976
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType2 } from "discord-api-types/v10";
909
977
  var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
910
978
  constructor() {
911
979
  super(...arguments);
912
- __publicField(this, "type", ApplicationCommandOptionType.Boolean);
980
+ __publicField(this, "type", ApplicationCommandOptionType2.Boolean);
913
981
  }
914
982
  toJSON() {
915
983
  this.runRequiredValidations();
@@ -919,12 +987,12 @@ var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
919
987
  __name(SlashCommandBooleanOption, "SlashCommandBooleanOption");
920
988
 
921
989
  // src/interactions/slashCommands/options/channel.ts
922
- import { ApplicationCommandOptionType as ApplicationCommandOptionType2 } from "discord-api-types/v10";
990
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "discord-api-types/v10";
923
991
  import { mix } from "ts-mixer";
924
992
 
925
993
  // src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
926
- import { ChannelType } from "discord-api-types/v10";
927
994
  import { s as s6 } from "@sapphire/shapeshift";
995
+ import { ChannelType } from "discord-api-types/v10";
928
996
  var allowedChannelTypes = [
929
997
  ChannelType.GuildText,
930
998
  ChannelType.GuildVoice,
@@ -954,7 +1022,7 @@ __name(ApplicationCommandOptionChannelTypesMixin, "ApplicationCommandOptionChann
954
1022
  var SlashCommandChannelOption = class extends ApplicationCommandOptionBase {
955
1023
  constructor() {
956
1024
  super(...arguments);
957
- __publicField(this, "type", ApplicationCommandOptionType2.Channel);
1025
+ __publicField(this, "type", ApplicationCommandOptionType3.Channel);
958
1026
  }
959
1027
  toJSON() {
960
1028
  this.runRequiredValidations();
@@ -967,9 +1035,9 @@ SlashCommandChannelOption = __decorateClass([
967
1035
  ], SlashCommandChannelOption);
968
1036
 
969
1037
  // src/interactions/slashCommands/options/integer.ts
970
- import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
971
- import { mix as mix2 } from "ts-mixer";
972
1038
  import { s as s8 } from "@sapphire/shapeshift";
1039
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType5 } from "discord-api-types/v10";
1040
+ import { mix as mix2 } from "ts-mixer";
973
1041
 
974
1042
  // src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
975
1043
  var ApplicationCommandNumericOptionMinMaxValueMixin = class {
@@ -981,8 +1049,8 @@ var ApplicationCommandNumericOptionMinMaxValueMixin = class {
981
1049
  __name(ApplicationCommandNumericOptionMinMaxValueMixin, "ApplicationCommandNumericOptionMinMaxValueMixin");
982
1050
 
983
1051
  // src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
984
- import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "discord-api-types/v10";
985
1052
  import { s as s7 } from "@sapphire/shapeshift";
1053
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
986
1054
  var stringPredicate = s7.string.lengthGe(1).lengthLe(100);
987
1055
  var numberPredicate = s7.number.gt(-Infinity).lt(Infinity);
988
1056
  var choicesPredicate = s7.object({ name: stringPredicate, value: s7.union(stringPredicate, numberPredicate) }).array;
@@ -1003,7 +1071,7 @@ var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
1003
1071
  }
1004
1072
  validateChoicesLength(choices.length, this.choices);
1005
1073
  for (const { name, value } of choices) {
1006
- if (this.type === ApplicationCommandOptionType3.String) {
1074
+ if (this.type === ApplicationCommandOptionType4.String) {
1007
1075
  stringPredicate.parse(value);
1008
1076
  } else {
1009
1077
  numberPredicate.parse(value);
@@ -1037,7 +1105,7 @@ var numberValidator = s8.number.int;
1037
1105
  var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
1038
1106
  constructor() {
1039
1107
  super(...arguments);
1040
- __publicField(this, "type", ApplicationCommandOptionType4.Integer);
1108
+ __publicField(this, "type", ApplicationCommandOptionType5.Integer);
1041
1109
  }
1042
1110
  setMaxValue(max) {
1043
1111
  numberValidator.parse(max);
@@ -1063,11 +1131,11 @@ SlashCommandIntegerOption = __decorateClass([
1063
1131
  ], SlashCommandIntegerOption);
1064
1132
 
1065
1133
  // src/interactions/slashCommands/options/mentionable.ts
1066
- import { ApplicationCommandOptionType as ApplicationCommandOptionType5 } from "discord-api-types/v10";
1134
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType6 } from "discord-api-types/v10";
1067
1135
  var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
1068
1136
  constructor() {
1069
1137
  super(...arguments);
1070
- __publicField(this, "type", ApplicationCommandOptionType5.Mentionable);
1138
+ __publicField(this, "type", ApplicationCommandOptionType6.Mentionable);
1071
1139
  }
1072
1140
  toJSON() {
1073
1141
  this.runRequiredValidations();
@@ -1077,14 +1145,14 @@ var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
1077
1145
  __name(SlashCommandMentionableOption, "SlashCommandMentionableOption");
1078
1146
 
1079
1147
  // src/interactions/slashCommands/options/number.ts
1080
- import { ApplicationCommandOptionType as ApplicationCommandOptionType6 } from "discord-api-types/v10";
1081
- import { mix as mix3 } from "ts-mixer";
1082
1148
  import { s as s9 } from "@sapphire/shapeshift";
1149
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType7 } from "discord-api-types/v10";
1150
+ import { mix as mix3 } from "ts-mixer";
1083
1151
  var numberValidator2 = s9.number;
1084
1152
  var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
1085
1153
  constructor() {
1086
1154
  super(...arguments);
1087
- __publicField(this, "type", ApplicationCommandOptionType6.Number);
1155
+ __publicField(this, "type", ApplicationCommandOptionType7.Number);
1088
1156
  }
1089
1157
  setMaxValue(max) {
1090
1158
  numberValidator2.parse(max);
@@ -1110,11 +1178,11 @@ SlashCommandNumberOption = __decorateClass([
1110
1178
  ], SlashCommandNumberOption);
1111
1179
 
1112
1180
  // src/interactions/slashCommands/options/role.ts
1113
- import { ApplicationCommandOptionType as ApplicationCommandOptionType7 } from "discord-api-types/v10";
1181
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType8 } from "discord-api-types/v10";
1114
1182
  var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
1115
1183
  constructor() {
1116
1184
  super(...arguments);
1117
- __publicField(this, "type", ApplicationCommandOptionType7.Role);
1185
+ __publicField(this, "type", ApplicationCommandOptionType8.Role);
1118
1186
  }
1119
1187
  toJSON() {
1120
1188
  this.runRequiredValidations();
@@ -1123,20 +1191,6 @@ var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
1123
1191
  };
1124
1192
  __name(SlashCommandRoleOption, "SlashCommandRoleOption");
1125
1193
 
1126
- // src/interactions/slashCommands/options/attachment.ts
1127
- import { ApplicationCommandOptionType as ApplicationCommandOptionType8 } from "discord-api-types/v10";
1128
- var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
1129
- constructor() {
1130
- super(...arguments);
1131
- __publicField(this, "type", ApplicationCommandOptionType8.Attachment);
1132
- }
1133
- toJSON() {
1134
- this.runRequiredValidations();
1135
- return { ...this };
1136
- }
1137
- };
1138
- __name(SlashCommandAttachmentOption, "SlashCommandAttachmentOption");
1139
-
1140
1194
  // src/interactions/slashCommands/options/string.ts
1141
1195
  import { ApplicationCommandOptionType as ApplicationCommandOptionType9 } from "discord-api-types/v10";
1142
1196
  import { mix as mix4 } from "ts-mixer";
@@ -1216,10 +1270,6 @@ var SharedSlashCommandOptions = class {
1216
1270
  __name(SharedSlashCommandOptions, "SharedSlashCommandOptions");
1217
1271
 
1218
1272
  // src/interactions/slashCommands/SlashCommandSubcommands.ts
1219
- import {
1220
- ApplicationCommandOptionType as ApplicationCommandOptionType11
1221
- } from "discord-api-types/v10";
1222
- import { mix as mix5 } from "ts-mixer";
1223
1273
  var SlashCommandSubcommandGroupBuilder = class {
1224
1274
  constructor() {
1225
1275
  __publicField(this, "name");
@@ -1273,7 +1323,9 @@ SlashCommandSubcommandBuilder = __decorateClass([
1273
1323
  var SlashCommandBuilder = class {
1274
1324
  constructor() {
1275
1325
  __publicField(this, "name");
1326
+ __publicField(this, "name_localizations");
1276
1327
  __publicField(this, "description");
1328
+ __publicField(this, "description_localizations");
1277
1329
  __publicField(this, "options", []);
1278
1330
  __publicField(this, "defaultPermission");
1279
1331
  }
@@ -1281,7 +1333,9 @@ var SlashCommandBuilder = class {
1281
1333
  validateRequiredParameters3(this.name, this.description, this.options);
1282
1334
  return {
1283
1335
  name: this.name,
1336
+ name_localizations: this.name_localizations,
1284
1337
  description: this.description,
1338
+ description_localizations: this.description_localizations,
1285
1339
  options: this.options.map((option) => option.toJSON()),
1286
1340
  default_permission: this.defaultPermission
1287
1341
  };