@buape/carbon 0.8.0 → 0.10.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 (277) hide show
  1. package/dist/package.json +7 -7
  2. package/dist/src/abstracts/AnySelectMenu.d.ts +2 -1
  3. package/dist/src/abstracts/AnySelectMenu.d.ts.map +1 -1
  4. package/dist/src/abstracts/AnySelectMenu.js +6 -0
  5. package/dist/src/abstracts/AnySelectMenu.js.map +1 -1
  6. package/dist/src/abstracts/AnySelectMenuInteraction.d.ts +0 -1
  7. package/dist/src/abstracts/AnySelectMenuInteraction.d.ts.map +1 -1
  8. package/dist/src/abstracts/AnySelectMenuInteraction.js +0 -2
  9. package/dist/src/abstracts/AnySelectMenuInteraction.js.map +1 -1
  10. package/dist/src/abstracts/BaseChannel.d.ts +10 -1
  11. package/dist/src/abstracts/BaseChannel.d.ts.map +1 -1
  12. package/dist/src/abstracts/BaseChannel.js +13 -0
  13. package/dist/src/abstracts/BaseChannel.js.map +1 -1
  14. package/dist/src/abstracts/BaseCommand.d.ts +18 -8
  15. package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
  16. package/dist/src/abstracts/BaseCommand.js +24 -7
  17. package/dist/src/abstracts/BaseCommand.js.map +1 -1
  18. package/dist/src/abstracts/BaseComponentInteraction.d.ts +0 -1
  19. package/dist/src/abstracts/BaseComponentInteraction.d.ts.map +1 -1
  20. package/dist/src/abstracts/BaseComponentInteraction.js +3 -3
  21. package/dist/src/abstracts/BaseComponentInteraction.js.map +1 -1
  22. package/dist/src/abstracts/BaseGuildChannel.d.ts +3 -2
  23. package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
  24. package/dist/src/abstracts/BaseGuildChannel.js +5 -3
  25. package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
  26. package/dist/src/abstracts/BaseGuildTextChannel.d.ts +1 -1
  27. package/dist/src/abstracts/BaseGuildTextChannel.d.ts.map +1 -1
  28. package/dist/src/abstracts/BaseInteraction.d.ts +45 -2
  29. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
  30. package/dist/src/abstracts/BaseInteraction.js +99 -14
  31. package/dist/src/abstracts/BaseInteraction.js.map +1 -1
  32. package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts +18 -12
  33. package/dist/src/abstracts/BaseMessageInteractiveComponent.d.ts.map +1 -1
  34. package/dist/src/abstracts/BaseMessageInteractiveComponent.js +18 -18
  35. package/dist/src/abstracts/BaseMessageInteractiveComponent.js.map +1 -1
  36. package/dist/src/abstracts/BaseModalComponent.d.ts +16 -10
  37. package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -1
  38. package/dist/src/abstracts/BaseModalComponent.js +25 -17
  39. package/dist/src/abstracts/BaseModalComponent.js.map +1 -1
  40. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +11 -4
  41. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
  42. package/dist/src/abstracts/GuildThreadOnlyChannel.js +14 -1
  43. package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
  44. package/dist/src/abstracts/Plugin.d.ts +1 -1
  45. package/dist/src/abstracts/Plugin.d.ts.map +1 -1
  46. package/dist/src/classes/Client.d.ts +32 -8
  47. package/dist/src/classes/Client.d.ts.map +1 -1
  48. package/dist/src/classes/Client.js +76 -17
  49. package/dist/src/classes/Client.js.map +1 -1
  50. package/dist/src/classes/ClientWithCaching.d.ts +51 -0
  51. package/dist/src/classes/ClientWithCaching.d.ts.map +1 -0
  52. package/dist/src/classes/ClientWithCaching.js +108 -0
  53. package/dist/src/classes/ClientWithCaching.js.map +1 -0
  54. package/dist/src/classes/Command.d.ts +10 -2
  55. package/dist/src/classes/Command.d.ts.map +1 -1
  56. package/dist/src/classes/Command.js +12 -1
  57. package/dist/src/classes/Command.js.map +1 -1
  58. package/dist/src/classes/Listener.d.ts +20 -0
  59. package/dist/src/classes/Listener.d.ts.map +1 -1
  60. package/dist/src/classes/Listener.js +116 -14
  61. package/dist/src/classes/Listener.js.map +1 -1
  62. package/dist/src/classes/Modal.d.ts +19 -2
  63. package/dist/src/classes/Modal.d.ts.map +1 -1
  64. package/dist/src/classes/Modal.js +14 -0
  65. package/dist/src/classes/Modal.js.map +1 -1
  66. package/dist/src/classes/RequestClient.d.ts +7 -5
  67. package/dist/src/classes/RequestClient.d.ts.map +1 -1
  68. package/dist/src/classes/RequestClient.js +28 -16
  69. package/dist/src/classes/RequestClient.js.map +1 -1
  70. package/dist/src/classes/components/Button.d.ts +3 -1
  71. package/dist/src/classes/components/Button.d.ts.map +1 -1
  72. package/dist/src/classes/components/Button.js +10 -1
  73. package/dist/src/classes/components/Button.js.map +1 -1
  74. package/dist/src/classes/components/ChannelSelectMenu.d.ts +2 -1
  75. package/dist/src/classes/components/ChannelSelectMenu.d.ts.map +1 -1
  76. package/dist/src/classes/components/ChannelSelectMenu.js +6 -0
  77. package/dist/src/classes/components/ChannelSelectMenu.js.map +1 -1
  78. package/dist/src/classes/components/Container.d.ts +0 -3
  79. package/dist/src/classes/components/Container.d.ts.map +1 -1
  80. package/dist/src/classes/components/Container.js +0 -3
  81. package/dist/src/classes/components/Container.js.map +1 -1
  82. package/dist/src/classes/components/MentionableSelectMenu.d.ts +2 -1
  83. package/dist/src/classes/components/MentionableSelectMenu.d.ts.map +1 -1
  84. package/dist/src/classes/components/MentionableSelectMenu.js +6 -0
  85. package/dist/src/classes/components/MentionableSelectMenu.js.map +1 -1
  86. package/dist/src/classes/components/RoleSelectMenu.d.ts +2 -1
  87. package/dist/src/classes/components/RoleSelectMenu.d.ts.map +1 -1
  88. package/dist/src/classes/components/RoleSelectMenu.js +6 -0
  89. package/dist/src/classes/components/RoleSelectMenu.js.map +1 -1
  90. package/dist/src/classes/components/StringSelectMenu.d.ts +2 -1
  91. package/dist/src/classes/components/StringSelectMenu.d.ts.map +1 -1
  92. package/dist/src/classes/components/StringSelectMenu.js +6 -0
  93. package/dist/src/classes/components/StringSelectMenu.js.map +1 -1
  94. package/dist/src/classes/components/UserSelectMenu.d.ts +2 -1
  95. package/dist/src/classes/components/UserSelectMenu.d.ts.map +1 -1
  96. package/dist/src/classes/components/UserSelectMenu.js +6 -0
  97. package/dist/src/classes/components/UserSelectMenu.js.map +1 -1
  98. package/dist/src/functions/enforceChoicesLimit.d.ts +3 -0
  99. package/dist/src/functions/enforceChoicesLimit.d.ts.map +1 -0
  100. package/dist/src/functions/enforceChoicesLimit.js +17 -0
  101. package/dist/src/functions/enforceChoicesLimit.js.map +1 -0
  102. package/dist/src/functions/errorsMapper.d.ts.map +1 -1
  103. package/dist/src/functions/errorsMapper.js +13 -1
  104. package/dist/src/functions/errorsMapper.js.map +1 -1
  105. package/dist/src/index.d.ts +8 -54
  106. package/dist/src/index.d.ts.map +1 -1
  107. package/dist/src/index.js +9 -5
  108. package/dist/src/index.js.map +1 -1
  109. package/dist/src/internals/AutocompleteInteraction.d.ts +9 -3
  110. package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
  111. package/dist/src/internals/AutocompleteInteraction.js +13 -3
  112. package/dist/src/internals/AutocompleteInteraction.js.map +1 -1
  113. package/dist/src/internals/ButtonInteraction.d.ts +0 -1
  114. package/dist/src/internals/ButtonInteraction.d.ts.map +1 -1
  115. package/dist/src/internals/ButtonInteraction.js +0 -2
  116. package/dist/src/internals/ButtonInteraction.js.map +1 -1
  117. package/dist/src/internals/Cache.d.ts +76 -0
  118. package/dist/src/internals/Cache.d.ts.map +1 -0
  119. package/dist/src/internals/Cache.js +122 -0
  120. package/dist/src/internals/Cache.js.map +1 -0
  121. package/dist/src/internals/CommandHandler.d.ts +2 -1
  122. package/dist/src/internals/CommandHandler.d.ts.map +1 -1
  123. package/dist/src/internals/CommandHandler.js +44 -13
  124. package/dist/src/internals/CommandHandler.js.map +1 -1
  125. package/dist/src/internals/CommandInteraction.d.ts +7 -1
  126. package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
  127. package/dist/src/internals/CommandInteraction.js +10 -4
  128. package/dist/src/internals/CommandInteraction.js.map +1 -1
  129. package/dist/src/internals/ComponentHandler.d.ts +5 -2
  130. package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
  131. package/dist/src/internals/ComponentHandler.js +34 -10
  132. package/dist/src/internals/ComponentHandler.js.map +1 -1
  133. package/dist/src/internals/ModalHandler.d.ts +1 -1
  134. package/dist/src/internals/ModalHandler.d.ts.map +1 -1
  135. package/dist/src/internals/ModalHandler.js +6 -2
  136. package/dist/src/internals/ModalHandler.js.map +1 -1
  137. package/dist/src/internals/ModalInteraction.js +1 -1
  138. package/dist/src/internals/ModalInteraction.js.map +1 -1
  139. package/dist/src/internals/OptionsHandler.d.ts +13 -3
  140. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  141. package/dist/src/internals/OptionsHandler.js +51 -1
  142. package/dist/src/internals/OptionsHandler.js.map +1 -1
  143. package/dist/src/permissions.d.ts +54 -0
  144. package/dist/src/permissions.d.ts.map +1 -0
  145. package/dist/src/permissions.js +4 -0
  146. package/dist/src/permissions.js.map +1 -0
  147. package/dist/src/plugins/command-data/CommandDataPlugin.d.ts +16 -0
  148. package/dist/src/plugins/command-data/CommandDataPlugin.d.ts.map +1 -0
  149. package/dist/src/plugins/command-data/CommandDataPlugin.js +46 -0
  150. package/dist/src/plugins/command-data/CommandDataPlugin.js.map +1 -0
  151. package/dist/src/plugins/command-data/index.d.ts +2 -0
  152. package/dist/src/plugins/command-data/index.d.ts.map +1 -0
  153. package/dist/src/plugins/command-data/index.js +2 -0
  154. package/dist/src/plugins/command-data/index.js.map +1 -0
  155. package/dist/src/plugins/gateway/GatewayPlugin.d.ts +47 -3
  156. package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
  157. package/dist/src/plugins/gateway/GatewayPlugin.js +169 -22
  158. package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
  159. package/dist/src/plugins/gateway/types.d.ts +58 -0
  160. package/dist/src/plugins/gateway/types.d.ts.map +1 -1
  161. package/dist/src/plugins/gateway/types.js.map +1 -1
  162. package/dist/src/plugins/gateway/utils/monitor.d.ts +2 -0
  163. package/dist/src/plugins/gateway/utils/monitor.d.ts.map +1 -1
  164. package/dist/src/plugins/gateway/utils/monitor.js +10 -1
  165. package/dist/src/plugins/gateway/utils/monitor.js.map +1 -1
  166. package/dist/src/plugins/gateway/utils/payload.d.ts +8 -5
  167. package/dist/src/plugins/gateway/utils/payload.d.ts.map +1 -1
  168. package/dist/src/plugins/gateway/utils/payload.js +20 -1
  169. package/dist/src/plugins/gateway/utils/payload.js.map +1 -1
  170. package/dist/src/plugins/gateway/utils/rateLimit.d.ts +41 -0
  171. package/dist/src/plugins/gateway/utils/rateLimit.d.ts.map +1 -0
  172. package/dist/src/plugins/gateway/utils/rateLimit.js +61 -0
  173. package/dist/src/plugins/gateway/utils/rateLimit.js.map +1 -0
  174. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +1 -1
  175. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
  176. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +2 -2
  177. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
  178. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts +10 -0
  179. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts.map +1 -0
  180. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js +11 -0
  181. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js.map +1 -0
  182. package/dist/src/plugins/gateway-forwarder/index.d.ts +1 -0
  183. package/dist/src/plugins/gateway-forwarder/index.d.ts.map +1 -1
  184. package/dist/src/plugins/gateway-forwarder/index.js +1 -0
  185. package/dist/src/plugins/gateway-forwarder/index.js.map +1 -1
  186. package/dist/src/plugins/paginator/GoToPageModal.d.ts +24 -0
  187. package/dist/src/plugins/paginator/GoToPageModal.d.ts.map +1 -0
  188. package/dist/src/plugins/paginator/GoToPageModal.js +50 -0
  189. package/dist/src/plugins/paginator/GoToPageModal.js.map +1 -0
  190. package/dist/src/plugins/paginator/Paginator.d.ts +53 -0
  191. package/dist/src/plugins/paginator/Paginator.d.ts.map +1 -0
  192. package/dist/src/plugins/paginator/Paginator.js +183 -0
  193. package/dist/src/plugins/paginator/Paginator.js.map +1 -0
  194. package/dist/src/plugins/paginator/index.d.ts +9 -0
  195. package/dist/src/plugins/paginator/index.d.ts.map +1 -0
  196. package/dist/src/plugins/paginator/index.js +9 -0
  197. package/dist/src/plugins/paginator/index.js.map +1 -0
  198. package/dist/src/plugins/sharding/ShardingPlugin.d.ts +3 -1
  199. package/dist/src/plugins/sharding/ShardingPlugin.d.ts.map +1 -1
  200. package/dist/src/plugins/sharding/ShardingPlugin.js +11 -2
  201. package/dist/src/plugins/sharding/ShardingPlugin.js.map +1 -1
  202. package/dist/src/structures/DmChannel.d.ts +3 -3
  203. package/dist/src/structures/DmChannel.d.ts.map +1 -1
  204. package/dist/src/structures/DmChannel.js +5 -3
  205. package/dist/src/structures/DmChannel.js.map +1 -1
  206. package/dist/src/structures/GroupDmChannel.d.ts +1 -1
  207. package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
  208. package/dist/src/structures/Guild.d.ts +184 -5
  209. package/dist/src/structures/Guild.d.ts.map +1 -1
  210. package/dist/src/structures/Guild.js +406 -12
  211. package/dist/src/structures/Guild.js.map +1 -1
  212. package/dist/src/structures/GuildCategoryChannel.d.ts +1 -1
  213. package/dist/src/structures/GuildCategoryChannel.d.ts.map +1 -1
  214. package/dist/src/structures/GuildForumChannel.d.ts +1 -1
  215. package/dist/src/structures/GuildForumChannel.d.ts.map +1 -1
  216. package/dist/src/structures/GuildMember.d.ts +15 -12
  217. package/dist/src/structures/GuildMember.d.ts.map +1 -1
  218. package/dist/src/structures/GuildMember.js +78 -19
  219. package/dist/src/structures/GuildMember.js.map +1 -1
  220. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts +1 -1
  221. package/dist/src/structures/GuildStageOrVoiceChannel.d.ts.map +1 -1
  222. package/dist/src/structures/GuildTextChannel.d.ts +1 -1
  223. package/dist/src/structures/GuildTextChannel.d.ts.map +1 -1
  224. package/dist/src/structures/GuildThreadChannel.d.ts +1 -1
  225. package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -1
  226. package/dist/src/structures/Message.d.ts +29 -10
  227. package/dist/src/structures/Message.d.ts.map +1 -1
  228. package/dist/src/structures/Message.js +82 -18
  229. package/dist/src/structures/Message.js.map +1 -1
  230. package/dist/src/structures/Poll.d.ts +25 -0
  231. package/dist/src/structures/Poll.d.ts.map +1 -0
  232. package/dist/src/structures/Poll.js +45 -0
  233. package/dist/src/structures/Poll.js.map +1 -0
  234. package/dist/src/structures/Role.d.ts +29 -12
  235. package/dist/src/structures/Role.d.ts.map +1 -1
  236. package/dist/src/structures/Role.js +48 -21
  237. package/dist/src/structures/Role.js.map +1 -1
  238. package/dist/src/structures/ThreadMember.d.ts +36 -0
  239. package/dist/src/structures/ThreadMember.d.ts.map +1 -0
  240. package/dist/src/structures/ThreadMember.js +72 -0
  241. package/dist/src/structures/ThreadMember.js.map +1 -0
  242. package/dist/src/structures/User.d.ts +7 -2
  243. package/dist/src/structures/User.d.ts.map +1 -1
  244. package/dist/src/structures/User.js +8 -1
  245. package/dist/src/structures/User.js.map +1 -1
  246. package/dist/src/structures/Webhook.d.ts +135 -0
  247. package/dist/src/structures/Webhook.d.ts.map +1 -0
  248. package/dist/src/structures/Webhook.js +239 -0
  249. package/dist/src/structures/Webhook.js.map +1 -0
  250. package/dist/src/types/index.d.ts +73 -8
  251. package/dist/src/types/index.d.ts.map +1 -1
  252. package/dist/src/types/index.js.map +1 -1
  253. package/dist/src/types/listeners.d.ts +71 -44
  254. package/dist/src/types/listeners.d.ts.map +1 -1
  255. package/dist/src/types/listeners.js.map +1 -1
  256. package/dist/src/utils/customIdParser.d.ts +3 -0
  257. package/dist/src/utils/customIdParser.d.ts.map +1 -0
  258. package/dist/src/utils/customIdParser.js +17 -0
  259. package/dist/src/utils/customIdParser.js.map +1 -0
  260. package/dist/src/utils/index.d.ts +4 -0
  261. package/dist/src/utils/index.d.ts.map +1 -0
  262. package/dist/src/utils/index.js +4 -0
  263. package/dist/src/utils/index.js.map +1 -0
  264. package/dist/src/utils/payload.d.ts +4 -0
  265. package/dist/src/utils/payload.d.ts.map +1 -0
  266. package/dist/src/utils/payload.js +45 -0
  267. package/dist/src/utils/payload.js.map +1 -0
  268. package/dist/src/utils/verification.d.ts +4 -0
  269. package/dist/src/utils/verification.d.ts.map +1 -0
  270. package/dist/src/utils/verification.js +52 -0
  271. package/dist/src/utils/verification.js.map +1 -0
  272. package/dist/tsconfig.tsbuildinfo +1 -1
  273. package/package.json +7 -7
  274. package/dist/src/utils.d.ts +0 -9
  275. package/dist/src/utils.d.ts.map +0 -1
  276. package/dist/src/utils.js +0 -93
  277. package/dist/src/utils.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { InteractionResponseType, MessageFlags, Routes } from "discord-api-types/v10";
2
- import { Embed, Guild, Message, User, channelFactory } from "../index.js";
2
+ import { BaseMessageInteractiveComponent, Container, Embed, Guild, Message, Row, Section, User, channelFactory } from "../index.js";
3
3
  import { GuildMember } from "../structures/GuildMember.js";
4
- import { serializePayload } from "../utils.js";
4
+ import { serializePayload } from "../utils/index.js";
5
5
  import { Base } from "./Base.js";
6
6
  /**
7
7
  * This is the base type interaction, all interaction types extend from this
@@ -68,26 +68,73 @@ export class BaseInteraction extends Base {
68
68
  return null;
69
69
  return new GuildMember(this.client, this.rawData.member, this.guild);
70
70
  }
71
+ /**
72
+ * @internal
73
+ * Automatically register components found in a message payload when sending the message.
74
+ */
75
+ _internalAutoRegisterComponentsOnSend(data) {
76
+ if (typeof data !== "string" && data.components) {
77
+ this._internalRegisterComponentsOnSend(data.components);
78
+ }
79
+ }
80
+ /**
81
+ * @internal
82
+ * Register components found in a message payload when sending the message.
83
+ */
84
+ _internalRegisterComponentsOnSend(components) {
85
+ for (const component of components) {
86
+ if (component instanceof Row) {
87
+ for (const childComponent of component.components) {
88
+ if (childComponent instanceof BaseMessageInteractiveComponent) {
89
+ const key = childComponent.customIdParser(childComponent.customId).key;
90
+ const existingComponent = this.client.componentHandler.components.find((comp) => comp.customIdParser(comp.customId).key === key);
91
+ if (!existingComponent) {
92
+ this.client.componentHandler.registerComponent(childComponent);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ else if (component instanceof Section) {
98
+ if (component.accessory instanceof BaseMessageInteractiveComponent) {
99
+ const key = component.accessory.customIdParser(component.accessory.customId).key;
100
+ const existingComponent = this.client.componentHandler.components.find((comp) => comp.customIdParser(comp.customId).key === key);
101
+ if (!existingComponent) {
102
+ this.client.componentHandler.registerComponent(component.accessory);
103
+ }
104
+ }
105
+ }
106
+ else if (component instanceof Container) {
107
+ this._internalRegisterComponentsOnSend(component.components);
108
+ }
109
+ }
110
+ }
71
111
  /**
72
112
  * Reply to an interaction.
73
113
  * If the interaction is deferred, this will edit the original response.
74
- * @param data The response data
114
+ * @param data The message data to send
75
115
  */
76
- async reply(data) {
116
+ async reply(data, overrideAutoRegister = false) {
77
117
  const serialized = serializePayload(data, this.defaultEphemeral);
118
+ // Auto-register any components in the message
119
+ if (!overrideAutoRegister)
120
+ this._internalAutoRegisterComponentsOnSend(data);
78
121
  if (this._deferred) {
79
- await this.client.rest.patch(Routes.webhookMessage(this.client.options.clientId, this.rawData.token, "@original"), {
122
+ const message = (await this.client.rest.patch(Routes.webhookMessage(this.client.options.clientId, this.rawData.token, "@original"), {
80
123
  body: serialized
81
- });
82
- }
83
- else {
84
- await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
85
- body: {
86
- type: InteractionResponseType.ChannelMessageWithSource,
87
- data: serialized
88
- }
89
- });
124
+ }));
125
+ return new Message(this.client, message);
90
126
  }
127
+ const done = (await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
128
+ body: {
129
+ type: InteractionResponseType.ChannelMessageWithSource,
130
+ data: serialized
131
+ }
132
+ }, {
133
+ with_response: true
134
+ }));
135
+ if (!done.resource?.message)
136
+ throw new Error(`No resource returned for message from interaction callback: ${done.resource}`);
137
+ return new Message(this.client, done.resource.message);
91
138
  }
92
139
  /**
93
140
  * Defer the interaction response. This is used automatically by commands that are set to defer.
@@ -116,6 +163,11 @@ export class BaseInteraction extends Base {
116
163
  async showModal(modal) {
117
164
  if (this._deferred)
118
165
  throw new Error("You cannot defer an interaction that shows a modal");
166
+ const key = modal.customIdParser(modal.customId).key;
167
+ const existingModal = this.client.modalHandler.modals.find((m) => m.customIdParser(m.customId).key === key);
168
+ if (!existingModal) {
169
+ this.client.modalHandler.registerModal(modal);
170
+ }
119
171
  await this.client.rest.post(Routes.interactionCallback(this.rawData.id, this.rawData.token), {
120
172
  body: {
121
173
  type: InteractionResponseType.Modal,
@@ -128,11 +180,44 @@ export class BaseInteraction extends Base {
128
180
  */
129
181
  async followUp(reply) {
130
182
  const serialized = serializePayload(reply);
183
+ // Auto-register any components in the message
184
+ this._internalAutoRegisterComponentsOnSend(reply);
131
185
  await this.client.rest.post(Routes.webhook(this.client.options.clientId, this.rawData.token), {
132
186
  body: {
133
187
  ...serialized
134
188
  }
135
189
  });
136
190
  }
191
+ /**
192
+ * This function will reply to the interaction and wait for a component to be pressed.
193
+ * Any components passed in the message will not have run() functions called and
194
+ * will only trigger the interaction.acknowledge() function.
195
+ * This function will also return a promise that resolves
196
+ * to the custom ID of the component that was pressed.
197
+ *
198
+ * @param data The message data to send
199
+ * @param timeout After this many milliseconds, the promise will resolve to null
200
+ */
201
+ async replyAndWaitForComponent(data, timeout = 300000) {
202
+ const message = await this.reply(data, true);
203
+ const id = `${message.id}-${message.channelId}`;
204
+ return new Promise((resolve) => {
205
+ const timer = setTimeout(() => {
206
+ this.client.componentHandler.oneOffComponents.delete(id);
207
+ resolve({ success: false, reason: "timed out" });
208
+ }, timeout);
209
+ this.client.componentHandler.oneOffComponents.set(id, {
210
+ resolve: (data) => {
211
+ clearTimeout(timer);
212
+ this.client.componentHandler.oneOffComponents.delete(id);
213
+ resolve({
214
+ success: true,
215
+ customId: data.custom_id,
216
+ values: "values" in data ? data.values : undefined
217
+ });
218
+ }
219
+ });
220
+ });
221
+ }
137
222
  }
138
223
  //# sourceMappingURL=BaseInteraction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseInteraction.js","sourceRoot":"","sources":["../../../src/abstracts/BaseInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,uBAAuB,EAEvB,YAAY,EAGZ,MAAM,EACN,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAEN,KAAK,EACL,KAAK,EACL,OAAO,EAEP,IAAI,EACJ,cAAc,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAMhC;;GAEG;AACH,MAAM,OAAgB,eAA0C,SAAQ,IAAI;IAC3E;;OAEG;IACH,IAAI,CAAiB;IACrB;;OAEG;IACH,OAAO,CAAG;IACV;;OAEG;IACH,MAAM,CAAoB;IAE1B;;;OAGG;IACH,SAAS,GAAG,KAAK,CAAA;IAET,gBAAgB,GAAG,KAAK,CAAA;IAEhC,YAAY,MAAc,EAAE,IAAO,EAAE,QAA6B;QACjE,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QACrB,IAAI,CAAC,MAAM;YACV,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,SAAS,CAAA;QACnE,IAAI,QAAQ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AO,CAAC,SAAS,EAAE,CAAA;QAEtE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9B,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;gBAC7B,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;gBACxD,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;YACjD,CAAC,EAAE,OAAO,CAAC,CAAA;YACX,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE;gBACrD,OAAO,EAAE,CAAC,IAAwC,EAAE,EAAE;oBACrD,YAAY,CAAC,KAAK,CAAC,CAAA;oBACnB,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;oBACxD,OAAO,CAAC;wBACP,OAAO,EAAE,IAAI;wBACb,QAAQ,EAAE,IAAI,CAAC,SAAS;wBACxB,MAAM,EAAE,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;qBAClD,CAAC,CAAA;gBACH,CAAC;aACD,CAAC,CAAA;QACH,CAAC,CAAC,CAAA;IACH,CAAC;CACD"}
@@ -1,14 +1,10 @@
1
1
  import type { APIComponentInMessageActionRow, ComponentType } from "discord-api-types/v10";
2
+ import type { ComponentData, ComponentParserResult } from "../types/index.js";
2
3
  import { BaseComponent } from "./BaseComponent.js";
3
- export type ComponentAdditionalData = {
4
- [key: string]: string | number | boolean;
5
- };
4
+ import type { BaseComponentInteraction } from "./BaseComponentInteraction.js";
6
5
  export declare abstract class BaseMessageInteractiveComponent extends BaseComponent {
7
6
  abstract type: ComponentType.Button | ComponentType.StringSelect | ComponentType.TextInput | ComponentType.UserSelect | ComponentType.RoleSelect | ComponentType.MentionableSelect | ComponentType.ChannelSelect;
8
7
  readonly isV2 = false;
9
- constructor(data?: {
10
- additionalData?: ComponentAdditionalData;
11
- });
12
8
  /**
13
9
  * Whether the component response should be automatically deferred
14
10
  */
@@ -18,16 +14,26 @@ export declare abstract class BaseMessageInteractiveComponent extends BaseCompon
18
14
  */
19
15
  ephemeral: boolean;
20
16
  /**
21
- * The custom ID of the component
17
+ * The custom ID of the component.
18
+ * 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.
19
+ *
20
+ * @see {@link customIdParser}
22
21
  */
23
22
  abstract customId: string;
24
- additionalData: ComponentAdditionalData | null;
25
23
  /**
26
- * Create a custom ID to use for this component that embeds additional data that you want to be handed
27
- * @param additionalData The additional data that you want to be passed in this component's custom ID
28
- * @returns The custom ID to use
24
+ * 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.
25
+ * 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.
26
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
27
+ *
28
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
29
+ * - 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.
30
+ * - 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.
31
+ *
32
+ * @param id - The custom ID of the component as received from an interaction event
33
+ * @returns The base key and the data object
29
34
  */
30
- createId: (additionalData: typeof this.additionalData) => string;
35
+ customIdParser: (id: string) => ComponentParserResult;
31
36
  abstract serialize: () => APIComponentInMessageActionRow;
37
+ run(interaction: BaseComponentInteraction, data: ComponentData): unknown | Promise<unknown>;
32
38
  }
33
39
  //# sourceMappingURL=BaseMessageInteractiveComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseMessageInteractiveComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,8BAA8B,EAC9B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,MAAM,uBAAuB,GAAG;IACrC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CACxC,CAAA;AAED,8BAAsB,+BAAgC,SAAQ,aAAa;IAC1E,QAAQ,CAAC,IAAI,EACV,aAAa,CAAC,MAAM,GACpB,aAAa,CAAC,YAAY,GAC1B,aAAa,CAAC,SAAS,GACvB,aAAa,CAAC,UAAU,GACxB,aAAa,CAAC,UAAU,GACxB,aAAa,CAAC,iBAAiB,GAC/B,aAAa,CAAC,aAAa,CAAA;IAE9B,QAAQ,CAAC,IAAI,SAAQ;gBAET,IAAI,CAAC,EAAE;QAClB,cAAc,CAAC,EAAE,uBAAuB,CAAA;KACxC;IAKD;;OAEG;IACH,KAAK,UAAQ;IACb;;OAEG;IACH,SAAS,UAAQ;IAEjB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB,cAAc,EAAE,uBAAuB,GAAG,IAAI,CAAO;IAErD;;;;OAIG;IACI,QAAQ,GAAI,gBAAgB,OAAO,IAAI,CAAC,cAAc,YAO5D;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,8BAA8B,CAAA;CACxD"}
1
+ {"version":3,"file":"BaseMessageInteractiveComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,8BAA8B,EAC9B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AAE7E,8BAAsB,+BAAgC,SAAQ,aAAa;IAC1E,QAAQ,CAAC,IAAI,EACV,aAAa,CAAC,MAAM,GACpB,aAAa,CAAC,YAAY,GAC1B,aAAa,CAAC,SAAS,GACvB,aAAa,CAAC,UAAU,GACxB,aAAa,CAAC,UAAU,GACxB,aAAa,CAAC,iBAAiB,GAC/B,aAAa,CAAC,aAAa,CAAA;IAE9B,QAAQ,CAAC,IAAI,SAAQ;IAErB;;OAEG;IACH,KAAK,UAAQ;IACb;;OAEG;IACH,SAAS,UAAQ;IAEjB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE,QAAQ,CAAC,SAAS,EAAE,MAAM,8BAA8B,CAAA;IAExD,GAAG,CACF,WAAW,EAAE,wBAAwB,EACrC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;CAM7B"}
@@ -1,11 +1,7 @@
1
+ import { parseCustomId } from "../utils/customIdParser.js";
1
2
  import { BaseComponent } from "./BaseComponent.js";
2
3
  export class BaseMessageInteractiveComponent extends BaseComponent {
3
4
  isV2 = false;
4
- constructor(data) {
5
- super();
6
- if (data?.additionalData)
7
- this.additionalData = data.additionalData;
8
- }
9
5
  /**
10
6
  * Whether the component response should be automatically deferred
11
7
  */
@@ -14,20 +10,24 @@ export class BaseMessageInteractiveComponent extends BaseComponent {
14
10
  * Whether the component response should be ephemeral
15
11
  */
16
12
  ephemeral = false;
17
- additionalData = null;
18
13
  /**
19
- * Create a custom ID to use for this component that embeds additional data that you want to be handed
20
- * @param additionalData The additional data that you want to be passed in this component's custom ID
21
- * @returns The custom ID to use
14
+ * 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.
15
+ * 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.
16
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
17
+ *
18
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
19
+ * - 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.
20
+ * - 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.
21
+ *
22
+ * @param id - The custom ID of the component as received from an interaction event
23
+ * @returns The base key and the data object
22
24
  */
23
- createId = (additionalData) => {
24
- if (!additionalData)
25
- return this.customId;
26
- // id:arg1=1;arg2=2
27
- const id = `${this.customId}:${Object.entries(additionalData)
28
- .map(([key, value]) => `${key}=${value}`)
29
- .join(";")}`;
30
- return id;
31
- };
25
+ customIdParser = parseCustomId;
26
+ run(interaction, data) {
27
+ // Random things to show the vars as used
28
+ typeof interaction === "string";
29
+ typeof data === "string";
30
+ return;
31
+ }
32
32
  }
33
33
  //# sourceMappingURL=BaseMessageInteractiveComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseMessageInteractiveComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAMlD,MAAM,OAAgB,+BAAgC,SAAQ,aAAa;IAUjE,IAAI,GAAG,KAAK,CAAA;IAErB,YAAY,IAEX;QACA,KAAK,EAAE,CAAA;QACP,IAAI,IAAI,EAAE,cAAc;YAAE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;IACpE,CAAC;IAED;;OAEG;IACH,KAAK,GAAG,KAAK,CAAA;IACb;;OAEG;IACH,SAAS,GAAG,KAAK,CAAA;IAOjB,cAAc,GAAmC,IAAI,CAAA;IAErD;;;;OAIG;IACI,QAAQ,GAAG,CAAC,cAA0C,EAAE,EAAE;QAChE,IAAI,CAAC,cAAc;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAA;QACzC,mBAAmB;QACnB,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;aAC3D,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC;aACxC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;QACb,OAAO,EAAE,CAAA;IACV,CAAC,CAAA;CAGD"}
1
+ {"version":3,"file":"BaseMessageInteractiveComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseMessageInteractiveComponent.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,MAAM,OAAgB,+BAAgC,SAAQ,aAAa;IAUjE,IAAI,GAAG,KAAK,CAAA;IAErB;;OAEG;IACH,KAAK,GAAG,KAAK,CAAA;IACb;;OAEG;IACH,SAAS,GAAG,KAAK,CAAA;IAUjB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAIrE,GAAG,CACF,WAAqC,EACrC,IAAmB;QAEnB,yCAAyC;QACzC,OAAO,WAAW,KAAK,QAAQ,CAAA;QAC/B,OAAO,IAAI,KAAK,QAAQ,CAAA;QACxB,OAAM;IACP,CAAC;CACD"}
@@ -1,23 +1,29 @@
1
1
  import type { APIComponentInModalActionRow, ComponentType } from "discord-api-types/v10";
2
+ import type { ComponentParserResult } from "../types/index.js";
2
3
  import { BaseComponent } from "./BaseComponent.js";
3
- import type { ComponentAdditionalData } from "./BaseMessageInteractiveComponent.js";
4
4
  export declare abstract class BaseModalComponent extends BaseComponent {
5
5
  abstract type: ComponentType.TextInput;
6
6
  readonly isV2 = false;
7
- constructor(data?: {
8
- additionalData?: ComponentAdditionalData;
9
- });
10
7
  /**
11
- * The custom ID of the component
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}
12
12
  */
13
13
  abstract customId: string;
14
- additionalData: ComponentAdditionalData | null;
15
14
  /**
16
- * Create a custom ID to use for this component that embeds additional data that you want to be handed
17
- * @param additionalData The additional data that you want to be passed in this component's custom ID
18
- * @returns The custom ID to use
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
19
25
  */
20
- createId: (additionalData: typeof this.additionalData) => string;
26
+ customIdParser: (id: string) => ComponentParserResult;
21
27
  abstract serialize: () => APIComponentInModalActionRow;
22
28
  }
23
29
  //# sourceMappingURL=BaseModalComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseModalComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,4BAA4B,EAC5B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAEnF,8BAAsB,kBAAmB,SAAQ,aAAa;IAC7D,SAAkB,IAAI,EAAE,aAAa,CAAC,SAAS,CAAA;IAE/C,QAAQ,CAAC,IAAI,SAAQ;gBAET,IAAI,CAAC,EAAE;QAClB,cAAc,CAAC,EAAE,uBAAuB,CAAA;KACxC;IAKD;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB,cAAc,EAAE,uBAAuB,GAAG,IAAI,CAAO;IAErD;;;;OAIG;IACI,QAAQ,GAAI,gBAAgB,OAAO,IAAI,CAAC,cAAc,YAO5D;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,4BAA4B,CAAA;CACtD"}
1
+ {"version":3,"file":"BaseModalComponent.d.ts","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,4BAA4B,EAC5B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,8BAAsB,kBAAmB,SAAQ,aAAa;IAC7D,SAAkB,IAAI,EAAE,aAAa,CAAC,SAAS,CAAA;IAE/C,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAcpD;IAED,QAAQ,CAAC,SAAS,EAAE,MAAM,4BAA4B,CAAA;CACtD"}
@@ -1,25 +1,33 @@
1
1
  import { BaseComponent } from "./BaseComponent.js";
2
2
  export class BaseModalComponent extends BaseComponent {
3
3
  isV2 = false;
4
- constructor(data) {
5
- super();
6
- if (data?.additionalData)
7
- this.additionalData = data.additionalData;
8
- }
9
- additionalData = null;
10
4
  /**
11
- * Create a custom ID to use for this component that embeds additional data that you want to be handed
12
- * @param additionalData The additional data that you want to be passed in this component's custom ID
13
- * @returns The custom ID to use
5
+ * 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.
6
+ * 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.
7
+ * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
8
+ *
9
+ * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
10
+ * - 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.
11
+ * - 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.
12
+ *
13
+ * @param id - The custom ID of the component as received from an interaction event
14
+ * @returns The base key and the data object
14
15
  */
15
- createId = (additionalData) => {
16
- if (!additionalData)
17
- return this.customId;
18
- // id:arg1=1;arg2=2
19
- const id = `${this.customId}:${Object.entries(additionalData)
20
- .map(([key, value]) => `${key}=${value}`)
21
- .join(";")}`;
22
- return id;
16
+ customIdParser = (id) => {
17
+ const [key, ...data] = id.split(":");
18
+ if (!key)
19
+ throw new Error(`Invalid component ID: ${id}`);
20
+ return {
21
+ key,
22
+ data: Object.fromEntries(data.map((d) => {
23
+ const [k, v] = d.split("=");
24
+ if (v === "true")
25
+ return [k, true];
26
+ if (v === "false")
27
+ return [k, false];
28
+ return [k, Number.isNaN(Number(v)) ? v : Number(v)];
29
+ }))
30
+ };
23
31
  };
24
32
  }
25
33
  //# sourceMappingURL=BaseModalComponent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseModalComponent.js","sourceRoot":"","sources":["../../../src/abstracts/BaseModalComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,MAAM,OAAgB,kBAAmB,SAAQ,aAAa;IAGpD,IAAI,GAAG,KAAK,CAAA;IAErB,YAAY,IAEX;QACA,KAAK,EAAE,CAAA;QACP,IAAI,IAAI,EAAE,cAAc;YAAE,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CAAC,EAAE,IAAI,CAAC,CAAA;gBAClC,IAAI,CAAC,KAAK,OAAO;oBAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;gBACpC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAA;YACpD,CAAC,CAAC,CACF;SACD,CAAA;IACF,CAAC,CAAA;CAGD"}
@@ -1,6 +1,8 @@
1
- import type { APIGuildForumDefaultReactionEmoji, APIGuildForumTag, APIThreadOnlyChannel, ChannelType, SortOrderType } from "discord-api-types/v10";
1
+ import type { APIGuildForumDefaultReactionEmoji, APIGuildForumTag, APIThreadOnlyChannel, ChannelType, SortOrderType, ThreadChannelType } from "discord-api-types/v10";
2
+ import { GuildThreadChannel } from "../structures/GuildThreadChannel.js";
3
+ import type { Message } from "../structures/Message.js";
2
4
  import type { MessagePayload } from "../types/index.js";
3
- import type { IfPartial } from "../utils.js";
5
+ import type { IfPartial } from "../types/index.js";
4
6
  import { BaseGuildChannel } from "./BaseGuildChannel.js";
5
7
  export declare abstract class GuildThreadOnlyChannel<Type extends ChannelType.GuildForum | ChannelType.GuildMedia, IsPartial extends boolean = false> extends BaseGuildChannel<Type, IsPartial> {
6
8
  rawData: APIThreadOnlyChannel<Type> | null;
@@ -32,12 +34,17 @@ export declare abstract class GuildThreadOnlyChannel<Type extends ChannelType.Gu
32
34
  * You cannot send a message directly to a forum or media channel, so this method throws an error.
33
35
  * Use {@link GuildThreadChannel.send} instead, or the alias {@link GuildThreadOnlyChannel.sendToPost} instead, to send a message to the channel's posts.
34
36
  */
35
- send(): Promise<void>;
37
+ send(): Promise<never>;
36
38
  /**
37
39
  * Send a message to a post in the channel
38
40
  * @remarks
39
41
  * This is an alias for {@link GuildThreadChannel.send} that will fetch the channel, but if you already have the channel, you can use {@link GuildThreadChannel.send} instead.
40
42
  */
41
- sendToPost(message: MessagePayload, postId: string): Promise<void>;
43
+ sendToPost(message: MessagePayload, postId: string): Promise<Message>;
44
+ createPost(name: string, message: MessagePayload, options?: {
45
+ autoArchiveDuration?: number;
46
+ rateLimitPerUser?: number;
47
+ appliedTags?: string[];
48
+ }): Promise<GuildThreadChannel<ThreadChannelType>>;
42
49
  }
43
50
  //# sourceMappingURL=GuildThreadOnlyChannel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GuildThreadOnlyChannel.d.ts","sourceRoot":"","sources":["../../../src/abstracts/GuildThreadOnlyChannel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,iCAAiC,EACjC,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,aAAa,EAEb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,8BAAsB,sBAAsB,CAC3C,IAAI,SAAS,WAAW,CAAC,UAAU,GAAG,WAAW,CAAC,UAAU,EAC5D,SAAS,SAAS,OAAO,GAAG,KAAK,CAChC,SAAQ,gBAAgB,CAAC,IAAI,EAAE,SAAS,CAAC;IAClC,OAAO,EAAE,oBAAoB,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;IAElD;;OAEG;IACH,IAAI,KAAK,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAG/C;IAED;;OAEG;IACH,IAAI,0BAA0B,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGpE;IAED;;OAEG;IACH,IAAI,6BAA6B,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGvE;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,SAAS,CAAC,SAAS,EAAE,g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I,0BAA0B,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGpE;IAED;;OAEG;IACH,IAAI,6BAA6B,IAAI,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC,CAGvE;IAED;;OAEG;IACH,IAAI,aAAa,IAAI,SAAS,CAAC,SAAS,EAAE,gBAAgB,EAAE,CAAC,CAG5D;IAED;;OAEG;IACH,IAAI,oBAAoB,IAAI,SAAS,CACpC,SAAS,EACT,iCAAiC,GAAG,IAAI,CACxC,CAGA;IAED;;OAEG;IACH,IAAI,gBAAgB,IAAI,SAAS,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAAC,CAGjE;IAED;;;OAGG;IACY,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC;IAMrC;;;;OAIG;IACG,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQrE,UAAU,CACf,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,EACvB,OAAO,CAAC,EAAE;QACT,mBAAmB,CAAC,EAAE,MAAM,CAAA;QAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;QACzB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;KACtB,GACC,OAAO,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;CAejD"}
@@ -1,3 +1,4 @@
1
+ import { Routes } from "discord-api-types/v10";
1
2
  import { GuildThreadChannel } from "../structures/GuildThreadChannel.js";
2
3
  import { BaseGuildChannel } from "./BaseGuildChannel.js";
3
4
  export class GuildThreadOnlyChannel extends BaseGuildChannel {
@@ -63,7 +64,19 @@ export class GuildThreadOnlyChannel extends BaseGuildChannel {
63
64
  */
64
65
  async sendToPost(message, postId) {
65
66
  const channel = new GuildThreadChannel(this.client, postId);
66
- await channel.send(message);
67
+ return await channel.send(message);
68
+ }
69
+ async createPost(name, message, options) {
70
+ const response = (await this.client.rest.post(Routes.threads(this.id), {
71
+ body: {
72
+ name,
73
+ message,
74
+ auto_archive_duration: options?.autoArchiveDuration,
75
+ rate_limit_per_user: options?.rateLimitPerUser,
76
+ applied_tags: options?.appliedTags
77
+ }
78
+ }));
79
+ return new GuildThreadChannel(this.client, response);
67
80
  }
68
81
  }
69
82
  //# sourceMappingURL=GuildThreadOnlyChannel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GuildThreadOnlyChannel.js","sourceRoot":"","sources":["../../../src/abstracts/GuildThreadOnlyChannel.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAGxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,MAAM,OAAgB,sBAGpB,SAAQ,gBAAiC;IAG1C;;OAEG;IACH,IAAI,KAAK;QACR,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,IAAI,CAAA;IAClC,CAAC;IAED;;OAEG;IACH,IAAI,0BAA0B;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,6BAA6B,IAAI,IAAI,CAAA;IAC1D,CAAC;IAED;;OAEG;IACH,IAAI,6BAA6B;QAChC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,kCAAkC,IAAI,IAAI,CAAA;IAC/D,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QAChB,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO,SAAkB,CAAA;QAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,IAAI,EAAE,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,IAAI,oBAAoB;QAIvB,IAAI,CAAC,IAAI,CAAC,OAA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E,OAAO,EAAE,gBAAgB;gBAC9C,YAAY,EAAE,OAAO,EAAE,WAAW;aAClC;SACD,CAAC,CAAqB,CAAA;QACvB,OAAO,IAAI,kBAAkB,CAC5B,IAAI,CAAC,MAAM,EACX,QAAkE,CAClE,CAAA;IACF,CAAC;CACD"}
@@ -6,7 +6,7 @@ export declare abstract class Plugin {
6
6
  /**
7
7
  * An ID that identifies the plugin uniquely between all other used plugins in the Client
8
8
  */
9
- protected abstract id: string;
9
+ abstract readonly id: string;
10
10
  /**
11
11
  * Registers the client with this plugin
12
12
  * @param client The client to register
@@ -1 +1 @@
1
- {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../src/abstracts/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD;;GAEG;AACH,8BAAsB,MAAM;IAC3B;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAC7B;;;OAGG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAErD;;;OAGG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CACrD;AAED,MAAM,WAAW,KAAK;IACrB;;OAEG;IACH,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IAEnD;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,EAAE,CAAA;IAElB;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAElE;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,OAAO;IAEvB,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;CACvC"}
1
+ {"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../../src/abstracts/Plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAElD;;GAEG;AACH,8BAAsB,MAAM;IAC3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAC5B;;;OAGG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAErD;;;OAGG;IACH,cAAc,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CACrD;AAED,MAAM,WAAW,KAAK;IACrB;;OAEG;IACH,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;IAEnD;;OAEG;IACH,IAAI,EAAE,IAAI,MAAM,EAAE,CAAA;IAElB;;;;;OAKG;IACH,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAElE;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,OAAO;IAEvB,SAAS,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;CACvC"}
@@ -1,5 +1,6 @@
1
1
  import type { BaseCommand } from "../abstracts/BaseCommand.js";
2
2
  import type { BaseListener } from "../abstracts/BaseListener.js";
3
+ import type { BaseMessageInteractiveComponent } from "../abstracts/BaseMessageInteractiveComponent.js";
3
4
  import type { Context, Plugin, Route } from "../abstracts/Plugin.js";
4
5
  import { CommandHandler } from "../internals/CommandHandler.js";
5
6
  import { ComponentHandler } from "../internals/ComponentHandler.js";
@@ -10,6 +11,7 @@ import { GuildMember } from "../structures/GuildMember.js";
10
11
  import { Message } from "../structures/Message.js";
11
12
  import { Role } from "../structures/Role.js";
12
13
  import { User } from "../structures/User.js";
14
+ import { Webhook, type WebhookInput } from "../structures/Webhook.js";
13
15
  import { RequestClient, type RequestClientOptions } from "./RequestClient.js";
14
16
  /**
15
17
  * The options used for initializing the client
@@ -45,12 +47,6 @@ export interface ClientOptions {
45
47
  * @default false
46
48
  */
47
49
  autoDeploy?: boolean;
48
- /**
49
- * Whether components and modals should not be registered automatically.
50
- * If you want you register components yourself (e.g. you are changing them at runtime), you can manually call {@link ComponentHandler#registerComponent} and {@link ModalHandler#registerModal} on the client.
51
- * @default false
52
- */
53
- disableAutoRegister?: boolean;
54
50
  /**
55
51
  * Whether the deploy route should be disabled.
56
52
  * @default false
@@ -66,6 +62,11 @@ export interface ClientOptions {
66
62
  * @default false
67
63
  */
68
64
  disableEventsRoute?: boolean;
65
+ /**
66
+ * A list of guild IDs to deploy all commands to during development (guild command deployment is instant and rate-limited higher).
67
+ * If set, all commands will be deployed to these guilds instead of globally.
68
+ */
69
+ devGuilds?: string[];
69
70
  }
70
71
  /**
71
72
  * The main client used to interact with Discord
@@ -78,7 +79,10 @@ export declare class Client {
78
79
  /**
79
80
  * The plugins that the client has registered
80
81
  */
81
- plugins: Plugin[];
82
+ plugins: {
83
+ id: string;
84
+ plugin: Plugin;
85
+ }[];
82
86
  /**
83
87
  * The options used to initialize the client
84
88
  */
@@ -91,6 +95,10 @@ export declare class Client {
91
95
  * The event listeners that the client has registered
92
96
  */
93
97
  listeners: BaseListener[];
98
+ /**
99
+ * The components that the client has globally registered
100
+ */
101
+ components: BaseMessageInteractiveComponent[];
94
102
  /**
95
103
  * The rest client used to interact with the Discord API
96
104
  */
@@ -115,6 +123,14 @@ export declare class Client {
115
123
  * @internal
116
124
  */
117
125
  eventHandler: EventHandler;
126
+ /**
127
+ * The ID of the shard this client is running on, if sharding is enabled
128
+ */
129
+ shardId?: number;
130
+ /**
131
+ * The total number of shards, if sharding is enabled
132
+ */
133
+ totalShards?: number;
118
134
  /**
119
135
  * Creates a new client
120
136
  * @param options The options used to initialize the client
@@ -124,7 +140,9 @@ export declare class Client {
124
140
  constructor(options: ClientOptions, handlers: {
125
141
  commands?: BaseCommand[];
126
142
  listeners?: BaseListener[];
143
+ components?: BaseMessageInteractiveComponent[];
127
144
  }, plugins?: Plugin[]);
145
+ getPlugin<T extends Plugin>(id: string): T | undefined;
128
146
  private appendRoutes;
129
147
  /**
130
148
  * Handle a request to deploy the commands to Discord
@@ -148,7 +166,7 @@ export declare class Client {
148
166
  * Validate a request from Discord
149
167
  * @param req The request to validate
150
168
  */
151
- private validateDiscordRequest;
169
+ protected validateDiscordRequest(req: Request): Promise<boolean>;
152
170
  /**
153
171
  * Fetch a user from the Discord API
154
172
  * @param id The ID of the user to fetch
@@ -187,6 +205,12 @@ export declare class Client {
187
205
  * @returns The message data
188
206
  */
189
207
  fetchMessage(channelId: string, messageId: string): Promise<Message<false>>;
208
+ /**
209
+ * Fetch a webhook from the Discord API
210
+ * @param input The webhook data, ID and token, or webhook URL
211
+ * @returns The webhook data
212
+ */
213
+ fetchWebhook(input: WebhookInput): Promise<Webhook<false>>;
190
214
  }
191
215
  /**
192
216
  * @hidden