@buape/carbon 0.10.0 → 0.12.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 (220) hide show
  1. package/README.md +1 -1
  2. package/dist/package.json +3 -3
  3. package/dist/src/abstracts/AnySelectMenu.d.ts +8 -0
  4. package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -1
  5. package/dist/src/abstracts/AnySelectMenu.js +19 -3
  6. package/dist/src/abstracts/AnySelectMenu.js.map +1 -1
  7. package/dist/src/abstracts/BaseChannel.d.ts +7 -1
  8. package/dist/src/abstracts/BaseChannel.d.ts.map +1 -1
  9. package/dist/src/abstracts/BaseChannel.js +18 -10
  10. package/dist/src/abstracts/BaseChannel.js.map +1 -1
  11. package/dist/src/abstracts/BaseCommand.d.ts +7 -5
  12. package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
  13. package/dist/src/abstracts/BaseCommand.js +4 -2
  14. package/dist/src/abstracts/BaseCommand.js.map +1 -1
  15. package/dist/src/abstracts/BaseComponent.d.ts +1 -1
  16. package/dist/src/abstracts/BaseComponent.d.ts.map +1 -1
  17. package/dist/src/abstracts/BaseGuildChannel.d.ts +0 -9
  18. package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
  19. package/dist/src/abstracts/BaseGuildChannel.js +0 -20
  20. package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
  21. package/dist/src/abstracts/BaseGuildTextChannel.d.ts +10 -3
  22. package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -1
  23. package/dist/src/abstracts/BaseGuildTextChannel.js +16 -4
  24. package/dist/src/abstracts/BaseGuildTextChannel.js.map +1 -1
  25. package/dist/src/abstracts/BaseInteraction.d.ts +12 -3
  26. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
  27. package/dist/src/abstracts/BaseInteraction.js +36 -23
  28. package/dist/src/abstracts/BaseInteraction.js.map +1 -1
  29. package/dist/src/abstracts/BaseListener.d.ts +3 -3
  30. package/dist/src/abstracts/BaseListener.d.ts.map +1 -1
  31. package/dist/src/abstracts/BaseListener.js.map +1 -1
  32. package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts +7 -5
  33. package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts.map +1 -1
  34. package/dist/src/abstracts/BaseMessageInteractiveComponent.js +4 -2
  35. package/dist/src/abstracts/BaseMessageInteractiveComponent.js.map +1 -1
  36. package/dist/src/abstracts/BaseModalComponent.d.ts +3 -24
  37. package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -1
  38. package/dist/src/abstracts/BaseModalComponent.js +0 -28
  39. package/dist/src/abstracts/BaseModalComponent.js.map +1 -1
  40. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +9 -0
  41. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
  42. package/dist/src/abstracts/GuildThreadOnlyChannel.js +20 -0
  43. package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
  44. package/dist/src/classes/Client.d.ts +6 -1
  45. package/dist/src/classes/Client.d.ts.map +1 -1
  46. package/dist/src/classes/Client.js +7 -1
  47. package/dist/src/classes/Client.js.map +1 -1
  48. package/dist/src/classes/Command.d.ts +4 -1
  49. package/dist/src/classes/Command.d.ts.map +1 -1
  50. package/dist/src/classes/Command.js +12 -1
  51. package/dist/src/classes/Command.js.map +1 -1
  52. package/dist/src/classes/CommandWithSubcommandGroups.d.ts.map +1 -1
  53. package/dist/src/classes/CommandWithSubcommandGroups.js +4 -8
  54. package/dist/src/classes/CommandWithSubcommandGroups.js.map +1 -1
  55. package/dist/src/classes/CommandWithSubcommands.d.ts.map +1 -1
  56. package/dist/src/classes/CommandWithSubcommands.js +2 -4
  57. package/dist/src/classes/CommandWithSubcommands.js.map +1 -1
  58. package/dist/src/classes/Listener.d.ts.map +1 -1
  59. package/dist/src/classes/Listener.js +1 -1
  60. package/dist/src/classes/Listener.js.map +1 -1
  61. package/dist/src/classes/Modal.d.ts +3 -3
  62. package/dist/src/classes/Modal.d.ts.map +1 -1
  63. package/dist/src/classes/Modal.js +1 -1
  64. package/dist/src/classes/Modal.js.map +1 -1
  65. package/dist/src/classes/components/Container.d.ts +2 -1
  66. package/dist/src/classes/components/Container.d.ts.map +1 -1
  67. package/dist/src/classes/components/Container.js.map +1 -1
  68. package/dist/src/classes/components/Label.d.ts +27 -0
  69. package/dist/src/classes/components/Label.d.ts.map +1 -0
  70. package/dist/src/classes/components/Label.js +36 -0
  71. package/dist/src/classes/components/Label.js.map +1 -0
  72. package/dist/src/classes/components/ModalChannelSelectMenu.d.ts +62 -0
  73. package/dist/src/classes/components/ModalChannelSelectMenu.d.ts.map +1 -0
  74. package/dist/src/classes/components/ModalChannelSelectMenu.js +73 -0
  75. package/dist/src/classes/components/ModalChannelSelectMenu.js.map +1 -0
  76. package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts +58 -0
  77. package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts.map +1 -0
  78. package/dist/src/classes/components/ModalMentionableSelectMenu.js +68 -0
  79. package/dist/src/classes/components/ModalMentionableSelectMenu.js.map +1 -0
  80. package/dist/src/classes/components/ModalRoleSelectMenu.d.ts +58 -0
  81. package/dist/src/classes/components/ModalRoleSelectMenu.d.ts.map +1 -0
  82. package/dist/src/classes/components/ModalRoleSelectMenu.js +68 -0
  83. package/dist/src/classes/components/ModalRoleSelectMenu.js.map +1 -0
  84. package/dist/src/classes/components/ModalStringSelectMenu.d.ts +58 -0
  85. package/dist/src/classes/components/ModalStringSelectMenu.d.ts.map +1 -0
  86. package/dist/src/classes/components/ModalStringSelectMenu.js +64 -0
  87. package/dist/src/classes/components/ModalStringSelectMenu.js.map +1 -0
  88. package/dist/src/classes/components/ModalUserSelectMenu.d.ts +58 -0
  89. package/dist/src/classes/components/ModalUserSelectMenu.d.ts.map +1 -0
  90. package/dist/src/classes/components/ModalUserSelectMenu.js +68 -0
  91. package/dist/src/classes/components/ModalUserSelectMenu.js.map +1 -0
  92. package/dist/src/classes/components/Row.d.ts +3 -4
  93. package/dist/src/classes/components/Row.d.ts.map +1 -1
  94. package/dist/src/classes/components/Row.js +0 -1
  95. package/dist/src/classes/components/Row.js.map +1 -1
  96. package/dist/src/classes/components/TextInput.d.ts +17 -4
  97. package/dist/src/classes/components/TextInput.d.ts.map +1 -1
  98. package/dist/src/classes/components/TextInput.js +14 -1
  99. package/dist/src/classes/components/TextInput.js.map +1 -1
  100. package/dist/src/functions/channelFactory.d.ts +2 -2
  101. package/dist/src/functions/channelFactory.d.ts.map +1 -1
  102. package/dist/src/index.d.ts +2 -0
  103. package/dist/src/index.d.ts.map +1 -1
  104. package/dist/src/index.js +2 -0
  105. package/dist/src/index.js.map +1 -1
  106. package/dist/src/internals/CommandHandler.d.ts.map +1 -1
  107. package/dist/src/internals/CommandHandler.js +26 -3
  108. package/dist/src/internals/CommandHandler.js.map +1 -1
  109. package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
  110. package/dist/src/internals/ComponentHandler.js +91 -15
  111. package/dist/src/internals/ComponentHandler.js.map +1 -1
  112. package/dist/src/internals/EmojiHandler.d.ts +19 -0
  113. package/dist/src/internals/EmojiHandler.d.ts.map +1 -0
  114. package/dist/src/internals/EmojiHandler.js +35 -0
  115. package/dist/src/internals/EmojiHandler.js.map +1 -0
  116. package/dist/src/internals/EventHandler.d.ts +2 -2
  117. package/dist/src/internals/EventHandler.d.ts.map +1 -1
  118. package/dist/src/internals/EventHandler.js +3 -1
  119. package/dist/src/internals/EventHandler.js.map +1 -1
  120. package/dist/src/internals/FieldsHandler.d.ts +49 -11
  121. package/dist/src/internals/FieldsHandler.d.ts.map +1 -1
  122. package/dist/src/internals/FieldsHandler.js +98 -12
  123. package/dist/src/internals/FieldsHandler.js.map +1 -1
  124. package/dist/src/internals/ModalHandler.d.ts.map +1 -1
  125. package/dist/src/internals/ModalHandler.js +7 -1
  126. package/dist/src/internals/ModalHandler.js.map +1 -1
  127. package/dist/src/internals/OptionsHandler.d.ts +17 -11
  128. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  129. package/dist/src/internals/OptionsHandler.js +50 -17
  130. package/dist/src/internals/OptionsHandler.js.map +1 -1
  131. package/dist/src/permissions.d.ts +1 -0
  132. package/dist/src/permissions.d.ts.map +1 -1
  133. package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
  134. package/dist/src/plugins/gateway/GatewayPlugin.js +1 -1
  135. package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
  136. package/dist/src/plugins/gateway/index.d.ts +1 -0
  137. package/dist/src/plugins/gateway/index.d.ts.map +1 -1
  138. package/dist/src/plugins/gateway/index.js +1 -0
  139. package/dist/src/plugins/gateway/index.js.map +1 -1
  140. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +4 -0
  141. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
  142. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +2 -0
  143. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
  144. package/dist/src/plugins/paginator/GoToPageModal.d.ts +5 -11
  145. package/dist/src/plugins/paginator/GoToPageModal.d.ts.map +1 -1
  146. package/dist/src/plugins/paginator/GoToPageModal.js +9 -3
  147. package/dist/src/plugins/paginator/GoToPageModal.js.map +1 -1
  148. package/dist/src/structures/DmChannel.d.ts +1 -2
  149. package/dist/src/structures/DmChannel.d.ts.map +1 -1
  150. package/dist/src/structures/DmChannel.js.map +1 -1
  151. package/dist/src/structures/Emoji.d.ts +64 -0
  152. package/dist/src/structures/Emoji.d.ts.map +1 -0
  153. package/dist/src/structures/Emoji.js +136 -0
  154. package/dist/src/structures/Emoji.js.map +1 -0
  155. package/dist/src/structures/GroupDmChannel.d.ts +1 -2
  156. package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
  157. package/dist/src/structures/GroupDmChannel.js.map +1 -1
  158. package/dist/src/structures/Guild.d.ts +19 -4
  159. package/dist/src/structures/Guild.d.ts.map +1 -1
  160. package/dist/src/structures/Guild.js +126 -94
  161. package/dist/src/structures/Guild.js.map +1 -1
  162. package/dist/src/structures/GuildAnnouncementChannel.d.ts +10 -0
  163. package/dist/src/structures/GuildAnnouncementChannel.d.ts.map +1 -1
  164. package/dist/src/structures/GuildAnnouncementChannel.js +20 -0
  165. package/dist/src/structures/GuildAnnouncementChannel.js.map +1 -1
  166. package/dist/src/structures/GuildCategoryChannel.d.ts +11 -1
  167. package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -1
  168. package/dist/src/structures/GuildCategoryChannel.js +21 -0
  169. package/dist/src/structures/GuildCategoryChannel.js.map +1 -1
  170. package/dist/src/structures/GuildMember.d.ts +21 -2
  171. package/dist/src/structures/GuildMember.d.ts.map +1 -1
  172. package/dist/src/structures/GuildMember.js +49 -27
  173. package/dist/src/structures/GuildMember.js.map +1 -1
  174. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +9 -0
  175. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -1
  176. package/dist/src/structures/GuildStageOrVoiceChannel.js +21 -1
  177. package/dist/src/structures/GuildStageOrVoiceChannel.js.map +1 -1
  178. package/dist/src/structures/GuildTextChannel.d.ts +10 -1
  179. package/dist/src/structures/GuildTextChannel.d.ts.map +1 -1
  180. package/dist/src/structures/GuildTextChannel.js +21 -0
  181. package/dist/src/structures/GuildTextChannel.js.map +1 -1
  182. package/dist/src/structures/Message.d.ts +6 -2
  183. package/dist/src/structures/Message.d.ts.map +1 -1
  184. package/dist/src/structures/Message.js +67 -59
  185. package/dist/src/structures/Message.js.map +1 -1
  186. package/dist/src/structures/Poll.d.ts +5 -1
  187. package/dist/src/structures/Poll.d.ts.map +1 -1
  188. package/dist/src/structures/Poll.js +15 -9
  189. package/dist/src/structures/Poll.js.map +1 -1
  190. package/dist/src/structures/Role.d.ts +5 -1
  191. package/dist/src/structures/Role.d.ts.map +1 -1
  192. package/dist/src/structures/Role.js +37 -29
  193. package/dist/src/structures/Role.js.map +1 -1
  194. package/dist/src/structures/ThreadMember.d.ts +5 -1
  195. package/dist/src/structures/ThreadMember.d.ts.map +1 -1
  196. package/dist/src/structures/ThreadMember.js +21 -13
  197. package/dist/src/structures/ThreadMember.js.map +1 -1
  198. package/dist/src/structures/User.d.ts +5 -1
  199. package/dist/src/structures/User.d.ts.map +1 -1
  200. package/dist/src/structures/User.js +32 -24
  201. package/dist/src/structures/User.js.map +1 -1
  202. package/dist/src/structures/Webhook.d.ts +5 -1
  203. package/dist/src/structures/Webhook.d.ts.map +1 -1
  204. package/dist/src/structures/Webhook.js +32 -24
  205. package/dist/src/structures/Webhook.js.map +1 -1
  206. package/dist/src/types/index.d.ts +14 -0
  207. package/dist/src/types/index.d.ts.map +1 -1
  208. package/dist/src/types/index.js.map +1 -1
  209. package/dist/src/types/listeners.d.ts +28 -19
  210. package/dist/src/types/listeners.d.ts.map +1 -1
  211. package/dist/src/types/listeners.js +1 -1
  212. package/dist/src/types/listeners.js.map +1 -1
  213. package/dist/src/utils/customIdParser.d.ts.map +1 -1
  214. package/dist/src/utils/customIdParser.js +21 -4
  215. package/dist/src/utils/customIdParser.js.map +1 -1
  216. package/dist/src/utils/payload.d.ts.map +1 -1
  217. package/dist/src/utils/payload.js +20 -5
  218. package/dist/src/utils/payload.js.map +1 -1
  219. package/dist/tsconfig.tsbuildinfo +1 -1
  220. package/package.json +3 -3
@@ -0,0 +1,58 @@
1
+ import { type APIMentionableSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { MentionableSelectMenuInteraction } from "../../internals/MentionableSelectMenuInteraction.js";
4
+ import type { ComponentParserResult } from "../../types/index.js";
5
+ import type { ComponentData } from "../../types/index.js";
6
+ export declare abstract class ModalMentionableSelectMenu extends BaseModalComponent {
7
+ readonly type: ComponentType.MentionableSelect;
8
+ readonly isV2 = false;
9
+ /**
10
+ * The custom ID of the component.
11
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
+ *
13
+ * @see {@link customIdParser}
14
+ */
15
+ abstract customId: string;
16
+ /**
17
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
+ *
21
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
+ *
25
+ * @param id - The custom ID of the component as received from an interaction event
26
+ * @returns The base key and the data object
27
+ */
28
+ customIdParser: (id: string) => ComponentParserResult;
29
+ /**
30
+ * The minimum number of values that must be selected
31
+ */
32
+ minValues?: number;
33
+ /**
34
+ * The maximum number of values that can be selected
35
+ */
36
+ maxValues?: number;
37
+ /**
38
+ * Whether this component is required (defaults to true in modals)
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * The placeholder text for the select menu
43
+ */
44
+ placeholder?: string;
45
+ /**
46
+ * Default values for the select menu
47
+ */
48
+ defaultValues?: APIMentionableSelectComponent["default_values"];
49
+ abstract run(interaction: MentionableSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
+ serialize: () => APIMentionableSelectComponent;
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value: boolean | undefined);
56
+ get disabled(): boolean | undefined;
57
+ }
58
+ //# sourceMappingURL=ModalMentionableSelectMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalMentionableSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalMentionableSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,6BAA6B,EAClC,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,qDAAqD,CAAA;AAC3G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,0BAA2B,SAAQ,kBAAkB;IAC1E,QAAQ,CAAC,IAAI,kCAA2C;IACxD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,6BAA6B,CAAC,gBAAgB,CAAC,CAAA;IAE/D,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,gCAAgC,EAC7C,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,6BAA6B,CAgB5C;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -0,0 +1,68 @@
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalMentionableSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.MentionableSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ /**
37
+ * Default values for the select menu
38
+ */
39
+ defaultValues;
40
+ serialize = () => {
41
+ const data = {
42
+ type: this.type,
43
+ custom_id: this.customId,
44
+ placeholder: this.placeholder,
45
+ min_values: this.minValues,
46
+ max_values: this.maxValues,
47
+ default_values: this.defaultValues
48
+ };
49
+ // In modals, required defaults to true
50
+ if (this.required !== undefined) {
51
+ data.required = this.required;
52
+ }
53
+ return data;
54
+ };
55
+ /**
56
+ * The disabled field is not allowed on modal select components
57
+ * @throws Error when trying to set disabled to true
58
+ */
59
+ set disabled(value) {
60
+ if (value === true) {
61
+ throw new Error("The 'disabled' field is not allowed on modal select components");
62
+ }
63
+ }
64
+ get disabled() {
65
+ return undefined;
66
+ }
67
+ }
68
+ //# sourceMappingURL=ModalMentionableSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalMentionableSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalMentionableSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,0BAA2B,SAAQ,kBAAkB;IACjE,IAAI,GAAG,aAAa,CAAC,iBAA0B,CAAA;IAC/C,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,aAAa,CAAkD;IAO/D,SAAS,GAAG,GAAkC,EAAE;QAC/C,MAAM,IAAI,GAAkC;YAC3C,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -0,0 +1,58 @@
1
+ import { type APIRoleSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { RoleSelectMenuInteraction } from "../../internals/RoleSelectMenuInteraction.js";
4
+ import type { ComponentParserResult } from "../../types/index.js";
5
+ import type { ComponentData } from "../../types/index.js";
6
+ export declare abstract class ModalRoleSelectMenu extends BaseModalComponent {
7
+ readonly type: ComponentType.RoleSelect;
8
+ readonly isV2 = false;
9
+ /**
10
+ * The custom ID of the component.
11
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
+ *
13
+ * @see {@link customIdParser}
14
+ */
15
+ abstract customId: string;
16
+ /**
17
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
+ *
21
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
+ *
25
+ * @param id - The custom ID of the component as received from an interaction event
26
+ * @returns The base key and the data object
27
+ */
28
+ customIdParser: (id: string) => ComponentParserResult;
29
+ /**
30
+ * The minimum number of values that must be selected
31
+ */
32
+ minValues?: number;
33
+ /**
34
+ * The maximum number of values that can be selected
35
+ */
36
+ maxValues?: number;
37
+ /**
38
+ * Whether this component is required (defaults to true in modals)
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * The placeholder text for the select menu
43
+ */
44
+ placeholder?: string;
45
+ /**
46
+ * Default values for the select menu
47
+ */
48
+ defaultValues?: APIRoleSelectComponent["default_values"];
49
+ abstract run(interaction: RoleSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
+ serialize: () => APIRoleSelectComponent;
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value: boolean | undefined);
56
+ get disabled(): boolean | undefined;
57
+ }
58
+ //# sourceMappingURL=ModalRoleSelectMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalRoleSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalRoleSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,sBAAsB,EAC3B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAA;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,mBAAoB,SAAQ,kBAAkB;IACnE,QAAQ,CAAC,IAAI,2BAAoC;IACjD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;IAExD,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,yBAAyB,EACtC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,sBAAsB,CAgBrC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -0,0 +1,68 @@
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalRoleSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.RoleSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ /**
37
+ * Default values for the select menu
38
+ */
39
+ defaultValues;
40
+ serialize = () => {
41
+ const data = {
42
+ type: this.type,
43
+ custom_id: this.customId,
44
+ placeholder: this.placeholder,
45
+ min_values: this.minValues,
46
+ max_values: this.maxValues,
47
+ default_values: this.defaultValues
48
+ };
49
+ // In modals, required defaults to true
50
+ if (this.required !== undefined) {
51
+ data.required = this.required;
52
+ }
53
+ return data;
54
+ };
55
+ /**
56
+ * The disabled field is not allowed on modal select components
57
+ * @throws Error when trying to set disabled to true
58
+ */
59
+ set disabled(value) {
60
+ if (value === true) {
61
+ throw new Error("The 'disabled' field is not allowed on modal select components");
62
+ }
63
+ }
64
+ get disabled() {
65
+ return undefined;
66
+ }
67
+ }
68
+ //# sourceMappingURL=ModalRoleSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalRoleSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalRoleSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,mBAAoB,SAAQ,kBAAkB;IAC1D,IAAI,GAAG,aAAa,CAAC,UAAmB,CAAA;IACxC,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,aAAa,CAA2C;IAOxD,SAAS,GAAG,GAA2B,EAAE;QACxC,MAAM,IAAI,GAA2B;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -0,0 +1,58 @@
1
+ import { type APIStringSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { StringSelectMenuInteraction } from "../../internals/StringSelectMenuInteraction.js";
4
+ import type { ComponentParserResult } from "../../types/index.js";
5
+ import type { ComponentData } from "../../types/index.js";
6
+ export declare abstract class ModalStringSelectMenu extends BaseModalComponent {
7
+ readonly type: ComponentType.StringSelect;
8
+ readonly isV2 = false;
9
+ /**
10
+ * The custom ID of the component.
11
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
+ *
13
+ * @see {@link customIdParser}
14
+ */
15
+ abstract customId: string;
16
+ /**
17
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
+ *
21
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
+ *
25
+ * @param id - The custom ID of the component as received from an interaction event
26
+ * @returns The base key and the data object
27
+ */
28
+ customIdParser: (id: string) => ComponentParserResult;
29
+ /**
30
+ * The minimum number of values that must be selected
31
+ */
32
+ minValues?: number;
33
+ /**
34
+ * The maximum number of values that can be selected
35
+ */
36
+ maxValues?: number;
37
+ /**
38
+ * Whether this component is required (defaults to true in modals)
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * The placeholder text for the select menu
43
+ */
44
+ placeholder?: string;
45
+ /**
46
+ * The options for the select menu
47
+ */
48
+ abstract options: APIStringSelectComponent["options"];
49
+ abstract run(interaction: StringSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
+ serialize: () => APIStringSelectComponent;
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value: boolean | undefined);
56
+ get disabled(): boolean | undefined;
57
+ }
58
+ //# sourceMappingURL=ModalStringSelectMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalStringSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,wBAAwB,EAC7B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAA;AACjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,qBAAsB,SAAQ,kBAAkB;IACrE,QAAQ,CAAC,IAAI,6BAAsC;IACnD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;IAErD,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,2BAA2B,EACxC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,wBAAwB,CAgBvC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -0,0 +1,64 @@
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalStringSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.StringSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ serialize = () => {
37
+ const data = {
38
+ type: this.type,
39
+ custom_id: this.customId,
40
+ placeholder: this.placeholder,
41
+ min_values: this.minValues,
42
+ max_values: this.maxValues,
43
+ options: this.options
44
+ };
45
+ // In modals, required defaults to true
46
+ if (this.required !== undefined) {
47
+ data.required = this.required;
48
+ }
49
+ return data;
50
+ };
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value) {
56
+ if (value === true) {
57
+ throw new Error("The 'disabled' field is not allowed on modal select components");
58
+ }
59
+ }
60
+ get disabled() {
61
+ return undefined;
62
+ }
63
+ }
64
+ //# sourceMappingURL=ModalStringSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalStringSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,qBAAsB,SAAQ,kBAAkB;IAC5D,IAAI,GAAG,aAAa,CAAC,YAAqB,CAAA;IAC1C,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAYpB,SAAS,GAAG,GAA6B,EAAE;QAC1C,MAAM,IAAI,GAA6B;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -0,0 +1,58 @@
1
+ import { type APIUserSelectComponent, ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { UserSelectMenuInteraction } from "../../internals/UserSelectMenuInteraction.js";
4
+ import type { ComponentParserResult } from "../../types/index.js";
5
+ import type { ComponentData } from "../../types/index.js";
6
+ export declare abstract class ModalUserSelectMenu extends BaseModalComponent {
7
+ readonly type: ComponentType.UserSelect;
8
+ readonly isV2 = false;
9
+ /**
10
+ * The custom ID of the component.
11
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
+ *
13
+ * @see {@link customIdParser}
14
+ */
15
+ abstract customId: string;
16
+ /**
17
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
+ *
21
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
+ *
25
+ * @param id - The custom ID of the component as received from an interaction event
26
+ * @returns The base key and the data object
27
+ */
28
+ customIdParser: (id: string) => ComponentParserResult;
29
+ /**
30
+ * The minimum number of values that must be selected
31
+ */
32
+ minValues?: number;
33
+ /**
34
+ * The maximum number of values that can be selected
35
+ */
36
+ maxValues?: number;
37
+ /**
38
+ * Whether this component is required (defaults to true in modals)
39
+ */
40
+ required?: boolean;
41
+ /**
42
+ * The placeholder text for the select menu
43
+ */
44
+ placeholder?: string;
45
+ /**
46
+ * Default values for the select menu
47
+ */
48
+ defaultValues?: APIUserSelectComponent["default_values"];
49
+ abstract run(interaction: UserSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
+ serialize: () => APIUserSelectComponent;
51
+ /**
52
+ * The disabled field is not allowed on modal select components
53
+ * @throws Error when trying to set disabled to true
54
+ */
55
+ set disabled(value: boolean | undefined);
56
+ get disabled(): boolean | undefined;
57
+ }
58
+ //# sourceMappingURL=ModalUserSelectMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalUserSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalUserSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,sBAAsB,EAC3B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAA;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,mBAAoB,SAAQ,kBAAkB;IACnE,QAAQ,CAAC,IAAI,2BAAoC;IACjD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;IAExD,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,yBAAyB,EACtC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,sBAAsB,CAgBrC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -0,0 +1,68 @@
1
+ import { ComponentType } from "discord-api-types/v10";
2
+ import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import { parseCustomId } from "../../utils/customIdParser.js";
4
+ export class ModalUserSelectMenu extends BaseModalComponent {
5
+ type = ComponentType.UserSelect;
6
+ isV2 = false;
7
+ /**
8
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
+ *
12
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
+ *
16
+ * @param id - The custom ID of the component as received from an interaction event
17
+ * @returns The base key and the data object
18
+ */
19
+ customIdParser = parseCustomId;
20
+ /**
21
+ * The minimum number of values that must be selected
22
+ */
23
+ minValues;
24
+ /**
25
+ * The maximum number of values that can be selected
26
+ */
27
+ maxValues;
28
+ /**
29
+ * Whether this component is required (defaults to true in modals)
30
+ */
31
+ required;
32
+ /**
33
+ * The placeholder text for the select menu
34
+ */
35
+ placeholder;
36
+ /**
37
+ * Default values for the select menu
38
+ */
39
+ defaultValues;
40
+ serialize = () => {
41
+ const data = {
42
+ type: this.type,
43
+ custom_id: this.customId,
44
+ placeholder: this.placeholder,
45
+ min_values: this.minValues,
46
+ max_values: this.maxValues,
47
+ default_values: this.defaultValues
48
+ };
49
+ // In modals, required defaults to true
50
+ if (this.required !== undefined) {
51
+ data.required = this.required;
52
+ }
53
+ return data;
54
+ };
55
+ /**
56
+ * The disabled field is not allowed on modal select components
57
+ * @throws Error when trying to set disabled to true
58
+ */
59
+ set disabled(value) {
60
+ if (value === true) {
61
+ throw new Error("The 'disabled' field is not allowed on modal select components");
62
+ }
63
+ }
64
+ get disabled() {
65
+ return undefined;
66
+ }
67
+ }
68
+ //# sourceMappingURL=ModalUserSelectMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModalUserSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalUserSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,mBAAoB,SAAQ,kBAAkB;IAC1D,IAAI,GAAG,aAAa,CAAC,UAAmB,CAAA;IACxC,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,aAAa,CAA2C;IAOxD,SAAS,GAAG,GAA2B,EAAE;QACxC,MAAM,IAAI,GAA2B;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -1,8 +1,7 @@
1
- import { ComponentType } from "discord-api-types/v10";
1
+ import { type APIActionRowComponent, type APIComponentInMessageActionRow, ComponentType } from "discord-api-types/v10";
2
2
  import { BaseComponent } from "../../abstracts/BaseComponent.js";
3
3
  import type { BaseMessageInteractiveComponent } from "../../abstracts/BaseMessageInteractiveComponent.js";
4
- import type { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
5
- export declare class Row<T extends BaseMessageInteractiveComponent | BaseModalComponent = BaseMessageInteractiveComponent> extends BaseComponent {
4
+ export declare class Row<T extends BaseMessageInteractiveComponent> extends BaseComponent {
6
5
  readonly type: ComponentType.ActionRow;
7
6
  readonly isV2 = false;
8
7
  /**
@@ -24,6 +23,6 @@ export declare class Row<T extends BaseMessageInteractiveComponent | BaseModalCo
24
23
  * Remove all components from the action row
25
24
  */
26
25
  removeAllComponents(): void;
27
- serialize: () => ReturnType<BaseComponent["serialize"]>;
26
+ serialize: () => APIActionRowComponent<APIComponentInMessageActionRow>;
28
27
  }
29
28
  //# sourceMappingURL=Row.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/Row.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAChE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAA;AACzG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAE/E,qBAAa,GAAG,CACf,CAAC,SACE,+BAA+B,GAC/B,kBAAkB,GAAG,+BAA+B,CACtD,SAAQ,aAAa;IACtB,QAAQ,CAAC,IAAI,0BAAmC;IAChD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;OAEG;IACH,UAAU,EAAE,CAAC,EAAE,CAAK;gBAER,UAAU,CAAC,EAAE,CAAC,EAAE;IAK5B;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,CAAC;IAIzB;;;OAGG;IACH,eAAe,CAAC,SAAS,EAAE,CAAC;IAM5B;;OAEG;IACH,mBAAmB;IAInB,SAAS,QAAO,UAAU,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAQrD;CACD"}
1
+ {"version":3,"file":"Row.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/Row.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAChE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,oDAAoD,CAAA;AAEzG,qBAAa,GAAG,CACf,CAAC,SAAS,+BAA+B,CACxC,SAAQ,aAAa;IACtB,QAAQ,CAAC,IAAI,0BAAmC;IAChD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;OAEG;IACH,UAAU,EAAE,CAAC,EAAE,CAAK;gBAER,UAAU,CAAC,EAAE,CAAC,EAAE;IAK5B;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,CAAC;IAIzB;;;OAGG;IACH,eAAe,CAAC,SAAS,EAAE,CAAC;IAM5B;;OAEG;IACH,mBAAmB;IAInB,SAAS,QAAO,qBAAqB,CAAC,8BAA8B,CAAC,CAKpE;CACD"}
@@ -40,7 +40,6 @@ export class Row extends BaseComponent {
40
40
  type: ComponentType.ActionRow,
41
41
  components: this.components.map((component) => component.serialize())
42
42
  };
43
- // god i hate these types
44
43
  };
45
44
  }
46
45
  //# sourceMappingURL=Row.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../../src/classes/components/Row.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAIhE,MAAM,OAAO,GAIX,SAAQ,aAAa;IACb,IAAI,GAAG,aAAa,CAAC,SAAkB,CAAA;IACvC,IAAI,GAAG,KAAK,CAAA;IAErB;;OAEG;IACH,UAAU,GAAQ,EAAE,CAAA;IAEpB,YAAY,UAAgB;QAC3B,KAAK,EAAE,CAAA;QACP,IAAI,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC7C,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,SAAY;QACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,SAAY;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAChD,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,OAAM;QACxB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,mBAAmB;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;IACrB,CAAC;IAED,SAAS,GAAG,GAA2C,EAAE;QACxD,OAAO;YACN,IAAI,EAAE,aAAa,CAAC,SAAS;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;SAGhB,CAAA;QACtD,yBAAyB;IAC1B,CAAC,CAAA;CACD"}
1
+ {"version":3,"file":"Row.js","sourceRoot":"","sources":["../../../../src/classes/components/Row.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAGhE,MAAM,OAAO,GAEX,SAAQ,aAAa;IACb,IAAI,GAAG,aAAa,CAAC,SAAkB,CAAA;IACvC,IAAI,GAAG,KAAK,CAAA;IAErB;;OAEG;IACH,UAAU,GAAQ,EAAE,CAAA;IAEpB,YAAY,UAAgB;QAC3B,KAAK,EAAE,CAAA;QACP,IAAI,UAAU;YAAE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC7C,CAAC;IAED;;;OAGG;IACH,YAAY,CAAC,SAAY;QACxB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAChC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,SAAY;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAChD,IAAI,KAAK,KAAK,CAAC,CAAC;YAAE,OAAM;QACxB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,mBAAmB;QAClB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;IACrB,CAAC;IAED,SAAS,GAAG,GAA0D,EAAE;QACvE,OAAO;YACN,IAAI,EAAE,aAAa,CAAC,SAAS;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;SACrE,CAAA;IACF,CAAC,CAAA;CACD"}
@@ -1,16 +1,29 @@
1
1
  import { type APITextInputComponent, ComponentType, TextInputStyle } from "discord-api-types/v10";
2
2
  import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
+ import type { ComponentParserResult } from "../../types/index.js";
3
4
  export declare abstract class TextInput extends BaseModalComponent {
4
5
  readonly type: ComponentType.TextInput;
5
6
  readonly isV2 = false;
6
7
  /**
7
- * The custom ID of the text input
8
+ * The custom ID of the component.
9
+ * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
10
+ *
11
+ * @see {@link customIdParser}
8
12
  */
9
13
  abstract customId: string;
10
14
  /**
11
- * The label of the text input
12
- */
13
- abstract label: string;
15
+ * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
16
+ * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
17
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
18
+ *
19
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
20
+ * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
21
+ * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
22
+ *
23
+ * @param id - The custom ID of the component as received from an interaction event
24
+ * @returns The base key and the data object
25
+ */
26
+ customIdParser: (id: string) => ComponentParserResult;
14
27
  /**
15
28
  * The style of the text input
16
29
  * @default TextInputStyle.Short
@@ -1 +1 @@
1
- {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/TextInput.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,qBAAqB,EAC1B,aAAa,EACb,cAAc,EACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAE1E,8BAAsB,SAAU,SAAQ,kBAAkB;IACzD,QAAQ,CAAC,IAAI,0BAAmC;IAChD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAuB;IAE5C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,SAAS,QAAO,qBAAqB,CAYpC;CACD"}
1
+ {"version":3,"file":"TextInput.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/TextInput.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,qBAAqB,EAC1B,aAAa,EACb,cAAc,EACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AAGjE,8BAAsB,SAAU,SAAQ,kBAAkB;IACzD,QAAQ,CAAC,IAAI,0BAAmC;IAChD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;;OAGG;IACH,KAAK,EAAE,cAAc,CAAuB;IAE5C;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,SAAS,QAAO,qBAAqB,CAWpC;CACD"}