@discordjs/builders 1.1.0-dev.1658102995-dda2895 → 1.1.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.
Files changed (245) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +5 -2
  3. package/dist/components/ActionRow.cjs +32 -0
  4. package/dist/components/ActionRow.cjs.map +1 -0
  5. package/dist/components/ActionRow.d.ts +35 -0
  6. package/dist/components/ActionRow.d.ts.map +1 -0
  7. package/dist/components/ActionRow.mjs +28 -0
  8. package/dist/components/ActionRow.mjs.map +1 -0
  9. package/dist/components/Assertions.cjs +77 -0
  10. package/dist/components/Assertions.cjs.map +1 -0
  11. package/dist/components/Assertions.d.ts +48 -0
  12. package/dist/components/Assertions.d.ts.map +1 -0
  13. package/dist/components/Assertions.mjs +57 -0
  14. package/dist/components/Assertions.mjs.map +1 -0
  15. package/dist/components/Component.cjs +12 -0
  16. package/dist/components/Component.cjs.map +1 -0
  17. package/dist/components/Component.d.ts +15 -0
  18. package/dist/components/Component.d.ts.map +1 -0
  19. package/dist/components/Component.mjs +8 -0
  20. package/dist/components/Component.mjs.map +1 -0
  21. package/dist/components/Components.cjs +31 -0
  22. package/dist/components/Components.cjs.map +1 -0
  23. package/dist/components/Components.d.ts +21 -0
  24. package/dist/components/Components.d.ts.map +1 -0
  25. package/dist/components/Components.mjs +27 -0
  26. package/dist/components/Components.mjs.map +1 -0
  27. package/dist/components/button/Button.cjs +46 -0
  28. package/dist/components/button/Button.cjs.map +1 -0
  29. package/dist/components/button/Button.d.ts +46 -0
  30. package/dist/components/button/Button.d.ts.map +1 -0
  31. package/dist/components/button/Button.mjs +42 -0
  32. package/dist/components/button/Button.mjs.map +1 -0
  33. package/dist/components/selectMenu/SelectMenu.cjs +59 -0
  34. package/dist/components/selectMenu/SelectMenu.cjs.map +1 -0
  35. package/dist/components/selectMenu/SelectMenu.d.ts +59 -0
  36. package/dist/components/selectMenu/SelectMenu.d.ts.map +1 -0
  37. package/dist/components/selectMenu/SelectMenu.mjs +55 -0
  38. package/dist/components/selectMenu/SelectMenu.mjs.map +1 -0
  39. package/dist/components/selectMenu/SelectMenuOption.cjs +40 -0
  40. package/dist/components/selectMenu/SelectMenuOption.cjs.map +1 -0
  41. package/dist/components/selectMenu/SelectMenuOption.d.ts +40 -0
  42. package/dist/components/selectMenu/SelectMenuOption.d.ts.map +1 -0
  43. package/dist/components/selectMenu/SelectMenuOption.mjs +36 -0
  44. package/dist/components/selectMenu/SelectMenuOption.mjs.map +1 -0
  45. package/dist/components/textInput/Assertions.cjs +31 -0
  46. package/dist/components/textInput/Assertions.cjs.map +1 -0
  47. package/dist/components/textInput/Assertions.d.ts +10 -0
  48. package/dist/components/textInput/Assertions.d.ts.map +1 -0
  49. package/dist/components/textInput/Assertions.mjs +20 -0
  50. package/dist/components/textInput/Assertions.mjs.map +1 -0
  51. package/dist/components/textInput/TextInput.cjs +67 -0
  52. package/dist/components/textInput/TextInput.cjs.map +1 -0
  53. package/dist/components/textInput/TextInput.d.ts +59 -0
  54. package/dist/components/textInput/TextInput.d.ts.map +1 -0
  55. package/dist/components/textInput/TextInput.mjs +59 -0
  56. package/dist/components/textInput/TextInput.mjs.map +1 -0
  57. package/dist/index.cjs +129 -0
  58. package/dist/index.cjs.map +1 -0
  59. package/dist/index.d.ts +40 -1406
  60. package/dist/index.d.ts.map +1 -0
  61. package/dist/index.mjs +46 -1482
  62. package/dist/index.mjs.map +1 -1
  63. package/dist/interactions/contextMenuCommands/Assertions.cjs +40 -0
  64. package/dist/interactions/contextMenuCommands/Assertions.cjs.map +1 -0
  65. package/dist/interactions/contextMenuCommands/Assertions.d.ts +8 -0
  66. package/dist/interactions/contextMenuCommands/Assertions.d.ts.map +1 -0
  67. package/dist/interactions/contextMenuCommands/Assertions.mjs +31 -0
  68. package/dist/interactions/contextMenuCommands/Assertions.mjs.map +1 -0
  69. package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.cjs +71 -0
  70. package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.cjs.map +1 -0
  71. package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.d.ts +94 -0
  72. package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.d.ts.map +1 -0
  73. package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.mjs +67 -0
  74. package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.mjs.map +1 -0
  75. package/dist/interactions/modals/Assertions.cjs +21 -0
  76. package/dist/interactions/modals/Assertions.cjs.map +1 -0
  77. package/dist/interactions/modals/Assertions.d.ts +5 -0
  78. package/dist/interactions/modals/Assertions.d.ts.map +1 -0
  79. package/dist/interactions/modals/Assertions.mjs +15 -0
  80. package/dist/interactions/modals/Assertions.mjs.map +1 -0
  81. package/dist/interactions/modals/Modal.cjs +43 -0
  82. package/dist/interactions/modals/Modal.cjs.map +1 -0
  83. package/dist/interactions/modals/Modal.d.ts +35 -0
  84. package/dist/interactions/modals/Modal.d.ts.map +1 -0
  85. package/dist/interactions/modals/Modal.mjs +39 -0
  86. package/dist/interactions/modals/Modal.mjs.map +1 -0
  87. package/dist/interactions/slashCommands/Assertions.cjs +70 -0
  88. package/dist/interactions/slashCommands/Assertions.cjs.map +1 -0
  89. package/dist/interactions/slashCommands/Assertions.d.ts +18 -0
  90. package/dist/interactions/slashCommands/Assertions.d.ts.map +1 -0
  91. package/dist/interactions/slashCommands/Assertions.mjs +54 -0
  92. package/dist/interactions/slashCommands/Assertions.mjs.map +1 -0
  93. package/dist/interactions/slashCommands/SlashCommandBuilder.cjs +75 -0
  94. package/dist/interactions/slashCommands/SlashCommandBuilder.cjs.map +1 -0
  95. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts +100 -0
  96. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts.map +1 -0
  97. package/dist/interactions/slashCommands/SlashCommandBuilder.mjs +73 -0
  98. package/dist/interactions/slashCommands/SlashCommandBuilder.mjs.map +1 -0
  99. package/dist/interactions/slashCommands/SlashCommandSubcommands.cjs +72 -0
  100. package/dist/interactions/slashCommands/SlashCommandSubcommands.cjs.map +1 -0
  101. package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts +56 -0
  102. package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts.map +1 -0
  103. package/dist/interactions/slashCommands/SlashCommandSubcommands.mjs +70 -0
  104. package/dist/interactions/slashCommands/SlashCommandSubcommands.mjs.map +1 -0
  105. package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.cjs +9 -0
  106. package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.cjs.map +1 -0
  107. package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.d.ts +17 -0
  108. package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.d.ts.map +1 -0
  109. package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.mjs +5 -0
  110. package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.mjs.map +1 -0
  111. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.cjs +27 -0
  112. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.cjs.map +1 -0
  113. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.d.ts +15 -0
  114. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.d.ts.map +1 -0
  115. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.mjs +23 -0
  116. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.mjs.map +1 -0
  117. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.cjs +30 -0
  118. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.cjs.map +1 -0
  119. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.d.ts +14 -0
  120. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.d.ts.map +1 -0
  121. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.mjs +26 -0
  122. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.mjs.map +1 -0
  123. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.cjs +57 -0
  124. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.cjs.map +1 -0
  125. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.d.ts +19 -0
  126. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.d.ts.map +1 -0
  127. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.mjs +53 -0
  128. package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.mjs.map +1 -0
  129. package/dist/interactions/slashCommands/mixins/NameAndDescription.cjs +65 -0
  130. package/dist/interactions/slashCommands/mixins/NameAndDescription.cjs.map +1 -0
  131. package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts +46 -0
  132. package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts.map +1 -0
  133. package/dist/interactions/slashCommands/mixins/NameAndDescription.mjs +61 -0
  134. package/dist/interactions/slashCommands/mixins/NameAndDescription.mjs.map +1 -0
  135. package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.cjs +55 -0
  136. package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.cjs.map +1 -0
  137. package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.d.ts +69 -0
  138. package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.d.ts.map +1 -0
  139. package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.mjs +51 -0
  140. package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.mjs.map +1 -0
  141. package/dist/interactions/slashCommands/options/attachment.cjs +20 -0
  142. package/dist/interactions/slashCommands/options/attachment.cjs.map +1 -0
  143. package/dist/interactions/slashCommands/options/attachment.d.ts +7 -0
  144. package/dist/interactions/slashCommands/options/attachment.d.ts.map +1 -0
  145. package/dist/interactions/slashCommands/options/attachment.mjs +16 -0
  146. package/dist/interactions/slashCommands/options/attachment.mjs.map +1 -0
  147. package/dist/interactions/slashCommands/options/boolean.cjs +20 -0
  148. package/dist/interactions/slashCommands/options/boolean.cjs.map +1 -0
  149. package/dist/interactions/slashCommands/options/boolean.d.ts +7 -0
  150. package/dist/interactions/slashCommands/options/boolean.d.ts.map +1 -0
  151. package/dist/interactions/slashCommands/options/boolean.mjs +16 -0
  152. package/dist/interactions/slashCommands/options/boolean.mjs.map +1 -0
  153. package/dist/interactions/slashCommands/options/channel.cjs +34 -0
  154. package/dist/interactions/slashCommands/options/channel.cjs.map +1 -0
  155. package/dist/interactions/slashCommands/options/channel.d.ts +10 -0
  156. package/dist/interactions/slashCommands/options/channel.d.ts.map +1 -0
  157. package/dist/interactions/slashCommands/options/channel.mjs +32 -0
  158. package/dist/interactions/slashCommands/options/channel.mjs.map +1 -0
  159. package/dist/interactions/slashCommands/options/integer.cjs +50 -0
  160. package/dist/interactions/slashCommands/options/integer.cjs.map +1 -0
  161. package/dist/interactions/slashCommands/options/integer.d.ts +13 -0
  162. package/dist/interactions/slashCommands/options/integer.d.ts.map +1 -0
  163. package/dist/interactions/slashCommands/options/integer.mjs +48 -0
  164. package/dist/interactions/slashCommands/options/integer.mjs.map +1 -0
  165. package/dist/interactions/slashCommands/options/mentionable.cjs +20 -0
  166. package/dist/interactions/slashCommands/options/mentionable.cjs.map +1 -0
  167. package/dist/interactions/slashCommands/options/mentionable.d.ts +7 -0
  168. package/dist/interactions/slashCommands/options/mentionable.d.ts.map +1 -0
  169. package/dist/interactions/slashCommands/options/mentionable.mjs +16 -0
  170. package/dist/interactions/slashCommands/options/mentionable.mjs.map +1 -0
  171. package/dist/interactions/slashCommands/options/number.cjs +50 -0
  172. package/dist/interactions/slashCommands/options/number.cjs.map +1 -0
  173. package/dist/interactions/slashCommands/options/number.d.ts +13 -0
  174. package/dist/interactions/slashCommands/options/number.d.ts.map +1 -0
  175. package/dist/interactions/slashCommands/options/number.mjs +48 -0
  176. package/dist/interactions/slashCommands/options/number.mjs.map +1 -0
  177. package/dist/interactions/slashCommands/options/role.cjs +20 -0
  178. package/dist/interactions/slashCommands/options/role.cjs.map +1 -0
  179. package/dist/interactions/slashCommands/options/role.d.ts +7 -0
  180. package/dist/interactions/slashCommands/options/role.d.ts.map +1 -0
  181. package/dist/interactions/slashCommands/options/role.mjs +16 -0
  182. package/dist/interactions/slashCommands/options/role.mjs.map +1 -0
  183. package/dist/interactions/slashCommands/options/string.cjs +50 -0
  184. package/dist/interactions/slashCommands/options/string.cjs.map +1 -0
  185. package/dist/interactions/slashCommands/options/string.d.ts +24 -0
  186. package/dist/interactions/slashCommands/options/string.d.ts.map +1 -0
  187. package/dist/interactions/slashCommands/options/string.mjs +48 -0
  188. package/dist/interactions/slashCommands/options/string.mjs.map +1 -0
  189. package/dist/interactions/slashCommands/options/user.cjs +20 -0
  190. package/dist/interactions/slashCommands/options/user.cjs.map +1 -0
  191. package/dist/interactions/slashCommands/options/user.d.ts +7 -0
  192. package/dist/interactions/slashCommands/options/user.d.ts.map +1 -0
  193. package/dist/interactions/slashCommands/options/user.mjs +16 -0
  194. package/dist/interactions/slashCommands/options/user.mjs.map +1 -0
  195. package/dist/messages/embed/Assertions.cjs +62 -0
  196. package/dist/messages/embed/Assertions.cjs.map +1 -0
  197. package/dist/messages/embed/Assertions.d.ts +50 -0
  198. package/dist/messages/embed/Assertions.d.ts.map +1 -0
  199. package/dist/messages/embed/Assertions.mjs +41 -0
  200. package/dist/messages/embed/Assertions.mjs.map +1 -0
  201. package/dist/messages/embed/Embed.cjs +101 -0
  202. package/dist/messages/embed/Embed.cjs.map +1 -0
  203. package/dist/messages/embed/Embed.d.ts +108 -0
  204. package/dist/messages/embed/Embed.d.ts.map +1 -0
  205. package/dist/messages/embed/Embed.mjs +97 -0
  206. package/dist/messages/embed/Embed.mjs.map +1 -0
  207. package/dist/messages/formatters.cjs +102 -0
  208. package/dist/messages/formatters.cjs.map +1 -0
  209. package/dist/messages/formatters.d.ts +246 -0
  210. package/dist/messages/formatters.d.ts.map +1 -0
  211. package/dist/messages/formatters.mjs +79 -0
  212. package/dist/messages/formatters.mjs.map +1 -0
  213. package/dist/util/componentUtil.cjs +10 -0
  214. package/dist/util/componentUtil.cjs.map +1 -0
  215. package/dist/util/componentUtil.d.ts +3 -0
  216. package/dist/util/componentUtil.d.ts.map +1 -0
  217. package/dist/util/componentUtil.mjs +6 -0
  218. package/dist/util/componentUtil.mjs.map +1 -0
  219. package/dist/util/equatable.cjs +10 -0
  220. package/dist/util/equatable.cjs.map +1 -0
  221. package/dist/util/equatable.d.ts +12 -0
  222. package/dist/util/equatable.d.ts.map +1 -0
  223. package/dist/util/equatable.mjs +6 -0
  224. package/dist/util/equatable.mjs.map +1 -0
  225. package/dist/util/jsonEncodable.cjs +10 -0
  226. package/dist/util/jsonEncodable.cjs.map +1 -0
  227. package/dist/util/jsonEncodable.d.ts +12 -0
  228. package/dist/util/jsonEncodable.d.ts.map +1 -0
  229. package/dist/util/jsonEncodable.mjs +6 -0
  230. package/dist/util/jsonEncodable.mjs.map +1 -0
  231. package/dist/util/normalizeArray.cjs +12 -0
  232. package/dist/util/normalizeArray.cjs.map +1 -0
  233. package/dist/util/normalizeArray.d.ts +3 -0
  234. package/dist/util/normalizeArray.d.ts.map +1 -0
  235. package/dist/util/normalizeArray.mjs +8 -0
  236. package/dist/util/normalizeArray.mjs.map +1 -0
  237. package/dist/util/validation.cjs +13 -0
  238. package/dist/util/validation.cjs.map +1 -0
  239. package/dist/util/validation.d.ts +4 -0
  240. package/dist/util/validation.d.ts.map +1 -0
  241. package/dist/util/validation.mjs +7 -0
  242. package/dist/util/validation.mjs.map +1 -0
  243. package/package.json +17 -16
  244. package/dist/index.js +0 -1557
  245. package/dist/index.js.map +0 -1
@@ -0,0 +1,67 @@
1
+ import { validateName, validateType, validateDefaultPermission, validateDefaultMemberPermissions, validateDMPermission, validateRequiredParameters } from './Assertions.mjs';
2
+ import { validateLocale, validateLocalizationMap } from '../slashCommands/Assertions.mjs';
3
+
4
+ class ContextMenuCommandBuilder {
5
+ constructor() {
6
+ this.name = void 0;
7
+ this.type = void 0;
8
+ this.default_permission = void 0;
9
+ this.default_member_permissions = void 0;
10
+ this.dm_permission = void 0;
11
+ }
12
+ setName(name) {
13
+ validateName(name);
14
+ Reflect.set(this, "name", name);
15
+ return this;
16
+ }
17
+ setType(type) {
18
+ validateType(type);
19
+ Reflect.set(this, "type", type);
20
+ return this;
21
+ }
22
+ setDefaultPermission(value) {
23
+ validateDefaultPermission(value);
24
+ Reflect.set(this, "default_permission", value);
25
+ return this;
26
+ }
27
+ setDefaultMemberPermissions(permissions) {
28
+ const permissionValue = validateDefaultMemberPermissions(permissions);
29
+ Reflect.set(this, "default_member_permissions", permissionValue);
30
+ return this;
31
+ }
32
+ setDMPermission(enabled) {
33
+ validateDMPermission(enabled);
34
+ Reflect.set(this, "dm_permission", enabled);
35
+ return this;
36
+ }
37
+ setNameLocalization(locale, localizedName) {
38
+ if (!this.name_localizations) {
39
+ Reflect.set(this, "name_localizations", {});
40
+ }
41
+ const parsedLocale = validateLocale(locale);
42
+ if (localizedName === null) {
43
+ this.name_localizations[parsedLocale] = null;
44
+ return this;
45
+ }
46
+ validateName(localizedName);
47
+ this.name_localizations[parsedLocale] = localizedName;
48
+ return this;
49
+ }
50
+ setNameLocalizations(localizedNames) {
51
+ if (localizedNames === null) {
52
+ Reflect.set(this, "name_localizations", null);
53
+ return this;
54
+ }
55
+ Reflect.set(this, "name_localizations", {});
56
+ Object.entries(localizedNames).forEach((args) => this.setNameLocalization(...args));
57
+ return this;
58
+ }
59
+ toJSON() {
60
+ validateRequiredParameters(this.name, this.type);
61
+ validateLocalizationMap(this.name_localizations);
62
+ return { ...this };
63
+ }
64
+ }
65
+
66
+ export { ContextMenuCommandBuilder };
67
+ //# sourceMappingURL=ContextMenuCommandBuilder.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContextMenuCommandBuilder.mjs","sources":["../../../src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts"],"sourcesContent":["import type {\n\tApplicationCommandType,\n\tLocaleString,\n\tLocalizationMap,\n\tPermissions,\n\tRESTPostAPIApplicationCommandsJSONBody,\n} from 'discord-api-types/v10';\nimport {\n\tvalidateRequiredParameters,\n\tvalidateName,\n\tvalidateType,\n\tvalidateDefaultPermission,\n\tvalidateDefaultMemberPermissions,\n\tvalidateDMPermission,\n} from './Assertions';\nimport { validateLocale, validateLocalizationMap } from '../slashCommands/Assertions';\n\nexport class ContextMenuCommandBuilder {\n\t/**\n\t * The name of this context menu command\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The localized names for this command\n\t */\n\tpublic readonly name_localizations?: LocalizationMap;\n\n\t/**\n\t * The type of this context menu command\n\t */\n\tpublic readonly type: ContextMenuCommandType = undefined!;\n\n\t/**\n\t * Whether the command is enabled by default when the app is added to a guild\n\t *\n\t * @deprecated This property is deprecated and will be removed in the future.\n\t * You should use `setDefaultMemberPermissions` or `setDMPermission` instead.\n\t */\n\tpublic readonly default_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Set of permissions represented as a bit set for the command\n\t */\n\tpublic readonly default_member_permissions: Permissions | null | undefined = undefined;\n\n\t/**\n\t * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t */\n\tpublic readonly dm_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Sets the name\n\t *\n\t * @param name - The name\n\t */\n\tpublic setName(name: string) {\n\t\t// Assert the name matches the conditions\n\t\tvalidateName(name);\n\n\t\tReflect.set(this, 'name', name);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the type\n\t *\n\t * @param type - The type\n\t */\n\tpublic setType(type: ContextMenuCommandType) {\n\t\t// Assert the type is valid\n\t\tvalidateType(type);\n\n\t\tReflect.set(this, 'type', type);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether the command is enabled by default when the application is added to a guild.\n\t *\n\t * **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.\n\t *\n\t * @param value - Whether or not to enable this command by default\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t * @deprecated Use `setDefaultMemberPermissions` or `setDMPermission` instead.\n\t */\n\tpublic setDefaultPermission(value: boolean) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDefaultPermission(value);\n\n\t\tReflect.set(this, 'default_permission', value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the default permissions a member should have in order to run the command.\n\t *\n\t * **Note:** You can set this to `'0'` to disable the command by default.\n\t *\n\t * @param permissions - The permissions bit field to set\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined) {\n\t\t// Assert the value and parse it\n\t\tconst permissionValue = validateDefaultMemberPermissions(permissions);\n\n\t\tReflect.set(this, 'default_member_permissions', permissionValue);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets if the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t *\n\t * @param enabled - If the command should be enabled in DMs\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDMPermission(enabled: boolean | null | undefined) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDMPermission(enabled);\n\n\t\tReflect.set(this, 'dm_permission', enabled);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets a name localization\n\t *\n\t * @param locale - The locale to set a description for\n\t * @param localizedName - The localized description for the given locale\n\t */\n\tpublic setNameLocalization(locale: LocaleString, localizedName: string | null) {\n\t\tif (!this.name_localizations) {\n\t\t\tReflect.set(this, 'name_localizations', {});\n\t\t}\n\n\t\tconst parsedLocale = validateLocale(locale);\n\n\t\tif (localizedName === null) {\n\t\t\tthis.name_localizations![parsedLocale] = null;\n\t\t\treturn this;\n\t\t}\n\n\t\tvalidateName(localizedName);\n\n\t\tthis.name_localizations![parsedLocale] = localizedName;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the name localizations\n\t *\n\t * @param localizedNames - The dictionary of localized descriptions to set\n\t */\n\tpublic setNameLocalizations(localizedNames: LocalizationMap | null) {\n\t\tif (localizedNames === null) {\n\t\t\tReflect.set(this, 'name_localizations', null);\n\t\t\treturn this;\n\t\t}\n\n\t\tReflect.set(this, 'name_localizations', {});\n\n\t\tObject.entries(localizedNames).forEach((args) =>\n\t\t\tthis.setNameLocalization(...(args as [LocaleString, string | null])),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the final data that should be sent to Discord.\n\t *\n\t * **Note:** Calling this function will validate required properties based on their conditions.\n\t */\n\tpublic toJSON(): RESTPostAPIApplicationCommandsJSONBody {\n\t\tvalidateRequiredParameters(this.name, this.type);\n\n\t\tvalidateLocalizationMap(this.name_localizations);\n\n\t\treturn { ...this };\n\t}\n}\n\nexport type ContextMenuCommandType = ApplicationCommandType.User | ApplicationCommandType.Message;\n"],"names":[],"mappings":";;;AASO,MAAM,yBAAyB,CAAC;AACvC,EAAE,WAAW,GAAG;AAChB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACvB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACvB,IAAI,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACrC,IAAI,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC7C,IAAI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAChC,GAAG;AACH,EAAE,OAAO,CAAC,IAAI,EAAE;AAChB,IAAI,YA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ChD,IAAI,IAAI,aAAa,KAAK,IAAI,EAAE;AAChC,MAAM,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;AACnD,MAAM,OAAO,IAAI,CAAC;AAClB,KAAK;AACL,IAAI,YAAY,CAAC,aAAa,CAAC,CAAC;AAChC,IAAI,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC;AAC1D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,oBAAoB,CAAC,cAAc,EAAE;AACvC,IAAI,IAAI,cAAc,KAAK,IAAI,EAAE;AACjC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;AACpD,MAAM,OAAO,IAAI,CAAC;AAClB,KAAK;AACL,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,CAAC,CAAC;AAChD,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AACxF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD,IAAI,uBAAuB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AACrD,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH;;;;"}
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const shapeshift = require('@sapphire/shapeshift');
6
+ const ActionRow = require('../../components/ActionRow.cjs');
7
+ const Assertions$1 = require('../../components/Assertions.cjs');
8
+ const validation = require('../../util/validation.cjs');
9
+
10
+ const titleValidator = shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(validation.isValidationEnabled);
11
+ const componentsValidator = shapeshift.s.instance(ActionRow.ActionRowBuilder).array.lengthGreaterThanOrEqual(1).setValidationEnabled(validation.isValidationEnabled);
12
+ function validateRequiredParameters(customId, title, components) {
13
+ Assertions$1.customIdValidator.parse(customId);
14
+ titleValidator.parse(title);
15
+ componentsValidator.parse(components);
16
+ }
17
+
18
+ exports.componentsValidator = componentsValidator;
19
+ exports.titleValidator = titleValidator;
20
+ exports.validateRequiredParameters = validateRequiredParameters;
21
+ //# sourceMappingURL=Assertions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assertions.cjs","sources":["../../../src/interactions/modals/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { isValidationEnabled } from '../../util/validation';\n\nexport const titleValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(45)\n\t.setValidationEnabled(isValidationEnabled);\nexport const componentsValidator = s\n\t.instance(ActionRowBuilder)\n\t.array.lengthGreaterThanOrEqual(1)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredParameters(\n\tcustomId?: string,\n\ttitle?: string,\n\tcomponents?: ActionRowBuilder<ModalActionRowComponentBuilder>[],\n) {\n\tcustomIdValidator.parse(customId);\n\ttitleValidator.parse(title);\n\tcomponentsValidator.parse(components);\n}\n"],"names":["s","isValidationEnabled","ActionRowBuilder","customIdValidator"],"mappings":";;;;;;;;;AAIY,MAAC,cAAc,GAAGA,YAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,oBAAoB,CAACC,8BAAmB,EAAE;AAC3H,MAAC,mBAAmB,GAAGD,YAAC,CAAC,QAAQ,CAACE,0BAAgB,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAACD,8BAAmB,EAAE;AACrI,SAAS,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;AACxE,EAAEE,8BAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACpC,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9B,EAAE,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACxC;;;;;;"}
@@ -0,0 +1,5 @@
1
+ import { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';
2
+ export declare const titleValidator: import("@sapphire/shapeshift").StringValidator<string>;
3
+ export declare const componentsValidator: import("@sapphire/shapeshift").ArrayValidator<[ActionRowBuilder<import("../../components/ActionRow").AnyComponentBuilder>, ...ActionRowBuilder<import("../../components/ActionRow").AnyComponentBuilder>[]], ActionRowBuilder<import("../../components/ActionRow").AnyComponentBuilder>>;
4
+ export declare function validateRequiredParameters(customId?: string, title?: string, components?: ActionRowBuilder<ModalActionRowComponentBuilder>[]): void;
5
+ //# sourceMappingURL=Assertions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assertions.d.ts","sourceRoot":"","sources":["../../../src/interactions/modals/Assertions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,KAAK,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAInG,eAAO,MAAM,cAAc,wDAGgB,CAAC;AAC5C,eAAO,MAAM,mBAAmB,0RAGW,CAAC;AAE5C,wBAAgB,0BAA0B,CACzC,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,MAAM,EACd,UAAU,CAAC,EAAE,gBAAgB,CAAC,8BAA8B,CAAC,EAAE,QAK/D"}
@@ -0,0 +1,15 @@
1
+ import { s } from '@sapphire/shapeshift';
2
+ import { ActionRowBuilder } from '../../components/ActionRow.mjs';
3
+ import { customIdValidator } from '../../components/Assertions.mjs';
4
+ import { isValidationEnabled } from '../../util/validation.mjs';
5
+
6
+ const titleValidator = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
7
+ const componentsValidator = s.instance(ActionRowBuilder).array.lengthGreaterThanOrEqual(1).setValidationEnabled(isValidationEnabled);
8
+ function validateRequiredParameters(customId, title, components) {
9
+ customIdValidator.parse(customId);
10
+ titleValidator.parse(title);
11
+ componentsValidator.parse(components);
12
+ }
13
+
14
+ export { componentsValidator, titleValidator, validateRequiredParameters };
15
+ //# sourceMappingURL=Assertions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assertions.mjs","sources":["../../../src/interactions/modals/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { isValidationEnabled } from '../../util/validation';\n\nexport const titleValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(45)\n\t.setValidationEnabled(isValidationEnabled);\nexport const componentsValidator = s\n\t.instance(ActionRowBuilder)\n\t.array.lengthGreaterThanOrEqual(1)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredParameters(\n\tcustomId?: string,\n\ttitle?: string,\n\tcomponents?: ActionRowBuilder<ModalActionRowComponentBuilder>[],\n) {\n\tcustomIdValidator.parse(customId);\n\ttitleValidator.parse(title);\n\tcomponentsValidator.parse(components);\n}\n"],"names":[],"mappings":";;;;;AAIY,MAAC,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,EAAE;AAC3H,MAAC,mBAAmB,GAAG,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,EAAE;AACrI,SAAS,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE;AACxE,EAAE,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACpC,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9B,EAAE,mBAAmB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AACxC;;;;"}
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const Assertions = require('./Assertions.cjs');
6
+ const ActionRow = require('../../components/ActionRow.cjs');
7
+ const Assertions$1 = require('../../components/Assertions.cjs');
8
+ const Components = require('../../components/Components.cjs');
9
+ const normalizeArray = require('../../util/normalizeArray.cjs');
10
+
11
+ class ModalBuilder {
12
+ constructor({ components, ...data } = {}) {
13
+ this.components = [];
14
+ this.data = { ...data };
15
+ this.components = components?.map((c) => Components.createComponentBuilder(c)) ?? [];
16
+ }
17
+ setTitle(title) {
18
+ this.data.title = Assertions.titleValidator.parse(title);
19
+ return this;
20
+ }
21
+ setCustomId(customId) {
22
+ this.data.custom_id = Assertions$1.customIdValidator.parse(customId);
23
+ return this;
24
+ }
25
+ addComponents(...components) {
26
+ this.components.push(...normalizeArray.normalizeArray(components).map((component) => component instanceof ActionRow.ActionRowBuilder ? component : new ActionRow.ActionRowBuilder(component)));
27
+ return this;
28
+ }
29
+ setComponents(...components) {
30
+ this.components.splice(0, this.components.length, ...normalizeArray.normalizeArray(components));
31
+ return this;
32
+ }
33
+ toJSON() {
34
+ Assertions.validateRequiredParameters(this.data.custom_id, this.data.title, this.components);
35
+ return {
36
+ ...this.data,
37
+ components: this.components.map((component) => component.toJSON())
38
+ };
39
+ }
40
+ }
41
+
42
+ exports.ModalBuilder = ModalBuilder;
43
+ //# sourceMappingURL=Modal.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.cjs","sources":["../../../src/interactions/modals/Modal.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIModalInteractionResponseCallbackData,\n} from 'discord-api-types/v10';\nimport { titleValidator, validateRequiredParameters } from './Assertions';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { createComponentBuilder } from '../../components/Components';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {\n\tpublic readonly data: Partial<APIModalInteractionResponseCallbackData>;\n\tpublic readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[] = [];\n\n\tpublic constructor({ components, ...data }: Partial<APIModalInteractionResponseCallbackData> = {}) {\n\t\tthis.data = { ...data };\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ??\n\t\t\t[]) as ActionRowBuilder<ModalActionRowComponentBuilder>[];\n\t}\n\n\t/**\n\t * Sets the title of the modal\n\t *\n\t * @param title - The title of the modal\n\t */\n\tpublic setTitle(title: string) {\n\t\tthis.data.title = titleValidator.parse(title);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id of the modal\n\t *\n\t * @param customId - The custom id of this modal\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds components to this modal\n\t *\n\t * @param components - The components to add to this modal\n\t */\n\tpublic addComponents(\n\t\t...components: RestOrArray<\n\t\t\tActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>\n\t\t>\n\t) {\n\t\tthis.components.push(\n\t\t\t...normalizeArray(components).map((component) =>\n\t\t\t\tcomponent instanceof ActionRowBuilder\n\t\t\t\t\t? component\n\t\t\t\t\t: new ActionRowBuilder<ModalActionRowComponentBuilder>(component),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this modal\n\t *\n\t * @param components - The components to set this modal to\n\t */\n\tpublic setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIModalInteractionResponseCallbackData {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.title, this.components);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t\tcomponents: this.components.map((component) => component.toJSON()),\n\t\t} as APIModalInteractionResponseCallbackData;\n\t}\n}\n"],"names":["createComponentBuilder","titleValidator","customIdValidator","normalizeArray","ActionRowBuilder","validateRequiredParameters"],"mappings":";;;;;;;;;;AAKO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE;AAC5C,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,CAAC,UAAU,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,KAAKA,iCAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGC,yBAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,QAAQ,EAAE;AACxB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAGC,8BAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC5D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAGC,6BAAc,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,YAAYC,0BAAgB,GAAG,SAAS,GAAG,IAAIA,0BAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAChK,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAGD,6BAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACrF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAIE,qCAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtF,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,MAAM,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;AACxE,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
@@ -0,0 +1,35 @@
1
+ import type { APIActionRowComponent, APIModalActionRowComponent, APIModalInteractionResponseCallbackData } from 'discord-api-types/v10';
2
+ import { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';
3
+ import type { JSONEncodable } from '../../util/jsonEncodable';
4
+ import { type RestOrArray } from '../../util/normalizeArray';
5
+ export declare class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {
6
+ readonly data: Partial<APIModalInteractionResponseCallbackData>;
7
+ readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[];
8
+ constructor({ components, ...data }?: Partial<APIModalInteractionResponseCallbackData>);
9
+ /**
10
+ * Sets the title of the modal
11
+ *
12
+ * @param title - The title of the modal
13
+ */
14
+ setTitle(title: string): this;
15
+ /**
16
+ * Sets the custom id of the modal
17
+ *
18
+ * @param customId - The custom id of this modal
19
+ */
20
+ setCustomId(customId: string): this;
21
+ /**
22
+ * Adds components to this modal
23
+ *
24
+ * @param components - The components to add to this modal
25
+ */
26
+ addComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>>): this;
27
+ /**
28
+ * Sets the components in this modal
29
+ *
30
+ * @param components - The components to set this modal to
31
+ */
32
+ setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>): this;
33
+ toJSON(): APIModalInteractionResponseCallbackData;
34
+ }
35
+ //# sourceMappingURL=Modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/interactions/modals/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,uCAAuC,EACvC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,KAAK,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAGnG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7E,qBAAa,YAAa,YAAW,aAAa,CAAC,uCAAuC,CAAC;IAC1F,SAAgB,IAAI,EAAE,OAAO,CAAC,uCAAuC,CAAC,CAAC;IACvE,SAAgB,UAAU,EAAE,gBAAgB,CAAC,8BAA8B,CAAC,EAAE,CAAM;gBAEjE,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAE,OAAO,CAAC,uCAAuC,CAAM;IAMjG;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAK7B;;;;OAIG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM;IAKnC;;;;OAIG;IACI,aAAa,CACnB,GAAG,UAAU,EAAE,WAAW,CACzB,gBAAgB,CAAC,8BAA8B,CAAC,GAAG,qBAAqB,CAAC,0BAA0B,CAAC,CACpG;IAYF;;;;OAIG;IACI,aAAa,CAAC,GAAG,UAAU,EAAE,WAAW,CAAC,gBAAgB,CAAC,8BAA8B,CAAC,CAAC;IAK1F,MAAM,IAAI,uCAAuC;CAQxD"}
@@ -0,0 +1,39 @@
1
+ import { titleValidator, validateRequiredParameters } from './Assertions.mjs';
2
+ import { ActionRowBuilder } from '../../components/ActionRow.mjs';
3
+ import { customIdValidator } from '../../components/Assertions.mjs';
4
+ import { createComponentBuilder } from '../../components/Components.mjs';
5
+ import { normalizeArray } from '../../util/normalizeArray.mjs';
6
+
7
+ class ModalBuilder {
8
+ constructor({ components, ...data } = {}) {
9
+ this.components = [];
10
+ this.data = { ...data };
11
+ this.components = components?.map((c) => createComponentBuilder(c)) ?? [];
12
+ }
13
+ setTitle(title) {
14
+ this.data.title = titleValidator.parse(title);
15
+ return this;
16
+ }
17
+ setCustomId(customId) {
18
+ this.data.custom_id = customIdValidator.parse(customId);
19
+ return this;
20
+ }
21
+ addComponents(...components) {
22
+ this.components.push(...normalizeArray(components).map((component) => component instanceof ActionRowBuilder ? component : new ActionRowBuilder(component)));
23
+ return this;
24
+ }
25
+ setComponents(...components) {
26
+ this.components.splice(0, this.components.length, ...normalizeArray(components));
27
+ return this;
28
+ }
29
+ toJSON() {
30
+ validateRequiredParameters(this.data.custom_id, this.data.title, this.components);
31
+ return {
32
+ ...this.data,
33
+ components: this.components.map((component) => component.toJSON())
34
+ };
35
+ }
36
+ }
37
+
38
+ export { ModalBuilder };
39
+ //# sourceMappingURL=Modal.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.mjs","sources":["../../../src/interactions/modals/Modal.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIModalInteractionResponseCallbackData,\n} from 'discord-api-types/v10';\nimport { titleValidator, validateRequiredParameters } from './Assertions';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { createComponentBuilder } from '../../components/Components';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {\n\tpublic readonly data: Partial<APIModalInteractionResponseCallbackData>;\n\tpublic readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[] = [];\n\n\tpublic constructor({ components, ...data }: Partial<APIModalInteractionResponseCallbackData> = {}) {\n\t\tthis.data = { ...data };\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ??\n\t\t\t[]) as ActionRowBuilder<ModalActionRowComponentBuilder>[];\n\t}\n\n\t/**\n\t * Sets the title of the modal\n\t *\n\t * @param title - The title of the modal\n\t */\n\tpublic setTitle(title: string) {\n\t\tthis.data.title = titleValidator.parse(title);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id of the modal\n\t *\n\t * @param customId - The custom id of this modal\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds components to this modal\n\t *\n\t * @param components - The components to add to this modal\n\t */\n\tpublic addComponents(\n\t\t...components: RestOrArray<\n\t\t\tActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>\n\t\t>\n\t) {\n\t\tthis.components.push(\n\t\t\t...normalizeArray(components).map((component) =>\n\t\t\t\tcomponent instanceof ActionRowBuilder\n\t\t\t\t\t? component\n\t\t\t\t\t: new ActionRowBuilder<ModalActionRowComponentBuilder>(component),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this modal\n\t *\n\t * @param components - The components to set this modal to\n\t */\n\tpublic setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIModalInteractionResponseCallbackData {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.title, this.components);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t\tcomponents: this.components.map((component) => component.toJSON()),\n\t\t} as APIModalInteractionResponseCallbackData;\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE;AAC5C,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,CAAC,UAAU,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,QAAQ,EAAE;AACxB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC5D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,YAAY,gBAAgB,GAAG,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAChK,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACrF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtF,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,MAAM,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;AACxE,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const shapeshift = require('@sapphire/shapeshift');
6
+ const v10 = require('discord-api-types/v10');
7
+ const validation = require('../../util/validation.cjs');
8
+
9
+ const namePredicate = shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u).setValidationEnabled(validation.isValidationEnabled);
10
+ function validateName(name) {
11
+ namePredicate.parse(name);
12
+ }
13
+ const descriptionPredicate = shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(validation.isValidationEnabled);
14
+ const localePredicate = shapeshift.s.nativeEnum(v10.Locale);
15
+ function validateDescription(description) {
16
+ descriptionPredicate.parse(description);
17
+ }
18
+ const maxArrayLengthPredicate = shapeshift.s.unknown.array.lengthLessThanOrEqual(25).setValidationEnabled(validation.isValidationEnabled);
19
+ function validateLocale(locale) {
20
+ return localePredicate.parse(locale);
21
+ }
22
+ function validateMaxOptionsLength(options) {
23
+ maxArrayLengthPredicate.parse(options);
24
+ }
25
+ function validateRequiredParameters(name, description, options) {
26
+ validateName(name);
27
+ validateDescription(description);
28
+ validateMaxOptionsLength(options);
29
+ }
30
+ const booleanPredicate = shapeshift.s.boolean;
31
+ function validateDefaultPermission(value) {
32
+ booleanPredicate.parse(value);
33
+ }
34
+ function validateRequired(required) {
35
+ booleanPredicate.parse(required);
36
+ }
37
+ const choicesLengthPredicate = shapeshift.s.number.lessThanOrEqual(25).setValidationEnabled(validation.isValidationEnabled);
38
+ function validateChoicesLength(amountAdding, choices) {
39
+ choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
40
+ }
41
+ function assertReturnOfBuilder(input, ExpectedInstanceOf) {
42
+ shapeshift.s.instance(ExpectedInstanceOf).parse(input);
43
+ }
44
+ const localizationMapPredicate = shapeshift.s.object(Object.fromEntries(Object.values(v10.Locale).map((locale) => [locale, shapeshift.s.string.nullish]))).strict.nullish.setValidationEnabled(validation.isValidationEnabled);
45
+ function validateLocalizationMap(value) {
46
+ localizationMapPredicate.parse(value);
47
+ }
48
+ const dmPermissionPredicate = shapeshift.s.boolean.nullish;
49
+ function validateDMPermission(value) {
50
+ dmPermissionPredicate.parse(value);
51
+ }
52
+ const memberPermissionPredicate = shapeshift.s.union(shapeshift.s.bigint.transform((value) => value.toString()), shapeshift.s.number.safeInt.transform((value) => value.toString()), shapeshift.s.string.regex(/^\d+$/)).nullish;
53
+ function validateDefaultMemberPermissions(permissions) {
54
+ return memberPermissionPredicate.parse(permissions);
55
+ }
56
+
57
+ exports.assertReturnOfBuilder = assertReturnOfBuilder;
58
+ exports.localizationMapPredicate = localizationMapPredicate;
59
+ exports.validateChoicesLength = validateChoicesLength;
60
+ exports.validateDMPermission = validateDMPermission;
61
+ exports.validateDefaultMemberPermissions = validateDefaultMemberPermissions;
62
+ exports.validateDefaultPermission = validateDefaultPermission;
63
+ exports.validateDescription = validateDescription;
64
+ exports.validateLocale = validateLocale;
65
+ exports.validateLocalizationMap = validateLocalizationMap;
66
+ exports.validateMaxOptionsLength = validateMaxOptionsLength;
67
+ exports.validateName = validateName;
68
+ exports.validateRequired = validateRequired;
69
+ exports.validateRequiredParameters = validateRequiredParameters;
70
+ //# sourceMappingURL=Assertions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assertions.cjs","sources":["../../../src/interactions/slashCommands/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { type APIApplicationCommandOptionChoice, Locale, LocalizationMap } from 'discord-api-types/v10';\nimport type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';\nimport type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';\nimport type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase';\nimport { isValidationEnabled } from '../../util/validation';\n\nconst namePredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(32)\n\t.regex(/^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateName(name: unknown): asserts name is string {\n\tnamePredicate.parse(name);\n}\n\nconst descriptionPredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\nconst localePredicate = s.nativeEnum(Locale);\n\nexport function validateDescription(description: unknown): asserts description is string {\n\tdescriptionPredicate.parse(description);\n}\n\nconst maxArrayLengthPredicate = s.unknown.array.lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);\nexport function validateLocale(locale: unknown) {\n\treturn localePredicate.parse(locale);\n}\n\nexport function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[] {\n\tmaxArrayLengthPredicate.parse(options);\n}\n\nexport function validateRequiredParameters(\n\tname: string,\n\tdescription: string,\n\toptions: ToAPIApplicationCommandOptions[],\n) {\n\t// Assert name matches all conditions\n\tvalidateName(name);\n\n\t// Assert description conditions\n\tvalidateDescription(description);\n\n\t// Assert options conditions\n\tvalidateMaxOptionsLength(options);\n}\n\nconst booleanPredicate = s.boolean;\n\nexport function validateDefaultPermission(value: unknown): asserts value is boolean {\n\tbooleanPredicate.parse(value);\n}\n\nexport function validateRequired(required: unknown): asserts required is boolean {\n\tbooleanPredicate.parse(required);\n}\n\nconst choicesLengthPredicate = s.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);\n\nexport function validateChoicesLength(amountAdding: number, choices?: APIApplicationCommandOptionChoice[]): void {\n\tchoicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);\n}\n\nexport function assertReturnOfBuilder<\n\tT extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder,\n>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T {\n\ts.instance(ExpectedInstanceOf).parse(input);\n}\n\nexport const localizationMapPredicate = s\n\t.object<LocalizationMap>(Object.fromEntries(Object.values(Locale).map((locale) => [locale, s.string.nullish])))\n\t.strict.nullish.setValidationEnabled(isValidationEnabled);\n\nexport function validateLocalizationMap(value: unknown): asserts value is LocalizationMap {\n\tlocalizationMapPredicate.parse(value);\n}\n\nconst dmPermissionPredicate = s.boolean.nullish;\n\nexport function validateDMPermission(value: unknown): asserts value is boolean | null | undefined {\n\tdmPermissionPredicate.parse(value);\n}\n\nconst memberPermissionPredicate = s.union(\n\ts.bigint.transform((value) => value.toString()),\n\ts.number.safeInt.transform((value) => value.toString()),\n\ts.string.regex(/^\\d+$/),\n).nullish;\n\nexport function validateDefaultMemberPermissions(permissions: unknown) {\n\treturn memberPermissionPredicate.parse(permissions);\n}\n"],"names":["s","isValidationEnabled","Locale"],"mappings":";;;;;;;;AAGA,MAAM,aAAa,GAAGA,YAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC,oBAAoB,CAACC,8BAAmB,CAAC,CAAC;AAC7L,SAAS,YAAY,CAAC,IAAI,EAAE;AACnC,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AACD,MAAM,oBAAoB,GAAGD,YAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAACC,8BAAmB,CAAC,CAAC;AACvI,MAAM,eAAe,GAAGD,YAAC,CAAC,UAAU,CAACE,UAAM,CAAC,CAAC;AACtC,SAAS,mBAAmB,CAAC,WAAW,EAAE;AACjD,EAAE,oBAAoB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC1C,CAAC;AACD,MAAM,uBAAuB,GAAGF,YAAC,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,oBAAoB,CAACC,8BAAmB,CAAC,CAAC;AAC7G,SAAS,cAAc,CAAC,MAAM,EAAE;AACvC,EAAE,OAAO,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC;AACM,SAAS,wBAAwB,CAAC,OAAO,EAAE;AAClD,EAAE,uBAAuB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AACM,SAAS,0BAA0B,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE;AACvE,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;AACrB,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAC;AACnC,EAAE,wBAAw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5C,EAAE,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACrC,CAAC;AACD,MAAM,yBAAyB,GAAGA,YAAC,CAAC,KAAK,CAACA,YAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAEA,YAAC,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,QAAQ,EAAE,CAAC,EAAEA,YAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;AAC9K,SAAS,gCAAgC,CAAC,WAAW,EAAE;AAC9D,EAAE,OAAO,yBAAyB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACtD;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,18 @@
1
+ import { type APIApplicationCommandOptionChoice, Locale, LocalizationMap } from 'discord-api-types/v10';
2
+ import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
3
+ import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
4
+ import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase';
5
+ export declare function validateName(name: unknown): asserts name is string;
6
+ export declare function validateDescription(description: unknown): asserts description is string;
7
+ export declare function validateLocale(locale: unknown): Locale;
8
+ export declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
9
+ export declare function validateRequiredParameters(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
10
+ export declare function validateDefaultPermission(value: unknown): asserts value is boolean;
11
+ export declare function validateRequired(required: unknown): asserts required is boolean;
12
+ export declare function validateChoicesLength(amountAdding: number, choices?: APIApplicationCommandOptionChoice[]): void;
13
+ export declare function assertReturnOfBuilder<T extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
14
+ export declare const localizationMapPredicate: import("@sapphire/shapeshift").UnionValidator<import("@sapphire/shapeshift").UndefinedToOptional<Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", string | null>>> | null | undefined>;
15
+ export declare function validateLocalizationMap(value: unknown): asserts value is LocalizationMap;
16
+ export declare function validateDMPermission(value: unknown): asserts value is boolean | null | undefined;
17
+ export declare function validateDefaultMemberPermissions(permissions: unknown): string | null | undefined;
18
+ //# sourceMappingURL=Assertions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assertions.d.ts","sourceRoot":"","sources":["../../../src/interactions/slashCommands/Assertions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,iCAAiC,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,6BAA6B,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AACnH,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AAS1F,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAElE;AAQD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,IAAI,MAAM,CAEvF;AAGD,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,UAE7C;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,8BAA8B,EAAE,CAE9G;AAED,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,8BAA8B,EAAE,QAUzC;AAID,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAElF;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,IAAI,OAAO,CAE/E;AAID,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iCAAiC,EAAE,GAAG,IAAI,CAE/G;AAED,wBAAgB,qBAAqB,CACpC,CAAC,SAAS,4BAA4B,GAAG,6BAA6B,GAAG,kCAAkC,EAC1G,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAErE;AAED,eAAO,MAAM,wBAAwB,4XAEqB,CAAC;AAE3D,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,eAAe,CAExF;AAID,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,GAAG,IAAI,GAAG,SAAS,CAEhG;AAQD,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,OAAO,6BAEpE"}
@@ -0,0 +1,54 @@
1
+ import { s } from '@sapphire/shapeshift';
2
+ import { Locale } from 'discord-api-types/v10';
3
+ import { isValidationEnabled } from '../../util/validation.mjs';
4
+
5
+ const namePredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u).setValidationEnabled(isValidationEnabled);
6
+ function validateName(name) {
7
+ namePredicate.parse(name);
8
+ }
9
+ const descriptionPredicate = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
10
+ const localePredicate = s.nativeEnum(Locale);
11
+ function validateDescription(description) {
12
+ descriptionPredicate.parse(description);
13
+ }
14
+ const maxArrayLengthPredicate = s.unknown.array.lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
15
+ function validateLocale(locale) {
16
+ return localePredicate.parse(locale);
17
+ }
18
+ function validateMaxOptionsLength(options) {
19
+ maxArrayLengthPredicate.parse(options);
20
+ }
21
+ function validateRequiredParameters(name, description, options) {
22
+ validateName(name);
23
+ validateDescription(description);
24
+ validateMaxOptionsLength(options);
25
+ }
26
+ const booleanPredicate = s.boolean;
27
+ function validateDefaultPermission(value) {
28
+ booleanPredicate.parse(value);
29
+ }
30
+ function validateRequired(required) {
31
+ booleanPredicate.parse(required);
32
+ }
33
+ const choicesLengthPredicate = s.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
34
+ function validateChoicesLength(amountAdding, choices) {
35
+ choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
36
+ }
37
+ function assertReturnOfBuilder(input, ExpectedInstanceOf) {
38
+ s.instance(ExpectedInstanceOf).parse(input);
39
+ }
40
+ const localizationMapPredicate = s.object(Object.fromEntries(Object.values(Locale).map((locale) => [locale, s.string.nullish]))).strict.nullish.setValidationEnabled(isValidationEnabled);
41
+ function validateLocalizationMap(value) {
42
+ localizationMapPredicate.parse(value);
43
+ }
44
+ const dmPermissionPredicate = s.boolean.nullish;
45
+ function validateDMPermission(value) {
46
+ dmPermissionPredicate.parse(value);
47
+ }
48
+ const memberPermissionPredicate = s.union(s.bigint.transform((value) => value.toString()), s.number.safeInt.transform((value) => value.toString()), s.string.regex(/^\d+$/)).nullish;
49
+ function validateDefaultMemberPermissions(permissions) {
50
+ return memberPermissionPredicate.parse(permissions);
51
+ }
52
+
53
+ export { assertReturnOfBuilder, localizationMapPredicate, validateChoicesLength, validateDMPermission, validateDefaultMemberPermissions, validateDefaultPermission, validateDescription, validateLocale, validateLocalizationMap, validateMaxOptionsLength, validateName, validateRequired, validateRequiredParameters };
54
+ //# sourceMappingURL=Assertions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Assertions.mjs","sources":["../../../src/interactions/slashCommands/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { type APIApplicationCommandOptionChoice, Locale, LocalizationMap } from 'discord-api-types/v10';\nimport type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';\nimport type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';\nimport type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOptionBase';\nimport { isValidationEnabled } from '../../util/validation';\n\nconst namePredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(32)\n\t.regex(/^[\\p{Ll}\\p{Lm}\\p{Lo}\\p{N}\\p{sc=Devanagari}\\p{sc=Thai}_-]+$/u)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateName(name: unknown): asserts name is string {\n\tnamePredicate.parse(name);\n}\n\nconst descriptionPredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\nconst localePredicate = s.nativeEnum(Locale);\n\nexport function validateDescription(description: unknown): asserts description is string {\n\tdescriptionPredicate.parse(description);\n}\n\nconst maxArrayLengthPredicate = s.unknown.array.lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);\nexport function validateLocale(locale: unknown) {\n\treturn localePredicate.parse(locale);\n}\n\nexport function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[] {\n\tmaxArrayLengthPredicate.parse(options);\n}\n\nexport function validateRequiredParameters(\n\tname: string,\n\tdescription: string,\n\toptions: ToAPIApplicationCommandOptions[],\n) {\n\t// Assert name matches all conditions\n\tvalidateName(name);\n\n\t// Assert description conditions\n\tvalidateDescription(description);\n\n\t// Assert options conditions\n\tvalidateMaxOptionsLength(options);\n}\n\nconst booleanPredicate = s.boolean;\n\nexport function validateDefaultPermission(value: unknown): asserts value is boolean {\n\tbooleanPredicate.parse(value);\n}\n\nexport function validateRequired(required: unknown): asserts required is boolean {\n\tbooleanPredicate.parse(required);\n}\n\nconst choicesLengthPredicate = s.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);\n\nexport function validateChoicesLength(amountAdding: number, choices?: APIApplicationCommandOptionChoice[]): void {\n\tchoicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);\n}\n\nexport function assertReturnOfBuilder<\n\tT extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder,\n>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T {\n\ts.instance(ExpectedInstanceOf).parse(input);\n}\n\nexport const localizationMapPredicate = s\n\t.object<LocalizationMap>(Object.fromEntries(Object.values(Locale).map((locale) => [locale, s.string.nullish])))\n\t.strict.nullish.setValidationEnabled(isValidationEnabled);\n\nexport function validateLocalizationMap(value: unknown): asserts value is LocalizationMap {\n\tlocalizationMapPredicate.parse(value);\n}\n\nconst dmPermissionPredicate = s.boolean.nullish;\n\nexport function validateDMPermission(value: unknown): asserts value is boolean | null | undefined {\n\tdmPermissionPredicate.parse(value);\n}\n\nconst memberPermissionPredicate = s.union(\n\ts.bigint.transform((value) => value.toString()),\n\ts.number.safeInt.transform((value) => value.toString()),\n\ts.string.regex(/^\\d+$/),\n).nullish;\n\nexport function validateDefaultMemberPermissions(permissions: unknown) {\n\treturn memberPermissionPredicate.parse(permissions);\n}\n"],"names":[],"mappings":";;;;AAGA,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,6DAA6D,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAC;AAC7L,SAAS,YAAY,CAAC,IAAI,EAAE;AACnC,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AACD,MAA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AW,EAAE;AAC9D,EAAE,OAAO,yBAAyB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACtD;;;;"}
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const tsMixer = require('ts-mixer');
6
+ const Assertions = require('./Assertions.cjs');
7
+ const SlashCommandSubcommands = require('./SlashCommandSubcommands.cjs');
8
+ const NameAndDescription = require('./mixins/NameAndDescription.cjs');
9
+ const SharedSlashCommandOptions = require('./mixins/SharedSlashCommandOptions.cjs');
10
+
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __decorateClass = (decorators, target, key, kind) => {
14
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
15
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
16
+ if (decorator = decorators[i])
17
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
18
+ if (kind && result)
19
+ __defProp(target, key, result);
20
+ return result;
21
+ };
22
+ exports.SlashCommandBuilder = class {
23
+ constructor() {
24
+ this.name = void 0;
25
+ this.description = void 0;
26
+ this.options = [];
27
+ this.default_permission = void 0;
28
+ this.default_member_permissions = void 0;
29
+ this.dm_permission = void 0;
30
+ }
31
+ toJSON() {
32
+ Assertions.validateRequiredParameters(this.name, this.description, this.options);
33
+ Assertions.validateLocalizationMap(this.name_localizations);
34
+ Assertions.validateLocalizationMap(this.description_localizations);
35
+ return {
36
+ ...this,
37
+ options: this.options.map((option) => option.toJSON())
38
+ };
39
+ }
40
+ setDefaultPermission(value) {
41
+ Assertions.validateDefaultPermission(value);
42
+ Reflect.set(this, "default_permission", value);
43
+ return this;
44
+ }
45
+ setDefaultMemberPermissions(permissions) {
46
+ const permissionValue = Assertions.validateDefaultMemberPermissions(permissions);
47
+ Reflect.set(this, "default_member_permissions", permissionValue);
48
+ return this;
49
+ }
50
+ setDMPermission(enabled) {
51
+ Assertions.validateDMPermission(enabled);
52
+ Reflect.set(this, "dm_permission", enabled);
53
+ return this;
54
+ }
55
+ addSubcommandGroup(input) {
56
+ const { options } = this;
57
+ Assertions.validateMaxOptionsLength(options);
58
+ const result = typeof input === "function" ? input(new SlashCommandSubcommands.SlashCommandSubcommandGroupBuilder()) : input;
59
+ Assertions.assertReturnOfBuilder(result, SlashCommandSubcommands.SlashCommandSubcommandGroupBuilder);
60
+ options.push(result);
61
+ return this;
62
+ }
63
+ addSubcommand(input) {
64
+ const { options } = this;
65
+ Assertions.validateMaxOptionsLength(options);
66
+ const result = typeof input === "function" ? input(new SlashCommandSubcommands.SlashCommandSubcommandBuilder()) : input;
67
+ Assertions.assertReturnOfBuilder(result, SlashCommandSubcommands.SlashCommandSubcommandBuilder);
68
+ options.push(result);
69
+ return this;
70
+ }
71
+ };
72
+ exports.SlashCommandBuilder = __decorateClass([
73
+ tsMixer.mix(SharedSlashCommandOptions.SharedSlashCommandOptions, NameAndDescription.SharedNameAndDescription)
74
+ ], exports.SlashCommandBuilder);
75
+ //# sourceMappingURL=SlashCommandBuilder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SlashCommandBuilder.cjs","sources":["../../../src/interactions/slashCommands/SlashCommandBuilder.ts"],"sourcesContent":["import type {\n\tAPIApplicationCommandOption,\n\tLocalizationMap,\n\tPermissions,\n\tRESTPostAPIApplicationCommandsJSONBody,\n} from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport {\n\tassertReturnOfBuilder,\n\tvalidateDefaultMemberPermissions,\n\tvalidateDefaultPermission,\n\tvalidateLocalizationMap,\n\tvalidateDMPermission,\n\tvalidateMaxOptionsLength,\n\tvalidateRequiredParameters,\n} from './Assertions';\nimport { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';\nimport { SharedNameAndDescription } from './mixins/NameAndDescription';\nimport { SharedSlashCommandOptions } from './mixins/SharedSlashCommandOptions';\n\n@mix(SharedSlashCommandOptions, SharedNameAndDescription)\nexport class SlashCommandBuilder {\n\t/**\n\t * The name of this slash command\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The localized names for this command\n\t */\n\tpublic readonly name_localizations?: LocalizationMap;\n\n\t/**\n\t * The description of this slash command\n\t */\n\tpublic readonly description: string = undefined!;\n\n\t/**\n\t * The localized descriptions for this command\n\t */\n\tpublic readonly description_localizations?: LocalizationMap;\n\n\t/**\n\t * The options of this slash command\n\t */\n\tpublic readonly options: ToAPIApplicationCommandOptions[] = [];\n\n\t/**\n\t * Whether the command is enabled by default when the app is added to a guild\n\t *\n\t * @deprecated This property is deprecated and will be removed in the future.\n\t * You should use `setDefaultMemberPermissions` or `setDMPermission` instead.\n\t */\n\tpublic readonly default_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Set of permissions represented as a bit set for the command\n\t */\n\tpublic readonly default_member_permissions: Permissions | null | undefined = undefined;\n\n\t/**\n\t * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t */\n\tpublic readonly dm_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Returns the final data that should be sent to Discord.\n\t *\n\t * **Note:** Calling this function will validate required properties based on their conditions.\n\t */\n\tpublic toJSON(): RESTPostAPIApplicationCommandsJSONBody {\n\t\tvalidateRequiredParameters(this.name, this.description, this.options);\n\n\t\tvalidateLocalizationMap(this.name_localizations);\n\t\tvalidateLocalizationMap(this.description_localizations);\n\n\t\treturn {\n\t\t\t...this,\n\t\t\toptions: this.options.map((option) => option.toJSON()),\n\t\t};\n\t}\n\n\t/**\n\t * Sets whether the command is enabled by default when the application is added to a guild.\n\t *\n\t * **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.\n\t *\n\t * @param value - Whether or not to enable this command by default\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t * @deprecated Use `setDefaultMemberPermissions` or `setDMPermission` instead.\n\t */\n\tpublic setDefaultPermission(value: boolean) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDefaultPermission(value);\n\n\t\tReflect.set(this, 'default_permission', value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the default permissions a member should have in order to run the command.\n\t *\n\t * **Note:** You can set this to `'0'` to disable the command by default.\n\t *\n\t * @param permissions - The permissions bit field to set\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined) {\n\t\t// Assert the value and parse it\n\t\tconst permissionValue = validateDefaultMemberPermissions(permissions);\n\n\t\tReflect.set(this, 'default_member_permissions', permissionValue);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets if the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t *\n\t * @param enabled - If the command should be enabled in DMs\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDMPermission(enabled: boolean | null | undefined) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDMPermission(enabled);\n\n\t\tReflect.set(this, 'dm_permission', enabled);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a new subcommand group to this command\n\t *\n\t * @param input - A function that returns a subcommand group builder, or an already built builder\n\t */\n\tpublic addSubcommandGroup(\n\t\tinput:\n\t\t\t| SlashCommandSubcommandGroupBuilder\n\t\t\t| ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder),\n\t): SlashCommandSubcommandsOnlyBuilder {\n\t\tconst { options } = this;\n\n\t\t// First, assert options conditions - we cannot have more than 25 options\n\t\tvalidateMaxOptionsLength(options);\n\n\t\t// Get the final result\n\t\tconst result = typeof input === 'function' ? input(new SlashCommandSubcommandGroupBuilder()) : input;\n\n\t\tassertReturnOfBuilder(result, SlashCommandSubcommandGroupBuilder);\n\n\t\t// Push it\n\t\toptions.push(result);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a new subcommand to this command\n\t *\n\t * @param input - A function that returns a subcommand builder, or an already built builder\n\t */\n\tpublic addSubcommand(\n\t\tinput:\n\t\t\t| SlashCommandSubcommandBuilder\n\t\t\t| ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder),\n\t): SlashCommandSubcommandsOnlyBuilder {\n\t\tconst { options } = this;\n\n\t\t// First, assert options conditions - we cannot have more than 25 options\n\t\tvalidateMaxOptionsLength(options);\n\n\t\t// Get the final result\n\t\tconst result = typeof input === 'function' ? input(new SlashCommandSubcommandBuilder()) : input;\n\n\t\tassertReturnOfBuilder(result, SlashCommandSubcommandBuilder);\n\n\t\t// Push it\n\t\toptions.push(result);\n\n\t\treturn this;\n\t}\n}\n\nexport interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {}\n\nexport interface SlashCommandSubcommandsOnlyBuilder\n\textends SharedNameAndDescription,\n\t\tPick<SlashCommandBuilder, 'toJSON' | 'addSubcommand' | 'addSubcommandGroup'> {}\n\nexport interface SlashCommandOptionsOnlyBuilder\n\textends SharedNameAndDescription,\n\t\tSharedSlashCommandOptions,\n\t\tPick<SlashCommandBuilder, 'toJSON'> {}\n\nexport interface ToAPIApplicationCommandOptions {\n\ttoJSON: () => APIApplicationCommandOption;\n}\n"],"names":["SlashCommandBuilder","validateRequiredParameters","validateLocalizationMap","validateDefaultPermission","validateDefaultMemberPermissions","validateDMPermission","validateMaxOptionsLength","SlashCommandSubcommandGroupBuilder","assertReturnOfBuilder","SlashCommandSubcommandBuilder","mix","SharedSlashCommandOptions","SharedNameAndDescription"],"mappings":";;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK;AACzD,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,I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