@mostfeatured/dbi 0.1.46 → 0.2.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 (299) hide show
  1. package/dist/src/DBI.d.ts.map +1 -0
  2. package/dist/src/DBI.js.map +1 -0
  3. package/dist/src/Events.d.ts.map +1 -0
  4. package/dist/src/Events.js.map +1 -0
  5. package/dist/src/index.d.ts.map +1 -0
  6. package/dist/src/index.js.map +1 -0
  7. package/dist/src/methods/handleMessageCommands.d.ts.map +1 -0
  8. package/dist/src/methods/handleMessageCommands.js.map +1 -0
  9. package/dist/src/methods/hookEventListeners.d.ts.map +1 -0
  10. package/dist/src/methods/hookEventListeners.js.map +1 -0
  11. package/dist/src/methods/hookInteractionListeners.d.ts.map +1 -0
  12. package/dist/{methods → src/methods}/hookInteractionListeners.js +22 -12
  13. package/dist/src/methods/hookInteractionListeners.js.map +1 -0
  14. package/dist/src/methods/publishInteractions.d.ts.map +1 -0
  15. package/dist/src/methods/publishInteractions.js.map +1 -0
  16. package/dist/src/types/ApplicationRoleConnectionMetadata.d.ts.map +1 -0
  17. package/dist/src/types/ApplicationRoleConnectionMetadata.js.map +1 -0
  18. package/dist/src/types/Builders/ButtonBuilder.d.ts.map +1 -0
  19. package/dist/src/types/Builders/ButtonBuilder.js.map +1 -0
  20. package/dist/src/types/Builders/ChannelSelectMenuBuilder.d.ts.map +1 -0
  21. package/dist/src/types/Builders/ChannelSelectMenuBuilder.js.map +1 -0
  22. package/dist/src/types/Builders/MentionableSelectMenuBuilder.d.ts.map +1 -0
  23. package/dist/src/types/Builders/MentionableSelectMenuBuilder.js.map +1 -0
  24. package/dist/src/types/Builders/ModalBuilder.d.ts.map +1 -0
  25. package/dist/src/types/Builders/ModalBuilder.js.map +1 -0
  26. package/dist/src/types/Builders/RoleSelectMenuBuilder.d.ts.map +1 -0
  27. package/dist/src/types/Builders/RoleSelectMenuBuilder.js.map +1 -0
  28. package/dist/src/types/Builders/StringSelectMenuBuilder.d.ts.map +1 -0
  29. package/dist/src/types/Builders/StringSelectMenuBuilder.js.map +1 -0
  30. package/dist/src/types/Builders/UserSelectMenuBuilder.d.ts.map +1 -0
  31. package/dist/src/types/Builders/UserSelectMenuBuilder.js.map +1 -0
  32. package/dist/src/types/ChatInput/ChatInput.d.ts.map +1 -0
  33. package/dist/src/types/ChatInput/ChatInput.js.map +1 -0
  34. package/dist/{types → src/types}/ChatInput/ChatInputOptions.d.ts +2 -2
  35. package/dist/src/types/ChatInput/ChatInputOptions.d.ts.map +1 -0
  36. package/dist/src/types/ChatInput/ChatInputOptions.js.map +1 -0
  37. package/dist/src/types/Components/Button.d.ts.map +1 -0
  38. package/dist/src/types/Components/Button.js.map +1 -0
  39. package/dist/src/types/Components/ChannelSelectMenu.d.ts.map +1 -0
  40. package/dist/src/types/Components/ChannelSelectMenu.js.map +1 -0
  41. package/dist/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.d.ts.map +1 -0
  42. package/dist/src/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.js.map +1 -0
  43. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts +91 -0
  44. package/dist/src/types/Components/HTMLComponentsV2/index.d.ts.map +1 -0
  45. package/dist/src/types/Components/HTMLComponentsV2/index.js +300 -0
  46. package/dist/src/types/Components/HTMLComponentsV2/index.js.map +1 -0
  47. package/dist/src/types/Components/HTMLComponentsV2/parser.d.ts.map +1 -0
  48. package/dist/{types → src/types}/Components/HTMLComponentsV2/parser.js +11 -4
  49. package/dist/src/types/Components/HTMLComponentsV2/parser.js.map +1 -0
  50. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts +35 -0
  51. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.d.ts.map +1 -0
  52. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js +822 -0
  53. package/dist/src/types/Components/HTMLComponentsV2/svelteParser.js.map +1 -0
  54. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts +24 -0
  55. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.d.ts.map +1 -0
  56. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js +294 -0
  57. package/dist/src/types/Components/HTMLComponentsV2/svelteRenderer.js.map +1 -0
  58. package/dist/src/types/Components/MentionableSelectMenu.d.ts.map +1 -0
  59. package/dist/src/types/Components/MentionableSelectMenu.js.map +1 -0
  60. package/dist/src/types/Components/Modal.d.ts.map +1 -0
  61. package/dist/src/types/Components/Modal.js.map +1 -0
  62. package/dist/src/types/Components/RoleSelectMenu.d.ts.map +1 -0
  63. package/dist/src/types/Components/RoleSelectMenu.js.map +1 -0
  64. package/dist/src/types/Components/StringSelectMenu.d.ts.map +1 -0
  65. package/dist/src/types/Components/StringSelectMenu.js.map +1 -0
  66. package/dist/src/types/Components/UserSelectMenu.d.ts.map +1 -0
  67. package/dist/src/types/Components/UserSelectMenu.js.map +1 -0
  68. package/dist/src/types/Event.d.ts.map +1 -0
  69. package/dist/src/types/Event.js.map +1 -0
  70. package/dist/src/types/Interaction.d.ts.map +1 -0
  71. package/dist/src/types/Interaction.js.map +1 -0
  72. package/dist/src/types/other/CustomEvent.d.ts.map +1 -0
  73. package/dist/src/types/other/CustomEvent.js.map +1 -0
  74. package/dist/src/types/other/FakeMessageInteraction.d.ts.map +1 -0
  75. package/dist/src/types/other/FakeMessageInteraction.js.map +1 -0
  76. package/dist/src/types/other/InteractionLocale.d.ts.map +1 -0
  77. package/dist/src/types/other/InteractionLocale.js.map +1 -0
  78. package/dist/src/types/other/Locale.d.ts.map +1 -0
  79. package/dist/src/types/other/Locale.js.map +1 -0
  80. package/dist/src/types/other/MessageContextMenu.d.ts.map +1 -0
  81. package/dist/src/types/other/MessageContextMenu.js.map +1 -0
  82. package/dist/src/types/other/UserContextMenu.d.ts.map +1 -0
  83. package/dist/src/types/other/UserContextMenu.js.map +1 -0
  84. package/dist/src/utils/MemoryStore.d.ts.map +1 -0
  85. package/dist/src/utils/MemoryStore.js.map +1 -0
  86. package/dist/src/utils/UtilTypes.d.ts.map +1 -0
  87. package/dist/src/utils/UtilTypes.js.map +1 -0
  88. package/dist/src/utils/customId.d.ts.map +1 -0
  89. package/dist/src/utils/customId.js.map +1 -0
  90. package/dist/src/utils/permissions.d.ts.map +1 -0
  91. package/dist/src/utils/permissions.js.map +1 -0
  92. package/dist/src/utils/recursiveImport.d.ts.map +1 -0
  93. package/dist/src/utils/recursiveImport.js.map +1 -0
  94. package/dist/src/utils/recursiveUnload.d.ts.map +1 -0
  95. package/dist/src/utils/recursiveUnload.js.map +1 -0
  96. package/dist/src/utils/unloadModule.d.ts.map +1 -0
  97. package/dist/src/utils/unloadModule.js.map +1 -0
  98. package/dist/test/index.d.ts +2 -0
  99. package/dist/test/index.d.ts.map +1 -0
  100. package/dist/test/index.js +103 -0
  101. package/dist/test/index.js.map +1 -0
  102. package/docs/ADVANCED_FEATURES.md +836 -0
  103. package/docs/API_REFERENCE.md +925 -0
  104. package/docs/CHAT_INPUT.md +807 -0
  105. package/docs/COMPONENTS.md +1035 -0
  106. package/docs/EVENTS.md +564 -0
  107. package/docs/GETTING_STARTED.md +394 -0
  108. package/docs/LOCALIZATION.md +773 -0
  109. package/docs/README.md +341 -0
  110. package/docs/SVELTE_COMPONENTS.md +955 -0
  111. package/generated/globals.d.ts +1 -0
  112. package/generated/index.d.ts +30 -0
  113. package/generated/svelte-dbi.d.ts +588 -0
  114. package/package.json +57 -47
  115. package/readme.md +168 -491
  116. package/src/methods/hookInteractionListeners.ts +23 -12
  117. package/src/types/Components/HTMLComponentsV2/index.ts +353 -12
  118. package/src/types/Components/HTMLComponentsV2/parser.ts +14 -4
  119. package/src/types/Components/HTMLComponentsV2/svelteParser.ts +904 -0
  120. package/src/types/Components/HTMLComponentsV2/svelteRenderer.ts +332 -0
  121. package/test/index.ts +105 -0
  122. package/test/product-showcase.svelte +199 -0
  123. package/tsconfig.json +13 -3
  124. package/dist/DBI.d.ts.map +0 -1
  125. package/dist/DBI.js.map +0 -1
  126. package/dist/Events.d.ts.map +0 -1
  127. package/dist/Events.js.map +0 -1
  128. package/dist/index.d.ts.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/methods/handleMessageCommands.d.ts.map +0 -1
  131. package/dist/methods/handleMessageCommands.js.map +0 -1
  132. package/dist/methods/hookEventListeners.d.ts.map +0 -1
  133. package/dist/methods/hookEventListeners.js.map +0 -1
  134. package/dist/methods/hookInteractionListeners.d.ts.map +0 -1
  135. package/dist/methods/hookInteractionListeners.js.map +0 -1
  136. package/dist/methods/publishInteractions.d.ts.map +0 -1
  137. package/dist/methods/publishInteractions.js.map +0 -1
  138. package/dist/types/ApplicationRoleConnectionMetadata.d.ts.map +0 -1
  139. package/dist/types/ApplicationRoleConnectionMetadata.js.map +0 -1
  140. package/dist/types/Builders/ButtonBuilder.d.ts.map +0 -1
  141. package/dist/types/Builders/ButtonBuilder.js.map +0 -1
  142. package/dist/types/Builders/ChannelSelectMenuBuilder.d.ts.map +0 -1
  143. package/dist/types/Builders/ChannelSelectMenuBuilder.js.map +0 -1
  144. package/dist/types/Builders/MentionableSelectMenuBuilder.d.ts.map +0 -1
  145. package/dist/types/Builders/MentionableSelectMenuBuilder.js.map +0 -1
  146. package/dist/types/Builders/ModalBuilder.d.ts.map +0 -1
  147. package/dist/types/Builders/ModalBuilder.js.map +0 -1
  148. package/dist/types/Builders/RoleSelectMenuBuilder.d.ts.map +0 -1
  149. package/dist/types/Builders/RoleSelectMenuBuilder.js.map +0 -1
  150. package/dist/types/Builders/StringSelectMenuBuilder.d.ts.map +0 -1
  151. package/dist/types/Builders/StringSelectMenuBuilder.js.map +0 -1
  152. package/dist/types/Builders/UserSelectMenuBuilder.d.ts.map +0 -1
  153. package/dist/types/Builders/UserSelectMenuBuilder.js.map +0 -1
  154. package/dist/types/ChatInput/ChatInput.d.ts.map +0 -1
  155. package/dist/types/ChatInput/ChatInput.js.map +0 -1
  156. package/dist/types/ChatInput/ChatInputOptions.d.ts.map +0 -1
  157. package/dist/types/ChatInput/ChatInputOptions.js.map +0 -1
  158. package/dist/types/Components/Button.d.ts.map +0 -1
  159. package/dist/types/Components/Button.js.map +0 -1
  160. package/dist/types/Components/ChannelSelectMenu.d.ts.map +0 -1
  161. package/dist/types/Components/ChannelSelectMenu.js.map +0 -1
  162. package/dist/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.d.ts.map +0 -1
  163. package/dist/types/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.js.map +0 -1
  164. package/dist/types/Components/HTMLComponentsV2/index.d.ts +0 -19
  165. package/dist/types/Components/HTMLComponentsV2/index.d.ts.map +0 -1
  166. package/dist/types/Components/HTMLComponentsV2/index.js +0 -31
  167. package/dist/types/Components/HTMLComponentsV2/index.js.map +0 -1
  168. package/dist/types/Components/HTMLComponentsV2/parser.d.ts.map +0 -1
  169. package/dist/types/Components/HTMLComponentsV2/parser.js.map +0 -1
  170. package/dist/types/Components/MentionableSelectMenu.d.ts.map +0 -1
  171. package/dist/types/Components/MentionableSelectMenu.js.map +0 -1
  172. package/dist/types/Components/Modal.d.ts.map +0 -1
  173. package/dist/types/Components/Modal.js.map +0 -1
  174. package/dist/types/Components/RoleSelectMenu.d.ts.map +0 -1
  175. package/dist/types/Components/RoleSelectMenu.js.map +0 -1
  176. package/dist/types/Components/StringSelectMenu.d.ts.map +0 -1
  177. package/dist/types/Components/StringSelectMenu.js.map +0 -1
  178. package/dist/types/Components/UserSelectMenu.d.ts.map +0 -1
  179. package/dist/types/Components/UserSelectMenu.js.map +0 -1
  180. package/dist/types/Event.d.ts.map +0 -1
  181. package/dist/types/Event.js.map +0 -1
  182. package/dist/types/Interaction.d.ts.map +0 -1
  183. package/dist/types/Interaction.js.map +0 -1
  184. package/dist/types/other/CustomEvent.d.ts.map +0 -1
  185. package/dist/types/other/CustomEvent.js.map +0 -1
  186. package/dist/types/other/FakeMessageInteraction.d.ts.map +0 -1
  187. package/dist/types/other/FakeMessageInteraction.js.map +0 -1
  188. package/dist/types/other/InteractionLocale.d.ts.map +0 -1
  189. package/dist/types/other/InteractionLocale.js.map +0 -1
  190. package/dist/types/other/Locale.d.ts.map +0 -1
  191. package/dist/types/other/Locale.js.map +0 -1
  192. package/dist/types/other/MessageContextMenu.d.ts.map +0 -1
  193. package/dist/types/other/MessageContextMenu.js.map +0 -1
  194. package/dist/types/other/UserContextMenu.d.ts.map +0 -1
  195. package/dist/types/other/UserContextMenu.js.map +0 -1
  196. package/dist/utils/MemoryStore.d.ts.map +0 -1
  197. package/dist/utils/MemoryStore.js.map +0 -1
  198. package/dist/utils/UtilTypes.d.ts.map +0 -1
  199. package/dist/utils/UtilTypes.js.map +0 -1
  200. package/dist/utils/customId.d.ts.map +0 -1
  201. package/dist/utils/customId.js.map +0 -1
  202. package/dist/utils/permissions.d.ts.map +0 -1
  203. package/dist/utils/permissions.js.map +0 -1
  204. package/dist/utils/recursiveImport.d.ts.map +0 -1
  205. package/dist/utils/recursiveImport.js.map +0 -1
  206. package/dist/utils/recursiveUnload.d.ts.map +0 -1
  207. package/dist/utils/recursiveUnload.js.map +0 -1
  208. package/dist/utils/unloadModule.d.ts.map +0 -1
  209. package/dist/utils/unloadModule.js.map +0 -1
  210. package/examples/modal/dbi.js +0 -30
  211. package/examples/modal/login.js +0 -15
  212. package/examples/modal/package.json +0 -15
  213. package/examples/modal/publish.js +0 -13
  214. package/examples/modal/src/chatInput.js +0 -38
  215. package/examples/modal/src/components.js +0 -33
  216. package/examples/modal/src/event.js +0 -20
  217. package/examples/modal/src/interactionlocales.js +0 -24
  218. package/examples/modal/src/locales.js +0 -38
  219. package/examples/modal/src/modal.js +0 -28
  220. /package/dist/{DBI.d.ts → src/DBI.d.ts} +0 -0
  221. /package/dist/{DBI.js → src/DBI.js} +0 -0
  222. /package/dist/{Events.d.ts → src/Events.d.ts} +0 -0
  223. /package/dist/{Events.js → src/Events.js} +0 -0
  224. /package/dist/{data → src/data}/eventMap.json +0 -0
  225. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  226. /package/dist/{index.js → src/index.js} +0 -0
  227. /package/dist/{methods → src/methods}/handleMessageCommands.d.ts +0 -0
  228. /package/dist/{methods → src/methods}/handleMessageCommands.js +0 -0
  229. /package/dist/{methods → src/methods}/hookEventListeners.d.ts +0 -0
  230. /package/dist/{methods → src/methods}/hookEventListeners.js +0 -0
  231. /package/dist/{methods → src/methods}/hookInteractionListeners.d.ts +0 -0
  232. /package/dist/{methods → src/methods}/publishInteractions.d.ts +0 -0
  233. /package/dist/{methods → src/methods}/publishInteractions.js +0 -0
  234. /package/dist/{types → src/types}/ApplicationRoleConnectionMetadata.d.ts +0 -0
  235. /package/dist/{types → src/types}/ApplicationRoleConnectionMetadata.js +0 -0
  236. /package/dist/{types → src/types}/Builders/ButtonBuilder.d.ts +0 -0
  237. /package/dist/{types → src/types}/Builders/ButtonBuilder.js +0 -0
  238. /package/dist/{types → src/types}/Builders/ChannelSelectMenuBuilder.d.ts +0 -0
  239. /package/dist/{types → src/types}/Builders/ChannelSelectMenuBuilder.js +0 -0
  240. /package/dist/{types → src/types}/Builders/MentionableSelectMenuBuilder.d.ts +0 -0
  241. /package/dist/{types → src/types}/Builders/MentionableSelectMenuBuilder.js +0 -0
  242. /package/dist/{types → src/types}/Builders/ModalBuilder.d.ts +0 -0
  243. /package/dist/{types → src/types}/Builders/ModalBuilder.js +0 -0
  244. /package/dist/{types → src/types}/Builders/RoleSelectMenuBuilder.d.ts +0 -0
  245. /package/dist/{types → src/types}/Builders/RoleSelectMenuBuilder.js +0 -0
  246. /package/dist/{types → src/types}/Builders/StringSelectMenuBuilder.d.ts +0 -0
  247. /package/dist/{types → src/types}/Builders/StringSelectMenuBuilder.js +0 -0
  248. /package/dist/{types → src/types}/Builders/UserSelectMenuBuilder.d.ts +0 -0
  249. /package/dist/{types → src/types}/Builders/UserSelectMenuBuilder.js +0 -0
  250. /package/dist/{types → src/types}/ChatInput/ChatInput.d.ts +0 -0
  251. /package/dist/{types → src/types}/ChatInput/ChatInput.js +0 -0
  252. /package/dist/{types → src/types}/ChatInput/ChatInputOptions.js +0 -0
  253. /package/dist/{types → src/types}/Components/Button.d.ts +0 -0
  254. /package/dist/{types → src/types}/Components/Button.js +0 -0
  255. /package/dist/{types → src/types}/Components/ChannelSelectMenu.d.ts +0 -0
  256. /package/dist/{types → src/types}/Components/ChannelSelectMenu.js +0 -0
  257. /package/dist/{types → src/types}/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.d.ts +0 -0
  258. /package/dist/{types → src/types}/Components/HTMLComponentsV2/HTMLComponentsV2Handlers.js +0 -0
  259. /package/dist/{types → src/types}/Components/HTMLComponentsV2/parser.d.ts +0 -0
  260. /package/dist/{types → src/types}/Components/MentionableSelectMenu.d.ts +0 -0
  261. /package/dist/{types → src/types}/Components/MentionableSelectMenu.js +0 -0
  262. /package/dist/{types → src/types}/Components/Modal.d.ts +0 -0
  263. /package/dist/{types → src/types}/Components/Modal.js +0 -0
  264. /package/dist/{types → src/types}/Components/RoleSelectMenu.d.ts +0 -0
  265. /package/dist/{types → src/types}/Components/RoleSelectMenu.js +0 -0
  266. /package/dist/{types → src/types}/Components/StringSelectMenu.d.ts +0 -0
  267. /package/dist/{types → src/types}/Components/StringSelectMenu.js +0 -0
  268. /package/dist/{types → src/types}/Components/UserSelectMenu.d.ts +0 -0
  269. /package/dist/{types → src/types}/Components/UserSelectMenu.js +0 -0
  270. /package/dist/{types → src/types}/Event.d.ts +0 -0
  271. /package/dist/{types → src/types}/Event.js +0 -0
  272. /package/dist/{types → src/types}/Interaction.d.ts +0 -0
  273. /package/dist/{types → src/types}/Interaction.js +0 -0
  274. /package/dist/{types → src/types}/other/CustomEvent.d.ts +0 -0
  275. /package/dist/{types → src/types}/other/CustomEvent.js +0 -0
  276. /package/dist/{types → src/types}/other/FakeMessageInteraction.d.ts +0 -0
  277. /package/dist/{types → src/types}/other/FakeMessageInteraction.js +0 -0
  278. /package/dist/{types → src/types}/other/InteractionLocale.d.ts +0 -0
  279. /package/dist/{types → src/types}/other/InteractionLocale.js +0 -0
  280. /package/dist/{types → src/types}/other/Locale.d.ts +0 -0
  281. /package/dist/{types → src/types}/other/Locale.js +0 -0
  282. /package/dist/{types → src/types}/other/MessageContextMenu.d.ts +0 -0
  283. /package/dist/{types → src/types}/other/MessageContextMenu.js +0 -0
  284. /package/dist/{types → src/types}/other/UserContextMenu.d.ts +0 -0
  285. /package/dist/{types → src/types}/other/UserContextMenu.js +0 -0
  286. /package/dist/{utils → src/utils}/MemoryStore.d.ts +0 -0
  287. /package/dist/{utils → src/utils}/MemoryStore.js +0 -0
  288. /package/dist/{utils → src/utils}/UtilTypes.d.ts +0 -0
  289. /package/dist/{utils → src/utils}/UtilTypes.js +0 -0
  290. /package/dist/{utils → src/utils}/customId.d.ts +0 -0
  291. /package/dist/{utils → src/utils}/customId.js +0 -0
  292. /package/dist/{utils → src/utils}/permissions.d.ts +0 -0
  293. /package/dist/{utils → src/utils}/permissions.js +0 -0
  294. /package/dist/{utils → src/utils}/recursiveImport.d.ts +0 -0
  295. /package/dist/{utils → src/utils}/recursiveImport.js +0 -0
  296. /package/dist/{utils → src/utils}/recursiveUnload.d.ts +0 -0
  297. /package/dist/{utils → src/utils}/recursiveUnload.js +0 -0
  298. /package/dist/{utils → src/utils}/unloadModule.d.ts +0 -0
  299. /package/dist/{utils → src/utils}/unloadModule.js +0 -0
@@ -0,0 +1 @@
1
+ /// <reference types="./svelte-dbi" />
@@ -0,0 +1,30 @@
1
+ /// <reference path="./svelte-dbi.d.ts" />
2
+
3
+ /**
4
+ * This file ensures Svelte files pick up the DBI type definitions.
5
+ *
6
+ * The following functions are available globally in your .svelte files:
7
+ *
8
+ * RENDER HELPERS:
9
+ * - render() - Force render the component
10
+ * - update() - Update message via interaction.update()
11
+ * - rerender() - Re-render via message.edit()
12
+ * - noRender() - Disable auto-render for current handler
13
+ * - setThrottle() - Set minimum interval between renders
14
+ *
15
+ * LIFECYCLE:
16
+ * - onMount() - Run on first render, can return cleanup function
17
+ * - onDestroy() - Run on component destroy
18
+ *
19
+ * CONTROL:
20
+ * - destroy() - Manually destroy the component instance
21
+ *
22
+ * REACTIVITY:
23
+ * - $effect() - Run when dependencies change
24
+ *
25
+ * CONTEXT:
26
+ * - ctx - The interaction context (ctx.interaction, ctx.dbi, ctx.locale)
27
+ * - data - Reactive data object (via $props())
28
+ */
29
+
30
+ export { };
@@ -0,0 +1,588 @@
1
+ /**
2
+ * Discord Bot Infrastructure - Svelte Components Type Definitions
3
+ *
4
+ * This file provides type definitions for Svelte components used with DBI.
5
+ * These types are available globally in .svelte files within the DBI context.
6
+ */
7
+
8
+ import type {
9
+ Interaction,
10
+ ButtonInteraction,
11
+ StringSelectMenuInteraction,
12
+ UserSelectMenuInteraction,
13
+ RoleSelectMenuInteraction,
14
+ ChannelSelectMenuInteraction,
15
+ MentionableSelectMenuInteraction,
16
+ ModalSubmitInteraction,
17
+ Message,
18
+ TextChannel,
19
+ DMChannel,
20
+ NewsChannel,
21
+ ThreadChannel
22
+ } from "discord.js";
23
+
24
+ declare global {
25
+ // ============================================
26
+ // RENDER HELPERS
27
+ // ============================================
28
+
29
+ /**
30
+ * Force renders the component by calling render() on the Svelte component.
31
+ * Use this when you need to manually trigger a render outside of reactive updates.
32
+ *
33
+ * @returns The rendered component JSON
34
+ *
35
+ * @example
36
+ * ```svelte
37
+ * function handleClick() {
38
+ * data.count++;
39
+ * render(); // Force immediate render
40
+ * }
41
+ * ```
42
+ */
43
+ function render(): any;
44
+
45
+ /**
46
+ * Updates the message using interaction.update().
47
+ * Best used for button/select menu interactions where you want to update the existing message.
48
+ * Disables auto-render since manual update is called.
49
+ *
50
+ * @returns Promise that resolves when update is complete
51
+ *
52
+ * @example
53
+ * ```svelte
54
+ * async function handleButton() {
55
+ * data.count++;
56
+ * await update(); // Updates the message with new data
57
+ * }
58
+ * ```
59
+ */
60
+ function update(): Promise<void>;
61
+
62
+ /**
63
+ * Re-renders the message using message.edit().
64
+ * Use this after reply/followUp when you need to update the original message.
65
+ * Disables auto-render since manual rerender is called.
66
+ *
67
+ * @returns Promise that resolves when edit is complete
68
+ *
69
+ * @example
70
+ * ```svelte
71
+ * async function handleButton() {
72
+ * await ctx.interaction.reply({ content: "Processing..." });
73
+ * data.result = await fetchData();
74
+ * await rerender(); // Updates the original message
75
+ * }
76
+ * ```
77
+ */
78
+ function rerender(): Promise<void>;
79
+
80
+ /**
81
+ * Disables automatic rendering for the current handler execution.
82
+ * Use when you don't want data changes to trigger a UI update.
83
+ *
84
+ * @example
85
+ * ```svelte
86
+ * function handleBackgroundTask() {
87
+ * noRender(); // Prevent auto-render
88
+ * data.internalState = calculateSomething(); // Won't trigger render
89
+ * }
90
+ * ```
91
+ */
92
+ function noRender(): void;
93
+
94
+ /**
95
+ * Sets the minimum interval between renders (throttle).
96
+ * Default is 250ms. Use this to control render frequency for rapid updates.
97
+ *
98
+ * @param ms - Minimum milliseconds between renders
99
+ *
100
+ * @example
101
+ * ```svelte
102
+ * setThrottle(500); // Minimum 500ms between renders
103
+ *
104
+ * // For a timer that updates every second:
105
+ * setThrottle(1000);
106
+ * ```
107
+ */
108
+ function setThrottle(ms: number): void;
109
+
110
+ // ============================================
111
+ // LIFECYCLE HOOKS
112
+ // ============================================
113
+
114
+ /**
115
+ * Registers a callback to run when the component is first mounted/sent.
116
+ * If the callback returns a function, it will be called on destroy (cleanup).
117
+ *
118
+ * @param callback - Function to run on mount. Can return a cleanup function.
119
+ *
120
+ * @example
121
+ * ```svelte
122
+ * onMount(() => {
123
+ * console.log("Component mounted!");
124
+ *
125
+ * const interval = setInterval(() => {
126
+ * data.seconds++;
127
+ * }, 1000);
128
+ *
129
+ * // Return cleanup function
130
+ * return () => clearInterval(interval);
131
+ * });
132
+ * ```
133
+ */
134
+ function onMount(callback: () => void | (() => void)): void;
135
+
136
+ /**
137
+ * Registers a callback to run when the component is destroyed.
138
+ * Use for cleanup: clearing intervals, timers, subscriptions, etc.
139
+ *
140
+ * @param callback - Function to run on destroy
141
+ *
142
+ * @example
143
+ * ```svelte
144
+ * let timer;
145
+ *
146
+ * onMount(() => {
147
+ * timer = setInterval(() => data.count++, 1000);
148
+ * });
149
+ *
150
+ * onDestroy(() => {
151
+ * clearInterval(timer);
152
+ * console.log("Cleaned up!");
153
+ * });
154
+ * ```
155
+ */
156
+ function onDestroy(callback: () => void): void;
157
+
158
+ // ============================================
159
+ // COMPONENT CONTROL
160
+ // ============================================
161
+
162
+ /**
163
+ * Destroys the component instance manually.
164
+ * - Runs all onDestroy callbacks (clears intervals, timers, etc.)
165
+ * - Removes the ref from DBI store
166
+ * - Disables further auto-renders
167
+ *
168
+ * Use when you want to clean up the component programmatically.
169
+ *
170
+ * @example
171
+ * ```svelte
172
+ * function handleClose() {
173
+ * destroy(); // Clean up everything
174
+ * }
175
+ *
176
+ * // Or after a timeout:
177
+ * onMount(() => {
178
+ * setTimeout(() => {
179
+ * destroy(); // Auto-destroy after 60 seconds
180
+ * }, 60000);
181
+ * });
182
+ * ```
183
+ */
184
+ function destroy(): void;
185
+
186
+ // ============================================
187
+ // REACTIVITY (Svelte 5 Runes)
188
+ // ============================================
189
+
190
+ /**
191
+ * Creates a reactive effect that runs when its dependencies change.
192
+ * Similar to Svelte 5's $effect rune.
193
+ *
194
+ * @param callback - Function to run when dependencies change
195
+ *
196
+ * @example
197
+ * ```svelte
198
+ * $effect(() => {
199
+ * console.log("Count changed:", data.count);
200
+ * });
201
+ * ```
202
+ */
203
+ function $effect(callback: () => void): void;
204
+
205
+ // ============================================
206
+ // CONTEXT TYPES
207
+ // ============================================
208
+
209
+ /**
210
+ * The interaction context available in handlers.
211
+ * Contains the Discord interaction and helper methods.
212
+ */
213
+ interface DBIContext<T extends Interaction = Interaction> {
214
+ /** The Discord.js interaction object */
215
+ interaction: T;
216
+ /** The DBI instance */
217
+ dbi: any;
218
+ /** Locale helper for translations */
219
+ locale: {
220
+ user: (key: string, ...args: any[]) => string;
221
+ guild: (key: string, ...args: any[]) => string;
222
+ };
223
+ }
224
+
225
+ /**
226
+ * The context object available in Svelte script handlers.
227
+ * Automatically typed based on the interaction type.
228
+ */
229
+ const ctx: DBIContext<ButtonInteraction | StringSelectMenuInteraction | UserSelectMenuInteraction | RoleSelectMenuInteraction | ChannelSelectMenuInteraction | MentionableSelectMenuInteraction | ModalSubmitInteraction>;
230
+
231
+ // ============================================
232
+ // DATA TYPES
233
+ // ============================================
234
+
235
+ /**
236
+ * The reactive data object passed to the component.
237
+ * Changes to this object automatically trigger re-renders.
238
+ *
239
+ * Special properties:
240
+ * - `$ref`: Unique reference ID for the component instance
241
+ * - `$unRef`: Set to true to destroy the component
242
+ *
243
+ * @example
244
+ * ```svelte
245
+ * <script>
246
+ * let { data = $bindable() } = $props();
247
+ *
248
+ * // data is reactive - changes trigger re-render
249
+ * function increment() {
250
+ * data.count++; // Auto-renders
251
+ * }
252
+ * </script>
253
+ * ```
254
+ */
255
+ interface DBIData {
256
+ /** Unique reference ID for this component instance */
257
+ $ref?: string;
258
+ /** Set to true to destroy this component instance */
259
+ $unRef?: boolean;
260
+ /** Any additional data properties */
261
+ [key: string]: any;
262
+ }
263
+ }
264
+
265
+ // ============================================
266
+ // MODULE DECLARATIONS
267
+ // ============================================
268
+
269
+ declare module "*.svelte" {
270
+ import type { Component } from "svelte";
271
+
272
+ const component: Component<any, any, any>;
273
+ export default component;
274
+ }
275
+
276
+ // ============================================
277
+ // SVELTE HTML ELEMENTS (Discord Components V2)
278
+ // ============================================
279
+
280
+ declare module "svelte/elements" {
281
+ type ButtonStyle = "Primary" | "Secondary" | "Success" | "Danger" | "Link" | "Premium";
282
+ type TextInputStyle = "Short" | "Paragraph";
283
+ type SelectType = "user" | "role" | "channel" | "mentionable";
284
+
285
+ // Common attributes for interactive components
286
+ interface DBIInteractiveAttributes {
287
+ /** Handler function for this component */
288
+ handler?: (ctx: any) => void | Promise<void>;
289
+ /** Custom ID for the component (auto-generated if not provided) */
290
+ "custom-id"?: string;
291
+ /** Name for auto-generated custom ID */
292
+ name?: string;
293
+ /** Time-to-live for the component data in milliseconds */
294
+ ttl?: number | string;
295
+ /** Whether the component is disabled */
296
+ disabled?: boolean;
297
+ }
298
+
299
+ // Data attributes for passing data to handlers
300
+ interface DBIDataAttributes {
301
+ /** Data attribute with index and type: data-0:string, data-1:int, etc. */
302
+ [key: `data-${number}:${"string" | "str" | "int" | "integer" | "float" | "number" | "bool" | "boolean" | "ref" | "reference" | "json"}`]: string;
303
+ /** Simple data attribute */
304
+ data?: string;
305
+ }
306
+
307
+ // ============================================
308
+ // DISCORD BUTTON
309
+ // ============================================
310
+ interface DiscordButtonAttributes extends DBIInteractiveAttributes, DBIDataAttributes {
311
+ /** Button style: Primary, Secondary, Success, Danger, Link, Premium */
312
+ style?: ButtonStyle;
313
+ /** Alternative to style attribute */
314
+ "button-style"?: ButtonStyle;
315
+ /** Emoji to display on the button */
316
+ emoji?: string;
317
+ /** URL for Link style buttons */
318
+ url?: string;
319
+ /** SKU ID for Premium style buttons */
320
+ "sku-id"?: string;
321
+ }
322
+
323
+ // ============================================
324
+ // SELECT MENUS
325
+ // ============================================
326
+ interface DBISelectMenuAttributes extends DBIInteractiveAttributes, DBIDataAttributes {
327
+ /** Placeholder text when nothing is selected */
328
+ placeholder?: string;
329
+ /** Minimum number of values that must be selected */
330
+ "min-values"?: number | string;
331
+ /** Maximum number of values that can be selected */
332
+ "max-values"?: number | string;
333
+ }
334
+
335
+ interface StringSelectAttributes extends DBISelectMenuAttributes { }
336
+ interface UserSelectAttributes extends DBISelectMenuAttributes { }
337
+ interface RoleSelectAttributes extends DBISelectMenuAttributes { }
338
+ interface ChannelSelectAttributes extends DBISelectMenuAttributes { }
339
+ interface MentionableSelectAttributes extends DBISelectMenuAttributes { }
340
+
341
+ // ============================================
342
+ // SELECT OPTION
343
+ // ============================================
344
+ interface SelectOptionAttributes {
345
+ /** The value sent when this option is selected */
346
+ value?: string;
347
+ /** Description shown below the label */
348
+ description?: string;
349
+ /** Emoji to display */
350
+ emoji?: string;
351
+ /** Whether this option is selected by default */
352
+ default?: boolean | "";
353
+ /** Option ID for non-string selects */
354
+ id?: string;
355
+ /** Option type for non-string selects */
356
+ type?: string;
357
+ }
358
+
359
+ // ============================================
360
+ // TEXT DISPLAY
361
+ // ============================================
362
+ interface TextDisplayAttributes {
363
+ /** Content is the text inside the element */
364
+ }
365
+
366
+ // ============================================
367
+ // SECTION
368
+ // ============================================
369
+ interface SectionAttributes {
370
+ /** Section contains <components> and optionally an <accessory> */
371
+ }
372
+
373
+ // ============================================
374
+ // THUMBNAIL
375
+ // ============================================
376
+ interface ThumbnailAttributes {
377
+ /** URL of the thumbnail image */
378
+ url?: string;
379
+ /** Alternative to url attribute */
380
+ media?: string;
381
+ }
382
+
383
+ // ============================================
384
+ // MEDIA GALLERY
385
+ // ============================================
386
+ interface MediaGalleryAttributes {
387
+ /** Contains <item> elements */
388
+ }
389
+
390
+ interface MediaGalleryItemAttributes {
391
+ /** URL of the media */
392
+ url?: string;
393
+ /** Description of the media */
394
+ description?: string;
395
+ /** Whether the media is a spoiler */
396
+ spoiler?: boolean | "";
397
+ }
398
+
399
+ // ============================================
400
+ // FILE
401
+ // ============================================
402
+ interface FileAttributes {
403
+ /** URL of the file */
404
+ url?: string;
405
+ /** Whether the file is a spoiler */
406
+ spoiler?: boolean | "";
407
+ }
408
+
409
+ // ============================================
410
+ // SEPARATOR
411
+ // ============================================
412
+ interface SeparatorAttributes {
413
+ /** Whether to show a divider line */
414
+ divider?: boolean | "";
415
+ /** Spacing size (1-3) */
416
+ spacing?: number | string;
417
+ }
418
+
419
+ // ============================================
420
+ // CONTAINER
421
+ // ============================================
422
+ interface ContainerAttributes {
423
+ /** Accent color (hex, rgb, or decimal) */
424
+ "accent-color"?: string;
425
+ /** Whether the container content is a spoiler */
426
+ spoiler?: boolean | "";
427
+ }
428
+
429
+ // ============================================
430
+ // ACTION ROW
431
+ // ============================================
432
+ interface ActionRowAttributes {
433
+ /** Contains buttons or a single select menu */
434
+ }
435
+
436
+ // ============================================
437
+ // COMPONENTS WRAPPER
438
+ // ============================================
439
+ interface ComponentsAttributes {
440
+ /** Root wrapper for Discord components */
441
+ }
442
+
443
+ // ============================================
444
+ // ACCESSORY WRAPPER
445
+ // ============================================
446
+ interface AccessoryAttributes {
447
+ /** Wrapper for section accessory (thumbnail or button) */
448
+ }
449
+
450
+ // ============================================
451
+ // TEXT INPUT (for Modals)
452
+ // ============================================
453
+ interface TextInputAttributes {
454
+ /** Custom ID for the text input */
455
+ "custom-id"?: string;
456
+ /** Alternative to custom-id */
457
+ id?: string;
458
+ /** Label shown above the input */
459
+ label?: string;
460
+ /** Placeholder text */
461
+ placeholder?: string;
462
+ /** Input style: Short or Paragraph */
463
+ style?: TextInputStyle;
464
+ /** Alternative to style */
465
+ "input-style"?: TextInputStyle;
466
+ /** Minimum character length */
467
+ "min-length"?: number | string;
468
+ /** Maximum character length */
469
+ "max-length"?: number | string;
470
+ /** Whether the input is required */
471
+ required?: boolean | "";
472
+ /** Default value */
473
+ value?: string;
474
+ }
475
+
476
+ // ============================================
477
+ // EXTEND SVELTE'S INTRINSIC ELEMENTS
478
+ // ============================================
479
+ export interface SvelteHTMLElements {
480
+ // Layout & Structure
481
+ /** Root wrapper containing all Discord components */
482
+ "components": ComponentsAttributes;
483
+ /** Row container for buttons or a single select menu */
484
+ "action-row": ActionRowAttributes;
485
+ /** Wrapper for section accessory element */
486
+ "accessory": AccessoryAttributes;
487
+
488
+ // Interactive Components
489
+ /** Discord button component */
490
+ "button": DiscordButtonAttributes;
491
+ /** Alias for button */
492
+ "discord-button": DiscordButtonAttributes;
493
+ /** String select menu with custom options */
494
+ "string-select": StringSelectAttributes;
495
+ /** User select menu */
496
+ "user-select": UserSelectAttributes;
497
+ /** Role select menu */
498
+ "role-select": RoleSelectAttributes;
499
+ /** Channel select menu */
500
+ "channel-select": ChannelSelectAttributes;
501
+ /** Mentionable (user/role) select menu */
502
+ "mentionable-select": MentionableSelectAttributes;
503
+ /** Option for select menus */
504
+ "option": SelectOptionAttributes;
505
+
506
+ // Display Components
507
+ /** Text display component - renders markdown text */
508
+ "text-display": TextDisplayAttributes;
509
+ /** Section with components and optional accessory */
510
+ "section": SectionAttributes;
511
+ /** Alias for section */
512
+ "discord-section": SectionAttributes;
513
+ /** Thumbnail image */
514
+ "thumbnail": ThumbnailAttributes;
515
+ /** Media gallery with multiple items */
516
+ "media-gallery": MediaGalleryAttributes;
517
+ /** Item in a media gallery */
518
+ "item": MediaGalleryItemAttributes;
519
+ /** File attachment */
520
+ "file": FileAttributes;
521
+ /** Visual separator between components */
522
+ "separator": SeparatorAttributes;
523
+ /** Container with accent color */
524
+ "container": ContainerAttributes;
525
+
526
+ // Modal Components
527
+ /** Text input for modals */
528
+ "text-input": TextInputAttributes;
529
+ }
530
+ }
531
+
532
+ // ============================================
533
+ // SVELTE PROPS HELPER
534
+ // ============================================
535
+
536
+ declare module "svelte" {
537
+ /**
538
+ * Svelte 5 $props() rune for declaring component props.
539
+ * Use with $bindable() for two-way binding.
540
+ *
541
+ * @example
542
+ * ```svelte
543
+ * <script>
544
+ * let { data = $bindable(), otherProp } = $props();
545
+ * </script>
546
+ * ```
547
+ */
548
+ export function $props<T extends Record<string, any>>(): T;
549
+
550
+ /**
551
+ * Svelte 5 $bindable() rune for two-way bindable props.
552
+ *
553
+ * @example
554
+ * ```svelte
555
+ * <script>
556
+ * let { value = $bindable() } = $props();
557
+ * </script>
558
+ * ```
559
+ */
560
+ export function $bindable<T>(initial?: T): T;
561
+
562
+ /**
563
+ * Svelte 5 $state() rune for reactive state.
564
+ *
565
+ * @example
566
+ * ```svelte
567
+ * <script>
568
+ * let count = $state(0);
569
+ * </script>
570
+ * ```
571
+ */
572
+ export function $state<T>(initial: T): T;
573
+
574
+ /**
575
+ * Svelte 5 $derived() rune for derived/computed values.
576
+ *
577
+ * @example
578
+ * ```svelte
579
+ * <script>
580
+ * let count = $state(0);
581
+ * let doubled = $derived(count * 2);
582
+ * </script>
583
+ * ```
584
+ */
585
+ export function $derived<T>(expression: T): T;
586
+ }
587
+
588
+ export { };