@buape/carbon 0.12.0 → 0.14.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 (305) hide show
  1. package/dist/package.json +8 -7
  2. package/dist/src/abstracts/BaseCommand.d.ts +4 -0
  3. package/dist/src/abstracts/BaseCommand.d.ts.map +1 -1
  4. package/dist/src/abstracts/BaseCommand.js +23 -0
  5. package/dist/src/abstracts/BaseCommand.js.map +1 -1
  6. package/dist/src/abstracts/BaseComponent.d.ts +2 -2
  7. package/dist/src/abstracts/BaseComponent.d.ts.map +1 -1
  8. package/dist/src/abstracts/BaseGuildChannel.d.ts +1 -2
  9. package/dist/src/abstracts/BaseGuildChannel.d.ts.map +1 -1
  10. package/dist/src/abstracts/BaseGuildChannel.js.map +1 -1
  11. package/dist/src/abstracts/BaseInteraction.d.ts +52 -0
  12. package/dist/src/abstracts/BaseInteraction.d.ts.map +1 -1
  13. package/dist/src/abstracts/BaseInteraction.js +44 -6
  14. package/dist/src/abstracts/BaseInteraction.js.map +1 -1
  15. package/dist/src/abstracts/BaseModalComponent.d.ts +4 -3
  16. package/dist/src/abstracts/BaseModalComponent.d.ts.map +1 -1
  17. package/dist/src/abstracts/BaseModalComponent.js +1 -1
  18. package/dist/src/abstracts/BaseModalComponent.js.map +1 -1
  19. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts +1 -2
  20. package/dist/src/abstracts/GuildThreadOnlyChannel.d.ts.map +1 -1
  21. package/dist/src/abstracts/GuildThreadOnlyChannel.js.map +1 -1
  22. package/dist/src/adapters/bun/index.d.ts +6 -5
  23. package/dist/src/adapters/bun/index.d.ts.map +1 -1
  24. package/dist/src/adapters/bun/index.js +2 -2
  25. package/dist/src/adapters/bun/index.js.map +1 -1
  26. package/dist/src/adapters/fetch/index.d.ts +4 -3
  27. package/dist/src/adapters/fetch/index.d.ts.map +1 -1
  28. package/dist/src/adapters/fetch/index.js +7 -2
  29. package/dist/src/adapters/fetch/index.js.map +1 -1
  30. package/dist/src/adapters/node/index.d.ts +4 -3
  31. package/dist/src/adapters/node/index.d.ts.map +1 -1
  32. package/dist/src/adapters/node/index.js +2 -2
  33. package/dist/src/adapters/node/index.js.map +1 -1
  34. package/dist/src/classes/Client.d.ts +24 -4
  35. package/dist/src/classes/Client.d.ts.map +1 -1
  36. package/dist/src/classes/Client.js +64 -15
  37. package/dist/src/classes/Client.js.map +1 -1
  38. package/dist/src/classes/Listener.d.ts +15 -2
  39. package/dist/src/classes/Listener.d.ts.map +1 -1
  40. package/dist/src/classes/Listener.js +27 -6
  41. package/dist/src/classes/Listener.js.map +1 -1
  42. package/dist/src/classes/Modal.d.ts +2 -3
  43. package/dist/src/classes/Modal.d.ts.map +1 -1
  44. package/dist/src/classes/Modal.js.map +1 -1
  45. package/dist/src/classes/RequestClient.d.ts +18 -2
  46. package/dist/src/classes/RequestClient.d.ts.map +1 -1
  47. package/dist/src/classes/RequestClient.js +268 -68
  48. package/dist/src/classes/RequestClient.js.map +1 -1
  49. package/dist/src/classes/components/Button.d.ts.map +1 -1
  50. package/dist/src/classes/components/Button.js.map +1 -1
  51. package/dist/src/classes/components/Checkbox.d.ts +12 -0
  52. package/dist/src/classes/components/Checkbox.d.ts.map +1 -0
  53. package/dist/src/classes/components/Checkbox.js +20 -0
  54. package/dist/src/classes/components/Checkbox.js.map +1 -0
  55. package/dist/src/classes/components/CheckboxGroup.d.ts +24 -0
  56. package/dist/src/classes/components/CheckboxGroup.d.ts.map +1 -0
  57. package/dist/src/classes/components/CheckboxGroup.js +37 -0
  58. package/dist/src/classes/components/CheckboxGroup.js.map +1 -0
  59. package/dist/src/classes/components/Container.d.ts +6 -2
  60. package/dist/src/classes/components/Container.d.ts.map +1 -1
  61. package/dist/src/classes/components/Container.js +11 -0
  62. package/dist/src/classes/components/Container.js.map +1 -1
  63. package/dist/src/classes/components/File.d.ts +2 -2
  64. package/dist/src/classes/components/File.d.ts.map +1 -1
  65. package/dist/src/classes/components/File.js +4 -1
  66. package/dist/src/classes/components/File.js.map +1 -1
  67. package/dist/src/classes/components/FileUpload.d.ts +23 -0
  68. package/dist/src/classes/components/FileUpload.d.ts.map +1 -0
  69. package/dist/src/classes/components/FileUpload.js +36 -0
  70. package/dist/src/classes/components/FileUpload.js.map +1 -0
  71. package/dist/src/classes/components/Label.d.ts +10 -6
  72. package/dist/src/classes/components/Label.d.ts.map +1 -1
  73. package/dist/src/classes/components/Label.js +1 -2
  74. package/dist/src/classes/components/Label.js.map +1 -1
  75. package/dist/src/classes/components/MediaGallery.d.ts +8 -13
  76. package/dist/src/classes/components/MediaGallery.d.ts.map +1 -1
  77. package/dist/src/classes/components/MediaGallery.js +5 -0
  78. package/dist/src/classes/components/MediaGallery.js.map +1 -1
  79. package/dist/src/classes/components/RadioGroup.d.ts +24 -0
  80. package/dist/src/classes/components/RadioGroup.d.ts.map +1 -0
  81. package/dist/src/classes/components/RadioGroup.js +33 -0
  82. package/dist/src/classes/components/RadioGroup.js.map +1 -0
  83. package/dist/src/classes/components/Row.d.ts.map +1 -1
  84. package/dist/src/classes/components/Row.js +2 -3
  85. package/dist/src/classes/components/Row.js.map +1 -1
  86. package/dist/src/classes/components/Section.d.ts +4 -3
  87. package/dist/src/classes/components/Section.d.ts.map +1 -1
  88. package/dist/src/classes/components/Section.js +22 -0
  89. package/dist/src/classes/components/Section.js.map +1 -1
  90. package/dist/src/classes/components/TextDisplay.d.ts +2 -2
  91. package/dist/src/classes/components/TextDisplay.d.ts.map +1 -1
  92. package/dist/src/classes/components/TextDisplay.js +3 -0
  93. package/dist/src/classes/components/TextDisplay.js.map +1 -1
  94. package/dist/src/classes/components/TextInput.d.ts +0 -1
  95. package/dist/src/classes/components/TextInput.d.ts.map +1 -1
  96. package/dist/src/classes/components/TextInput.js +0 -1
  97. package/dist/src/classes/components/TextInput.js.map +1 -1
  98. package/dist/src/classes/components/Thumbnail.d.ts +3 -2
  99. package/dist/src/classes/components/Thumbnail.d.ts.map +1 -1
  100. package/dist/src/classes/components/Thumbnail.js +11 -0
  101. package/dist/src/classes/components/Thumbnail.js.map +1 -1
  102. package/dist/src/errors/DiscordError.d.ts.map +1 -1
  103. package/dist/src/errors/DiscordError.js.map +1 -1
  104. package/dist/src/index.d.ts +10 -0
  105. package/dist/src/index.d.ts.map +1 -1
  106. package/dist/src/index.js +9 -0
  107. package/dist/src/index.js.map +1 -1
  108. package/dist/src/internals/AutocompleteInteraction.d.ts +1 -1
  109. package/dist/src/internals/AutocompleteInteraction.d.ts.map +1 -1
  110. package/dist/src/internals/CommandInteraction.d.ts +4 -0
  111. package/dist/src/internals/CommandInteraction.d.ts.map +1 -1
  112. package/dist/src/internals/CommandInteraction.js +32 -1
  113. package/dist/src/internals/CommandInteraction.js.map +1 -1
  114. package/dist/src/internals/ComponentHandler.d.ts +4 -10
  115. package/dist/src/internals/ComponentHandler.d.ts.map +1 -1
  116. package/dist/src/internals/ComponentHandler.js +46 -38
  117. package/dist/src/internals/ComponentHandler.js.map +1 -1
  118. package/dist/src/internals/EmojiHandler.d.ts.map +1 -1
  119. package/dist/src/internals/EmojiHandler.js +0 -1
  120. package/dist/src/internals/EmojiHandler.js.map +1 -1
  121. package/dist/src/internals/EventHandler.d.ts +13 -2
  122. package/dist/src/internals/EventHandler.d.ts.map +1 -1
  123. package/dist/src/internals/EventHandler.js +14 -11
  124. package/dist/src/internals/EventHandler.js.map +1 -1
  125. package/dist/src/internals/EventQueue.d.ts +59 -0
  126. package/dist/src/internals/EventQueue.d.ts.map +1 -0
  127. package/dist/src/internals/EventQueue.js +131 -0
  128. package/dist/src/internals/EventQueue.js.map +1 -0
  129. package/dist/src/internals/FieldsHandler.d.ts +4 -1
  130. package/dist/src/internals/FieldsHandler.d.ts.map +1 -1
  131. package/dist/src/internals/FieldsHandler.js +26 -3
  132. package/dist/src/internals/FieldsHandler.js.map +1 -1
  133. package/dist/src/internals/OptionsHandler.d.ts +12 -2
  134. package/dist/src/internals/OptionsHandler.d.ts.map +1 -1
  135. package/dist/src/internals/OptionsHandler.js +31 -4
  136. package/dist/src/internals/OptionsHandler.js.map +1 -1
  137. package/dist/src/internals/TemporaryListenerManager.d.ts +20 -0
  138. package/dist/src/internals/TemporaryListenerManager.d.ts.map +1 -0
  139. package/dist/src/internals/TemporaryListenerManager.js +59 -0
  140. package/dist/src/internals/TemporaryListenerManager.js.map +1 -0
  141. package/dist/src/permissions.d.ts +1 -0
  142. package/dist/src/permissions.d.ts.map +1 -1
  143. package/dist/src/plugins/client-manager/ClientManager.d.ts +151 -0
  144. package/dist/src/plugins/client-manager/ClientManager.d.ts.map +1 -0
  145. package/dist/src/plugins/client-manager/ClientManager.js +253 -0
  146. package/dist/src/plugins/client-manager/ClientManager.js.map +1 -0
  147. package/dist/src/plugins/client-manager/index.d.ts +2 -0
  148. package/dist/src/plugins/client-manager/index.d.ts.map +1 -0
  149. package/dist/src/plugins/client-manager/index.js +2 -0
  150. package/dist/src/plugins/client-manager/index.js.map +1 -0
  151. package/dist/src/plugins/command-data/CommandDataPlugin.d.ts.map +1 -1
  152. package/dist/src/plugins/command-data/CommandDataPlugin.js +3 -6
  153. package/dist/src/plugins/command-data/CommandDataPlugin.js.map +1 -1
  154. package/dist/src/plugins/gateway/BabyCache.d.ts +16 -0
  155. package/dist/src/plugins/gateway/BabyCache.d.ts.map +1 -0
  156. package/dist/src/plugins/gateway/BabyCache.js +53 -0
  157. package/dist/src/plugins/gateway/BabyCache.js.map +1 -0
  158. package/dist/src/plugins/gateway/GatewayPlugin.d.ts +7 -2
  159. package/dist/src/plugins/gateway/GatewayPlugin.d.ts.map +1 -1
  160. package/dist/src/plugins/gateway/GatewayPlugin.js +137 -31
  161. package/dist/src/plugins/gateway/GatewayPlugin.js.map +1 -1
  162. package/dist/src/plugins/gateway/InteractionEventListener.d.ts +8 -0
  163. package/dist/src/plugins/gateway/InteractionEventListener.d.ts.map +1 -0
  164. package/dist/src/plugins/gateway/InteractionEventListener.js +9 -0
  165. package/dist/src/plugins/gateway/InteractionEventListener.js.map +1 -0
  166. package/dist/src/plugins/gateway/types.d.ts +5 -0
  167. package/dist/src/plugins/gateway/types.d.ts.map +1 -1
  168. package/dist/src/plugins/gateway/types.js.map +1 -1
  169. package/dist/src/plugins/gateway/utils/heartbeat.d.ts +1 -0
  170. package/dist/src/plugins/gateway/utils/heartbeat.d.ts.map +1 -1
  171. package/dist/src/plugins/gateway/utils/heartbeat.js +13 -8
  172. package/dist/src/plugins/gateway/utils/heartbeat.js.map +1 -1
  173. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts +1 -1
  174. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.d.ts.map +1 -1
  175. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js +10 -6
  176. package/dist/src/plugins/gateway-forwarder/GatewayForwarderPlugin.js.map +1 -1
  177. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts +0 -1
  178. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.d.ts.map +1 -1
  179. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js +0 -4
  180. package/dist/src/plugins/gateway-forwarder/ShardedGatewayForwarderPlugin.js.map +1 -1
  181. package/dist/src/plugins/gateway-forwarder/index.d.ts +1 -1
  182. package/dist/src/plugins/gateway-forwarder/index.d.ts.map +1 -1
  183. package/dist/src/plugins/gateway-forwarder/index.js +1 -1
  184. package/dist/src/plugins/gateway-forwarder/index.js.map +1 -1
  185. package/dist/src/plugins/paginator/GoToPageModal.d.ts +1 -1
  186. package/dist/src/plugins/paginator/GoToPageModal.d.ts.map +1 -1
  187. package/dist/src/plugins/paginator/GoToPageModal.js +2 -2
  188. package/dist/src/plugins/paginator/GoToPageModal.js.map +1 -1
  189. package/dist/src/plugins/paginator/Paginator.d.ts.map +1 -1
  190. package/dist/src/plugins/paginator/Paginator.js +1 -1
  191. package/dist/src/plugins/paginator/Paginator.js.map +1 -1
  192. package/dist/src/plugins/paginator/index.d.ts +2 -0
  193. package/dist/src/plugins/paginator/index.d.ts.map +1 -1
  194. package/dist/src/plugins/paginator/index.js +2 -0
  195. package/dist/src/plugins/paginator/index.js.map +1 -1
  196. package/dist/src/plugins/sharding/index.d.ts +1 -1
  197. package/dist/src/plugins/sharding/index.js +1 -1
  198. package/dist/src/plugins/voice/GuildDeleteListener.d.ts +7 -0
  199. package/dist/src/plugins/voice/GuildDeleteListener.d.ts.map +1 -0
  200. package/dist/src/plugins/voice/GuildDeleteListener.js +11 -0
  201. package/dist/src/plugins/voice/GuildDeleteListener.js.map +1 -0
  202. package/dist/src/plugins/voice/VoicePlugin.d.ts +15 -0
  203. package/dist/src/plugins/voice/VoicePlugin.d.ts.map +1 -0
  204. package/dist/src/plugins/voice/VoicePlugin.js +54 -0
  205. package/dist/src/plugins/voice/VoicePlugin.js.map +1 -0
  206. package/dist/src/plugins/voice/index.d.ts +2 -0
  207. package/dist/src/plugins/voice/index.d.ts.map +1 -0
  208. package/dist/src/plugins/voice/index.js +2 -0
  209. package/dist/src/plugins/voice/index.js.map +1 -0
  210. package/dist/src/structures/DmChannel.d.ts +4 -0
  211. package/dist/src/structures/DmChannel.d.ts.map +1 -1
  212. package/dist/src/structures/DmChannel.js +6 -0
  213. package/dist/src/structures/DmChannel.js.map +1 -1
  214. package/dist/src/structures/Emoji.d.ts +11 -0
  215. package/dist/src/structures/Emoji.d.ts.map +1 -1
  216. package/dist/src/structures/Emoji.js +20 -0
  217. package/dist/src/structures/Emoji.js.map +1 -1
  218. package/dist/src/structures/GroupDmChannel.d.ts +12 -1
  219. package/dist/src/structures/GroupDmChannel.d.ts.map +1 -1
  220. package/dist/src/structures/GroupDmChannel.js +19 -4
  221. package/dist/src/structures/GroupDmChannel.js.map +1 -1
  222. package/dist/src/structures/Guild.d.ts +70 -4
  223. package/dist/src/structures/Guild.d.ts.map +1 -1
  224. package/dist/src/structures/Guild.js +152 -21
  225. package/dist/src/structures/Guild.js.map +1 -1
  226. package/dist/src/structures/GuildMember.d.ts +18 -6
  227. package/dist/src/structures/GuildMember.d.ts.map +1 -1
  228. package/dist/src/structures/GuildMember.js +24 -9
  229. package/dist/src/structures/GuildMember.js.map +1 -1
  230. package/dist/src/structures/GuildScheduledEvent.d.ts +121 -0
  231. package/dist/src/structures/GuildScheduledEvent.d.ts.map +1 -0
  232. package/dist/src/structures/GuildScheduledEvent.js +228 -0
  233. package/dist/src/structures/GuildScheduledEvent.js.map +1 -0
  234. package/dist/src/structures/GuildThreadChannel.d.ts +1 -1
  235. package/dist/src/structures/GuildThreadChannel.d.ts.map +1 -1
  236. package/dist/src/structures/Role.d.ts +33 -12
  237. package/dist/src/structures/Role.d.ts.map +1 -1
  238. package/dist/src/structures/Role.js +58 -24
  239. package/dist/src/structures/Role.js.map +1 -1
  240. package/dist/src/structures/ThreadMember.d.ts.map +1 -1
  241. package/dist/src/structures/ThreadMember.js +0 -1
  242. package/dist/src/structures/ThreadMember.js.map +1 -1
  243. package/dist/src/structures/User.d.ts +17 -5
  244. package/dist/src/structures/User.d.ts.map +1 -1
  245. package/dist/src/structures/User.js +28 -12
  246. package/dist/src/structures/User.js.map +1 -1
  247. package/dist/src/structures/Webhook.d.ts +40 -19
  248. package/dist/src/structures/Webhook.d.ts.map +1 -1
  249. package/dist/src/structures/Webhook.js +70 -30
  250. package/dist/src/structures/Webhook.js.map +1 -1
  251. package/dist/src/types/index.d.ts +55 -2
  252. package/dist/src/types/index.d.ts.map +1 -1
  253. package/dist/src/types/index.js.map +1 -1
  254. package/dist/src/types/listeners.d.ts +13 -9
  255. package/dist/src/types/listeners.d.ts.map +1 -1
  256. package/dist/src/types/listeners.js +3 -1
  257. package/dist/src/types/listeners.js.map +1 -1
  258. package/dist/src/utils/LRUCache.d.ts +46 -0
  259. package/dist/src/utils/LRUCache.d.ts.map +1 -0
  260. package/dist/src/utils/LRUCache.js +78 -0
  261. package/dist/src/utils/LRUCache.js.map +1 -0
  262. package/dist/src/utils/cdn.d.ts +31 -0
  263. package/dist/src/utils/cdn.d.ts.map +1 -0
  264. package/dist/src/utils/cdn.js +18 -0
  265. package/dist/src/utils/cdn.js.map +1 -0
  266. package/dist/src/utils/customIdParser.d.ts.map +1 -1
  267. package/dist/src/utils/customIdParser.js +6 -2
  268. package/dist/src/utils/customIdParser.js.map +1 -1
  269. package/dist/src/utils/index.d.ts +1 -0
  270. package/dist/src/utils/index.d.ts.map +1 -1
  271. package/dist/src/utils/index.js +1 -0
  272. package/dist/src/utils/index.js.map +1 -1
  273. package/dist/src/utils/payload.d.ts.map +1 -1
  274. package/dist/src/utils/payload.js +2 -1
  275. package/dist/src/utils/payload.js.map +1 -1
  276. package/dist/tsconfig.tsbuildinfo +1 -1
  277. package/package.json +8 -7
  278. package/dist/src/classes/ClientWithCaching.d.ts +0 -51
  279. package/dist/src/classes/ClientWithCaching.d.ts.map +0 -1
  280. package/dist/src/classes/ClientWithCaching.js +0 -108
  281. package/dist/src/classes/ClientWithCaching.js.map +0 -1
  282. package/dist/src/classes/components/ModalChannelSelectMenu.d.ts +0 -62
  283. package/dist/src/classes/components/ModalChannelSelectMenu.d.ts.map +0 -1
  284. package/dist/src/classes/components/ModalChannelSelectMenu.js +0 -73
  285. package/dist/src/classes/components/ModalChannelSelectMenu.js.map +0 -1
  286. package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts +0 -58
  287. package/dist/src/classes/components/ModalMentionableSelectMenu.d.ts.map +0 -1
  288. package/dist/src/classes/components/ModalMentionableSelectMenu.js +0 -68
  289. package/dist/src/classes/components/ModalMentionableSelectMenu.js.map +0 -1
  290. package/dist/src/classes/components/ModalRoleSelectMenu.d.ts +0 -58
  291. package/dist/src/classes/components/ModalRoleSelectMenu.d.ts.map +0 -1
  292. package/dist/src/classes/components/ModalRoleSelectMenu.js +0 -68
  293. package/dist/src/classes/components/ModalRoleSelectMenu.js.map +0 -1
  294. package/dist/src/classes/components/ModalStringSelectMenu.d.ts +0 -58
  295. package/dist/src/classes/components/ModalStringSelectMenu.d.ts.map +0 -1
  296. package/dist/src/classes/components/ModalStringSelectMenu.js +0 -64
  297. package/dist/src/classes/components/ModalStringSelectMenu.js.map +0 -1
  298. package/dist/src/classes/components/ModalUserSelectMenu.d.ts +0 -58
  299. package/dist/src/classes/components/ModalUserSelectMenu.d.ts.map +0 -1
  300. package/dist/src/classes/components/ModalUserSelectMenu.js +0 -68
  301. package/dist/src/classes/components/ModalUserSelectMenu.js.map +0 -1
  302. package/dist/src/internals/Cache.d.ts +0 -76
  303. package/dist/src/internals/Cache.d.ts.map +0 -1
  304. package/dist/src/internals/Cache.js +0 -122
  305. package/dist/src/internals/Cache.js.map +0 -1
@@ -1,58 +0,0 @@
1
- import { type APIStringSelectComponent, ComponentType } from "discord-api-types/v10";
2
- import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
- import type { StringSelectMenuInteraction } from "../../internals/StringSelectMenuInteraction.js";
4
- import type { ComponentParserResult } from "../../types/index.js";
5
- import type { ComponentData } from "../../types/index.js";
6
- export declare abstract class ModalStringSelectMenu extends BaseModalComponent {
7
- readonly type: ComponentType.StringSelect;
8
- readonly isV2 = false;
9
- /**
10
- * The custom ID of the component.
11
- * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
- *
13
- * @see {@link customIdParser}
14
- */
15
- abstract customId: string;
16
- /**
17
- * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
- * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
- * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
- *
21
- * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
- * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
- * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
- *
25
- * @param id - The custom ID of the component as received from an interaction event
26
- * @returns The base key and the data object
27
- */
28
- customIdParser: (id: string) => ComponentParserResult;
29
- /**
30
- * The minimum number of values that must be selected
31
- */
32
- minValues?: number;
33
- /**
34
- * The maximum number of values that can be selected
35
- */
36
- maxValues?: number;
37
- /**
38
- * Whether this component is required (defaults to true in modals)
39
- */
40
- required?: boolean;
41
- /**
42
- * The placeholder text for the select menu
43
- */
44
- placeholder?: string;
45
- /**
46
- * The options for the select menu
47
- */
48
- abstract options: APIStringSelectComponent["options"];
49
- abstract run(interaction: StringSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
- serialize: () => APIStringSelectComponent;
51
- /**
52
- * The disabled field is not allowed on modal select components
53
- * @throws Error when trying to set disabled to true
54
- */
55
- set disabled(value: boolean | undefined);
56
- get disabled(): boolean | undefined;
57
- }
58
- //# sourceMappingURL=ModalStringSelectMenu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModalStringSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,wBAAwB,EAC7B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAA;AACjG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,qBAAsB,SAAQ,kBAAkB;IACrE,QAAQ,CAAC,IAAI,6BAAsC;IACnD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAA;IAErD,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,2BAA2B,EACxC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,wBAAwB,CAgBvC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -1,64 +0,0 @@
1
- import { ComponentType } from "discord-api-types/v10";
2
- import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
- import { parseCustomId } from "../../utils/customIdParser.js";
4
- export class ModalStringSelectMenu extends BaseModalComponent {
5
- type = ComponentType.StringSelect;
6
- isV2 = false;
7
- /**
8
- * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
- * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
- * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
- *
12
- * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
- * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
- * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
- *
16
- * @param id - The custom ID of the component as received from an interaction event
17
- * @returns The base key and the data object
18
- */
19
- customIdParser = parseCustomId;
20
- /**
21
- * The minimum number of values that must be selected
22
- */
23
- minValues;
24
- /**
25
- * The maximum number of values that can be selected
26
- */
27
- maxValues;
28
- /**
29
- * Whether this component is required (defaults to true in modals)
30
- */
31
- required;
32
- /**
33
- * The placeholder text for the select menu
34
- */
35
- placeholder;
36
- serialize = () => {
37
- const data = {
38
- type: this.type,
39
- custom_id: this.customId,
40
- placeholder: this.placeholder,
41
- min_values: this.minValues,
42
- max_values: this.maxValues,
43
- options: this.options
44
- };
45
- // In modals, required defaults to true
46
- if (this.required !== undefined) {
47
- data.required = this.required;
48
- }
49
- return data;
50
- };
51
- /**
52
- * The disabled field is not allowed on modal select components
53
- * @throws Error when trying to set disabled to true
54
- */
55
- set disabled(value) {
56
- if (value === true) {
57
- throw new Error("The 'disabled' field is not allowed on modal select components");
58
- }
59
- }
60
- get disabled() {
61
- return undefined;
62
- }
63
- }
64
- //# sourceMappingURL=ModalStringSelectMenu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModalStringSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalStringSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,qBAAsB,SAAQ,kBAAkB;IAC5D,IAAI,GAAG,aAAa,CAAC,YAAqB,CAAA;IAC1C,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAYpB,SAAS,GAAG,GAA6B,EAAE;QAC1C,MAAM,IAAI,GAA6B;YACtC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -1,58 +0,0 @@
1
- import { type APIUserSelectComponent, ComponentType } from "discord-api-types/v10";
2
- import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
- import type { UserSelectMenuInteraction } from "../../internals/UserSelectMenuInteraction.js";
4
- import type { ComponentParserResult } from "../../types/index.js";
5
- import type { ComponentData } from "../../types/index.js";
6
- export declare abstract class ModalUserSelectMenu extends BaseModalComponent {
7
- readonly type: ComponentType.UserSelect;
8
- readonly isV2 = false;
9
- /**
10
- * The custom ID of the component.
11
- * If you want to provide a custom ID with additional data, you should either follow the default parser's format or implement your own custom parser.
12
- *
13
- * @see {@link customIdParser}
14
- */
15
- abstract customId: string;
16
- /**
17
- * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
18
- * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
19
- * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
20
- *
21
- * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
22
- * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
23
- * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
24
- *
25
- * @param id - The custom ID of the component as received from an interaction event
26
- * @returns The base key and the data object
27
- */
28
- customIdParser: (id: string) => ComponentParserResult;
29
- /**
30
- * The minimum number of values that must be selected
31
- */
32
- minValues?: number;
33
- /**
34
- * The maximum number of values that can be selected
35
- */
36
- maxValues?: number;
37
- /**
38
- * Whether this component is required (defaults to true in modals)
39
- */
40
- required?: boolean;
41
- /**
42
- * The placeholder text for the select menu
43
- */
44
- placeholder?: string;
45
- /**
46
- * Default values for the select menu
47
- */
48
- defaultValues?: APIUserSelectComponent["default_values"];
49
- abstract run(interaction: UserSelectMenuInteraction, data: ComponentData): unknown | Promise<unknown>;
50
- serialize: () => APIUserSelectComponent;
51
- /**
52
- * The disabled field is not allowed on modal select components
53
- * @throws Error when trying to set disabled to true
54
- */
55
- set disabled(value: boolean | undefined);
56
- get disabled(): boolean | undefined;
57
- }
58
- //# sourceMappingURL=ModalUserSelectMenu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModalUserSelectMenu.d.ts","sourceRoot":"","sources":["../../../../src/classes/components/ModalUserSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,sBAAsB,EAC3B,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAC1E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAA;AAC7F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAGzD,8BAAsB,mBAAoB,SAAQ,kBAAkB;IACnE,QAAQ,CAAC,IAAI,2BAAoC;IACjD,QAAQ,CAAC,IAAI,SAAQ;IAErB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IAEzB;;;;;;;;;;;OAWG;IACH,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,qBAAqB,CAAgB;IAErE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,aAAa,CAAC,EAAE,sBAAsB,CAAC,gBAAgB,CAAC,CAAA;IAExD,QAAQ,CAAC,GAAG,CACX,WAAW,EAAE,yBAAyB,EACtC,IAAI,EAAE,aAAa,GACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAE7B,SAAS,QAAO,sBAAsB,CAgBrC;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAMtC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;CACD"}
@@ -1,68 +0,0 @@
1
- import { ComponentType } from "discord-api-types/v10";
2
- import { BaseModalComponent } from "../../abstracts/BaseModalComponent.js";
3
- import { parseCustomId } from "../../utils/customIdParser.js";
4
- export class ModalUserSelectMenu extends BaseModalComponent {
5
- type = ComponentType.UserSelect;
6
- isV2 = false;
7
- /**
8
- * This function is called by the handler when a component is received, and is used to parse the custom ID into a key and data object.
9
- * By default, the ID is parsed in this format: `key:arg1=true;arg2=2;arg3=cheese`, where `arg1`, `arg2`, and `arg3` are the data arguments.
10
- * It will also automatically parse `true` and `false` as booleans, and will parse numbers as numbers.
11
- *
12
- * You can override this to parse the ID in a different format as you see fit, but it must follow these rules:
13
- * - The ID must have a `key` somewhere in the ID that can be returned by the parser. This key is what Carbon's component handler will use to identify the component and pass an interaction to the correct component.
14
- * - The data must be able to be arbitrary as far as Carbon's handler is concerned, meaning that any component with the same base key can be treated as the same component with logic within the component's logic methods to handle the data.
15
- *
16
- * @param id - The custom ID of the component as received from an interaction event
17
- * @returns The base key and the data object
18
- */
19
- customIdParser = parseCustomId;
20
- /**
21
- * The minimum number of values that must be selected
22
- */
23
- minValues;
24
- /**
25
- * The maximum number of values that can be selected
26
- */
27
- maxValues;
28
- /**
29
- * Whether this component is required (defaults to true in modals)
30
- */
31
- required;
32
- /**
33
- * The placeholder text for the select menu
34
- */
35
- placeholder;
36
- /**
37
- * Default values for the select menu
38
- */
39
- defaultValues;
40
- serialize = () => {
41
- const data = {
42
- type: this.type,
43
- custom_id: this.customId,
44
- placeholder: this.placeholder,
45
- min_values: this.minValues,
46
- max_values: this.maxValues,
47
- default_values: this.defaultValues
48
- };
49
- // In modals, required defaults to true
50
- if (this.required !== undefined) {
51
- data.required = this.required;
52
- }
53
- return data;
54
- };
55
- /**
56
- * The disabled field is not allowed on modal select components
57
- * @throws Error when trying to set disabled to true
58
- */
59
- set disabled(value) {
60
- if (value === true) {
61
- throw new Error("The 'disabled' field is not allowed on modal select components");
62
- }
63
- }
64
- get disabled() {
65
- return undefined;
66
- }
67
- }
68
- //# sourceMappingURL=ModalUserSelectMenu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModalUserSelectMenu.js","sourceRoot":"","sources":["../../../../src/classes/components/ModalUserSelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,aAAa,EACb,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAA;AAI1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAE7D,MAAM,OAAgB,mBAAoB,SAAQ,kBAAkB;IAC1D,IAAI,GAAG,aAAa,CAAC,UAAmB,CAAA;IACxC,IAAI,GAAG,KAAK,CAAA;IAUrB;;;;;;;;;;;OAWG;IACH,cAAc,GAA0C,aAAa,CAAA;IAErE;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,SAAS,CAAS;IAElB;;OAEG;IACH,QAAQ,CAAU;IAElB;;OAEG;IACH,WAAW,CAAS;IAEpB;;OAEG;IACH,aAAa,CAA2C;IAOxD,SAAS,GAAG,GAA2B,EAAE;QACxC,MAAM,IAAI,GAA2B;YACpC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,SAAS,EAAE,IAAI,CAAC,QAAQ;YACxB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,cAAc,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;QAED,uCAAuC;QACvC,IAAI,IAAI,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC9B,CAAC;QAED,OAAO,IAAI,CAAA;IACZ,CAAC,CAAA;IAED;;;OAGG;IACH,IAAI,QAAQ,CAAC,KAA0B;QACtC,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACd,gEAAgE,CAChE,CAAA;QACF,CAAC;IACF,CAAC;IAED,IAAI,QAAQ;QACX,OAAO,SAAS,CAAA;IACjB,CAAC;CACD"}
@@ -1,76 +0,0 @@
1
- import type { Client } from "../classes/Client.js";
2
- import type { GuildMember } from "../structures/GuildMember.js";
3
- import type { Webhook } from "../structures/Webhook.js";
4
- export type CacheTypes = {
5
- user: Awaited<ReturnType<typeof Client.prototype.fetchUser>>;
6
- guild: Awaited<ReturnType<typeof Client.prototype.fetchGuild>>;
7
- channel: Awaited<ReturnType<typeof Client.prototype.fetchChannel>>;
8
- role: Awaited<ReturnType<typeof Client.prototype.fetchRole>>;
9
- member: Awaited<ReturnType<typeof Client.prototype.fetchMember>>;
10
- message: Awaited<ReturnType<typeof Client.prototype.fetchMessage>>;
11
- voiceState: Awaited<ReturnType<typeof GuildMember.prototype.getVoiceState>>;
12
- permissions: bigint[];
13
- webhook: Webhook<false>;
14
- };
15
- export interface CacheEntry<V> {
16
- value: V;
17
- expiresAt?: number;
18
- }
19
- export interface CacheOptions {
20
- defaultExpiry?: number;
21
- }
22
- export declare class Cache<K extends keyof CacheTypes | string, V = K extends keyof CacheTypes ? CacheTypes[K] : unknown> {
23
- private cache;
24
- private defaultExpiry;
25
- constructor(options?: CacheOptions);
26
- /**
27
- * Get a value from the cache
28
- * @param key The key to get
29
- * @returns The value if it exists and hasn't expired, undefined otherwise
30
- */
31
- get(key: K): V | undefined;
32
- /**
33
- * Set a value in the cache
34
- * @param key The key to set
35
- * @param value The value to set
36
- * @param expiresIn Optional time in milliseconds until the entry expires
37
- */
38
- set(key: K, value: V, expiresIn?: number): void;
39
- /**
40
- * Delete a value from the cache
41
- * @param key The key to delete
42
- * @returns Whether the key was deleted
43
- */
44
- delete(key: K): boolean;
45
- /**
46
- * Clear all values of a specific type from the cache
47
- * @param type The type to clear
48
- */
49
- clearType(type: K): void;
50
- /**
51
- * Clear all values from the cache
52
- */
53
- clear(): void;
54
- /**
55
- * Get the size of the cache
56
- */
57
- get size(): number;
58
- /**
59
- * Check if a key exists in the cache and hasn't expired
60
- * @param key The key to check
61
- */
62
- has(key: K): boolean;
63
- /**
64
- * Get all keys in the cache that haven't expired
65
- */
66
- keys(): K[];
67
- /**
68
- * Get all values in the cache that haven't expired
69
- */
70
- values(): V[];
71
- /**
72
- * Get all entries in the cache that haven't expired
73
- */
74
- entries(): [K, V][];
75
- }
76
- //# sourceMappingURL=Cache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Cache.d.ts","sourceRoot":"","sources":["../../../src/internals/Cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA;AAEvD,MAAM,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C,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAYjC;;;;;OAKG;IACI,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI;IAKtD;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAI9B;;;OAGG;IACI,SAAS,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAQ/B;;OAEG;IACI,KAAK,IAAI,IAAI;IAIpB;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;OAGG;IACI,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,OAAO;IAY3B;;OAEG;IACI,IAAI,IAAI,CAAC,EAAE;IAYlB;;OAEG;IACI,MAAM,IAAI,CAAC,EAAE;IAYpB;;OAEG;IACI,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;CAW1B"}
@@ -1,122 +0,0 @@
1
- export class Cache {
2
- cache = new Map();
3
- defaultExpiry = 1000 * 60 * 60 * 24; // 1 day
4
- constructor(options = {}) {
5
- if (options.defaultExpiry) {
6
- this.defaultExpiry = options.defaultExpiry;
7
- }
8
- }
9
- /**
10
- * Get a value from the cache
11
- * @param key The key to get
12
- * @returns The value if it exists and hasn't expired, undefined otherwise
13
- */
14
- get(key) {
15
- const entry = this.cache.get(key);
16
- if (!entry)
17
- return undefined;
18
- if (entry.expiresAt && entry.expiresAt < Date.now()) {
19
- this.delete(key);
20
- return undefined;
21
- }
22
- return entry.value;
23
- }
24
- /**
25
- * Set a value in the cache
26
- * @param key The key to set
27
- * @param value The value to set
28
- * @param expiresIn Optional time in milliseconds until the entry expires
29
- */
30
- set(key, value, expiresIn) {
31
- const expiresAt = expiresIn ? Date.now() + expiresIn : this.defaultExpiry;
32
- this.cache.set(key, { value, expiresAt });
33
- }
34
- /**
35
- * Delete a value from the cache
36
- * @param key The key to delete
37
- * @returns Whether the key was deleted
38
- */
39
- delete(key) {
40
- return this.cache.delete(key);
41
- }
42
- /**
43
- * Clear all values of a specific type from the cache
44
- * @param type The type to clear
45
- */
46
- clearType(type) {
47
- for (const [key] of this.cache) {
48
- if (key === type) {
49
- this.delete(key);
50
- }
51
- }
52
- }
53
- /**
54
- * Clear all values from the cache
55
- */
56
- clear() {
57
- this.cache.clear();
58
- }
59
- /**
60
- * Get the size of the cache
61
- */
62
- get size() {
63
- return this.cache.size;
64
- }
65
- /**
66
- * Check if a key exists in the cache and hasn't expired
67
- * @param key The key to check
68
- */
69
- has(key) {
70
- const entry = this.cache.get(key);
71
- if (!entry)
72
- return false;
73
- if (entry.expiresAt && entry.expiresAt < Date.now()) {
74
- this.delete(key);
75
- return false;
76
- }
77
- return true;
78
- }
79
- /**
80
- * Get all keys in the cache that haven't expired
81
- */
82
- keys() {
83
- const keys = [];
84
- for (const [key, entry] of this.cache) {
85
- if (entry.expiresAt && entry.expiresAt < Date.now()) {
86
- this.delete(key);
87
- continue;
88
- }
89
- keys.push(key);
90
- }
91
- return keys;
92
- }
93
- /**
94
- * Get all values in the cache that haven't expired
95
- */
96
- values() {
97
- const values = [];
98
- for (const [key, entry] of this.cache) {
99
- if (entry.expiresAt && entry.expiresAt < Date.now()) {
100
- this.delete(key);
101
- continue;
102
- }
103
- values.push(entry.value);
104
- }
105
- return values;
106
- }
107
- /**
108
- * Get all entries in the cache that haven't expired
109
- */
110
- entries() {
111
- const entries = [];
112
- for (const [key, entry] of this.cache) {
113
- if (entry.expiresAt && entry.expiresAt < Date.now()) {
114
- this.delete(key);
115
- continue;
116
- }
117
- entries.push([key, entry.value]);
118
- }
119
- return entries;
120
- }
121
- }
122
- //# sourceMappingURL=Cache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../src/internals/Cache.ts"],"names":[],"mappings":"AAyBA,MAAM,OAAO,KAAK;IAIT,KAAK,GAA0B,IAAI,GAAG,EAAE,CAAA;IACxC,aAA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