commandkit 0.1.11-dev.20250208090624 → 0.1.11-dev.20250208131735

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 (349) hide show
  1. package/dist/index.d.mts +988 -22
  2. package/dist/index.d.ts +988 -22
  3. package/dist/index.js +3 -3
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +28 -1
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +1 -1
  8. package/dist/CommandKit-BRxmnywX.d.mts +0 -468
  9. package/dist/CommandKit-BhFmurtb.d.ts +0 -468
  10. package/dist/CommandKit.d.mts +0 -10
  11. package/dist/CommandKit.d.ts +0 -10
  12. package/dist/CommandKit.js +0 -11
  13. package/dist/CommandKit.js.map +0 -1
  14. package/dist/CommandKit.mjs +0 -2
  15. package/dist/CommandKit.mjs.map +0 -1
  16. package/dist/async-context-B5Gze_ie.d.mts +0 -143
  17. package/dist/async-context-BW1JD1Dt.d.ts +0 -143
  18. package/dist/cache/CacheProvider.d.mts +0 -14
  19. package/dist/cache/CacheProvider.d.ts +0 -14
  20. package/dist/cache/CacheProvider.js +0 -2
  21. package/dist/cache/CacheProvider.js.map +0 -1
  22. package/dist/cache/CacheProvider.mjs +0 -2
  23. package/dist/cache/CacheProvider.mjs.map +0 -1
  24. package/dist/cache/MemoryCache.d.mts +0 -13
  25. package/dist/cache/MemoryCache.d.ts +0 -13
  26. package/dist/cache/MemoryCache.js +0 -2
  27. package/dist/cache/MemoryCache.js.map +0 -1
  28. package/dist/cache/MemoryCache.mjs +0 -2
  29. package/dist/cache/MemoryCache.mjs.map +0 -1
  30. package/dist/cache/cache.d.mts +0 -66
  31. package/dist/cache/cache.d.ts +0 -66
  32. package/dist/cache/cache.js +0 -11
  33. package/dist/cache/cache.js.map +0 -1
  34. package/dist/cache/cache.mjs +0 -2
  35. package/dist/cache/cache.mjs.map +0 -1
  36. package/dist/cache/index.d.mts +0 -13
  37. package/dist/cache/index.d.ts +0 -13
  38. package/dist/cache/index.js +0 -11
  39. package/dist/cache/index.js.map +0 -1
  40. package/dist/cache/index.mjs +0 -2
  41. package/dist/cache/index.mjs.map +0 -1
  42. package/dist/chunk-2F6IEOYN.mjs +0 -1
  43. package/dist/chunk-2F6IEOYN.mjs.map +0 -1
  44. package/dist/chunk-35OSBS47.mjs +0 -2
  45. package/dist/chunk-35OSBS47.mjs.map +0 -1
  46. package/dist/chunk-4VJMT2KT.mjs +0 -1
  47. package/dist/chunk-4VJMT2KT.mjs.map +0 -1
  48. package/dist/chunk-5CQ732SA.mjs +0 -2
  49. package/dist/chunk-5CQ732SA.mjs.map +0 -1
  50. package/dist/chunk-5KLEVIDX.mjs +0 -2
  51. package/dist/chunk-5KLEVIDX.mjs.map +0 -1
  52. package/dist/chunk-6EE35LXH.mjs +0 -2
  53. package/dist/chunk-6EE35LXH.mjs.map +0 -1
  54. package/dist/chunk-73NFQRKA.mjs +0 -7
  55. package/dist/chunk-73NFQRKA.mjs.map +0 -1
  56. package/dist/chunk-75Q5UTDQ.mjs +0 -2
  57. package/dist/chunk-75Q5UTDQ.mjs.map +0 -1
  58. package/dist/chunk-BNTMQC76.mjs +0 -2
  59. package/dist/chunk-BNTMQC76.mjs.map +0 -1
  60. package/dist/chunk-D4IIOMFB.mjs +0 -2
  61. package/dist/chunk-D4IIOMFB.mjs.map +0 -1
  62. package/dist/chunk-DKIEPYCH.mjs +0 -2
  63. package/dist/chunk-DKIEPYCH.mjs.map +0 -1
  64. package/dist/chunk-DMNZASZO.mjs +0 -2
  65. package/dist/chunk-DMNZASZO.mjs.map +0 -1
  66. package/dist/chunk-DTKEXOZL.mjs +0 -4
  67. package/dist/chunk-DTKEXOZL.mjs.map +0 -1
  68. package/dist/chunk-FC5WQLBI.mjs +0 -3
  69. package/dist/chunk-FC5WQLBI.mjs.map +0 -1
  70. package/dist/chunk-HFOCTXRX.mjs +0 -2
  71. package/dist/chunk-HFOCTXRX.mjs.map +0 -1
  72. package/dist/chunk-HN3WQT6R.mjs +0 -2
  73. package/dist/chunk-HN3WQT6R.mjs.map +0 -1
  74. package/dist/chunk-HXRSHVHI.mjs +0 -2
  75. package/dist/chunk-HXRSHVHI.mjs.map +0 -1
  76. package/dist/chunk-ICJ4BBWI.mjs +0 -2
  77. package/dist/chunk-ICJ4BBWI.mjs.map +0 -1
  78. package/dist/chunk-IRBJOQ7G.mjs +0 -2
  79. package/dist/chunk-IRBJOQ7G.mjs.map +0 -1
  80. package/dist/chunk-JPMIJRUL.mjs +0 -2
  81. package/dist/chunk-JPMIJRUL.mjs.map +0 -1
  82. package/dist/chunk-MNPCM4QU.mjs +0 -2
  83. package/dist/chunk-MNPCM4QU.mjs.map +0 -1
  84. package/dist/chunk-P7PNFSAC.mjs +0 -13
  85. package/dist/chunk-P7PNFSAC.mjs.map +0 -1
  86. package/dist/chunk-PDPQ6BZU.mjs +0 -4
  87. package/dist/chunk-PDPQ6BZU.mjs.map +0 -1
  88. package/dist/chunk-PTP2L33V.mjs +0 -2
  89. package/dist/chunk-PTP2L33V.mjs.map +0 -1
  90. package/dist/chunk-QXMWKQIO.mjs +0 -2
  91. package/dist/chunk-QXMWKQIO.mjs.map +0 -1
  92. package/dist/chunk-R4SWJR4N.mjs +0 -2
  93. package/dist/chunk-R4SWJR4N.mjs.map +0 -1
  94. package/dist/chunk-RQ3ABUE3.mjs +0 -2
  95. package/dist/chunk-RQ3ABUE3.mjs.map +0 -1
  96. package/dist/chunk-RVGLG66X.mjs +0 -2
  97. package/dist/chunk-RVGLG66X.mjs.map +0 -1
  98. package/dist/chunk-SI3L34FF.mjs +0 -2
  99. package/dist/chunk-SI3L34FF.mjs.map +0 -1
  100. package/dist/chunk-SMY6O53N.mjs +0 -2
  101. package/dist/chunk-SMY6O53N.mjs.map +0 -1
  102. package/dist/chunk-Y522NY4J.mjs +0 -2
  103. package/dist/chunk-Y522NY4J.mjs.map +0 -1
  104. package/dist/cli/build.d.mts +0 -4
  105. package/dist/cli/build.d.ts +0 -4
  106. package/dist/cli/build.js +0 -14
  107. package/dist/cli/build.js.map +0 -1
  108. package/dist/cli/build.mjs +0 -2
  109. package/dist/cli/build.mjs.map +0 -1
  110. package/dist/cli/common.d.mts +0 -35
  111. package/dist/cli/common.d.ts +0 -35
  112. package/dist/cli/common.js +0 -3
  113. package/dist/cli/common.js.map +0 -1
  114. package/dist/cli/common.mjs +0 -2
  115. package/dist/cli/common.mjs.map +0 -1
  116. package/dist/cli/development.d.mts +0 -3
  117. package/dist/cli/development.d.ts +0 -3
  118. package/dist/cli/development.js +0 -17
  119. package/dist/cli/development.js.map +0 -1
  120. package/dist/cli/development.mjs +0 -7
  121. package/dist/cli/development.mjs.map +0 -1
  122. package/dist/cli/esbuild-plugins/plugin.d.mts +0 -11
  123. package/dist/cli/esbuild-plugins/plugin.d.ts +0 -11
  124. package/dist/cli/esbuild-plugins/plugin.js +0 -2
  125. package/dist/cli/esbuild-plugins/plugin.js.map +0 -1
  126. package/dist/cli/esbuild-plugins/plugin.mjs +0 -2
  127. package/dist/cli/esbuild-plugins/plugin.mjs.map +0 -1
  128. package/dist/cli/esbuild-plugins/use-cache.d.mts +0 -6
  129. package/dist/cli/esbuild-plugins/use-cache.d.ts +0 -6
  130. package/dist/cli/esbuild-plugins/use-cache.js +0 -2
  131. package/dist/cli/esbuild-plugins/use-cache.js.map +0 -1
  132. package/dist/cli/esbuild-plugins/use-cache.mjs +0 -2
  133. package/dist/cli/esbuild-plugins/use-cache.mjs.map +0 -1
  134. package/dist/cli/init.d.mts +0 -10
  135. package/dist/cli/init.d.ts +0 -10
  136. package/dist/cli/init.js +0 -20
  137. package/dist/cli/init.js.map +0 -1
  138. package/dist/cli/init.mjs +0 -2
  139. package/dist/cli/init.mjs.map +0 -1
  140. package/dist/cli/parse-env.d.mts +0 -3
  141. package/dist/cli/parse-env.d.ts +0 -3
  142. package/dist/cli/parse-env.js +0 -2
  143. package/dist/cli/parse-env.js.map +0 -1
  144. package/dist/cli/parse-env.mjs +0 -2
  145. package/dist/cli/parse-env.mjs.map +0 -1
  146. package/dist/cli/production.d.mts +0 -3
  147. package/dist/cli/production.d.ts +0 -3
  148. package/dist/cli/production.js +0 -4
  149. package/dist/cli/production.js.map +0 -1
  150. package/dist/cli/production.mjs +0 -3
  151. package/dist/cli/production.mjs.map +0 -1
  152. package/dist/components/action-row/ActionRow.d.mts +0 -18
  153. package/dist/components/action-row/ActionRow.d.ts +0 -18
  154. package/dist/components/action-row/ActionRow.js +0 -2
  155. package/dist/components/action-row/ActionRow.js.map +0 -1
  156. package/dist/components/action-row/ActionRow.mjs +0 -2
  157. package/dist/components/action-row/ActionRow.mjs.map +0 -1
  158. package/dist/components/button/Button.d.mts +0 -30
  159. package/dist/components/button/Button.d.ts +0 -30
  160. package/dist/components/button/Button.js +0 -11
  161. package/dist/components/button/Button.js.map +0 -1
  162. package/dist/components/button/Button.mjs +0 -2
  163. package/dist/components/button/Button.mjs.map +0 -1
  164. package/dist/components/button/ButtonKit.d.mts +0 -60
  165. package/dist/components/button/ButtonKit.d.ts +0 -60
  166. package/dist/components/button/ButtonKit.js +0 -11
  167. package/dist/components/button/ButtonKit.js.map +0 -1
  168. package/dist/components/button/ButtonKit.mjs +0 -2
  169. package/dist/components/button/ButtonKit.mjs.map +0 -1
  170. package/dist/components/common/EventInterceptor.d.mts +0 -73
  171. package/dist/components/common/EventInterceptor.d.ts +0 -73
  172. package/dist/components/common/EventInterceptor.js +0 -2
  173. package/dist/components/common/EventInterceptor.js.map +0 -1
  174. package/dist/components/common/EventInterceptor.mjs +0 -2
  175. package/dist/components/common/EventInterceptor.mjs.map +0 -1
  176. package/dist/components/common/element.d.mts +0 -29
  177. package/dist/components/common/element.d.ts +0 -29
  178. package/dist/components/common/element.js +0 -2
  179. package/dist/components/common/element.js.map +0 -1
  180. package/dist/components/common/element.mjs +0 -2
  181. package/dist/components/common/element.mjs.map +0 -1
  182. package/dist/components/common/types.d.mts +0 -3
  183. package/dist/components/common/types.d.ts +0 -3
  184. package/dist/components/common/types.js +0 -2
  185. package/dist/components/common/types.js.map +0 -1
  186. package/dist/components/common/types.mjs +0 -2
  187. package/dist/components/common/types.mjs.map +0 -1
  188. package/dist/components/index.d.mts +0 -9
  189. package/dist/components/index.d.ts +0 -9
  190. package/dist/components/index.js +0 -11
  191. package/dist/components/index.js.map +0 -1
  192. package/dist/components/index.mjs +0 -2
  193. package/dist/components/index.mjs.map +0 -1
  194. package/dist/components/modal/Modal.d.mts +0 -56
  195. package/dist/components/modal/Modal.d.ts +0 -56
  196. package/dist/components/modal/Modal.js +0 -11
  197. package/dist/components/modal/Modal.js.map +0 -1
  198. package/dist/components/modal/Modal.mjs +0 -2
  199. package/dist/components/modal/Modal.mjs.map +0 -1
  200. package/dist/components/modal/ModalKit.d.mts +0 -58
  201. package/dist/components/modal/ModalKit.d.ts +0 -58
  202. package/dist/components/modal/ModalKit.js +0 -11
  203. package/dist/components/modal/ModalKit.js.map +0 -1
  204. package/dist/components/modal/ModalKit.mjs +0 -2
  205. package/dist/components/modal/ModalKit.mjs.map +0 -1
  206. package/dist/config.d.mts +0 -53
  207. package/dist/config.d.ts +0 -53
  208. package/dist/config.js +0 -2
  209. package/dist/config.js.map +0 -1
  210. package/dist/config.mjs +0 -2
  211. package/dist/config.mjs.map +0 -1
  212. package/dist/context/async-context.d.mts +0 -11
  213. package/dist/context/async-context.d.ts +0 -11
  214. package/dist/context/async-context.js +0 -11
  215. package/dist/context/async-context.js.map +0 -1
  216. package/dist/context/async-context.mjs +0 -2
  217. package/dist/context/async-context.mjs.map +0 -1
  218. package/dist/context/environment.d.mts +0 -11
  219. package/dist/context/environment.d.ts +0 -11
  220. package/dist/context/environment.js +0 -2
  221. package/dist/context/environment.js.map +0 -1
  222. package/dist/context/environment.mjs +0 -2
  223. package/dist/context/environment.mjs.map +0 -1
  224. package/dist/handlers/command-handler/CommandHandler.d.mts +0 -10
  225. package/dist/handlers/command-handler/CommandHandler.d.ts +0 -10
  226. package/dist/handlers/command-handler/CommandHandler.js +0 -11
  227. package/dist/handlers/command-handler/CommandHandler.js.map +0 -1
  228. package/dist/handlers/command-handler/CommandHandler.mjs +0 -2
  229. package/dist/handlers/command-handler/CommandHandler.mjs.map +0 -1
  230. package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.mts +0 -40
  231. package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.ts +0 -40
  232. package/dist/handlers/command-handler/functions/loadCommandsWithRest.js +0 -4
  233. package/dist/handlers/command-handler/functions/loadCommandsWithRest.js.map +0 -1
  234. package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs +0 -2
  235. package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs.map +0 -1
  236. package/dist/handlers/command-handler/functions/registerCommands.d.mts +0 -25
  237. package/dist/handlers/command-handler/functions/registerCommands.d.ts +0 -25
  238. package/dist/handlers/command-handler/functions/registerCommands.js +0 -7
  239. package/dist/handlers/command-handler/functions/registerCommands.js.map +0 -1
  240. package/dist/handlers/command-handler/functions/registerCommands.mjs +0 -2
  241. package/dist/handlers/command-handler/functions/registerCommands.mjs.map +0 -1
  242. package/dist/handlers/command-handler/typings.d.mts +0 -10
  243. package/dist/handlers/command-handler/typings.d.ts +0 -10
  244. package/dist/handlers/command-handler/typings.js +0 -2
  245. package/dist/handlers/command-handler/typings.js.map +0 -1
  246. package/dist/handlers/command-handler/typings.mjs +0 -1
  247. package/dist/handlers/command-handler/typings.mjs.map +0 -1
  248. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.mts +0 -9
  249. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.d.ts +0 -9
  250. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js +0 -2
  251. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.js.map +0 -1
  252. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs +0 -2
  253. package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs.map +0 -1
  254. package/dist/handlers/command-handler/validations/devOnly.d.mts +0 -14
  255. package/dist/handlers/command-handler/validations/devOnly.d.ts +0 -14
  256. package/dist/handlers/command-handler/validations/devOnly.js +0 -2
  257. package/dist/handlers/command-handler/validations/devOnly.js.map +0 -1
  258. package/dist/handlers/command-handler/validations/devOnly.mjs +0 -2
  259. package/dist/handlers/command-handler/validations/devOnly.mjs.map +0 -1
  260. package/dist/handlers/command-handler/validations/index.d.mts +0 -15
  261. package/dist/handlers/command-handler/validations/index.d.ts +0 -15
  262. package/dist/handlers/command-handler/validations/index.js +0 -4
  263. package/dist/handlers/command-handler/validations/index.js.map +0 -1
  264. package/dist/handlers/command-handler/validations/index.mjs +0 -2
  265. package/dist/handlers/command-handler/validations/index.mjs.map +0 -1
  266. package/dist/handlers/command-handler/validations/permissions.d.mts +0 -14
  267. package/dist/handlers/command-handler/validations/permissions.d.ts +0 -14
  268. package/dist/handlers/command-handler/validations/permissions.js +0 -4
  269. package/dist/handlers/command-handler/validations/permissions.js.map +0 -1
  270. package/dist/handlers/command-handler/validations/permissions.mjs +0 -2
  271. package/dist/handlers/command-handler/validations/permissions.mjs.map +0 -1
  272. package/dist/handlers/event-handler/EventHandler.d.mts +0 -10
  273. package/dist/handlers/event-handler/EventHandler.d.ts +0 -10
  274. package/dist/handlers/event-handler/EventHandler.js +0 -2
  275. package/dist/handlers/event-handler/EventHandler.js.map +0 -1
  276. package/dist/handlers/event-handler/EventHandler.mjs +0 -2
  277. package/dist/handlers/event-handler/EventHandler.mjs.map +0 -1
  278. package/dist/handlers/event-handler/typings.d.mts +0 -10
  279. package/dist/handlers/event-handler/typings.d.ts +0 -10
  280. package/dist/handlers/event-handler/typings.js +0 -2
  281. package/dist/handlers/event-handler/typings.js.map +0 -1
  282. package/dist/handlers/event-handler/typings.mjs +0 -1
  283. package/dist/handlers/event-handler/typings.mjs.map +0 -1
  284. package/dist/handlers/index.d.mts +0 -10
  285. package/dist/handlers/index.d.ts +0 -10
  286. package/dist/handlers/index.js +0 -11
  287. package/dist/handlers/index.js.map +0 -1
  288. package/dist/handlers/index.mjs +0 -2
  289. package/dist/handlers/index.mjs.map +0 -1
  290. package/dist/handlers/validation-handler/ValidationHandler.d.mts +0 -14
  291. package/dist/handlers/validation-handler/ValidationHandler.d.ts +0 -14
  292. package/dist/handlers/validation-handler/ValidationHandler.js +0 -2
  293. package/dist/handlers/validation-handler/ValidationHandler.js.map +0 -1
  294. package/dist/handlers/validation-handler/ValidationHandler.mjs +0 -2
  295. package/dist/handlers/validation-handler/ValidationHandler.mjs.map +0 -1
  296. package/dist/handlers/validation-handler/typings.d.mts +0 -14
  297. package/dist/handlers/validation-handler/typings.d.ts +0 -14
  298. package/dist/handlers/validation-handler/typings.js +0 -2
  299. package/dist/handlers/validation-handler/typings.js.map +0 -1
  300. package/dist/handlers/validation-handler/typings.mjs +0 -1
  301. package/dist/handlers/validation-handler/typings.mjs.map +0 -1
  302. package/dist/types.d.mts +0 -10
  303. package/dist/types.d.ts +0 -10
  304. package/dist/types.js +0 -2
  305. package/dist/types.js.map +0 -1
  306. package/dist/types.mjs +0 -2
  307. package/dist/types.mjs.map +0 -1
  308. package/dist/utils/clone.d.mts +0 -3
  309. package/dist/utils/clone.d.ts +0 -3
  310. package/dist/utils/clone.js +0 -2
  311. package/dist/utils/clone.js.map +0 -1
  312. package/dist/utils/clone.mjs +0 -2
  313. package/dist/utils/clone.mjs.map +0 -1
  314. package/dist/utils/colors.d.mts +0 -27
  315. package/dist/utils/colors.d.ts +0 -27
  316. package/dist/utils/colors.js +0 -2
  317. package/dist/utils/colors.js.map +0 -1
  318. package/dist/utils/colors.mjs +0 -2
  319. package/dist/utils/colors.mjs.map +0 -1
  320. package/dist/utils/constants.d.mts +0 -3
  321. package/dist/utils/constants.d.ts +0 -3
  322. package/dist/utils/constants.js +0 -2
  323. package/dist/utils/constants.js.map +0 -1
  324. package/dist/utils/constants.mjs +0 -2
  325. package/dist/utils/constants.mjs.map +0 -1
  326. package/dist/utils/error-codes.d.mts +0 -9
  327. package/dist/utils/error-codes.d.ts +0 -9
  328. package/dist/utils/error-codes.js +0 -2
  329. package/dist/utils/error-codes.js.map +0 -1
  330. package/dist/utils/error-codes.mjs +0 -2
  331. package/dist/utils/error-codes.mjs.map +0 -1
  332. package/dist/utils/get-paths.d.mts +0 -4
  333. package/dist/utils/get-paths.d.ts +0 -4
  334. package/dist/utils/get-paths.js +0 -2
  335. package/dist/utils/get-paths.js.map +0 -1
  336. package/dist/utils/get-paths.mjs +0 -2
  337. package/dist/utils/get-paths.mjs.map +0 -1
  338. package/dist/utils/resolve-file-url.d.mts +0 -8
  339. package/dist/utils/resolve-file-url.d.ts +0 -8
  340. package/dist/utils/resolve-file-url.js +0 -2
  341. package/dist/utils/resolve-file-url.js.map +0 -1
  342. package/dist/utils/resolve-file-url.mjs +0 -2
  343. package/dist/utils/resolve-file-url.mjs.map +0 -1
  344. package/dist/utils/warn-unstable.d.mts +0 -4
  345. package/dist/utils/warn-unstable.d.ts +0 -4
  346. package/dist/utils/warn-unstable.js +0 -2
  347. package/dist/utils/warn-unstable.js.map +0 -1
  348. package/dist/utils/warn-unstable.mjs +0 -2
  349. package/dist/utils/warn-unstable.mjs.map +0 -1
@@ -1,468 +0,0 @@
1
- import { ValidationHandler } from './handlers/validation-handler/ValidationHandler.js';
2
- import * as discord_js from 'discord.js';
3
- import { Client, Interaction, CacheType, ChatInputCommandInteraction, ContextMenuCommandInteraction, UserContextMenuCommandInteraction, MessageContextMenuCommandInteraction, AutocompleteInteraction, PermissionsString, RESTPostAPIApplicationCommandsJSONBody } from 'discord.js';
4
- import EventEmitter from 'node:events';
5
- import { CacheProvider } from './cache/CacheProvider.js';
6
- import { createElement, Fragment } from './components/common/element.js';
7
- import { EventInterceptor } from './components/common/EventInterceptor.js';
8
-
9
- /**
10
- * Options for instantiating a CommandKit handler.
11
- */
12
- interface CommandKitOptions {
13
- /**
14
- * The Discord.js client object to use with CommandKit.
15
- */
16
- client: Client;
17
- /**
18
- * The path to your commands directory.
19
- */
20
- commandsPath?: string;
21
- /**
22
- * The path to your events directory.
23
- */
24
- eventsPath?: string;
25
- /**
26
- * The path to the validations directory.
27
- */
28
- validationsPath?: string;
29
- /**
30
- * List of development guild IDs to restrict devOnly commands to.
31
- */
32
- devGuildIds?: string[];
33
- /**
34
- * List of developer user IDs to restrict devOnly commands to.
35
- */
36
- devUserIds?: string[];
37
- /**
38
- * List of developer role IDs to restrict devOnly commands to.
39
- */
40
- devRoleIds?: string[];
41
- /**
42
- * Skip CommandKit's built-in validations (for devOnly commands).
43
- */
44
- skipBuiltInValidations?: boolean;
45
- /**
46
- * Bulk register application commands instead of one-by-one.
47
- */
48
- bulkRegister?: boolean;
49
- /**
50
- * Whether or not to debug the command handler.
51
- */
52
- debugCommands?: boolean;
53
- /**
54
- * The cache provider to use with CommandKit. Defaults to MemoryCache provider.
55
- * Set this to `null` to not use any cache provider.
56
- */
57
- cacheProvider?: CacheProvider | null;
58
- }
59
- /**
60
- * Private data for the CommandKit class.
61
- */
62
- interface CommandKitData extends CommandKitOptions {
63
- commandHandler?: CommandHandler;
64
- eventHandler?: EventHandler;
65
- validationHandler?: ValidationHandler;
66
- }
67
- /**
68
- * Represents a command context.
69
- */
70
- interface CommandContext<T extends Interaction, Cached extends CacheType> {
71
- /**
72
- * The interaction that triggered this command.
73
- */
74
- interaction: Interaction<CacheType>;
75
- /**
76
- * The client that instantiated this command.
77
- */
78
- client: Client;
79
- /**
80
- * The command data.
81
- */
82
- handler: CommandKit;
83
- }
84
- /**
85
- * Represents a command file.
86
- */
87
- interface CommandFileObject {
88
- data: CommandData;
89
- options?: CommandOptions;
90
- run: <Cached extends CacheType = CacheType>(ctx: CommandContext<Interaction, Cached>) => Awaited<void>;
91
- autocomplete?: <Cached extends CacheType = CacheType>(ctx: CommandContext<Interaction, Cached>) => Awaited<void>;
92
- filePath: string;
93
- category: string | null;
94
- [key: string]: any;
95
- }
96
- /**
97
- * A reload type for commands.
98
- */
99
- type ReloadOptions = 'dev' | 'global' | ReloadType;
100
- /**
101
- * Props for command run functions.
102
- */
103
- interface CommandProps {
104
- /**
105
- * The current command interaction object.
106
- */
107
- interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction | UserContextMenuCommandInteraction | MessageContextMenuCommandInteraction | AutocompleteInteraction;
108
- /**
109
- * The Discord.js client object that CommandKit is handling.
110
- */
111
- client: Client<true>;
112
- /**
113
- * The current CommandKit handler instance.
114
- */
115
- handler: CommandKit;
116
- }
117
- /**
118
- * Props for autocomplete command run functions.
119
- */
120
- interface AutocompleteProps extends CommandProps {
121
- /**
122
- * The current autocomplete command interaction object.
123
- */
124
- interaction: AutocompleteInteraction;
125
- }
126
- /**
127
- * Props for slash (chat input) command run functions.
128
- */
129
- interface SlashCommandProps extends CommandProps {
130
- /**
131
- * The current slash (chat input) command interaction object.
132
- */
133
- interaction: ChatInputCommandInteraction;
134
- }
135
- /**
136
- * Props for context menu command run functions.
137
- */
138
- interface ContextMenuCommandProps extends CommandProps {
139
- /**
140
- * The current context menu command interaction object.
141
- */
142
- interaction: ContextMenuCommandInteraction;
143
- }
144
- /**
145
- * Props for user context menu command run functions.
146
- */
147
- interface UserContextMenuCommandProps extends CommandProps {
148
- interaction: UserContextMenuCommandInteraction;
149
- }
150
- /**
151
- * Props for message context menu command run functions.
152
- */
153
- interface MessageContextMenuCommandProps extends CommandProps {
154
- interaction: MessageContextMenuCommandInteraction;
155
- }
156
- /**
157
- * Props for command validation functions.
158
- */
159
- interface ValidationProps {
160
- /**
161
- * The current command interaction object.
162
- */
163
- interaction: ChatInputCommandInteraction | ContextMenuCommandInteraction | AutocompleteInteraction;
164
- /**
165
- * The Discord.js client object that CommandKit is handling.
166
- */
167
- client: Client<true>;
168
- /**
169
- * The current (local) target command object.
170
- */
171
- commandObj: CommandObject;
172
- /**
173
- * The current CommandKit handler instance.
174
- */
175
- handler: CommandKit;
176
- }
177
- /**
178
- * Additional command configuration options.
179
- */
180
- interface CommandOptions {
181
- /**
182
- * A boolean indicating whether the command is guild-only.
183
- * Used for built-in validation.
184
- *
185
- * @deprecated Use `dm_permission` in the command's `data` object instead.
186
- */
187
- guildOnly?: boolean;
188
- /**
189
- * A boolean indicating whether the command is developer-only.
190
- * Used for registration and built-in validation.
191
- */
192
- devOnly?: boolean;
193
- /**
194
- * A boolean indicating whether the command is deleted/ignored on restart/reload.
195
- */
196
- deleted?: boolean;
197
- /**
198
- * A string or array of permissions that a user needs for the current command to be executed.
199
- * Used for built-in validation.
200
- *
201
- * @example
202
- * userPermissions: 'BanMembers'
203
- * or
204
- * userPermissions: ['BanMembers', 'KickMembers']
205
- */
206
- userPermissions?: PermissionsString | PermissionsString[];
207
- /**
208
- * A string or array of permissions that the bot needs to execute the current command.
209
- * Used for built-in validation.
210
- *
211
- * @example
212
- * botPermissions: 'BanMembers'
213
- * or
214
- * botPermissions: ['BanMembers', 'KickMembers']
215
- */
216
- botPermissions?: PermissionsString | PermissionsString[];
217
- [key: string]: any;
218
- }
219
- type CommandData = RESTPostAPIApplicationCommandsJSONBody;
220
- type CommandObject = {
221
- /**
222
- * An object which defines the structure of the application command.
223
- */
224
- data: CommandData;
225
- /**
226
- * Additional command configuration options.
227
- */
228
- options?: CommandOptions;
229
- /**
230
- * The path to the command file.
231
- */
232
- filePath: string;
233
- /**
234
- * The command's category. Determined based on the command folder.
235
- *
236
- * @example
237
- * ```txt
238
- * "/src/commands/ping.js" -> null
239
- * "/src/commands/Misc/ping.js" -> "Misc"
240
- * ```
241
- */
242
- category: string | null;
243
- [key: string]: any;
244
- };
245
- declare enum ReloadType {
246
- /**
247
- * Reload developer/guild commands.
248
- */
249
- Developer = "dev",
250
- /**
251
- * Reload global commands.
252
- */
253
- Global = "global"
254
- }
255
-
256
- /**
257
- * Command handler options.
258
- * Similar to CommandKit options in structure.
259
- */
260
- interface CommandHandlerOptions {
261
- /**
262
- * The client created by the user.
263
- */
264
- client: Client;
265
- /**
266
- * Path to the user's commands.
267
- */
268
- commandsPath: string;
269
- /**
270
- * An array of developer guild IDs.
271
- */
272
- devGuildIds: string[];
273
- /**
274
- * An array of developer user IDs.
275
- */
276
- devUserIds: string[];
277
- /**
278
- * An array of developer role IDs.
279
- */
280
- devRoleIds: string[];
281
- /**
282
- * A validation handler instance to run validations before commands.
283
- */
284
- validationHandler?: ValidationHandler;
285
- /**
286
- * A boolean indicating whether to skip CommandKit's built-in validations (permission checking, etc.)
287
- */
288
- skipBuiltInValidations: boolean;
289
- /**
290
- * The CommandKit handler that instantiated this.
291
- */
292
- commandkitInstance: CommandKit;
293
- /**
294
- * A boolean indicating whether to register all commands in bulk.
295
- */
296
- bulkRegister: boolean;
297
- }
298
- /**
299
- * Private command handler data.
300
- */
301
- interface CommandHandlerData extends CommandHandlerOptions {
302
- /**
303
- * An array of command file objects.
304
- */
305
- commands: CommandFileObject[];
306
- /**
307
- * An array of built-in validations.
308
- */
309
- builtInValidations: BuiltInValidation[];
310
- /**
311
- * A validation handler instance to run validations before commands.
312
- */
313
- validationHandler?: ValidationHandler;
314
- }
315
- /**
316
- * Parameters for CommandKit's built-in validations.
317
- */
318
- interface BuiltInValidationParams {
319
- /**
320
- * The target command to validate.
321
- */
322
- targetCommand: CommandFileObject;
323
- /**
324
- * The interaction of the target command.
325
- */
326
- interaction: CommandKitInteraction;
327
- /**
328
- * The command handler's data.
329
- */
330
- handlerData: CommandHandlerData;
331
- }
332
- /**
333
- * Represents a command interaction.
334
- */
335
- type CommandKitInteraction = ChatInputCommandInteraction | ContextMenuCommandInteraction | AutocompleteInteraction;
336
- /**
337
- * A built in validation. Returns a boolean or void.
338
- */
339
- type BuiltInValidation = ({}: BuiltInValidationParams) => boolean | void;
340
-
341
- interface hCommandContext {
342
- interaction: CommandKitInteraction;
343
- command: CommandData;
344
- }
345
- /**
346
- * A handler for client application commands.
347
- */
348
- declare class CommandHandler {
349
- #private;
350
- constructor({ ...options }: CommandHandlerOptions);
351
- init(): Promise<void>;
352
- handleCommands(): void;
353
- get commands(): CommandFileObject[];
354
- reloadCommands(type?: ReloadOptions): Promise<void>;
355
- }
356
-
357
- /**
358
- * Event handler options.
359
- */
360
- interface EventHandlerOptions {
361
- client: Client;
362
- eventsPath: string;
363
- commandKitInstance: CommandKit;
364
- }
365
- /**
366
- * Private event handler data.
367
- */
368
- interface EventHandlerData extends EventHandlerOptions {
369
- events: {
370
- name: string;
371
- functions: Function[];
372
- }[];
373
- }
374
-
375
- /**
376
- * A handler for client events.
377
- */
378
- declare class EventHandler {
379
- #private;
380
- constructor({ ...options }: EventHandlerOptions);
381
- init(): Promise<void>;
382
- get events(): {
383
- name: string;
384
- functions: Function[];
385
- }[];
386
- reloadEvents(commandHandler?: CommandHandler): Promise<void>;
387
- }
388
-
389
- declare class CommandKit extends EventEmitter {
390
- #private;
391
- readonly eventInterceptor: EventInterceptor;
392
- static readonly createElement: typeof createElement;
393
- static readonly Fragment: typeof Fragment;
394
- static instance: CommandKit | undefined;
395
- /**
396
- * Create a new command and event handler with CommandKit.
397
- *
398
- * @param options - The default CommandKit configuration.
399
- * @see {@link https://commandkit.dev/guide/commandkit-setup}
400
- */
401
- constructor(options: CommandKitOptions);
402
- /**
403
- * Resolves the current cache provider.
404
- */
405
- getCacheProvider(): CacheProvider | null;
406
- /**
407
- * Whether or not to debug the command handler.
408
- */
409
- isDebuggingCommands(): boolean;
410
- /**
411
- * Get the client attached to this CommandKit instance.
412
- */
413
- get client(): discord_js.Client<boolean>;
414
- /**
415
- * Get command handler instance.
416
- */
417
- get commandHandler(): CommandHandler | undefined;
418
- /**
419
- * Updates application commands with the latest from "commandsPath".
420
- */
421
- reloadCommands(type?: ReloadOptions): Promise<void>;
422
- /**
423
- * Updates application events with the latest from "eventsPath".
424
- */
425
- reloadEvents(): Promise<void>;
426
- /**
427
- * Updates application command validations with the latest from "validationsPath".
428
- */
429
- reloadValidations(): Promise<void>;
430
- /**
431
- * @returns An array of objects of all the commands that CommandKit is handling.
432
- */
433
- get commands(): CommandObject[];
434
- /**
435
- * @returns The path to the commands folder which was set when instantiating CommandKit.
436
- */
437
- get commandsPath(): string | undefined;
438
- /**
439
- * @returns The path to the events folder which was set when instantiating CommandKit.
440
- */
441
- get eventsPath(): string | undefined;
442
- /**
443
- * @returns The path to the validations folder which was set when instantiating CommandKit.
444
- */
445
- get validationsPath(): string | undefined;
446
- /**
447
- * @returns An array of all the developer user IDs which was set when instantiating CommandKit.
448
- */
449
- get devUserIds(): string[];
450
- /**
451
- * @returns An array of all the developer guild IDs which was set when instantiating CommandKit.
452
- */
453
- get devGuildIds(): string[];
454
- /**
455
- * @returns An array of all the developer role IDs which was set when instantiating CommandKit.
456
- */
457
- get devRoleIds(): string[];
458
- /**
459
- * Increment the client listeners count.
460
- */
461
- incrementClientListenersCount(): void;
462
- /**
463
- * Decrement the client listeners count.
464
- */
465
- decrementClientListenersCount(): void;
466
- }
467
-
468
- export { type AutocompleteProps as A, type BuiltInValidationParams as B, CommandKit as C, type EventHandlerOptions as E, type MessageContextMenuCommandProps as M, type ReloadOptions as R, type SlashCommandProps as S, type UserContextMenuCommandProps as U, type ValidationProps as V, type CommandKitOptions as a, type CommandKitData as b, type CommandContext as c, type CommandFileObject as d, type CommandProps as e, type ContextMenuCommandProps as f, type CommandOptions as g, type CommandData as h, type CommandObject as i, ReloadType as j, type CommandHandlerOptions as k, type CommandHandlerData as l, type CommandKitInteraction as m, type BuiltInValidation as n, type hCommandContext as o, CommandHandler as p, type EventHandlerData as q, EventHandler as r };
@@ -1,10 +0,0 @@
1
- import 'discord.js';
2
- import 'node:events';
3
- export { C as CommandKit } from './CommandKit-BRxmnywX.mjs';
4
- import './cache/CacheProvider.mjs';
5
- import './components/common/element.mjs';
6
- import './components/common/EventInterceptor.mjs';
7
- import './handlers/validation-handler/ValidationHandler.mjs';
8
- import './handlers/validation-handler/typings.mjs';
9
- import './components/button/ButtonKit.mjs';
10
- import './components/modal/ModalKit.mjs';
@@ -1,10 +0,0 @@
1
- import 'discord.js';
2
- import 'node:events';
3
- export { C as CommandKit } from './CommandKit-BhFmurtb.js';
4
- import './cache/CacheProvider.js';
5
- import './components/common/element.js';
6
- import './components/common/EventInterceptor.js';
7
- import './handlers/validation-handler/ValidationHandler.js';
8
- import './handlers/validation-handler/typings.js';
9
- import './components/button/ButtonKit.js';
10
- import './components/modal/ModalKit.js';
@@ -1,11 +0,0 @@
1
- "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var __publicField=(obj,key,value)=>__defNormalProp(obj,typeof key!="symbol"?key+"":key,value),__accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var CommandKit_exports={};__export(CommandKit_exports,{CommandKit:()=>CommandKit});module.exports=__toCommonJS(CommandKit_exports);var import_node_events=__toESM(require("events"));var import_rfdc=__toESM(require("rfdc")),clone=(0,import_rfdc.default)();var resetColor="\x1B[0m",colors_default={reset:__name(text=>`${text}${resetColor}`,"reset"),bright:__name(text=>`\x1B[1m${text}${resetColor}`,"bright"),dim:__name(text=>`\x1B[2m${text}${resetColor}`,"dim"),underscore:__name(text=>`\x1B[4m${text}${resetColor}`,"underscore"),blink:__name(text=>`\x1B[5m${text}${resetColor}`,"blink"),reverse:__name(text=>`\x1B[7m${text}${resetColor}`,"reverse"),hidden:__name(text=>`\x1B[8m${text}${resetColor}`,"hidden"),black:__name(text=>`\x1B[30m${text}${resetColor}`,"black"),red:__name(text=>`\x1B[31m${text}${resetColor}`,"red"),green:__name(text=>`\x1B[32m${text}${resetColor}`,"green"),yellow:__name(text=>`\x1B[33m${text}${resetColor}`,"yellow"),blue:__name(text=>`\x1B[34m${text}${resetColor}`,"blue"),magenta:__name(text=>`\x1B[35m${text}${resetColor}`,"magenta"),cyan:__name(text=>`\x1B[36m${text}${resetColor}`,"cyan"),white:__name(text=>`\x1B[37m${text}${resetColor}`,"white"),bgBlack:__name(text=>`\x1B[40m${text}${resetColor}`,"bgBlack"),bgRed:__name(text=>`\x1B[41m${text}${resetColor}`,"bgRed"),bgGreen:__name(text=>`\x1B[42m${text}${resetColor}`,"bgGreen"),bgYellow:__name(text=>`\x1B[43m${text}${resetColor}`,"bgYellow"),bgBlue:__name(text=>`\x1B[44m${text}${resetColor}`,"bgBlue"),bgMagenta:__name(text=>`\x1B[45m${text}${resetColor}`,"bgMagenta"),bgCyan:__name(text=>`\x1B[46m${text}${resetColor}`,"bgCyan"),bgWhite:__name(text=>`\x1B[47m${text}${resetColor}`,"bgWhite")};var import_path=__toESM(require("path")),import_promises=__toESM(require("fs/promises"));async function getFilePaths(directory,nesting){let filePaths=[];if(!directory)return filePaths;let files=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let file of files){let filePath=import_path.default.join(directory,file.name);file.isFile()&&filePaths.push(filePath),nesting&&file.isDirectory()&&(filePaths=[...filePaths,...await getFilePaths(filePath,!0)])}return filePaths}__name(getFilePaths,"getFilePaths");async function getFolderPaths(directory,nesting){let folderPaths=[];if(!directory)return folderPaths;let folders=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let folder of folders){let folderPath=import_path.default.join(directory,folder.name);folder.isDirectory()&&(folderPaths.push(folderPath),nesting&&(folderPaths=[...folderPaths,...await getFolderPaths(folderPath,!0)]))}return folderPaths}__name(getFolderPaths,"getFolderPaths");var import_path2=__toESM(require("path"));function toFileURL(filePath){return"file://"+import_path2.default.resolve(filePath).replace(/\\\\|\\/g,"/")}__name(toFileURL,"toFileURL");async function loadCommandsWithRest(props){if(props.reloading)if(props.client.isReady())await handleLoading(props.client,props.commands,props.devGuildIds,props.reloading,props.type);else throw new Error(colors_default.red("Cannot reload commands when client is not ready."));else props.client.once("ready",async c=>{await handleLoading(c,props.commands,props.devGuildIds,props.reloading,props.type)})}__name(loadCommandsWithRest,"loadCommandsWithRest");async function handleLoading(client,commands,devGuildIds,reloading,type){commands=commands.filter(cmd=>{var _a;return!((_a=cmd.options)!=null&&_a.deleted)});let devOnlyCommands=commands.filter(cmd=>{var _a;return(_a=cmd.options)==null?void 0:_a.devOnly}),globalCommands=commands.filter(cmd=>{var _a;return!((_a=cmd.options)!=null&&_a.devOnly)});type==="dev"?await loadDevCommands(client,devOnlyCommands,devGuildIds,reloading):type==="global"?await loadGlobalCommands(client,globalCommands,reloading):(await loadDevCommands(client,devOnlyCommands,devGuildIds,reloading),await loadGlobalCommands(client,globalCommands,reloading))}__name(handleLoading,"handleLoading");async function loadGlobalCommands(client,commands,reloading){let requestBody=commands.map(cmd=>cmd.data);await client.application.commands.set(requestBody).catch(error=>{throw new Error(colors_default.red(`Error ${reloading?"reloading":"loading"} global application commands.
2
- `),error)}),console.log(colors_default.green(`${reloading?"Reloaded":"Loaded"} ${requestBody.length} global commands.`))}__name(loadGlobalCommands,"loadGlobalCommands");async function loadDevCommands(client,commands,guildIds,reloading){let requestBody=commands.map(cmd=>cmd.data);for(let guildId of guildIds){let targetGuild=client.guilds.cache.get(guildId)||await client.guilds.fetch(guildId);if(!targetGuild){process.emitWarning(`Cannot ${reloading?"reload":"load"} commands in guild "${guildId}" - guild doesn't exist or client isn't part of the guild.`);continue}await targetGuild.commands.set(requestBody).catch(error=>{throw new Error(colors_default.red(`Error ${reloading?"reloading":"loading"} developer application commands in guild "${(targetGuild==null?void 0:targetGuild.name)||guildId}".
3
- `),error)}),console.log(colors_default.green(`${reloading?"Reloaded":"Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`))}}__name(loadDevCommands,"loadDevCommands");function areSlashCommandsDifferent(appCommand,localCommand){if(appCommand.options||(appCommand.options=[]),localCommand.options||(localCommand.options=[]),appCommand.description||(appCommand.description=""),localCommand.description||(localCommand.description=""),localCommand.description!==appCommand.description||localCommand.options.length!==appCommand.options.length)return!0}__name(areSlashCommandsDifferent,"areSlashCommandsDifferent");async function registerCommands(props){if(props.reloading)if(props.client.isReady())await handleRegistration(props.client,props.commands,props.devGuildIds,props.type);else throw new Error(colors_default.red("Cannot reload commands when client is not ready."));else props.client.once("ready",async c=>{await handleRegistration(c,props.commands,props.devGuildIds,props.type)})}__name(registerCommands,"registerCommands");async function handleRegistration(client,commands,devGuildIds,type){let devOnlyCommands=commands.filter(cmd=>{var _a;return(_a=cmd.options)==null?void 0:_a.devOnly}),globalCommands=commands.filter(cmd=>{var _a;return!((_a=cmd.options)!=null&&_a.devOnly)});type==="dev"?await registerDevCommands(client,devOnlyCommands,devGuildIds):type==="global"?await registerGlobalCommands(client,globalCommands):(await registerDevCommands(client,devOnlyCommands,devGuildIds),await registerGlobalCommands(client,globalCommands))}__name(handleRegistration,"handleRegistration");async function registerGlobalCommands(client,commands){var _a;let appCommandsManager=client.application.commands;await appCommandsManager.fetch();for(let command of commands){let targetCommand=appCommandsManager.cache.find(cmd=>cmd.name===command.data.name);if((_a=command.options)!=null&&_a.deleted){targetCommand?(await targetCommand.delete().catch(error=>{throw new Error(colors_default.red(`Failed to delete command "${command.data.name}" globally.
4
- `),error)}),console.log(colors_default.green(`Deleted command "${command.data.name}" globally.`))):process.emitWarning(colors_default.yellow(`Ignoring: Command "${command.data.name}" is globally marked as deleted.`));continue}if(targetCommand&&areSlashCommandsDifferent(targetCommand,command.data)){await targetCommand.edit(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to edit command "${command.data.name}" globally.
5
- `),error)}),console.log(colors_default.green(`Edited command "${command.data.name}" globally.`));continue}targetCommand||(await appCommandsManager.create(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to register command "${command.data.name}" globally.
6
- `),error)}),console.log(colors_default.green(`Registered command "${command.data.name}" globally.`)))}}__name(registerGlobalCommands,"registerGlobalCommands");async function registerDevCommands(client,commands,guildIds){var _a;let devGuilds=[];for(let guildId of guildIds){let guild=client.guilds.cache.get(guildId)||await client.guilds.fetch(guildId);if(!guild){process.emitWarning(colors_default.yellow(`Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.`));continue}devGuilds.push(guild)}let guildCommandsManagers=[];for(let guild of devGuilds){let guildCommandsManager=guild.commands;await guildCommandsManager.fetch(),guildCommandsManagers.push(guildCommandsManager)}for(let command of commands)for(let guildCommands of guildCommandsManagers){let targetCommand=guildCommands.cache.find(cmd=>cmd.name===command.data.name);if((_a=command.options)!=null&&_a.deleted){targetCommand?(await targetCommand.delete().catch(error=>{throw new Error(colors_default.red(`Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`),error)}),console.log(colors_default.green(`Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`))):process.emitWarning(colors_default.yellow(`Ignoring: Command "${command.data.name}" is marked as deleted in ${guildCommands.guild.name}.`));continue}if(targetCommand&&areSlashCommandsDifferent(targetCommand,command.data)){await targetCommand.edit(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.
7
- `),error)}),console.log(colors_default.green(`Edited command "${command.data.name}" in ${guildCommands.guild.name}.`));continue}targetCommand||(await guildCommands.create(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to register command "${command.data.name}" in ${guildCommands.guild.name}.
8
- `),error)}),console.log(colors_default.green(`Registered command "${command.data.name}" in ${guildCommands.guild.name}.`)))}}__name(registerDevCommands,"registerDevCommands");var import_discord=require("discord.js");function devOnly_default({interaction,targetCommand,handlerData}){var _a,_b;if(!interaction.isAutocomplete()&&(_a=targetCommand.options)!=null&&_a.devOnly){if(interaction.inGuild()&&!handlerData.devGuildIds.includes(interaction.guildId))return interaction.reply({content:"\u274C This command can only be used inside development servers.",flags:import_discord.MessageFlags.Ephemeral}),!0;let guildMember=(_b=interaction.guild)==null?void 0:_b.members.cache.get(interaction.user.id),memberRoles=guildMember==null?void 0:guildMember.roles.cache,hasDevRole=!1;if(memberRoles==null||memberRoles.forEach(role=>{handlerData.devRoleIds.includes(role.id)&&(hasDevRole=!0)}),!(handlerData.devUserIds.includes(interaction.user.id)||hasDevRole))return interaction.reply({content:"\u274C This command can only be used by developers.",flags:import_discord.MessageFlags.Ephemeral}),!0}}__name(devOnly_default,"default");var import_discord2=require("discord.js");function permissions_default({interaction,targetCommand}){var _a,_b,_c,_d;if(interaction.isAutocomplete())return;let userPermissions=interaction.memberPermissions,userPermissionsRequired=(_a=targetCommand.options)==null?void 0:_a.userPermissions,missingUserPermissions=[];typeof userPermissionsRequired=="string"&&(userPermissionsRequired=[userPermissionsRequired]);let botPermissions=(_c=(_b=interaction.guild)==null?void 0:_b.members.me)==null?void 0:_c.permissions,botPermissionsRequired=(_d=targetCommand.options)==null?void 0:_d.botPermissions,missingBotPermissions=[];if(typeof botPermissionsRequired=="string"&&(botPermissionsRequired=[botPermissionsRequired]),!(userPermissionsRequired!=null&&userPermissionsRequired.length)&&!(botPermissionsRequired!=null&&botPermissionsRequired.length))return;if(userPermissions&&userPermissionsRequired)for(let permission of userPermissionsRequired)userPermissions.has(permission)||missingUserPermissions.push(permission);if(botPermissions&&botPermissionsRequired)for(let permission of botPermissionsRequired)botPermissions.has(permission)||missingBotPermissions.push(permission);if(!missingUserPermissions.length&&!missingBotPermissions.length)return;let pattern=/([a-z])([A-Z])|([A-Z]+)([A-Z][a-z])/g;missingUserPermissions=missingUserPermissions.map(str=>str.replace(pattern,"$1$3 $2$4")),missingBotPermissions=missingBotPermissions.map(str=>str.replace(pattern,"$1$3 $2$4"));let embedDescription="",formatter=new Intl.ListFormat("en",{style:"long",type:"conjunction"}),getPermissionWord=__name(permissions=>permissions.length===1?"permission":"permissions","getPermissionWord");if(missingUserPermissions.length){let formattedPermissions=missingUserPermissions.map(p=>`\`${p}\``),permissionsString=formatter.format(formattedPermissions);embedDescription+=`- You must have the ${permissionsString} ${getPermissionWord(missingUserPermissions)} to be able to run this command.
9
- `}if(missingBotPermissions.length){let formattedPermissions=missingBotPermissions.map(p=>`\`${p}\``),permissionsString=formatter.format(formattedPermissions);embedDescription+=`- I must have the ${permissionsString} ${getPermissionWord(missingBotPermissions)} to be able to execute this command.
10
- `}let embed=new import_discord2.EmbedBuilder().setTitle(":x: Missing permissions!").setDescription(embedDescription).setColor("Red");return interaction.reply({embeds:[embed],flags:import_discord2.MessageFlags.Ephemeral}),!0}__name(permissions_default,"default");var validations_default=[devOnly_default,permissions_default];var import_node_async_hooks=require("async_hooks");var CommandKitErrorCodes={GuildOnlyException:Symbol("kGuildOnlyException"),DMOnlyException:Symbol("kDMOnlyException")};function isCommandKitError(error){if(!(error instanceof Error))return!1;let code=Reflect.get(error,"code");for(let key in CommandKitErrorCodes)if(CommandKitErrorCodes[key]===code)return!0;return!1}__name(isCommandKitError,"isCommandKitError");var import_discord3=require("discord.js");var context=new import_node_async_hooks.AsyncLocalStorage;function makeContextAwareFunction(env,fn,finalizer){return __name((...args)=>context.run(env,async()=>{try{return await fn(...args)}catch(e){if(isCommandKitError(e)){let code=Reflect.get(e,"code"),interaction=env.variables.get("interaction");if(!interaction)return;switch(code){case CommandKitErrorCodes.GuildOnlyException:{interaction.isRepliable()&&await interaction.reply({content:"This command is only available in guilds.",flags:import_discord3.MessageFlags.Ephemeral});return}case CommandKitErrorCodes.DMOnlyException:{interaction.isRepliable()&&await interaction.reply({content:"This command is only available in DMs.",flags:import_discord3.MessageFlags.Ephemeral});return}}return}env.setExecutionError(e)}finally{if(typeof finalizer=="function")try{await finalizer(...args)}catch{}}}),"_fn")}__name(makeContextAwareFunction,"makeContextAwareFunction");function getContext(){return context.getStore()}__name(getContext,"getContext");function useEnvironment(){let ctx=context.getStore();if(!ctx)throw new Error("No commandkit environment found. Please make sure you are inside commandkit handler.");return ctx}__name(useEnvironment,"useEnvironment");var import_node_crypto=require("crypto");var _data,_CommandKitEnvironment=class _CommandKitEnvironment{constructor(commandkit){this.commandkit=commandkit;__privateAdd(this,_data,{executionError:null,type:null,variables:new Map,deferredFunctions:new Map,marker:"",markStart:0,markEnd:0})}getExecutionError(){return __privateGet(this,_data).executionError}setExecutionError(error){if(__privateGet(this,_data).executionError)throw new Error("Execution error already set.");__privateGet(this,_data).executionError=error}getType(){let type=__privateGet(this,_data).type;if(!type)throw new Error("Environment type not set.");return type}setType(type){__privateGet(this,_data).type=type}get variables(){return __privateGet(this,_data).variables}registerDeferredFunction(fn){let id=(0,import_node_crypto.randomUUID)();return __privateGet(this,_data).deferredFunctions.set(id,fn),id}clearDeferredFunction(id){__privateGet(this,_data).deferredFunctions.delete(id)}async runDeferredFunctions(){for(let[id,fn]of __privateGet(this,_data).deferredFunctions)try{await fn(this)}catch(e){this.commandkit.emit("unhandledDeferredFunctionRejection",e)}finally{this.clearDeferredFunction(id)}}clearAllDeferredFunctions(){__privateGet(this,_data).deferredFunctions.clear()}markStart(marker){__privateGet(this,_data).marker=marker,__privateGet(this,_data).markStart=performance.now()}markEnd(){__privateGet(this,_data).markEnd||(__privateGet(this,_data).markEnd=performance.now())}getMarker(){return __privateGet(this,_data).marker}getExecutionTime(){return Math.abs(__privateGet(this,_data).markEnd-__privateGet(this,_data).markStart)}};_data=new WeakMap,__name(_CommandKitEnvironment,"CommandKitEnvironment");var CommandKitEnvironment=_CommandKitEnvironment;function after(fn){let env=getContext();if(!env)throw new Error("after must be called inside commandkit handler.");return env.registerDeferredFunction(fn)}__name(after,"after");var _data2,_CommandHandler_instances,buildCommands_fn,buildBuiltInValidations_fn,commandFinalizer_fn,interactionHandler_fn,_CommandHandler=class _CommandHandler{constructor({...options}){__privateAdd(this,_CommandHandler_instances);__privateAdd(this,_data2);__privateSet(this,_data2,{...options,builtInValidations:[],commands:[]})}async init(){await __privateMethod(this,_CommandHandler_instances,buildCommands_fn).call(this),__privateMethod(this,_CommandHandler_instances,buildBuiltInValidations_fn).call(this);let devOnlyCommands=__privateGet(this,_data2).commands.filter(cmd=>{var _a;return(_a=cmd.options)==null?void 0:_a.devOnly});devOnlyCommands.length&&!__privateGet(this,_data2).devGuildIds.length&&process.emitWarning(colors_default.yellow('You have commands marked as "devOnly", but "devGuildIds" have not been set.')),devOnlyCommands.length&&!__privateGet(this,_data2).devUserIds.length&&!__privateGet(this,_data2).devRoleIds.length&&process.emitWarning(colors_default.yellow('You have commands marked as "devOnly", but "devUserIds" or "devRoleIds" have not been set.')),__privateGet(this,_data2).bulkRegister?await loadCommandsWithRest({client:__privateGet(this,_data2).client,devGuildIds:__privateGet(this,_data2).devGuildIds,commands:__privateGet(this,_data2).commands}):await registerCommands({client:__privateGet(this,_data2).client,devGuildIds:__privateGet(this,_data2).devGuildIds,commands:__privateGet(this,_data2).commands}),this.handleCommands()}handleCommands(){__privateGet(this,_data2).client.on("interactionCreate",interaction=>{let env=new CommandKitEnvironment(__privateGet(this,_data2).commandkitInstance);return env.setType("COMMAND_HANDLER"),makeContextAwareFunction(env,__privateMethod(this,_CommandHandler_instances,interactionHandler_fn).bind(this),__privateMethod(this,_CommandHandler_instances,commandFinalizer_fn).bind(this))(interaction)})}get commands(){return __privateGet(this,_data2).commands}async reloadCommands(type){if(!__privateGet(this,_data2).commandsPath)throw new Error(colors_default.red('Cannot reload commands as "commandsPath" was not provided when instantiating CommandKit.'));__privateGet(this,_data2).commands=[],await __privateMethod(this,_CommandHandler_instances,buildCommands_fn).call(this),__privateGet(this,_data2).bulkRegister?await loadCommandsWithRest({client:__privateGet(this,_data2).client,devGuildIds:__privateGet(this,_data2).devGuildIds,commands:__privateGet(this,_data2).commands,reloading:!0,type}):await registerCommands({client:__privateGet(this,_data2).client,devGuildIds:__privateGet(this,_data2).devGuildIds,commands:__privateGet(this,_data2).commands,reloading:!0,type})}};_data2=new WeakMap,_CommandHandler_instances=new WeakSet,buildCommands_fn=__name(async function(){var _a;let allowedExtensions=/\.(js|mjs|cjs|ts)$/i,commandFilePaths=(await getFilePaths(__privateGet(this,_data2).commandsPath,!0)).filter(path3=>allowedExtensions.test(path3));for(let commandFilePath of commandFilePaths){let importedObj=await import(`${toFileURL(commandFilePath)}?t=${Date.now()}`),commandObj=clone(importedObj);typeof module<"u"&&typeof require<"u"&&delete require.cache[require.resolve(commandFilePath)];let compactFilePath=commandFilePath.split(process.cwd())[1]||commandFilePath;if(commandObj.default&&(commandObj=commandObj.default),importedObj.default?commandObj.data=importedObj.default.data:commandObj.data=importedObj.data,!commandObj.data){process.emitWarning(colors_default.yellow(`Ignoring: Command file ${compactFilePath} does not export "data".`));continue}if(!commandObj.data.name){process.emitWarning(colors_default.yellow(`Ignoring: Command file ${compactFilePath} does not export "data.name".`));continue}if(!commandObj.run){process.emitWarning(colors_default.yellow(`Ignoring: Command file ${commandObj.data.name} does not export "run".`));continue}if(typeof commandObj.run!="function"){process.emitWarning(colors_default.yellow(`Ignoring: Command file ${commandObj.data.name} does not export "run" as a function.`));continue}commandObj.filePath=commandFilePath;let commandCategory=((_a=commandFilePath.split(__privateGet(this,_data2).commandsPath)[1])==null?void 0:_a.replace(/\\\\|\\/g,"/").split("/")[1])||null;commandCategory&&allowedExtensions.test(commandCategory)?commandObj.category=null:commandObj.category=commandCategory,__privateGet(this,_data2).commands.push(commandObj)}},"#buildCommands"),buildBuiltInValidations_fn=__name(function(){for(let builtInValidationFunction of validations_default)__privateGet(this,_data2).builtInValidations.push(builtInValidationFunction)},"#buildBuiltInValidations"),commandFinalizer_fn=__name(async function(){let env=useEnvironment();await env.runDeferredFunctions(),env.clearAllDeferredFunctions()},"#commandFinalizer"),interactionHandler_fn=__name(async function(interaction){if(!interaction.isChatInputCommand()&&!interaction.isContextMenuCommand()&&!interaction.isAutocomplete())return;let isAutocomplete=interaction.isAutocomplete(),targetCommand=__privateGet(this,_data2).commands.find(cmd=>cmd.data.name===interaction.commandName);if(!targetCommand)return;let env=useEnvironment();env.variables.set("interaction",interaction);let{data,options,run,autocomplete,...rest}=targetCommand;return isAutocomplete&&!autocomplete?void 0:__name(async()=>{let commandObj={data:targetCommand.data,options:targetCommand.options,...rest};if(__privateGet(this,_data2).validationHandler){let canRun2=!0;for(let validationFunction of __privateGet(this,_data2).validationHandler.validations)if(await validationFunction({interaction,commandObj,client:__privateGet(this,_data2).client,handler:__privateGet(this,_data2).commandkitInstance})){canRun2=!1;break}if(!canRun2)return}let canRun=!0;if(!__privateGet(this,_data2).skipBuiltInValidations){for(let validation of __privateGet(this,_data2).builtInValidations)if(validation({targetCommand,interaction,handlerData:__privateGet(this,_data2)})){canRun=!1;break}}if(!canRun)return;let command=targetCommand[isAutocomplete?"autocomplete":"run"],context2={interaction,client:__privateGet(this,_data2).client,handler:__privateGet(this,_data2).commandkitInstance};if(!__privateGet(this,_data2).commandkitInstance.isDebuggingCommands())return command(context2);after(env2=>{let error=env2.getExecutionError(),marker=env2.getMarker(),time=`${env2.getExecutionTime().toFixed(2)}ms`;if(error){console.error(colors_default.red(`[${marker} - ${time}] Error executing command: ${error.stack||error}`));return}console.log(colors_default.green(`[${marker} - ${time}] Command executed successfully`))});try{return env.markStart(interaction.commandName),await command(context2)}finally{env.markEnd()}},"executor")()},"#interactionHandler"),__name(_CommandHandler,"CommandHandler");var CommandHandler=_CommandHandler;var _data3,_EventHandler_instances,buildEvents_fn,registerEvents_fn,_EventHandler=class _EventHandler{constructor({...options}){__privateAdd(this,_EventHandler_instances);__privateAdd(this,_data3);__privateSet(this,_data3,{...options,events:[]})}async init(){await __privateMethod(this,_EventHandler_instances,buildEvents_fn).call(this),__privateMethod(this,_EventHandler_instances,registerEvents_fn).call(this)}get events(){return __privateGet(this,_data3).events}async reloadEvents(commandHandler){if(!__privateGet(this,_data3).eventsPath)throw new Error(colors_default.red('Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'));__privateGet(this,_data3).events=[],await __privateMethod(this,_EventHandler_instances,buildEvents_fn).call(this),__privateGet(this,_data3).client.removeAllListeners(),__privateMethod(this,_EventHandler_instances,registerEvents_fn).call(this),commandHandler==null||commandHandler.handleCommands()}};_data3=new WeakMap,_EventHandler_instances=new WeakSet,buildEvents_fn=__name(async function(){let eventFolderPaths=await getFolderPaths(__privateGet(this,_data3).eventsPath);for(let eventFolderPath of eventFolderPaths){let eventName=eventFolderPath.replace(/\\\\|\\/g,"/").split("/").pop(),allowedExtensions=/\.(js|mjs|cjs|ts)$/i,eventFilePaths=(await getFilePaths(eventFolderPath,!0)).filter(path3=>allowedExtensions.test(path3)),eventObj={name:eventName,functions:[]};__privateGet(this,_data3).events.push(eventObj);for(let eventFilePath of eventFilePaths){let importedFunction=(await import(`${toFileURL(eventFilePath)}?t=${Date.now()}`)).default,eventFunction=clone(importedFunction);typeof module<"u"&&typeof require<"u"&&delete require.cache[require.resolve(eventFilePath)],eventFunction!=null&&eventFunction.default&&(eventFunction=eventFunction.default);let compactFilePath=eventFilePath.split(process.cwd())[1]||eventFilePath;if(typeof eventFunction!="function"){process.emitWarning(colors_default.yellow(`Ignoring: Event file ${compactFilePath} does not export a function.`));continue}eventObj.functions.push(eventFunction)}}},"#buildEvents"),registerEvents_fn=__name(function(){let client=__privateGet(this,_data3).client,handler=__privateGet(this,_data3).commandKitInstance;for(let eventObj of __privateGet(this,_data3).events)client.on(eventObj.name,async(...params)=>{for(let eventFunction of eventObj.functions)if(await eventFunction(...params,client,handler))break})},"#registerEvents"),__name(_EventHandler,"EventHandler");var EventHandler=_EventHandler;var _data4,_ValidationHandler_instances,buildValidations_fn,_ValidationHandler=class _ValidationHandler{constructor({...options}){__privateAdd(this,_ValidationHandler_instances);__privateAdd(this,_data4);__privateSet(this,_data4,{...options,validations:[]})}async init(){__privateGet(this,_data4).validations=await __privateMethod(this,_ValidationHandler_instances,buildValidations_fn).call(this)}get validations(){return __privateGet(this,_data4).validations}async reloadValidations(){if(!__privateGet(this,_data4).validationsPath)throw new Error(colors_default.red('Cannot reload validations as "validationsPath" was not provided when instantiating CommandKit.'));let newValidations=await __privateMethod(this,_ValidationHandler_instances,buildValidations_fn).call(this);__privateGet(this,_data4).validations=newValidations}};_data4=new WeakMap,_ValidationHandler_instances=new WeakSet,buildValidations_fn=__name(async function(){let allowedExtensions=/\.(js|mjs|cjs|ts)$/i,validationFilePaths=(await getFilePaths(__privateGet(this,_data4).validationsPath,!0)).filter(path3=>allowedExtensions.test(path3)),validationFunctions=[];for(let validationFilePath of validationFilePaths){let importedFunction=(await import(`${toFileURL(validationFilePath)}?t=${Date.now()}`)).default,validationFunction=clone(importedFunction);typeof module<"u"&&typeof require<"u"&&delete require.cache[require.resolve(validationFilePath)],validationFunction!=null&&validationFunction.default&&(validationFunction=validationFunction.default);let compactFilePath=validationFilePath.split(process.cwd())[1]||validationFilePath;if(typeof validationFunction!="function"){process.emitWarning(colors_default.yellow(`Ignoring: Validation file ${compactFilePath} does not export a function.`));continue}validationFunctions.push(validationFunction)}return validationFunctions},"#buildValidations"),__name(_ValidationHandler,"ValidationHandler");var ValidationHandler=_ValidationHandler;var _CacheProvider=class _CacheProvider{};__name(_CacheProvider,"CacheProvider");var CacheProvider=_CacheProvider;var _cache,_MemoryCache=class _MemoryCache extends CacheProvider{constructor(){super(...arguments);__privateAdd(this,_cache,new Map)}async get(key){let entry=__privateGet(this,_cache).get(key);if(entry){if(entry.ttl&&Date.now()>entry.ttl){__privateGet(this,_cache).delete(key);return}return entry}}async set(key,value,ttl){let entry={value,ttl:ttl!=null?Date.now()+ttl:void 0};__privateGet(this,_cache).set(key,entry)}async exists(key){return __privateGet(this,_cache).has(key)}async delete(key){__privateGet(this,_cache).delete(key)}async clear(){__privateGet(this,_cache).clear()}async expire(key,ttl){let entry=__privateGet(this,_cache).get(key);if(!entry)return;let _ttl=Date.now()+ttl;if(_ttl<Date.now()){__privateGet(this,_cache).delete(key);return}entry.ttl=_ttl}};_cache=new WeakMap,__name(_MemoryCache,"MemoryCache");var MemoryCache=_MemoryCache;var import_discord4=require("discord.js");var import_discord5=require("discord.js");var import_discord6=require("discord.js");var import_discord7=require("discord.js");var import_discord8=require("discord.js");var WARNED_KEYS=new Set;function emitWarning(message,code="CommandKitWarning"){process.emitWarning(message,{code})}__name(emitWarning,"emitWarning");function warnUnstable(name){WARNED_KEYS.has(name)||(WARNED_KEYS.add(name),emitWarning(`${name} is unstable and may change in future versions.`,"CommandKitUnstableWarning"))}__name(warnUnstable,"warnUnstable");function Fragment(props){return warnUnstable("CommandKit JSX"),Array.isArray(props.children)?props.children.flat():props.children}__name(Fragment,"Fragment");function createElement(type,props,...children){return warnUnstable("CommandKit JSX"),type({...props,children})}__name(createElement,"createElement");var _EventInterceptor_instances,cleanupLoop_fn,_EventInterceptor=class _EventInterceptor{constructor(client){this.client=client;__privateAdd(this,_EventInterceptor_instances);__publicField(this,"subscribers",new Map);__publicField(this,"globalHandlers",new Map);__publicField(this,"cleanupTimer",null);__privateMethod(this,_EventInterceptor_instances,cleanupLoop_fn).call(this)}destroy(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null);for(let[event,handlers]of this.subscribers)for(let handler of handlers)this.unsubscribe(event,handler,"destroy");this.subscribers.clear(),this.globalHandlers.clear()}hasSubscribers(event){return this.subscribers.has(event)}getSubscriberCount(event){let handlers=this.subscribers.get(event);return(handlers==null?void 0:handlers.size)??0}hasGlobalHandlers(){return this.globalHandlers.size>0}getGlobalHandlersCount(){return this.subscribers.size}subscribe(event,listener,options){return this.subscribers.has(event)||(this.subscribers.set(event,new Set),this.client.on(event,this.createGlobalHandler(event)),this.client.setMaxListeners(this.client.getMaxListeners()+1)),options??={},options.registeredAt=Date.now(),Reflect.set(listener,"options",options),this.subscribers.get(event).add(listener),()=>{this.unsubscribe(event,listener)}}unsubscribe(event,listener,reason){var _a,_b;let handlers=this.subscribers.get(event);handlers&&(handlers.delete(listener),handlers.size<1&&(this.subscribers.delete(event),this.client.removeListener(event,this.globalHandlers.get(event)),this.globalHandlers.delete(event),this.client.setMaxListeners(Math.max(this.client.getMaxListeners()-1,0))),(_b=(_a=Reflect.get(listener,"options")).onEnd)==null||_b.call(_a,reason??"unsubscribe"))}createGlobalHandler(event){if(this.globalHandlers.has(event))return this.globalHandlers.get(event);let handler=__name(async(...args)=>{let subscribers=this.subscribers.get(event);if(subscribers&&subscribers.size>0)for(let subscriber of subscribers){let options=Reflect.get(subscriber,"options");if(options.time&&Date.now()-options.registeredAt>options.time){this.unsubscribe(event,subscriber,"time");continue}options.autoReset&&(options.registeredAt=Date.now()),!(options.filter&&!await options.filter(...args))&&await subscriber(...args)}},"handler");return this.globalHandlers.set(event,handler),handler}};_EventInterceptor_instances=new WeakSet,cleanupLoop_fn=__name(function(){this.cleanupTimer&&clearInterval(this.cleanupTimer),this.cleanupTimer=setInterval(()=>{for(let[event,handlers]of this.subscribers)for(let handler of handlers){let options=Reflect.get(handler,"options");options.time&&Date.now()-options.registeredAt>options.time&&this.unsubscribe(event,handler,"time")}},6e4).unref()},"#cleanupLoop"),__name(_EventInterceptor,"EventInterceptor");var EventInterceptor=_EventInterceptor;var _data5,_CommandKit_instances,init_fn,_CommandKit=class _CommandKit extends import_node_events.default{constructor(options){if(_CommandKit.instance&&process.emitWarning("CommandKit instance already exists. Having multiple instance in same project is discouraged and it may lead to unexpected behavior.",{code:"MultiInstanceWarning"}),!options.client)throw new Error(colors_default.red('"client" is required when instantiating CommandKit.'));if(options.validationsPath&&!options.commandsPath)throw new Error(colors_default.red('"commandsPath" is required when "validationsPath" is set.'));super();__privateAdd(this,_CommandKit_instances);__privateAdd(this,_data5);__publicField(this,"eventInterceptor");options.debugCommands??=process.env.NODE_ENV!=="production",options.cacheProvider!==null&&(!options.cacheProvider||!(options.cacheProvider instanceof CacheProvider))&&(options.cacheProvider=new MemoryCache),this.eventInterceptor=new EventInterceptor(options.client),__privateSet(this,_data5,options),__privateMethod(this,_CommandKit_instances,init_fn).call(this).then(()=>{this.incrementClientListenersCount()}),_CommandKit.instance||(_CommandKit.instance=this)}getCacheProvider(){return __privateGet(this,_data5).cacheProvider??null}isDebuggingCommands(){return __privateGet(this,_data5).debugCommands||!1}get client(){return __privateGet(this,_data5).client}get commandHandler(){return __privateGet(this,_data5).commandHandler}async reloadCommands(type){__privateGet(this,_data5).commandHandler&&await __privateGet(this,_data5).commandHandler.reloadCommands(type)}async reloadEvents(){__privateGet(this,_data5).eventHandler&&await __privateGet(this,_data5).eventHandler.reloadEvents(__privateGet(this,_data5).commandHandler)}async reloadValidations(){__privateGet(this,_data5).validationHandler&&await __privateGet(this,_data5).validationHandler.reloadValidations()}get commands(){return __privateGet(this,_data5).commandHandler?__privateGet(this,_data5).commandHandler.commands.map(cmd=>{let{run,autocomplete,...command}=cmd;return command}):[]}get commandsPath(){return __privateGet(this,_data5).commandsPath}get eventsPath(){return __privateGet(this,_data5).eventsPath}get validationsPath(){return __privateGet(this,_data5).validationsPath}get devUserIds(){return __privateGet(this,_data5).devUserIds||[]}get devGuildIds(){return __privateGet(this,_data5).devGuildIds||[]}get devRoleIds(){return __privateGet(this,_data5).devRoleIds||[]}incrementClientListenersCount(){__privateGet(this,_data5).client.setMaxListeners(__privateGet(this,_data5).client.getMaxListeners()+1)}decrementClientListenersCount(){__privateGet(this,_data5).client.setMaxListeners(__privateGet(this,_data5).client.getMaxListeners()-1)}};_data5=new WeakMap,_CommandKit_instances=new WeakSet,init_fn=__name(async function(){if(__privateGet(this,_data5).eventsPath){let eventHandler=new EventHandler({client:__privateGet(this,_data5).client,eventsPath:__privateGet(this,_data5).eventsPath,commandKitInstance:this});await eventHandler.init(),__privateGet(this,_data5).eventHandler=eventHandler}if(__privateGet(this,_data5).validationsPath){let validationHandler=new ValidationHandler({validationsPath:__privateGet(this,_data5).validationsPath});await validationHandler.init(),__privateGet(this,_data5).validationHandler=validationHandler}if(__privateGet(this,_data5).commandsPath){let commandHandler=new CommandHandler({client:__privateGet(this,_data5).client,commandsPath:__privateGet(this,_data5).commandsPath,devGuildIds:__privateGet(this,_data5).devGuildIds||[],devUserIds:__privateGet(this,_data5).devUserIds||[],devRoleIds:__privateGet(this,_data5).devRoleIds||[],validationHandler:__privateGet(this,_data5).validationHandler,skipBuiltInValidations:__privateGet(this,_data5).skipBuiltInValidations||!1,commandkitInstance:this,bulkRegister:__privateGet(this,_data5).bulkRegister||!1});await commandHandler.init(),__privateGet(this,_data5).commandHandler=commandHandler}},"#init"),__name(_CommandKit,"CommandKit"),__publicField(_CommandKit,"createElement",createElement),__publicField(_CommandKit,"Fragment",Fragment),__publicField(_CommandKit,"instance");var CommandKit=_CommandKit;0&&(module.exports={CommandKit});
11
- //# sourceMappingURL=CommandKit.js.map