@azurioh/discord-kernel 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (373) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/dist/authz/authorizer.d.ts +45 -0
  4. package/dist/authz/authorizer.d.ts.map +1 -0
  5. package/dist/authz/authorizer.js +31 -0
  6. package/dist/authz/authorizer.js.map +1 -0
  7. package/dist/authz/require-level-guard.d.ts +23 -0
  8. package/dist/authz/require-level-guard.d.ts.map +1 -0
  9. package/dist/authz/require-level-guard.js +37 -0
  10. package/dist/authz/require-level-guard.js.map +1 -0
  11. package/dist/clock.d.ts +13 -0
  12. package/dist/clock.d.ts.map +1 -0
  13. package/dist/clock.js +13 -0
  14. package/dist/clock.js.map +1 -0
  15. package/dist/concurrency/keyed-queue.d.ts +18 -0
  16. package/dist/concurrency/keyed-queue.d.ts.map +1 -0
  17. package/dist/concurrency/keyed-queue.js +37 -0
  18. package/dist/concurrency/keyed-queue.js.map +1 -0
  19. package/dist/concurrency/run-with-concurrency.d.ts +15 -0
  20. package/dist/concurrency/run-with-concurrency.d.ts.map +1 -0
  21. package/dist/concurrency/run-with-concurrency.js +40 -0
  22. package/dist/concurrency/run-with-concurrency.js.map +1 -0
  23. package/dist/config/env.d.ts +17 -0
  24. package/dist/config/env.d.ts.map +1 -0
  25. package/dist/config/env.js +49 -0
  26. package/dist/config/env.js.map +1 -0
  27. package/dist/config/errors.d.ts +14 -0
  28. package/dist/config/errors.d.ts.map +1 -0
  29. package/dist/config/errors.js +25 -0
  30. package/dist/config/errors.js.map +1 -0
  31. package/dist/datetime.d.ts +34 -0
  32. package/dist/datetime.d.ts.map +1 -0
  33. package/dist/datetime.js +188 -0
  34. package/dist/datetime.js.map +1 -0
  35. package/dist/discord/api-errors.d.ts +20 -0
  36. package/dist/discord/api-errors.d.ts.map +1 -0
  37. package/dist/discord/api-errors.js +90 -0
  38. package/dist/discord/api-errors.js.map +1 -0
  39. package/dist/discord/channel-exporter.d.ts +42 -0
  40. package/dist/discord/channel-exporter.d.ts.map +1 -0
  41. package/dist/discord/channel-exporter.js +3 -0
  42. package/dist/discord/channel-exporter.js.map +1 -0
  43. package/dist/discord/command/autocomplete-dispatcher.d.ts +26 -0
  44. package/dist/discord/command/autocomplete-dispatcher.d.ts.map +1 -0
  45. package/dist/discord/command/autocomplete-dispatcher.js +41 -0
  46. package/dist/discord/command/autocomplete-dispatcher.js.map +1 -0
  47. package/dist/discord/command/autocomplete.d.ts +18 -0
  48. package/dist/discord/command/autocomplete.d.ts.map +1 -0
  49. package/dist/discord/command/autocomplete.js +65 -0
  50. package/dist/discord/command/autocomplete.js.map +1 -0
  51. package/dist/discord/command/context.d.ts +33 -0
  52. package/dist/discord/command/context.d.ts.map +1 -0
  53. package/dist/discord/command/context.js +48 -0
  54. package/dist/discord/command/context.js.map +1 -0
  55. package/dist/discord/command/cooldown-guard.d.ts +25 -0
  56. package/dist/discord/command/cooldown-guard.d.ts.map +1 -0
  57. package/dist/discord/command/cooldown-guard.js +60 -0
  58. package/dist/discord/command/cooldown-guard.js.map +1 -0
  59. package/dist/discord/command/create-command.d.ts +100 -0
  60. package/dist/discord/command/create-command.d.ts.map +1 -0
  61. package/dist/discord/command/create-command.js +245 -0
  62. package/dist/discord/command/create-command.js.map +1 -0
  63. package/dist/discord/command/create-context-menu-command.d.ts +51 -0
  64. package/dist/discord/command/create-context-menu-command.d.ts.map +1 -0
  65. package/dist/discord/command/create-context-menu-command.js +128 -0
  66. package/dist/discord/command/create-context-menu-command.js.map +1 -0
  67. package/dist/discord/command/errors.d.ts +19 -0
  68. package/dist/discord/command/errors.d.ts.map +1 -0
  69. package/dist/discord/command/errors.js +27 -0
  70. package/dist/discord/command/errors.js.map +1 -0
  71. package/dist/discord/command/guard.d.ts +30 -0
  72. package/dist/discord/command/guard.d.ts.map +1 -0
  73. package/dist/discord/command/guard.js +34 -0
  74. package/dist/discord/command/guard.js.map +1 -0
  75. package/dist/discord/command/localization.d.ts +9 -0
  76. package/dist/discord/command/localization.d.ts.map +1 -0
  77. package/dist/discord/command/localization.js +13 -0
  78. package/dist/discord/command/localization.js.map +1 -0
  79. package/dist/discord/command/options.d.ts +113 -0
  80. package/dist/discord/command/options.d.ts.map +1 -0
  81. package/dist/discord/command/options.js +509 -0
  82. package/dist/discord/command/options.js.map +1 -0
  83. package/dist/discord/command/permission-guard.d.ts +21 -0
  84. package/dist/discord/command/permission-guard.d.ts.map +1 -0
  85. package/dist/discord/command/permission-guard.js +69 -0
  86. package/dist/discord/command/permission-guard.js.map +1 -0
  87. package/dist/discord/command/router.d.ts +48 -0
  88. package/dist/discord/command/router.d.ts.map +1 -0
  89. package/dist/discord/command/router.js +118 -0
  90. package/dist/discord/command/router.js.map +1 -0
  91. package/dist/discord/command/types.d.ts +51 -0
  92. package/dist/discord/command/types.d.ts.map +1 -0
  93. package/dist/discord/command/types.js +3 -0
  94. package/dist/discord/command/types.js.map +1 -0
  95. package/dist/discord/components/component-router.d.ts +116 -0
  96. package/dist/discord/components/component-router.d.ts.map +1 -0
  97. package/dist/discord/components/component-router.js +123 -0
  98. package/dist/discord/components/component-router.js.map +1 -0
  99. package/dist/discord/components/interactive-message/index.d.ts +3 -0
  100. package/dist/discord/components/interactive-message/index.d.ts.map +1 -0
  101. package/dist/discord/components/interactive-message/index.js +11 -0
  102. package/dist/discord/components/interactive-message/index.js.map +1 -0
  103. package/dist/discord/components/interactive-message/interactive-message-collector.d.ts +195 -0
  104. package/dist/discord/components/interactive-message/interactive-message-collector.d.ts.map +1 -0
  105. package/dist/discord/components/interactive-message/interactive-message-collector.js +151 -0
  106. package/dist/discord/components/interactive-message/interactive-message-collector.js.map +1 -0
  107. package/dist/discord/components/interactive-message/mount-interactive-message.d.ts +30 -0
  108. package/dist/discord/components/interactive-message/mount-interactive-message.d.ts.map +1 -0
  109. package/dist/discord/components/interactive-message/mount-interactive-message.js +44 -0
  110. package/dist/discord/components/interactive-message/mount-interactive-message.js.map +1 -0
  111. package/dist/discord/components/paginator/index.d.ts +5 -0
  112. package/dist/discord/components/paginator/index.d.ts.map +1 -0
  113. package/dist/discord/components/paginator/index.js +15 -0
  114. package/dist/discord/components/paginator/index.js.map +1 -0
  115. package/dist/discord/components/paginator/mount-paginator.d.ts +25 -0
  116. package/dist/discord/components/paginator/mount-paginator.d.ts.map +1 -0
  117. package/dist/discord/components/paginator/mount-paginator.js +41 -0
  118. package/dist/discord/components/paginator/mount-paginator.js.map +1 -0
  119. package/dist/discord/components/paginator/page-state.d.ts +21 -0
  120. package/dist/discord/components/paginator/page-state.d.ts.map +1 -0
  121. package/dist/discord/components/paginator/page-state.js +44 -0
  122. package/dist/discord/components/paginator/page-state.js.map +1 -0
  123. package/dist/discord/components/paginator/paginator-buttons.d.ts +17 -0
  124. package/dist/discord/components/paginator/paginator-buttons.d.ts.map +1 -0
  125. package/dist/discord/components/paginator/paginator-buttons.js +45 -0
  126. package/dist/discord/components/paginator/paginator-buttons.js.map +1 -0
  127. package/dist/discord/components/paginator/paginator-view.d.ts +26 -0
  128. package/dist/discord/components/paginator/paginator-view.d.ts.map +1 -0
  129. package/dist/discord/components/paginator/paginator-view.js +28 -0
  130. package/dist/discord/components/paginator/paginator-view.js.map +1 -0
  131. package/dist/discord/components/persistent-paginator.d.ts +47 -0
  132. package/dist/discord/components/persistent-paginator.d.ts.map +1 -0
  133. package/dist/discord/components/persistent-paginator.js +137 -0
  134. package/dist/discord/components/persistent-paginator.js.map +1 -0
  135. package/dist/discord/components/settings-editor/index.d.ts +7 -0
  136. package/dist/discord/components/settings-editor/index.d.ts.map +1 -0
  137. package/dist/discord/components/settings-editor/index.js +22 -0
  138. package/dist/discord/components/settings-editor/index.js.map +1 -0
  139. package/dist/discord/components/settings-editor/mount-settings-editor.d.ts +140 -0
  140. package/dist/discord/components/settings-editor/mount-settings-editor.d.ts.map +1 -0
  141. package/dist/discord/components/settings-editor/mount-settings-editor.js +344 -0
  142. package/dist/discord/components/settings-editor/mount-settings-editor.js.map +1 -0
  143. package/dist/discord/components/settings-editor/navigation.d.ts +49 -0
  144. package/dist/discord/components/settings-editor/navigation.d.ts.map +1 -0
  145. package/dist/discord/components/settings-editor/navigation.js +39 -0
  146. package/dist/discord/components/settings-editor/navigation.js.map +1 -0
  147. package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts +56 -0
  148. package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts.map +1 -0
  149. package/dist/discord/components/settings-editor/settings-editor-card.view.js +284 -0
  150. package/dist/discord/components/settings-editor/settings-editor-card.view.js.map +1 -0
  151. package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts +69 -0
  152. package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts.map +1 -0
  153. package/dist/discord/components/settings-editor/settings-editor-field-modal.js +353 -0
  154. package/dist/discord/components/settings-editor/settings-editor-field-modal.js.map +1 -0
  155. package/dist/discord/components/settings-editor/settings-editor-fields.d.ts +216 -0
  156. package/dist/discord/components/settings-editor/settings-editor-fields.d.ts.map +1 -0
  157. package/dist/discord/components/settings-editor/settings-editor-fields.js +66 -0
  158. package/dist/discord/components/settings-editor/settings-editor-fields.js.map +1 -0
  159. package/dist/discord/components/settings-editor/settings-editor.view.d.ts +303 -0
  160. package/dist/discord/components/settings-editor/settings-editor.view.d.ts.map +1 -0
  161. package/dist/discord/components/settings-editor/settings-editor.view.js +316 -0
  162. package/dist/discord/components/settings-editor/settings-editor.view.js.map +1 -0
  163. package/dist/discord/events/create-event.d.ts +5 -0
  164. package/dist/discord/events/create-event.d.ts.map +1 -0
  165. package/dist/discord/events/create-event.js +8 -0
  166. package/dist/discord/events/create-event.js.map +1 -0
  167. package/dist/discord/events/event-router.d.ts +16 -0
  168. package/dist/discord/events/event-router.d.ts.map +1 -0
  169. package/dist/discord/events/event-router.js +51 -0
  170. package/dist/discord/events/event-router.js.map +1 -0
  171. package/dist/discord/events/types.d.ts +16 -0
  172. package/dist/discord/events/types.d.ts.map +1 -0
  173. package/dist/discord/events/types.js +3 -0
  174. package/dist/discord/events/types.js.map +1 -0
  175. package/dist/discord/i18n.d.ts +58 -0
  176. package/dist/discord/i18n.d.ts.map +1 -0
  177. package/dist/discord/i18n.js +173 -0
  178. package/dist/discord/i18n.js.map +1 -0
  179. package/dist/discord/interaction/button.d.ts +39 -0
  180. package/dist/discord/interaction/button.d.ts.map +1 -0
  181. package/dist/discord/interaction/button.js +36 -0
  182. package/dist/discord/interaction/button.js.map +1 -0
  183. package/dist/discord/interaction/interaction-router.d.ts +21 -0
  184. package/dist/discord/interaction/interaction-router.d.ts.map +1 -0
  185. package/dist/discord/interaction/interaction-router.js +24 -0
  186. package/dist/discord/interaction/interaction-router.js.map +1 -0
  187. package/dist/discord/interaction/modal.d.ts +171 -0
  188. package/dist/discord/interaction/modal.d.ts.map +1 -0
  189. package/dist/discord/interaction/modal.js +264 -0
  190. package/dist/discord/interaction/modal.js.map +1 -0
  191. package/dist/discord/interaction/select-menu.d.ts +104 -0
  192. package/dist/discord/interaction/select-menu.d.ts.map +1 -0
  193. package/dist/discord/interaction/select-menu.js +126 -0
  194. package/dist/discord/interaction/select-menu.js.map +1 -0
  195. package/dist/discord/permissions.d.ts +32 -0
  196. package/dist/discord/permissions.d.ts.map +1 -0
  197. package/dist/discord/permissions.js +40 -0
  198. package/dist/discord/permissions.js.map +1 -0
  199. package/dist/discord/placeholder-registry-errors.d.ts +10 -0
  200. package/dist/discord/placeholder-registry-errors.d.ts.map +1 -0
  201. package/dist/discord/placeholder-registry-errors.js +18 -0
  202. package/dist/discord/placeholder-registry-errors.js.map +1 -0
  203. package/dist/discord/placeholder-registry.d.ts +53 -0
  204. package/dist/discord/placeholder-registry.d.ts.map +1 -0
  205. package/dist/discord/placeholder-registry.js +52 -0
  206. package/dist/discord/placeholder-registry.js.map +1 -0
  207. package/dist/discord/presenter.d.ts +26 -0
  208. package/dist/discord/presenter.d.ts.map +1 -0
  209. package/dist/discord/presenter.js +3 -0
  210. package/dist/discord/presenter.js.map +1 -0
  211. package/dist/discord/ui/card.d.ts +114 -0
  212. package/dist/discord/ui/card.d.ts.map +1 -0
  213. package/dist/discord/ui/card.js +162 -0
  214. package/dist/discord/ui/card.js.map +1 -0
  215. package/dist/discord/ui/color-input-errors.d.ts +12 -0
  216. package/dist/discord/ui/color-input-errors.d.ts.map +1 -0
  217. package/dist/discord/ui/color-input-errors.js +21 -0
  218. package/dist/discord/ui/color-input-errors.js.map +1 -0
  219. package/dist/discord/ui/color-input.d.ts +37 -0
  220. package/dist/discord/ui/color-input.d.ts.map +1 -0
  221. package/dist/discord/ui/color-input.js +166 -0
  222. package/dist/discord/ui/color-input.js.map +1 -0
  223. package/dist/discord/ui/colors.d.ts +44 -0
  224. package/dist/discord/ui/colors.d.ts.map +1 -0
  225. package/dist/discord/ui/colors.js +45 -0
  226. package/dist/discord/ui/colors.js.map +1 -0
  227. package/dist/discord/ui/embed.d.ts +16 -0
  228. package/dist/discord/ui/embed.d.ts.map +1 -0
  229. package/dist/discord/ui/embed.js +53 -0
  230. package/dist/discord/ui/embed.js.map +1 -0
  231. package/dist/discord/ui/message-attachments.d.ts +40 -0
  232. package/dist/discord/ui/message-attachments.d.ts.map +1 -0
  233. package/dist/discord/ui/message-attachments.js +27 -0
  234. package/dist/discord/ui/message-attachments.js.map +1 -0
  235. package/dist/errors/business-error.d.ts +41 -0
  236. package/dist/errors/business-error.d.ts.map +1 -0
  237. package/dist/errors/business-error.js +39 -0
  238. package/dist/errors/business-error.js.map +1 -0
  239. package/dist/errors/describe-error.d.ts +29 -0
  240. package/dist/errors/describe-error.d.ts.map +1 -0
  241. package/dist/errors/describe-error.js +49 -0
  242. package/dist/errors/describe-error.js.map +1 -0
  243. package/dist/errors/incident-ref.d.ts +7 -0
  244. package/dist/errors/incident-ref.d.ts.map +1 -0
  245. package/dist/errors/incident-ref.js +13 -0
  246. package/dist/errors/incident-ref.js.map +1 -0
  247. package/dist/errors/index.d.ts +4 -0
  248. package/dist/errors/index.d.ts.map +1 -0
  249. package/dist/errors/index.js +15 -0
  250. package/dist/errors/index.js.map +1 -0
  251. package/dist/i18n/business-message.d.ts +14 -0
  252. package/dist/i18n/business-message.d.ts.map +1 -0
  253. package/dist/i18n/business-message.js +19 -0
  254. package/dist/i18n/business-message.js.map +1 -0
  255. package/dist/i18n/catalog.d.ts +27 -0
  256. package/dist/i18n/catalog.d.ts.map +1 -0
  257. package/dist/i18n/catalog.js +25 -0
  258. package/dist/i18n/catalog.js.map +1 -0
  259. package/dist/i18n/errors.d.ts +10 -0
  260. package/dist/i18n/errors.d.ts.map +1 -0
  261. package/dist/i18n/errors.js +18 -0
  262. package/dist/i18n/errors.js.map +1 -0
  263. package/dist/i18n/index.d.ts +6 -0
  264. package/dist/i18n/index.d.ts.map +1 -0
  265. package/dist/i18n/index.js +16 -0
  266. package/dist/i18n/index.js.map +1 -0
  267. package/dist/i18n/locale.d.ts +22 -0
  268. package/dist/i18n/locale.d.ts.map +1 -0
  269. package/dist/i18n/locale.js +40 -0
  270. package/dist/i18n/locale.js.map +1 -0
  271. package/dist/i18n/translator.d.ts +35 -0
  272. package/dist/i18n/translator.d.ts.map +1 -0
  273. package/dist/i18n/translator.js +40 -0
  274. package/dist/i18n/translator.js.map +1 -0
  275. package/dist/logger.d.ts +28 -0
  276. package/dist/logger.d.ts.map +1 -0
  277. package/dist/logger.js +3 -0
  278. package/dist/logger.js.map +1 -0
  279. package/dist/module/module.d.ts +42 -0
  280. package/dist/module/module.d.ts.map +1 -0
  281. package/dist/module/module.js +3 -0
  282. package/dist/module/module.js.map +1 -0
  283. package/dist/persistence/database.d.ts +24 -0
  284. package/dist/persistence/database.d.ts.map +1 -0
  285. package/dist/persistence/database.js +3 -0
  286. package/dist/persistence/database.js.map +1 -0
  287. package/dist/resilience/retry.d.ts +36 -0
  288. package/dist/resilience/retry.d.ts.map +1 -0
  289. package/dist/resilience/retry.js +78 -0
  290. package/dist/resilience/retry.js.map +1 -0
  291. package/dist/scheduler/errors.d.ts +25 -0
  292. package/dist/scheduler/errors.d.ts.map +1 -0
  293. package/dist/scheduler/errors.js +45 -0
  294. package/dist/scheduler/errors.js.map +1 -0
  295. package/dist/scheduler/scheduler.d.ts +68 -0
  296. package/dist/scheduler/scheduler.d.ts.map +1 -0
  297. package/dist/scheduler/scheduler.js +162 -0
  298. package/dist/scheduler/scheduler.js.map +1 -0
  299. package/package.json +89 -0
  300. package/src/authz/authorizer.ts +76 -0
  301. package/src/authz/require-level-guard.ts +42 -0
  302. package/src/clock.ts +18 -0
  303. package/src/concurrency/keyed-queue.ts +50 -0
  304. package/src/concurrency/run-with-concurrency.ts +44 -0
  305. package/src/config/env.ts +58 -0
  306. package/src/config/errors.ts +21 -0
  307. package/src/datetime.ts +221 -0
  308. package/src/discord/api-errors.ts +91 -0
  309. package/src/discord/channel-exporter.ts +48 -0
  310. package/src/discord/command/autocomplete-dispatcher.ts +54 -0
  311. package/src/discord/command/autocomplete.ts +76 -0
  312. package/src/discord/command/context.ts +85 -0
  313. package/src/discord/command/cooldown-guard.ts +81 -0
  314. package/src/discord/command/create-command.ts +431 -0
  315. package/src/discord/command/create-context-menu-command.ts +227 -0
  316. package/src/discord/command/errors.ts +22 -0
  317. package/src/discord/command/guard.ts +54 -0
  318. package/src/discord/command/localization.ts +11 -0
  319. package/src/discord/command/options.ts +847 -0
  320. package/src/discord/command/permission-guard.ts +74 -0
  321. package/src/discord/command/router.ts +142 -0
  322. package/src/discord/command/types.ts +52 -0
  323. package/src/discord/components/component-router.ts +213 -0
  324. package/src/discord/components/interactive-message/index.ts +18 -0
  325. package/src/discord/components/interactive-message/interactive-message-collector.ts +374 -0
  326. package/src/discord/components/interactive-message/mount-interactive-message.ts +71 -0
  327. package/src/discord/components/paginator/index.ts +17 -0
  328. package/src/discord/components/paginator/mount-paginator.ts +69 -0
  329. package/src/discord/components/paginator/page-state.ts +45 -0
  330. package/src/discord/components/paginator/paginator-buttons.ts +60 -0
  331. package/src/discord/components/paginator/paginator-view.ts +61 -0
  332. package/src/discord/components/persistent-paginator.ts +197 -0
  333. package/src/discord/components/settings-editor/index.ts +41 -0
  334. package/src/discord/components/settings-editor/mount-settings-editor.ts +646 -0
  335. package/src/discord/components/settings-editor/navigation.ts +67 -0
  336. package/src/discord/components/settings-editor/settings-editor-card.view.ts +344 -0
  337. package/src/discord/components/settings-editor/settings-editor-field-modal.ts +538 -0
  338. package/src/discord/components/settings-editor/settings-editor-fields.ts +290 -0
  339. package/src/discord/components/settings-editor/settings-editor.view.ts +654 -0
  340. package/src/discord/events/create-event.ts +7 -0
  341. package/src/discord/events/event-router.ts +53 -0
  342. package/src/discord/events/types.ts +17 -0
  343. package/src/discord/i18n.ts +173 -0
  344. package/src/discord/interaction/button.ts +75 -0
  345. package/src/discord/interaction/interaction-router.ts +28 -0
  346. package/src/discord/interaction/modal.ts +505 -0
  347. package/src/discord/interaction/select-menu.ts +246 -0
  348. package/src/discord/permissions.ts +57 -0
  349. package/src/discord/placeholder-registry-errors.ts +11 -0
  350. package/src/discord/placeholder-registry.ts +77 -0
  351. package/src/discord/presenter.ts +26 -0
  352. package/src/discord/ui/card.ts +303 -0
  353. package/src/discord/ui/color-input-errors.ts +17 -0
  354. package/src/discord/ui/color-input.ts +179 -0
  355. package/src/discord/ui/colors.ts +58 -0
  356. package/src/discord/ui/embed.ts +64 -0
  357. package/src/discord/ui/message-attachments.ts +57 -0
  358. package/src/errors/business-error.ts +49 -0
  359. package/src/errors/describe-error.ts +73 -0
  360. package/src/errors/incident-ref.ts +10 -0
  361. package/src/errors/index.ts +12 -0
  362. package/src/i18n/business-message.ts +23 -0
  363. package/src/i18n/catalog.ts +41 -0
  364. package/src/i18n/errors.ts +11 -0
  365. package/src/i18n/index.ts +11 -0
  366. package/src/i18n/locale.ts +41 -0
  367. package/src/i18n/translator.ts +78 -0
  368. package/src/logger.ts +28 -0
  369. package/src/module/module.ts +42 -0
  370. package/src/persistence/database.ts +23 -0
  371. package/src/resilience/retry.ts +102 -0
  372. package/src/scheduler/errors.ts +40 -0
  373. package/src/scheduler/scheduler.ts +248 -0
@@ -0,0 +1,509 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createStringOption = createStringOption;
4
+ exports.createUserOption = createUserOption;
5
+ exports.createBooleanOption = createBooleanOption;
6
+ exports.createIntegerOption = createIntegerOption;
7
+ exports.createNumberOption = createNumberOption;
8
+ exports.createDateTimeOption = createDateTimeOption;
9
+ exports.createWallClockOption = createWallClockOption;
10
+ exports.createDateOption = createDateOption;
11
+ exports.createChannelOption = createChannelOption;
12
+ exports.createRoleOption = createRoleOption;
13
+ exports.createMentionableOption = createMentionableOption;
14
+ exports.createAttachmentOption = createAttachmentOption;
15
+ exports.allRequired = allRequired;
16
+ const datetime_1 = require("../../datetime");
17
+ const errors_1 = require("../../discord/command/errors");
18
+ /** Applies the localization maps to a builder, if any were provided. */
19
+ function applyOptionLocalizations(option, localizations) {
20
+ if (localizations.nameLocalizations) {
21
+ option.setNameLocalizations(localizations.nameLocalizations);
22
+ }
23
+ if (localizations.descriptionLocalizations) {
24
+ option.setDescriptionLocalizations(localizations.descriptionLocalizations);
25
+ }
26
+ }
27
+ const CHOICES_WITH_AUTOCOMPLETE_MESSAGE = "An option cannot declare both `choices` and `autocomplete`; Discord rejects the command.";
28
+ /**
29
+ * Discord refuses a command whose option carries both a static choice list and
30
+ * an autocomplete resolver, so fail at registration rather than at deploy time.
31
+ */
32
+ function assertChoicesAndAutocompleteExclusive(hasChoices, resolver) {
33
+ if (hasChoices && resolver !== undefined) {
34
+ throw new errors_1.OptionValidationError(CHOICES_WITH_AUTOCOMPLETE_MESSAGE);
35
+ }
36
+ }
37
+ class StringOption {
38
+ description;
39
+ isRequired;
40
+ choiceValues;
41
+ validator;
42
+ bounds;
43
+ autocomplete;
44
+ localizations;
45
+ constructor(description, isRequired, choiceValues, validator, bounds, autocomplete, localizations = {}) {
46
+ this.description = description;
47
+ this.isRequired = isRequired;
48
+ this.choiceValues = choiceValues;
49
+ this.validator = validator;
50
+ this.bounds = bounds;
51
+ this.autocomplete = autocomplete;
52
+ this.localizations = localizations;
53
+ }
54
+ required() {
55
+ return new StringOption(this.description, true, this.choiceValues, this.validator, this.bounds, this.autocomplete, this.localizations);
56
+ }
57
+ choices(values) {
58
+ return new StringOption(this.description, this.isRequired, values, this.validator, this.bounds, this.autocomplete, this.localizations);
59
+ }
60
+ withAutocomplete(resolver) {
61
+ return new StringOption(this.description, this.isRequired, this.choiceValues, this.validator, this.bounds, resolver, this.localizations);
62
+ }
63
+ apply(container, name) {
64
+ assertChoicesAndAutocompleteExclusive(this.choiceValues !== null, this.autocomplete);
65
+ container.addStringOption((option) => {
66
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
67
+ applyOptionLocalizations(option, this.localizations);
68
+ if (this.choiceValues) {
69
+ option.addChoices(...this.choiceValues.map((value) => ({ name: value, value })));
70
+ }
71
+ if (this.bounds.minLength !== undefined) {
72
+ option.setMinLength(this.bounds.minLength);
73
+ }
74
+ if (this.bounds.maxLength !== undefined) {
75
+ option.setMaxLength(this.bounds.maxLength);
76
+ }
77
+ if (this.autocomplete !== undefined) {
78
+ option.setAutocomplete(true);
79
+ }
80
+ return option;
81
+ });
82
+ }
83
+ read(interaction, name) {
84
+ const raw = interaction.options.getString(name, this.isRequired);
85
+ if (raw !== null && this.validator) {
86
+ this.validator(raw);
87
+ }
88
+ return raw;
89
+ }
90
+ }
91
+ function createStringOption(description, bounds = {}, localizations = {}) {
92
+ return new StringOption(description, false, null, null, bounds, undefined, localizations);
93
+ }
94
+ class UserOption {
95
+ description;
96
+ isRequired;
97
+ localizations;
98
+ constructor(description, isRequired, localizations = {}) {
99
+ this.description = description;
100
+ this.isRequired = isRequired;
101
+ this.localizations = localizations;
102
+ }
103
+ required() {
104
+ return new UserOption(this.description, true, this.localizations);
105
+ }
106
+ choices(_values) {
107
+ throw new errors_1.OptionValidationError("User options do not support choices.");
108
+ }
109
+ apply(container, name) {
110
+ container.addUserOption((option) => {
111
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
112
+ applyOptionLocalizations(option, this.localizations);
113
+ return option;
114
+ });
115
+ }
116
+ read(interaction, name) {
117
+ return interaction.options.getUser(name, this.isRequired);
118
+ }
119
+ }
120
+ function createUserOption(description, localizations = {}) {
121
+ return new UserOption(description, false, localizations);
122
+ }
123
+ class BooleanOption {
124
+ description;
125
+ isRequired;
126
+ localizations;
127
+ constructor(description, isRequired, localizations = {}) {
128
+ this.description = description;
129
+ this.isRequired = isRequired;
130
+ this.localizations = localizations;
131
+ }
132
+ required() {
133
+ return new BooleanOption(this.description, true, this.localizations);
134
+ }
135
+ choices(_values) {
136
+ throw new errors_1.OptionValidationError("Boolean options do not support choices.");
137
+ }
138
+ apply(container, name) {
139
+ container.addBooleanOption((option) => {
140
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
141
+ applyOptionLocalizations(option, this.localizations);
142
+ return option;
143
+ });
144
+ }
145
+ read(interaction, name) {
146
+ return interaction.options.getBoolean(name, this.isRequired);
147
+ }
148
+ }
149
+ function createBooleanOption(description, localizations = {}) {
150
+ return new BooleanOption(description, false, localizations);
151
+ }
152
+ class IntegerOption {
153
+ description;
154
+ isRequired;
155
+ bounds;
156
+ autocomplete;
157
+ localizations;
158
+ constructor(description, isRequired, bounds, autocomplete, localizations = {}) {
159
+ this.description = description;
160
+ this.isRequired = isRequired;
161
+ this.bounds = bounds;
162
+ this.autocomplete = autocomplete;
163
+ this.localizations = localizations;
164
+ }
165
+ required() {
166
+ return new IntegerOption(this.description, true, this.bounds, this.autocomplete, this.localizations);
167
+ }
168
+ choices(_values) {
169
+ throw new errors_1.OptionValidationError("Integer options do not support choices.");
170
+ }
171
+ withAutocomplete(resolver) {
172
+ return new IntegerOption(this.description, this.isRequired, this.bounds, resolver, this.localizations);
173
+ }
174
+ apply(container, name) {
175
+ container.addIntegerOption((option) => {
176
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
177
+ applyOptionLocalizations(option, this.localizations);
178
+ if (this.bounds.min !== undefined) {
179
+ option.setMinValue(this.bounds.min);
180
+ }
181
+ if (this.bounds.max !== undefined) {
182
+ option.setMaxValue(this.bounds.max);
183
+ }
184
+ if (this.autocomplete !== undefined) {
185
+ option.setAutocomplete(true);
186
+ }
187
+ return option;
188
+ });
189
+ }
190
+ read(interaction, name) {
191
+ return interaction.options.getInteger(name, this.isRequired);
192
+ }
193
+ }
194
+ function createIntegerOption(description, bounds = {}, localizations = {}) {
195
+ return new IntegerOption(description, false, bounds, undefined, localizations);
196
+ }
197
+ class NumberOption {
198
+ description;
199
+ isRequired;
200
+ bounds;
201
+ autocomplete;
202
+ localizations;
203
+ constructor(description, isRequired, bounds, autocomplete, localizations = {}) {
204
+ this.description = description;
205
+ this.isRequired = isRequired;
206
+ this.bounds = bounds;
207
+ this.autocomplete = autocomplete;
208
+ this.localizations = localizations;
209
+ }
210
+ required() {
211
+ return new NumberOption(this.description, true, this.bounds, this.autocomplete, this.localizations);
212
+ }
213
+ choices(_values) {
214
+ throw new errors_1.OptionValidationError("Number options do not support choices.");
215
+ }
216
+ withAutocomplete(resolver) {
217
+ return new NumberOption(this.description, this.isRequired, this.bounds, resolver, this.localizations);
218
+ }
219
+ apply(container, name) {
220
+ container.addNumberOption((option) => {
221
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
222
+ applyOptionLocalizations(option, this.localizations);
223
+ if (this.bounds.min !== undefined) {
224
+ option.setMinValue(this.bounds.min);
225
+ }
226
+ if (this.bounds.max !== undefined) {
227
+ option.setMaxValue(this.bounds.max);
228
+ }
229
+ if (this.autocomplete !== undefined) {
230
+ option.setAutocomplete(true);
231
+ }
232
+ return option;
233
+ });
234
+ }
235
+ read(interaction, name) {
236
+ return interaction.options.getNumber(name, this.isRequired);
237
+ }
238
+ }
239
+ function createNumberOption(description, bounds = {}, localizations = {}) {
240
+ return new NumberOption(description, false, bounds, undefined, localizations);
241
+ }
242
+ const INVALID_DATETIME_MESSAGE = "Invalid date format. Use `YYYY-MM-DD HH:MM` (e.g. `2025-03-15 14:00`).";
243
+ function assertValidDate(value, message) {
244
+ if (Number.isNaN(Date.parse(value))) {
245
+ throw new errors_1.OptionValidationError(message);
246
+ }
247
+ }
248
+ class DateTimeOption {
249
+ description;
250
+ isRequired;
251
+ localizations;
252
+ constructor(description, isRequired, localizations = {}) {
253
+ this.description = description;
254
+ this.isRequired = isRequired;
255
+ this.localizations = localizations;
256
+ }
257
+ required() {
258
+ return new DateTimeOption(this.description, true, this.localizations);
259
+ }
260
+ choices(_values) {
261
+ throw new errors_1.OptionValidationError("Date options do not support choices.");
262
+ }
263
+ apply(container, name) {
264
+ container.addStringOption((option) => {
265
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
266
+ applyOptionLocalizations(option, this.localizations);
267
+ return option;
268
+ });
269
+ }
270
+ read(interaction, name) {
271
+ const raw = interaction.options.getString(name, this.isRequired);
272
+ if (raw === null) {
273
+ return null;
274
+ }
275
+ assertValidDate(raw, INVALID_DATETIME_MESSAGE);
276
+ return new Date(raw.replace(" ", "T"));
277
+ }
278
+ }
279
+ function createDateTimeOption(description, localizations = {}) {
280
+ return new DateTimeOption(description, false, localizations);
281
+ }
282
+ const INVALID_WALL_CLOCK_MESSAGE = "Invalid date format. Use `YYYY-MM-DD` or `YYYY-MM-DD HH:MM` (e.g. `2025-03-15 14:00`).";
283
+ const INVALID_DATE_ONLY_MESSAGE = "Invalid date format. Use `YYYY-MM-DD` (e.g. `2025-03-15`).";
284
+ const DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
285
+ /**
286
+ * A raw `YYYY-MM-DD[ HH:MM[:SS]]` string, validated but *not* anchored to any
287
+ * timezone here — the core has no notion of "the guild's timezone", so
288
+ * anchoring (`zonedWallClockToUtc`) is the caller's job, once it knows which
289
+ * IANA zone applies. This is what lets the same option be reused by any module
290
+ * that needs a wall-clock input.
291
+ */
292
+ class WallClockOption {
293
+ description;
294
+ isRequired;
295
+ localizations;
296
+ constructor(description, isRequired, localizations = {}) {
297
+ this.description = description;
298
+ this.isRequired = isRequired;
299
+ this.localizations = localizations;
300
+ }
301
+ required() {
302
+ return new WallClockOption(this.description, true, this.localizations);
303
+ }
304
+ choices(_values) {
305
+ throw new errors_1.OptionValidationError("Wall-clock options do not support choices.");
306
+ }
307
+ apply(container, name) {
308
+ container.addStringOption((option) => {
309
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
310
+ applyOptionLocalizations(option, this.localizations);
311
+ return option;
312
+ });
313
+ }
314
+ read(interaction, name) {
315
+ const raw = interaction.options.getString(name, this.isRequired);
316
+ if (raw === null) {
317
+ return null;
318
+ }
319
+ if (!(0, datetime_1.isValidWallClock)(raw)) {
320
+ throw new errors_1.OptionValidationError(INVALID_WALL_CLOCK_MESSAGE);
321
+ }
322
+ return raw;
323
+ }
324
+ }
325
+ /**
326
+ * A `YYYY-MM-DD[ HH:MM[:SS]]` string option, validated against the wall-clock
327
+ * grammar but left unanchored (no `Date` conversion, no assumed timezone) — the
328
+ * caller anchors it with `zonedWallClockToUtc` once it knows the guild zone.
329
+ */
330
+ function createWallClockOption(description, localizations = {}) {
331
+ return new WallClockOption(description, false, localizations);
332
+ }
333
+ /** A strict, date-only (`YYYY-MM-DD`) option — rejects any time component. */
334
+ class DateOption {
335
+ description;
336
+ isRequired;
337
+ localizations;
338
+ constructor(description, isRequired, localizations = {}) {
339
+ this.description = description;
340
+ this.isRequired = isRequired;
341
+ this.localizations = localizations;
342
+ }
343
+ required() {
344
+ return new DateOption(this.description, true, this.localizations);
345
+ }
346
+ choices(_values) {
347
+ throw new errors_1.OptionValidationError("Date options do not support choices.");
348
+ }
349
+ apply(container, name) {
350
+ container.addStringOption((option) => {
351
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
352
+ applyOptionLocalizations(option, this.localizations);
353
+ return option;
354
+ });
355
+ }
356
+ read(interaction, name) {
357
+ const raw = interaction.options.getString(name, this.isRequired);
358
+ if (raw === null) {
359
+ return null;
360
+ }
361
+ // Strict `YYYY-MM-DD` with a real-calendar check (rejects `2026/03/15`,
362
+ // time-bearing input, and impossible dates like `2026-02-30`).
363
+ if (!DATE_ONLY_PATTERN.test(raw) || !(0, datetime_1.isValidWallClock)(raw)) {
364
+ throw new errors_1.OptionValidationError(INVALID_DATE_ONLY_MESSAGE);
365
+ }
366
+ return new Date(raw);
367
+ }
368
+ }
369
+ /**
370
+ * A strict date-only (`YYYY-MM-DD`) option. The returned `Date` is UTC
371
+ * midnight of that calendar day — a caller that needs it anchored to a guild
372
+ * timezone (start/end of that guild-local day) uses `startOfGuildDay`/
373
+ * `endOfGuildDay` from `core/datetime`.
374
+ */
375
+ function createDateOption(description, localizations = {}) {
376
+ return new DateOption(description, false, localizations);
377
+ }
378
+ class ChannelOption {
379
+ description;
380
+ isRequired;
381
+ channelTypes;
382
+ localizations;
383
+ constructor(description, isRequired, channelTypes, localizations = {}) {
384
+ this.description = description;
385
+ this.isRequired = isRequired;
386
+ this.channelTypes = channelTypes;
387
+ this.localizations = localizations;
388
+ }
389
+ required() {
390
+ return new ChannelOption(this.description, true, this.channelTypes, this.localizations);
391
+ }
392
+ choices(_values) {
393
+ throw new errors_1.OptionValidationError("Channel options do not support choices.");
394
+ }
395
+ apply(container, name) {
396
+ container.addChannelOption((option) => {
397
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
398
+ applyOptionLocalizations(option, this.localizations);
399
+ if (this.channelTypes !== undefined) {
400
+ option.addChannelTypes(...this.channelTypes);
401
+ }
402
+ return option;
403
+ });
404
+ }
405
+ read(interaction, name) {
406
+ // The declared types are re-sent at read time: `addChannelTypes` only drives
407
+ // the client-side picker, so Discord can still deliver another channel kind.
408
+ return interaction.options.getChannel(name, this.isRequired, this.channelTypes);
409
+ }
410
+ }
411
+ function createChannelOption(description, channelTypes, localizations = {}) {
412
+ return new ChannelOption(description, false, channelTypes, localizations);
413
+ }
414
+ class RoleOption {
415
+ description;
416
+ isRequired;
417
+ localizations;
418
+ constructor(description, isRequired, localizations = {}) {
419
+ this.description = description;
420
+ this.isRequired = isRequired;
421
+ this.localizations = localizations;
422
+ }
423
+ required() {
424
+ return new RoleOption(this.description, true, this.localizations);
425
+ }
426
+ choices(_values) {
427
+ throw new errors_1.OptionValidationError("Role options do not support choices.");
428
+ }
429
+ apply(container, name) {
430
+ container.addRoleOption((option) => {
431
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
432
+ applyOptionLocalizations(option, this.localizations);
433
+ return option;
434
+ });
435
+ }
436
+ read(interaction, name) {
437
+ return interaction.options.getRole(name, this.isRequired);
438
+ }
439
+ }
440
+ function createRoleOption(description, localizations = {}) {
441
+ return new RoleOption(description, false, localizations);
442
+ }
443
+ class MentionableOption {
444
+ description;
445
+ isRequired;
446
+ localizations;
447
+ constructor(description, isRequired, localizations = {}) {
448
+ this.description = description;
449
+ this.isRequired = isRequired;
450
+ this.localizations = localizations;
451
+ }
452
+ required() {
453
+ return new MentionableOption(this.description, true, this.localizations);
454
+ }
455
+ choices(_values) {
456
+ throw new errors_1.OptionValidationError("Mentionable options do not support choices.");
457
+ }
458
+ apply(container, name) {
459
+ container.addMentionableOption((option) => {
460
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
461
+ applyOptionLocalizations(option, this.localizations);
462
+ return option;
463
+ });
464
+ }
465
+ read(interaction, name) {
466
+ return interaction.options.getMentionable(name, this.isRequired);
467
+ }
468
+ }
469
+ function createMentionableOption(description, localizations = {}) {
470
+ return new MentionableOption(description, false, localizations);
471
+ }
472
+ class AttachmentOption {
473
+ description;
474
+ isRequired;
475
+ localizations;
476
+ constructor(description, isRequired, localizations = {}) {
477
+ this.description = description;
478
+ this.isRequired = isRequired;
479
+ this.localizations = localizations;
480
+ }
481
+ required() {
482
+ return new AttachmentOption(this.description, true, this.localizations);
483
+ }
484
+ choices(_values) {
485
+ throw new errors_1.OptionValidationError("Attachment options do not support choices.");
486
+ }
487
+ apply(container, name) {
488
+ container.addAttachmentOption((option) => {
489
+ option.setName(name).setDescription(this.description).setRequired(this.isRequired);
490
+ applyOptionLocalizations(option, this.localizations);
491
+ return option;
492
+ });
493
+ }
494
+ read(interaction, name) {
495
+ return interaction.options.getAttachment(name, this.isRequired);
496
+ }
497
+ }
498
+ function createAttachmentOption(description, localizations = {}) {
499
+ return new AttachmentOption(description, false, localizations);
500
+ }
501
+ /** Turn every option in a record into its required variant. */
502
+ function allRequired(fields) {
503
+ const out = {};
504
+ for (const [key, option] of Object.entries(fields)) {
505
+ out[key] = option.required();
506
+ }
507
+ return out;
508
+ }
509
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/discord/command/options.ts"],"names":[],"mappings":";;AAuOA,gDAcC;AAmCD,4CAKC;AAoCD,kDAKC;AAoED,kDAMC;AA8DD,gDAMC;AA+CD,oDAKC;AAyDD,sDAKC;AAiDD,4CAKC;AAuED,kDAMC;AAmCD,4CAKC;AAoCD,0DAKC;AAoCD,wDAKC;AAKD,kCAMC;AA1zBD,yCAA8C;AAC9C,qDAAiE;AAajE,wEAAwE;AACxE,SAAS,wBAAwB,CAChC,MAGC,EACD,aAAkC;IAElC,IAAI,aAAa,CAAC,iBAAiB,EAAE,CAAC;QACrC,MAAM,CAAC,oBAAoB,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAC9D,CAAC;IACD,IAAI,aAAa,CAAC,wBAAwB,EAAE,CAAC;QAC5C,MAAM,CAAC,2BAA2B,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC;IAC5E,CAAC;AACF,CAAC;AA+ED,MAAM,iCAAiC,GACtC,0FAA0F,CAAC;AAE5F;;;GAGG;AACH,SAAS,qCAAqC,CAC7C,UAAmB,EACnB,QAA0C;IAE1C,IAAI,UAAU,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,8BAAqB,CAAC,iCAAiC,CAAC,CAAC;IACpE,CAAC;AACF,CAAC;AAQD,MAAM,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AAoB,MAAS;IACvD,MAAM,GAAG,GAAG,EAA0C,CAAC;IACvD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpD,GAAG,CAAC,GAAc,CAAC,GAAG,MAAM,CAAC,QAAQ,EAA4B,CAAC;IACnE,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Guard } from "../../discord/command/guard";
2
+ import { type PermissionBit } from "../../discord/permissions";
3
+ import type { LocalizedText } from "../../i18n";
4
+ /**
5
+ * Deny unless the member holds every permission in `required`.
6
+ *
7
+ * `interaction.memberPermissions` is `null` outside a guild; that is a denial,
8
+ * since an unknown permission set cannot be treated as a granted one.
9
+ */
10
+ export declare function createPermissionGuard(required: readonly PermissionBit[], denyMessage?: LocalizedText): Guard;
11
+ /**
12
+ * Deny unless the member holds one of `roleIds`.
13
+ *
14
+ * Outside a guild there is no member and therefore no role: deny. The member's
15
+ * role cache is authoritative here because `interactionCreate` always carries a
16
+ * fully resolved member object for guild interactions.
17
+ */
18
+ export declare function createRoleGuard(roleIds: readonly string[], denyMessage?: LocalizedText): Guard;
19
+ /** Deny outside a guild, so a handler can rely on the guild context existing. */
20
+ export declare const guildOnlyGuard: Guard;
21
+ //# sourceMappingURL=permission-guard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-guard.d.ts","sourceRoot":"","sources":["../../../src/discord/command/permission-guard.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAe,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAyC,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAClG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAW5C;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,WAAW,CAAC,EAAE,aAAa,GACzB,KAAK,CAgBP;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,WAAW,CAAC,EAAE,aAAa,GAAG,KAAK,CAc9F;AAED,iFAAiF;AACjF,eAAO,MAAM,cAAc,EAAE,KAO5B,CAAC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.guildOnlyGuard = void 0;
4
+ exports.createPermissionGuard = createPermissionGuard;
5
+ exports.createRoleGuard = createRoleGuard;
6
+ const i18n_1 = require("../../discord/i18n");
7
+ const permissions_1 = require("../../discord/permissions");
8
+ /**
9
+ * Generic, reusable guards. They complement — never replace —
10
+ * `defaultMemberPermissions` on a command: that field only *hides* the command
11
+ * in the Discord client, and a server admin can override it in the Integrations
12
+ * UI. The guard is the enforcement that actually runs server-side.
13
+ */
14
+ const ALLOW = { ok: true };
15
+ /**
16
+ * Deny unless the member holds every permission in `required`.
17
+ *
18
+ * `interaction.memberPermissions` is `null` outside a guild; that is a denial,
19
+ * since an unknown permission set cannot be treated as a granted one.
20
+ */
21
+ function createPermissionGuard(required, denyMessage) {
22
+ return {
23
+ check(interaction) {
24
+ const missing = (0, permissions_1.missingPermissions)(interaction.memberPermissions, required);
25
+ if (missing.length === 0) {
26
+ return ALLOW;
27
+ }
28
+ return {
29
+ ok: false,
30
+ message: denyMessage ?? {
31
+ key: i18n_1.CORE_MESSAGES.guardPermissionDenied,
32
+ params: { missing: (0, permissions_1.formatPermissions)(missing) },
33
+ },
34
+ };
35
+ },
36
+ };
37
+ }
38
+ /**
39
+ * Deny unless the member holds one of `roleIds`.
40
+ *
41
+ * Outside a guild there is no member and therefore no role: deny. The member's
42
+ * role cache is authoritative here because `interactionCreate` always carries a
43
+ * fully resolved member object for guild interactions.
44
+ */
45
+ function createRoleGuard(roleIds, denyMessage) {
46
+ return {
47
+ check(interaction) {
48
+ const member = interaction.member;
49
+ if (!member || !interaction.inCachedGuild()) {
50
+ return { ok: false, message: denyMessage ?? { key: i18n_1.CORE_MESSAGES.guardGuildOnly } };
51
+ }
52
+ const held = interaction.member.roles.cache;
53
+ if (roleIds.some((roleId) => held.has(roleId))) {
54
+ return ALLOW;
55
+ }
56
+ return { ok: false, message: denyMessage ?? { key: i18n_1.CORE_MESSAGES.guardRoleDenied } };
57
+ },
58
+ };
59
+ }
60
+ /** Deny outside a guild, so a handler can rely on the guild context existing. */
61
+ exports.guildOnlyGuard = {
62
+ check(interaction) {
63
+ if (interaction.inGuild()) {
64
+ return ALLOW;
65
+ }
66
+ return { ok: false, message: { key: i18n_1.CORE_MESSAGES.guardGuildOnly } };
67
+ },
68
+ };
69
+ //# sourceMappingURL=permission-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-guard.js","sourceRoot":"","sources":["../../../src/discord/command/permission-guard.ts"],"names":[],"mappings":";;;AAqBA,sDAmBC;AASD,0CAcC;AA7DD,yCAA+C;AAC/C,uDAAkG;AAGlG;;;;;GAKG;AAEH,MAAM,KAAK,GAAgB,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AAExC;;;;;GAKG;AACH,SAAgB,qBAAqB,CACpC,QAAkC,EAClC,WAA2B;IAE3B,OAAO;QACN,KAAK,CAAC,WAA+B;YACpC,MAAM,OAAO,GAAG,IAAA,gCAAkB,EAAC,WAAW,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;YAC5E,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1B,OAAO,KAAK,CAAC;YACd,CAAC;YACD,OAAO;gBACN,EAAE,EAAE,KAAK;gBACT,OAAO,EAAE,WAAW,IAAI;oBACvB,GAAG,EAAE,oBAAa,CAAC,qBAAqB;oBACxC,MAAM,EAAE,EAAE,OAAO,EAAE,IAAA,+BAAiB,EAAC,OAAO,CAAC,EAAE;iBAC/C;aACD,CAAC;QACH,CAAC;KACD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;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