@discordjs/builders 0.13.0-dev.1649505810-3c0bbac → 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
@@ -252,10 +252,6 @@ function userMention(userId) {
252
252
  return `<@${userId}>`;
253
253
  }
254
254
  __name(userMention, "userMention");
255
- function memberNicknameMention(memberId) {
256
- return `<@!${memberId}>`;
257
- }
258
- __name(memberNicknameMention, "memberNicknameMention");
259
255
  function channelMention(channelId) {
260
256
  return `<#${channelId}>`;
261
257
  }
@@ -312,8 +308,8 @@ __export(Assertions_exports2, {
312
308
  validateRequiredSelectMenuOptionParameters: () => validateRequiredSelectMenuOptionParameters,
313
309
  validateRequiredSelectMenuParameters: () => validateRequiredSelectMenuParameters
314
310
  });
315
- import { ButtonStyle } from "discord-api-types/v10";
316
311
  import { s as s2 } from "@sapphire/shapeshift";
312
+ import { ButtonStyle } from "discord-api-types/v10";
317
313
 
318
314
  // src/components/selectMenu/UnsafeSelectMenuOption.ts
319
315
  var UnsafeSelectMenuOptionBuilder = class {
@@ -439,10 +435,7 @@ __name(createComponentBuilder, "createComponentBuilder");
439
435
 
440
436
  // src/components/ActionRow.ts
441
437
  var ActionRowBuilder = class extends ComponentBuilder {
442
- constructor({
443
- components,
444
- ...data
445
- } = {}) {
438
+ constructor({ components, ...data } = {}) {
446
439
  super({ type: ComponentType2.ActionRow, ...data });
447
440
  __publicField(this, "components");
448
441
  this.components = components?.map((c) => createComponentBuilder(c)) ?? [];
@@ -543,8 +536,8 @@ __export(Assertions_exports3, {
543
536
  validateRequiredParameters: () => validateRequiredParameters,
544
537
  valueValidator: () => valueValidator
545
538
  });
546
- import { TextInputStyle } from "discord-api-types/v10";
547
539
  import { s as s3 } from "@sapphire/shapeshift";
540
+ import { TextInputStyle } from "discord-api-types/v10";
548
541
  var textInputStyleValidator = s3.nativeEnum(TextInputStyle);
549
542
  var minLengthValidator = s3.number.int.ge(0).le(4e3);
550
543
  var maxLengthValidator = s3.number.int.ge(1).le(4e3);
@@ -806,24 +799,31 @@ __export(Assertions_exports5, {
806
799
  validateChoicesLength: () => validateChoicesLength,
807
800
  validateDefaultPermission: () => validateDefaultPermission,
808
801
  validateDescription: () => validateDescription,
802
+ validateLocale: () => validateLocale,
809
803
  validateMaxOptionsLength: () => validateMaxOptionsLength,
810
804
  validateName: () => validateName,
811
805
  validateRequired: () => validateRequired,
812
806
  validateRequiredParameters: () => validateRequiredParameters3
813
807
  });
814
- import is from "@sindresorhus/is";
815
808
  import { s as s5 } from "@sapphire/shapeshift";
816
- var namePredicate = s5.string.lengthGe(1).lengthLe(32).regex(/^[\P{Lu}\p{N}_-]+$/u);
809
+ import is from "@sindresorhus/is";
810
+ import { Locale } from "discord-api-types/v10";
811
+ var namePredicate = s5.string.lengthGe(1).lengthLe(32).regex(/^[\P{Lu}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u);
817
812
  function validateName(name) {
818
813
  namePredicate.parse(name);
819
814
  }
820
815
  __name(validateName, "validateName");
821
816
  var descriptionPredicate2 = s5.string.lengthGe(1).lengthLe(100);
817
+ var localePredicate = s5.nativeEnum(Locale);
822
818
  function validateDescription(description) {
823
819
  descriptionPredicate2.parse(description);
824
820
  }
825
821
  __name(validateDescription, "validateDescription");
826
822
  var maxArrayLengthPredicate = s5.unknown.array.lengthLe(25);
823
+ function validateLocale(locale) {
824
+ return localePredicate.parse(locale);
825
+ }
826
+ __name(validateLocale, "validateLocale");
827
827
  function validateMaxOptionsLength(options) {
828
828
  maxArrayLengthPredicate.parse(options);
829
829
  }
@@ -869,14 +869,19 @@ __name(assertReturnOfBuilder, "assertReturnOfBuilder");
869
869
  // src/interactions/slashCommands/SlashCommandBuilder.ts
870
870
  import { mix as mix6 } from "ts-mixer";
871
871
 
872
- // src/interactions/slashCommands/options/boolean.ts
873
- 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";
874
877
 
875
878
  // src/interactions/slashCommands/mixins/NameAndDescription.ts
876
879
  var SharedNameAndDescription = class {
877
880
  constructor() {
878
881
  __publicField(this, "name");
882
+ __publicField(this, "name_localizations");
879
883
  __publicField(this, "description");
884
+ __publicField(this, "description_localizations");
880
885
  }
881
886
  setName(name) {
882
887
  validateName(name);
@@ -888,9 +893,54 @@ var SharedNameAndDescription = class {
888
893
  Reflect.set(this, "description", description);
889
894
  return this;
890
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
+ }
891
938
  };
892
939
  __name(SharedNameAndDescription, "SharedNameAndDescription");
893
940
 
941
+ // src/interactions/slashCommands/options/attachment.ts
942
+ import { ApplicationCommandOptionType } from "discord-api-types/v10";
943
+
894
944
  // src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
895
945
  var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
896
946
  constructor() {
@@ -909,11 +959,25 @@ var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
909
959
  };
910
960
  __name(ApplicationCommandOptionBase, "ApplicationCommandOptionBase");
911
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
+
912
975
  // src/interactions/slashCommands/options/boolean.ts
976
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType2 } from "discord-api-types/v10";
913
977
  var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
914
978
  constructor() {
915
979
  super(...arguments);
916
- __publicField(this, "type", ApplicationCommandOptionType.Boolean);
980
+ __publicField(this, "type", ApplicationCommandOptionType2.Boolean);
917
981
  }
918
982
  toJSON() {
919
983
  this.runRequiredValidations();
@@ -923,12 +987,12 @@ var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
923
987
  __name(SlashCommandBooleanOption, "SlashCommandBooleanOption");
924
988
 
925
989
  // src/interactions/slashCommands/options/channel.ts
926
- import { ApplicationCommandOptionType as ApplicationCommandOptionType2 } from "discord-api-types/v10";
990
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "discord-api-types/v10";
927
991
  import { mix } from "ts-mixer";
928
992
 
929
993
  // src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
930
- import { ChannelType } from "discord-api-types/v10";
931
994
  import { s as s6 } from "@sapphire/shapeshift";
995
+ import { ChannelType } from "discord-api-types/v10";
932
996
  var allowedChannelTypes = [
933
997
  ChannelType.GuildText,
934
998
  ChannelType.GuildVoice,
@@ -958,7 +1022,7 @@ __name(ApplicationCommandOptionChannelTypesMixin, "ApplicationCommandOptionChann
958
1022
  var SlashCommandChannelOption = class extends ApplicationCommandOptionBase {
959
1023
  constructor() {
960
1024
  super(...arguments);
961
- __publicField(this, "type", ApplicationCommandOptionType2.Channel);
1025
+ __publicField(this, "type", ApplicationCommandOptionType3.Channel);
962
1026
  }
963
1027
  toJSON() {
964
1028
  this.runRequiredValidations();
@@ -971,9 +1035,9 @@ SlashCommandChannelOption = __decorateClass([
971
1035
  ], SlashCommandChannelOption);
972
1036
 
973
1037
  // src/interactions/slashCommands/options/integer.ts
974
- import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
975
- import { mix as mix2 } from "ts-mixer";
976
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";
977
1041
 
978
1042
  // src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
979
1043
  var ApplicationCommandNumericOptionMinMaxValueMixin = class {
@@ -985,8 +1049,8 @@ var ApplicationCommandNumericOptionMinMaxValueMixin = class {
985
1049
  __name(ApplicationCommandNumericOptionMinMaxValueMixin, "ApplicationCommandNumericOptionMinMaxValueMixin");
986
1050
 
987
1051
  // src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts
988
- import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "discord-api-types/v10";
989
1052
  import { s as s7 } from "@sapphire/shapeshift";
1053
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
990
1054
  var stringPredicate = s7.string.lengthGe(1).lengthLe(100);
991
1055
  var numberPredicate = s7.number.gt(-Infinity).lt(Infinity);
992
1056
  var choicesPredicate = s7.object({ name: stringPredicate, value: s7.union(stringPredicate, numberPredicate) }).array;
@@ -1007,7 +1071,7 @@ var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
1007
1071
  }
1008
1072
  validateChoicesLength(choices.length, this.choices);
1009
1073
  for (const { name, value } of choices) {
1010
- if (this.type === ApplicationCommandOptionType3.String) {
1074
+ if (this.type === ApplicationCommandOptionType4.String) {
1011
1075
  stringPredicate.parse(value);
1012
1076
  } else {
1013
1077
  numberPredicate.parse(value);
@@ -1041,7 +1105,7 @@ var numberValidator = s8.number.int;
1041
1105
  var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
1042
1106
  constructor() {
1043
1107
  super(...arguments);
1044
- __publicField(this, "type", ApplicationCommandOptionType4.Integer);
1108
+ __publicField(this, "type", ApplicationCommandOptionType5.Integer);
1045
1109
  }
1046
1110
  setMaxValue(max) {
1047
1111
  numberValidator.parse(max);
@@ -1067,11 +1131,11 @@ SlashCommandIntegerOption = __decorateClass([
1067
1131
  ], SlashCommandIntegerOption);
1068
1132
 
1069
1133
  // src/interactions/slashCommands/options/mentionable.ts
1070
- import { ApplicationCommandOptionType as ApplicationCommandOptionType5 } from "discord-api-types/v10";
1134
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType6 } from "discord-api-types/v10";
1071
1135
  var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
1072
1136
  constructor() {
1073
1137
  super(...arguments);
1074
- __publicField(this, "type", ApplicationCommandOptionType5.Mentionable);
1138
+ __publicField(this, "type", ApplicationCommandOptionType6.Mentionable);
1075
1139
  }
1076
1140
  toJSON() {
1077
1141
  this.runRequiredValidations();
@@ -1081,14 +1145,14 @@ var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
1081
1145
  __name(SlashCommandMentionableOption, "SlashCommandMentionableOption");
1082
1146
 
1083
1147
  // src/interactions/slashCommands/options/number.ts
1084
- import { ApplicationCommandOptionType as ApplicationCommandOptionType6 } from "discord-api-types/v10";
1085
- import { mix as mix3 } from "ts-mixer";
1086
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";
1087
1151
  var numberValidator2 = s9.number;
1088
1152
  var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
1089
1153
  constructor() {
1090
1154
  super(...arguments);
1091
- __publicField(this, "type", ApplicationCommandOptionType6.Number);
1155
+ __publicField(this, "type", ApplicationCommandOptionType7.Number);
1092
1156
  }
1093
1157
  setMaxValue(max) {
1094
1158
  numberValidator2.parse(max);
@@ -1114,11 +1178,11 @@ SlashCommandNumberOption = __decorateClass([
1114
1178
  ], SlashCommandNumberOption);
1115
1179
 
1116
1180
  // src/interactions/slashCommands/options/role.ts
1117
- import { ApplicationCommandOptionType as ApplicationCommandOptionType7 } from "discord-api-types/v10";
1181
+ import { ApplicationCommandOptionType as ApplicationCommandOptionType8 } from "discord-api-types/v10";
1118
1182
  var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
1119
1183
  constructor() {
1120
1184
  super(...arguments);
1121
- __publicField(this, "type", ApplicationCommandOptionType7.Role);
1185
+ __publicField(this, "type", ApplicationCommandOptionType8.Role);
1122
1186
  }
1123
1187
  toJSON() {
1124
1188
  this.runRequiredValidations();
@@ -1127,20 +1191,6 @@ var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
1127
1191
  };
1128
1192
  __name(SlashCommandRoleOption, "SlashCommandRoleOption");
1129
1193
 
1130
- // src/interactions/slashCommands/options/attachment.ts
1131
- import { ApplicationCommandOptionType as ApplicationCommandOptionType8 } from "discord-api-types/v10";
1132
- var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
1133
- constructor() {
1134
- super(...arguments);
1135
- __publicField(this, "type", ApplicationCommandOptionType8.Attachment);
1136
- }
1137
- toJSON() {
1138
- this.runRequiredValidations();
1139
- return { ...this };
1140
- }
1141
- };
1142
- __name(SlashCommandAttachmentOption, "SlashCommandAttachmentOption");
1143
-
1144
1194
  // src/interactions/slashCommands/options/string.ts
1145
1195
  import { ApplicationCommandOptionType as ApplicationCommandOptionType9 } from "discord-api-types/v10";
1146
1196
  import { mix as mix4 } from "ts-mixer";
@@ -1220,10 +1270,6 @@ var SharedSlashCommandOptions = class {
1220
1270
  __name(SharedSlashCommandOptions, "SharedSlashCommandOptions");
1221
1271
 
1222
1272
  // src/interactions/slashCommands/SlashCommandSubcommands.ts
1223
- import {
1224
- ApplicationCommandOptionType as ApplicationCommandOptionType11
1225
- } from "discord-api-types/v10";
1226
- import { mix as mix5 } from "ts-mixer";
1227
1273
  var SlashCommandSubcommandGroupBuilder = class {
1228
1274
  constructor() {
1229
1275
  __publicField(this, "name");
@@ -1277,7 +1323,9 @@ SlashCommandSubcommandBuilder = __decorateClass([
1277
1323
  var SlashCommandBuilder = class {
1278
1324
  constructor() {
1279
1325
  __publicField(this, "name");
1326
+ __publicField(this, "name_localizations");
1280
1327
  __publicField(this, "description");
1328
+ __publicField(this, "description_localizations");
1281
1329
  __publicField(this, "options", []);
1282
1330
  __publicField(this, "defaultPermission");
1283
1331
  }
@@ -1285,7 +1333,9 @@ var SlashCommandBuilder = class {
1285
1333
  validateRequiredParameters3(this.name, this.description, this.options);
1286
1334
  return {
1287
1335
  name: this.name,
1336
+ name_localizations: this.name_localizations,
1288
1337
  description: this.description,
1338
+ description_localizations: this.description_localizations,
1289
1339
  options: this.options.map((option) => option.toJSON()),
1290
1340
  default_permission: this.defaultPermission
1291
1341
  };
@@ -1327,7 +1377,7 @@ __export(Assertions_exports6, {
1327
1377
  });
1328
1378
  import { s as s10 } from "@sapphire/shapeshift";
1329
1379
  import { ApplicationCommandType } from "discord-api-types/v10";
1330
- var namePredicate2 = s10.string.lengthGe(1).lengthLe(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u);
1380
+ var namePredicate2 = s10.string.lengthGe(1).lengthLe(32).regex(/^( *[\p{L}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+ *)+$/u);
1331
1381
  var typePredicate = s10.union(s10.literal(ApplicationCommandType.User), s10.literal(ApplicationCommandType.Message));
1332
1382
  var booleanPredicate3 = s10.boolean;
1333
1383
  function validateDefaultPermission2(value) {
@@ -1447,7 +1497,6 @@ export {
1447
1497
  isEquatable,
1448
1498
  isJSONEncodable,
1449
1499
  italic,
1450
- memberNicknameMention,
1451
1500
  quote,
1452
1501
  roleMention,
1453
1502
  spoiler,