seyfert 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 (345) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +57 -0
  3. package/lib/api/CDN.d.ts +220 -0
  4. package/lib/api/CDN.js +236 -0
  5. package/lib/api/REST.d.ts +127 -0
  6. package/lib/api/REST.js +424 -0
  7. package/lib/api/Router.d.ts +17 -0
  8. package/lib/api/Router.js +63 -0
  9. package/lib/api/Routes/applications.d.ts +46 -0
  10. package/lib/api/Routes/applications.js +2 -0
  11. package/lib/api/Routes/cdn.d.ts +66 -0
  12. package/lib/api/Routes/cdn.js +2 -0
  13. package/lib/api/Routes/channels.d.ts +109 -0
  14. package/lib/api/Routes/channels.js +2 -0
  15. package/lib/api/Routes/gateway.d.ts +11 -0
  16. package/lib/api/Routes/gateway.js +2 -0
  17. package/lib/api/Routes/guilds.d.ts +171 -0
  18. package/lib/api/Routes/guilds.js +2 -0
  19. package/lib/api/Routes/index.d.ts +13 -0
  20. package/lib/api/Routes/index.js +17 -0
  21. package/lib/api/Routes/interactions.d.ts +14 -0
  22. package/lib/api/Routes/interactions.js +2 -0
  23. package/lib/api/Routes/invites.d.ts +9 -0
  24. package/lib/api/Routes/invites.js +2 -0
  25. package/lib/api/Routes/stage-instances.d.ts +13 -0
  26. package/lib/api/Routes/stage-instances.js +2 -0
  27. package/lib/api/Routes/stickers.d.ts +11 -0
  28. package/lib/api/Routes/stickers.js +2 -0
  29. package/lib/api/Routes/users.d.ts +35 -0
  30. package/lib/api/Routes/users.js +2 -0
  31. package/lib/api/Routes/voice.d.ts +10 -0
  32. package/lib/api/Routes/voice.js +2 -0
  33. package/lib/api/Routes/webhooks.d.ts +29 -0
  34. package/lib/api/Routes/webhooks.js +2 -0
  35. package/lib/api/errors/DiscordAPIError.d.ts +51 -0
  36. package/lib/api/errors/DiscordAPIError.js +81 -0
  37. package/lib/api/errors/HTTPError.d.ts +20 -0
  38. package/lib/api/errors/HTTPError.js +28 -0
  39. package/lib/api/errors/RateLimitError.d.ts +19 -0
  40. package/lib/api/errors/RateLimitError.js +37 -0
  41. package/lib/api/handlers/BurstHandler.d.ts +51 -0
  42. package/lib/api/handlers/BurstHandler.js +124 -0
  43. package/lib/api/handlers/SequentialHandler.d.ts +81 -0
  44. package/lib/api/handlers/SequentialHandler.js +365 -0
  45. package/lib/api/handlers/Shared.d.ts +14 -0
  46. package/lib/api/handlers/Shared.js +125 -0
  47. package/lib/api/index.d.ts +5 -0
  48. package/lib/api/index.js +21 -0
  49. package/lib/api/interfaces/Handler.d.ts +21 -0
  50. package/lib/api/interfaces/Handler.js +2 -0
  51. package/lib/api/shared.d.ts +7 -0
  52. package/lib/api/shared.js +27 -0
  53. package/lib/api/utils/constants.d.ts +39 -0
  54. package/lib/api/utils/constants.js +50 -0
  55. package/lib/api/utils/types.d.ts +335 -0
  56. package/lib/api/utils/types.js +14 -0
  57. package/lib/api/utils/utils.d.ts +52 -0
  58. package/lib/api/utils/utils.js +159 -0
  59. package/lib/builders/ActionRow.d.ts +40 -0
  60. package/lib/builders/ActionRow.js +58 -0
  61. package/lib/builders/Attachment.d.ts +106 -0
  62. package/lib/builders/Attachment.js +196 -0
  63. package/lib/builders/Base.d.ts +10 -0
  64. package/lib/builders/Base.js +13 -0
  65. package/lib/builders/Button.d.ts +59 -0
  66. package/lib/builders/Button.js +94 -0
  67. package/lib/builders/MessageEmbed.d.ts +116 -0
  68. package/lib/builders/MessageEmbed.js +159 -0
  69. package/lib/builders/Modal.d.ts +111 -0
  70. package/lib/builders/Modal.js +162 -0
  71. package/lib/builders/SelectMenu.d.ts +201 -0
  72. package/lib/builders/SelectMenu.js +293 -0
  73. package/lib/builders/index.d.ts +12 -0
  74. package/lib/builders/index.js +54 -0
  75. package/lib/builders/types.d.ts +21 -0
  76. package/lib/builders/types.js +2 -0
  77. package/lib/cache/adapters/default.d.ts +24 -0
  78. package/lib/cache/adapters/default.js +118 -0
  79. package/lib/cache/adapters/index.d.ts +4 -0
  80. package/lib/cache/adapters/index.js +20 -0
  81. package/lib/cache/adapters/redis.d.ts +35 -0
  82. package/lib/cache/adapters/redis.js +180 -0
  83. package/lib/cache/adapters/types.d.ts +25 -0
  84. package/lib/cache/adapters/types.js +2 -0
  85. package/lib/cache/adapters/workeradapter.d.ts +24 -0
  86. package/lib/cache/adapters/workeradapter.js +76 -0
  87. package/lib/cache/index.d.ts +97 -0
  88. package/lib/cache/index.js +394 -0
  89. package/lib/cache/resources/channels.d.ts +7 -0
  90. package/lib/cache/resources/channels.js +20 -0
  91. package/lib/cache/resources/default/base.d.ts +25 -0
  92. package/lib/cache/resources/default/base.js +75 -0
  93. package/lib/cache/resources/default/guild-based.d.ts +33 -0
  94. package/lib/cache/resources/default/guild-based.js +91 -0
  95. package/lib/cache/resources/default/guild-related.d.ts +32 -0
  96. package/lib/cache/resources/default/guild-related.js +102 -0
  97. package/lib/cache/resources/emojis.d.ts +7 -0
  98. package/lib/cache/resources/emojis.js +17 -0
  99. package/lib/cache/resources/guilds.d.ts +10 -0
  100. package/lib/cache/resources/guilds.js +117 -0
  101. package/lib/cache/resources/members.d.ts +10 -0
  102. package/lib/cache/resources/members.js +41 -0
  103. package/lib/cache/resources/presence.d.ts +9 -0
  104. package/lib/cache/resources/presence.js +14 -0
  105. package/lib/cache/resources/roles.d.ts +7 -0
  106. package/lib/cache/resources/roles.js +17 -0
  107. package/lib/cache/resources/stage-instances.d.ts +5 -0
  108. package/lib/cache/resources/stage-instances.js +8 -0
  109. package/lib/cache/resources/stickers.d.ts +7 -0
  110. package/lib/cache/resources/stickers.js +17 -0
  111. package/lib/cache/resources/threads.d.ts +7 -0
  112. package/lib/cache/resources/threads.js +17 -0
  113. package/lib/cache/resources/users.d.ts +7 -0
  114. package/lib/cache/resources/users.js +17 -0
  115. package/lib/cache/resources/voice-states.d.ts +9 -0
  116. package/lib/cache/resources/voice-states.js +13 -0
  117. package/lib/client/base.d.ts +244 -0
  118. package/lib/client/base.js +178 -0
  119. package/lib/client/client.d.ts +32 -0
  120. package/lib/client/client.js +156 -0
  121. package/lib/client/httpclient.d.ts +21 -0
  122. package/lib/client/httpclient.js +143 -0
  123. package/lib/client/index.d.ts +4 -0
  124. package/lib/client/index.js +19 -0
  125. package/lib/client/oninteraction.d.ts +4 -0
  126. package/lib/client/oninteraction.js +180 -0
  127. package/lib/client/workerclient.d.ts +28 -0
  128. package/lib/client/workerclient.js +213 -0
  129. package/lib/collection.d.ts +233 -0
  130. package/lib/collection.js +371 -0
  131. package/lib/commands/applications/chat.d.ts +139 -0
  132. package/lib/commands/applications/chat.js +173 -0
  133. package/lib/commands/applications/chatcontext.d.ts +28 -0
  134. package/lib/commands/applications/chatcontext.js +53 -0
  135. package/lib/commands/applications/menu.d.ts +39 -0
  136. package/lib/commands/applications/menu.js +87 -0
  137. package/lib/commands/applications/menucontext.d.ts +25 -0
  138. package/lib/commands/applications/menucontext.js +64 -0
  139. package/lib/commands/applications/options.d.ts +67 -0
  140. package/lib/commands/applications/options.js +44 -0
  141. package/lib/commands/applications/shared.d.ts +35 -0
  142. package/lib/commands/applications/shared.js +2 -0
  143. package/lib/commands/decorators.d.ts +107 -0
  144. package/lib/commands/decorators.js +85 -0
  145. package/lib/commands/handler.d.ts +15 -0
  146. package/lib/commands/handler.js +140 -0
  147. package/lib/commands/index.d.ts +8 -0
  148. package/lib/commands/index.js +24 -0
  149. package/lib/commands/optionresolver.d.ts +49 -0
  150. package/lib/commands/optionresolver.js +146 -0
  151. package/lib/common/bot/watcher.d.ts +53 -0
  152. package/lib/common/bot/watcher.js +104 -0
  153. package/lib/common/index.d.ts +13 -0
  154. package/lib/common/index.js +30 -0
  155. package/lib/common/it/colors.d.ts +274 -0
  156. package/lib/common/it/colors.js +453 -0
  157. package/lib/common/it/constants.d.ts +36 -0
  158. package/lib/common/it/constants.js +40 -0
  159. package/lib/common/it/logger.d.ts +114 -0
  160. package/lib/common/it/logger.js +189 -0
  161. package/lib/common/it/utils.d.ts +107 -0
  162. package/lib/common/it/utils.js +275 -0
  163. package/lib/common/shorters/base.d.ts +5 -0
  164. package/lib/common/shorters/base.js +10 -0
  165. package/lib/common/shorters/channels.d.ts +90 -0
  166. package/lib/common/shorters/channels.js +95 -0
  167. package/lib/common/shorters/guilds.d.ts +389 -0
  168. package/lib/common/shorters/guilds.js +350 -0
  169. package/lib/common/shorters/members.d.ts +115 -0
  170. package/lib/common/shorters/members.js +179 -0
  171. package/lib/common/shorters/messages.d.ts +27 -0
  172. package/lib/common/shorters/messages.js +117 -0
  173. package/lib/common/shorters/roles.d.ts +12 -0
  174. package/lib/common/shorters/roles.js +51 -0
  175. package/lib/common/shorters/templates.d.ts +12 -0
  176. package/lib/common/shorters/templates.js +29 -0
  177. package/lib/common/shorters/users.d.ts +11 -0
  178. package/lib/common/shorters/users.js +42 -0
  179. package/lib/common/shorters/webhook.d.ts +33 -0
  180. package/lib/common/shorters/webhook.js +69 -0
  181. package/lib/common/types/options.d.ts +10 -0
  182. package/lib/common/types/options.js +2 -0
  183. package/lib/common/types/resolvables.d.ts +10 -0
  184. package/lib/common/types/resolvables.js +2 -0
  185. package/lib/common/types/util.d.ts +90 -0
  186. package/lib/common/types/util.js +2 -0
  187. package/lib/common/types/write.d.ts +21 -0
  188. package/lib/common/types/write.js +2 -0
  189. package/lib/components/ActionRow.d.ts +10 -0
  190. package/lib/components/ActionRow.js +13 -0
  191. package/lib/components/ButtonComponent.d.ts +19 -0
  192. package/lib/components/ButtonComponent.js +34 -0
  193. package/lib/components/ChannelSelectMenuComponent.d.ts +6 -0
  194. package/lib/components/ChannelSelectMenuComponent.js +12 -0
  195. package/lib/components/MentionableSelectMenuComponent.d.ts +4 -0
  196. package/lib/components/MentionableSelectMenuComponent.js +7 -0
  197. package/lib/components/RoleSelectMenuComponent.d.ts +4 -0
  198. package/lib/components/RoleSelectMenuComponent.js +7 -0
  199. package/lib/components/StringSelectMenuComponent.d.ts +6 -0
  200. package/lib/components/StringSelectMenuComponent.js +12 -0
  201. package/lib/components/TextInputComponent.d.ts +7 -0
  202. package/lib/components/TextInputComponent.js +14 -0
  203. package/lib/components/UserSelectMenuComponent.d.ts +4 -0
  204. package/lib/components/UserSelectMenuComponent.js +7 -0
  205. package/lib/components/command.d.ts +23 -0
  206. package/lib/components/command.js +15 -0
  207. package/lib/components/handler.d.ts +48 -0
  208. package/lib/components/handler.js +231 -0
  209. package/lib/components/index.d.ts +20 -0
  210. package/lib/components/index.js +55 -0
  211. package/lib/components/listener.d.ts +11 -0
  212. package/lib/components/listener.js +18 -0
  213. package/lib/events/event.d.ts +23 -0
  214. package/lib/events/event.js +2 -0
  215. package/lib/events/handler.d.ts +19 -0
  216. package/lib/events/handler.js +112 -0
  217. package/lib/events/hooks/application_command.d.ts +12 -0
  218. package/lib/events/hooks/application_command.js +8 -0
  219. package/lib/events/hooks/auto_moderation.d.ts +22 -0
  220. package/lib/events/hooks/auto_moderation.js +21 -0
  221. package/lib/events/hooks/channel.d.ts +11 -0
  222. package/lib/events/hooks/channel.js +24 -0
  223. package/lib/events/hooks/custom.d.ts +4 -0
  224. package/lib/events/hooks/custom.js +11 -0
  225. package/lib/events/hooks/dispatch.d.ts +5 -0
  226. package/lib/events/hooks/dispatch.js +12 -0
  227. package/lib/events/hooks/entitlement.d.ts +35 -0
  228. package/lib/events/hooks/entitlement.js +16 -0
  229. package/lib/events/hooks/guild.d.ts +228 -0
  230. package/lib/events/hooks/guild.js +101 -0
  231. package/lib/events/hooks/index.d.ts +23 -0
  232. package/lib/events/hooks/index.js +34 -0
  233. package/lib/events/hooks/integration.d.ts +94 -0
  234. package/lib/events/hooks/integration.js +27 -0
  235. package/lib/events/hooks/interactions.d.ts +4 -0
  236. package/lib/events/hooks/interactions.js +8 -0
  237. package/lib/events/hooks/invite.d.ts +21 -0
  238. package/lib/events/hooks/invite.js +12 -0
  239. package/lib/events/hooks/message.d.ts +69 -0
  240. package/lib/events/hooks/message.js +37 -0
  241. package/lib/events/hooks/presence.d.ts +27 -0
  242. package/lib/events/hooks/presence.js +8 -0
  243. package/lib/events/hooks/stage.d.ts +29 -0
  244. package/lib/events/hooks/stage.js +16 -0
  245. package/lib/events/hooks/thread.d.ts +198 -0
  246. package/lib/events/hooks/thread.js +29 -0
  247. package/lib/events/hooks/typing.d.ts +16 -0
  248. package/lib/events/hooks/typing.js +14 -0
  249. package/lib/events/hooks/user.d.ts +4 -0
  250. package/lib/events/hooks/user.js +8 -0
  251. package/lib/events/hooks/voice.d.ts +37 -0
  252. package/lib/events/hooks/voice.js +18 -0
  253. package/lib/events/hooks/webhook.d.ts +6 -0
  254. package/lib/events/hooks/webhook.js +8 -0
  255. package/lib/events/index.d.ts +2 -0
  256. package/lib/events/index.js +18 -0
  257. package/lib/index.d.ts +79 -0
  258. package/lib/index.js +104 -0
  259. package/lib/langs/handler.d.ts +11 -0
  260. package/lib/langs/handler.js +34 -0
  261. package/lib/langs/index.d.ts +2 -0
  262. package/lib/langs/index.js +18 -0
  263. package/lib/langs/router.d.ts +18 -0
  264. package/lib/langs/router.js +42 -0
  265. package/lib/structures/AnonymousGuild.d.ts +7 -0
  266. package/lib/structures/AnonymousGuild.js +11 -0
  267. package/lib/structures/AutoModerationRule.d.ts +22 -0
  268. package/lib/structures/AutoModerationRule.js +34 -0
  269. package/lib/structures/ClientUser.d.ts +25 -0
  270. package/lib/structures/ClientUser.js +52 -0
  271. package/lib/structures/Guild.d.ts +86 -0
  272. package/lib/structures/Guild.js +66 -0
  273. package/lib/structures/GuildEmoji.d.ts +29 -0
  274. package/lib/structures/GuildEmoji.js +47 -0
  275. package/lib/structures/GuildMember.d.ts +92 -0
  276. package/lib/structures/GuildMember.js +137 -0
  277. package/lib/structures/GuildPreview.d.ts +10 -0
  278. package/lib/structures/GuildPreview.js +14 -0
  279. package/lib/structures/GuildRole.d.ts +21 -0
  280. package/lib/structures/GuildRole.js +32 -0
  281. package/lib/structures/GuildTemplate.d.ts +23 -0
  282. package/lib/structures/GuildTemplate.js +36 -0
  283. package/lib/structures/Interaction.d.ts +152 -0
  284. package/lib/structures/Interaction.js +409 -0
  285. package/lib/structures/Message.d.ts +53 -0
  286. package/lib/structures/Message.js +123 -0
  287. package/lib/structures/Sticker.d.ts +27 -0
  288. package/lib/structures/Sticker.js +44 -0
  289. package/lib/structures/User.d.ts +20 -0
  290. package/lib/structures/User.js +37 -0
  291. package/lib/structures/Webhook.d.ts +42 -0
  292. package/lib/structures/Webhook.js +63 -0
  293. package/lib/structures/channels.d.ts +232 -0
  294. package/lib/structures/channels.js +366 -0
  295. package/lib/structures/extra/Base.d.ts +7 -0
  296. package/lib/structures/extra/Base.js +39 -0
  297. package/lib/structures/extra/BaseComponent.d.ts +9 -0
  298. package/lib/structures/extra/BaseComponent.js +12 -0
  299. package/lib/structures/extra/BaseGuild.d.ts +40 -0
  300. package/lib/structures/extra/BaseGuild.js +71 -0
  301. package/lib/structures/extra/BaseSelectMenuComponent.d.ts +9 -0
  302. package/lib/structures/extra/BaseSelectMenuComponent.js +13 -0
  303. package/lib/structures/extra/BitField.d.ts +14 -0
  304. package/lib/structures/extra/BitField.js +56 -0
  305. package/lib/structures/extra/DiscordBase.d.ts +18 -0
  306. package/lib/structures/extra/DiscordBase.js +28 -0
  307. package/lib/structures/extra/Permissions.d.ts +54 -0
  308. package/lib/structures/extra/Permissions.js +9 -0
  309. package/lib/structures/extra/functions.d.ts +11 -0
  310. package/lib/structures/extra/functions.js +69 -0
  311. package/lib/structures/index.d.ts +15 -0
  312. package/lib/structures/index.js +31 -0
  313. package/lib/websocket/SharedTypes.d.ts +128 -0
  314. package/lib/websocket/SharedTypes.js +2 -0
  315. package/lib/websocket/constants/index.d.ts +26 -0
  316. package/lib/websocket/constants/index.js +31 -0
  317. package/lib/websocket/discord/basesocket.d.ts +12 -0
  318. package/lib/websocket/discord/basesocket.js +37 -0
  319. package/lib/websocket/discord/events/memberUpdate.d.ts +16 -0
  320. package/lib/websocket/discord/events/memberUpdate.js +47 -0
  321. package/lib/websocket/discord/events/presenceUpdate.d.ts +24 -0
  322. package/lib/websocket/discord/events/presenceUpdate.js +46 -0
  323. package/lib/websocket/discord/handlemessage.d.ts +0 -0
  324. package/lib/websocket/discord/handlemessage.js +1 -0
  325. package/lib/websocket/discord/index.d.ts +4 -0
  326. package/lib/websocket/discord/index.js +20 -0
  327. package/lib/websocket/discord/memberUpdate.d.ts +16 -0
  328. package/lib/websocket/discord/memberUpdate.js +47 -0
  329. package/lib/websocket/discord/shard.d.ts +46 -0
  330. package/lib/websocket/discord/shard.js +278 -0
  331. package/lib/websocket/discord/sharder.d.ts +25 -0
  332. package/lib/websocket/discord/sharder.js +153 -0
  333. package/lib/websocket/discord/shared.d.ts +99 -0
  334. package/lib/websocket/discord/shared.js +8 -0
  335. package/lib/websocket/discord/worker.d.ts +43 -0
  336. package/lib/websocket/discord/worker.js +2 -0
  337. package/lib/websocket/discord/workermanager.d.ts +69 -0
  338. package/lib/websocket/discord/workermanager.js +273 -0
  339. package/lib/websocket/index.d.ts +3 -0
  340. package/lib/websocket/index.js +19 -0
  341. package/lib/websocket/structures/index.d.ts +117 -0
  342. package/lib/websocket/structures/index.js +261 -0
  343. package/lib/websocket/structures/timeout.d.ts +20 -0
  344. package/lib/websocket/structures/timeout.js +75 -0
  345. package/package.json +70 -0
@@ -0,0 +1,394 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Cache = void 0;
18
+ const guilds_1 = require("./resources/guilds");
19
+ const users_1 = require("./resources/users");
20
+ const channels_1 = require("./resources/channels");
21
+ const emojis_1 = require("./resources/emojis");
22
+ const members_1 = require("./resources/members");
23
+ const presence_1 = require("./resources/presence");
24
+ const roles_1 = require("./resources/roles");
25
+ const stage_instances_1 = require("./resources/stage-instances");
26
+ const stickers_1 = require("./resources/stickers");
27
+ const threads_1 = require("./resources/threads");
28
+ const voice_states_1 = require("./resources/voice-states");
29
+ const common_1 = require("../common");
30
+ __exportStar(require("./adapters/index"), exports);
31
+ class Cache {
32
+ intents;
33
+ adapter;
34
+ disabledCache;
35
+ // non-guild based
36
+ users;
37
+ guilds;
38
+ // guild based
39
+ members;
40
+ // guild related
41
+ roles;
42
+ emojis;
43
+ threads;
44
+ channels;
45
+ stickers;
46
+ presences;
47
+ voiceStates;
48
+ stageInstances;
49
+ constructor(intents, adapter, disabledCache = [], client) {
50
+ this.intents = intents;
51
+ this.adapter = adapter;
52
+ this.disabledCache = disabledCache;
53
+ // non-guild based
54
+ if (!this.disabledCache.includes('users')) {
55
+ this.users = new users_1.Users(this, client);
56
+ }
57
+ if (!this.disabledCache.includes('guilds')) {
58
+ this.guilds = new guilds_1.Guilds(this, client);
59
+ }
60
+ // guild related
61
+ if (!this.disabledCache.includes('members')) {
62
+ this.members = new members_1.Members(this, client);
63
+ }
64
+ // guild based
65
+ if (!this.disabledCache.includes('roles')) {
66
+ this.roles = new roles_1.Roles(this, client);
67
+ }
68
+ if (!this.disabledCache.includes('channels')) {
69
+ this.channels = new channels_1.Channels(this, client);
70
+ }
71
+ if (!this.disabledCache.includes('emojis')) {
72
+ this.emojis = new emojis_1.Emojis(this, client);
73
+ }
74
+ if (!this.disabledCache.includes('stickers')) {
75
+ this.stickers = new stickers_1.Stickers(this, client);
76
+ }
77
+ if (!this.disabledCache.includes('presences')) {
78
+ this.presences = new presence_1.Presences(this, client);
79
+ }
80
+ if (!this.disabledCache.includes('voiceStates')) {
81
+ this.voiceStates = new voice_states_1.VoiceStates(this, client);
82
+ }
83
+ if (!this.disabledCache.includes('threads')) {
84
+ this.threads = new threads_1.Threads(this, client);
85
+ }
86
+ if (!this.disabledCache.includes('stageInstances')) {
87
+ this.stageInstances = new stage_instances_1.StageInstances(this, client);
88
+ }
89
+ }
90
+ /** @internal */
91
+ __setClient(client) {
92
+ this.users?.__setClient(client);
93
+ this.guilds?.__setClient(client);
94
+ this.members?.__setClient(client);
95
+ this.roles?.__setClient(client);
96
+ this.channels?.__setClient(client);
97
+ this.emojis?.__setClient(client);
98
+ this.stickers?.__setClient(client);
99
+ this.presences?.__setClient(client);
100
+ this.voiceStates?.__setClient(client);
101
+ this.threads?.__setClient(client);
102
+ this.stageInstances?.__setClient(client);
103
+ }
104
+ // internal use ./structures
105
+ hasIntent(intent) {
106
+ return (this.intents & common_1.GatewayIntentBits[intent]) === common_1.GatewayIntentBits[intent];
107
+ }
108
+ get hasGuildsIntent() {
109
+ return this.hasIntent('Guilds');
110
+ }
111
+ get hasRolesIntent() {
112
+ return this.hasGuildsIntent;
113
+ }
114
+ get hasChannelsIntent() {
115
+ return this.hasGuildsIntent;
116
+ }
117
+ get hasGuildMembersIntent() {
118
+ return this.hasIntent('GuildMembers');
119
+ }
120
+ get hasEmojisAndStickersIntent() {
121
+ return this.hasIntent('GuildEmojisAndStickers');
122
+ }
123
+ get hasVoiceStatesIntent() {
124
+ return this.hasIntent('GuildVoiceStates');
125
+ }
126
+ get hasPrenseceUpdates() {
127
+ return this.hasIntent('GuildPresences');
128
+ }
129
+ get hasDirectMessages() {
130
+ return this.hasIntent('DirectMessages');
131
+ }
132
+ async bulkGet(keys) {
133
+ const allData = {};
134
+ for (const [type, id, guildId] of keys) {
135
+ switch (type) {
136
+ case 'members':
137
+ {
138
+ if (!allData[type]) {
139
+ allData[type] = [];
140
+ }
141
+ allData[type].push([id, guildId]);
142
+ }
143
+ break;
144
+ case 'roles':
145
+ case 'threads':
146
+ case 'stickers':
147
+ case 'channels':
148
+ case 'presences':
149
+ case 'voiceStates':
150
+ case 'stageInstances':
151
+ case 'emojis':
152
+ case 'users':
153
+ case 'guilds':
154
+ {
155
+ if (!allData[type]) {
156
+ allData[type] = [];
157
+ }
158
+ allData[type].push([id]);
159
+ }
160
+ break;
161
+ default:
162
+ throw new Error(`Invalid type ${type}`);
163
+ }
164
+ }
165
+ const obj = {};
166
+ for (const i in allData) {
167
+ const key = i;
168
+ const values = allData[key];
169
+ obj[key] = [];
170
+ for (const value of values) {
171
+ const g = await this[key]?.get(value[0], value[1]);
172
+ if (!g) {
173
+ continue;
174
+ }
175
+ obj[key].push(g);
176
+ }
177
+ }
178
+ return obj;
179
+ }
180
+ async bulkPatch(keys) {
181
+ const allData = [];
182
+ const relationshipsData = {};
183
+ for (const [type, data, id, guildId] of keys) {
184
+ switch (type) {
185
+ case 'roles':
186
+ case 'threads':
187
+ case 'stickers':
188
+ case 'channels':
189
+ case 'presences':
190
+ case 'voiceStates':
191
+ case 'stageInstances':
192
+ case 'emojis':
193
+ {
194
+ const hashId = this[type]?.hashId(guildId);
195
+ if (!hashId) {
196
+ continue;
197
+ }
198
+ if (!(hashId in relationshipsData)) {
199
+ relationshipsData[hashId] = [];
200
+ }
201
+ relationshipsData[hashId].push(id);
202
+ data.guild_id = guildId;
203
+ allData.push([this[type].hashId(id), this[type].parse(data, id, guildId)]);
204
+ }
205
+ break;
206
+ case 'members':
207
+ {
208
+ const hashId = this[type]?.hashId(guildId);
209
+ if (!hashId) {
210
+ continue;
211
+ }
212
+ if (!(hashId in relationshipsData)) {
213
+ relationshipsData[hashId] = [];
214
+ }
215
+ relationshipsData[hashId].push(id);
216
+ data.guild_id = guildId;
217
+ allData.push([this[type].hashGuildId(id, guildId), this[type].parse(data, id, guildId)]);
218
+ }
219
+ break;
220
+ case 'users':
221
+ case 'guilds':
222
+ {
223
+ const hashId = this[type]?.namespace;
224
+ if (!hashId) {
225
+ continue;
226
+ }
227
+ if (!(hashId in relationshipsData)) {
228
+ relationshipsData[hashId] = [];
229
+ }
230
+ relationshipsData[hashId].push(id);
231
+ allData.push([this[type].hashId(id), data]);
232
+ }
233
+ break;
234
+ default:
235
+ throw new Error(`Invalid type ${type}`);
236
+ }
237
+ }
238
+ await this.adapter.patch(false, allData);
239
+ await this.adapter.bulkAddToRelationShip(relationshipsData);
240
+ }
241
+ async bulkSet(keys) {
242
+ const allData = [];
243
+ const relationshipsData = {};
244
+ for (const [type, data, id, guildId] of keys) {
245
+ switch (type) {
246
+ case 'roles':
247
+ case 'threads':
248
+ case 'stickers':
249
+ case 'channels':
250
+ case 'presences':
251
+ case 'voiceStates':
252
+ case 'stageInstances':
253
+ case 'emojis':
254
+ {
255
+ const hashId = this[type]?.hashId(guildId);
256
+ if (!hashId) {
257
+ continue;
258
+ }
259
+ if (!(hashId in relationshipsData)) {
260
+ relationshipsData[hashId] = [];
261
+ }
262
+ relationshipsData[hashId].push(id);
263
+ data.guild_id = guildId;
264
+ allData.push([this[type].hashId(id), this[type].parse(data, id, guildId)]);
265
+ }
266
+ break;
267
+ case 'members':
268
+ {
269
+ const hashId = this[type]?.hashId(guildId);
270
+ if (!hashId) {
271
+ continue;
272
+ }
273
+ if (!(hashId in relationshipsData)) {
274
+ relationshipsData[hashId] = [];
275
+ }
276
+ relationshipsData[hashId].push(id);
277
+ data.guild_id = guildId;
278
+ allData.push([this[type].hashGuildId(id, guildId), this[type].parse(data, id, guildId)]);
279
+ }
280
+ break;
281
+ case 'users':
282
+ case 'guilds':
283
+ {
284
+ const hashId = this[type]?.namespace;
285
+ if (!hashId) {
286
+ continue;
287
+ }
288
+ if (!(hashId in relationshipsData)) {
289
+ relationshipsData[hashId] = [];
290
+ }
291
+ relationshipsData[hashId].push(id);
292
+ allData.push([this[type].hashId(id), data]);
293
+ }
294
+ break;
295
+ default:
296
+ throw new Error(`Invalid type ${type}`);
297
+ }
298
+ }
299
+ await this.adapter.set(allData);
300
+ await this.adapter.bulkAddToRelationShip(relationshipsData);
301
+ }
302
+ async onPacket(event) {
303
+ switch (event.t) {
304
+ case 'READY':
305
+ {
306
+ const data = event.d;
307
+ await this.users?.set(data.user.id, data.user);
308
+ }
309
+ break;
310
+ case 'GUILD_CREATE':
311
+ case 'GUILD_UPDATE':
312
+ await this.guilds?.patch(event.d.id, { unavailable: false, ...event.d });
313
+ break;
314
+ case 'GUILD_DELETE':
315
+ if (event.d.unavailable) {
316
+ await this.guilds?.patch(event.d.id, event.d);
317
+ }
318
+ else {
319
+ await this.guilds?.remove(event.d.id);
320
+ }
321
+ break;
322
+ case 'CHANNEL_CREATE':
323
+ case 'CHANNEL_UPDATE':
324
+ if ('guild_id' in event.d) {
325
+ await this.channels?.set(event.d.id, event.d.guild_id, event.d);
326
+ break;
327
+ }
328
+ if (event.d.type === common_1.ChannelType.DM) {
329
+ await this.channels?.set(event.d.recipients[0]?.id, '@me', event.d);
330
+ break;
331
+ }
332
+ break;
333
+ case 'CHANNEL_DELETE':
334
+ await this.channels?.remove(event.d.id, 'guild_id' in event.d ? event.d.guild_id : '@me');
335
+ break;
336
+ case 'GUILD_ROLE_CREATE':
337
+ case 'GUILD_ROLE_UPDATE':
338
+ await this.roles?.set(event.d.role.id, event.d.guild_id, event.d.role);
339
+ break;
340
+ case 'GUILD_ROLE_DELETE':
341
+ await this.roles?.remove(event.d.role_id, event.d.guild_id);
342
+ break;
343
+ case 'GUILD_EMOJIS_UPDATE':
344
+ await this.emojis?.remove(await this.emojis?.keys(event.d.guild_id), event.d.guild_id);
345
+ await this.emojis?.set(event.d.emojis.map(x => [x.id, x]), event.d.guild_id);
346
+ break;
347
+ case 'GUILD_STICKERS_UPDATE':
348
+ await this.stickers?.remove(await this.stickers?.keys(event.d.guild_id), event.d.guild_id);
349
+ await this.stickers?.set(event.d.stickers.map(x => [x.id, x]), event.d.guild_id);
350
+ break;
351
+ case 'GUILD_MEMBER_ADD':
352
+ case 'GUILD_MEMBER_UPDATE':
353
+ if (event.d.user)
354
+ await this.members?.set(event.d.user.id, event.d.guild_id, event.d);
355
+ break;
356
+ case 'GUILD_MEMBER_REMOVE':
357
+ await this.members?.remove(event.d.user.id, event.d.guild_id);
358
+ break;
359
+ case 'PRESENCE_UPDATE':
360
+ // Should update member data?
361
+ await this.presences?.set(event.d.user.id, event.d.guild_id, event.d);
362
+ break;
363
+ case 'THREAD_CREATE':
364
+ case 'THREAD_UPDATE':
365
+ await this.threads?.set(event.d.id, event.d.guild_id, event.d);
366
+ break;
367
+ case 'THREAD_DELETE':
368
+ await this.threads?.remove(event.d.id, event.d.guild_id);
369
+ break;
370
+ case 'USER_UPDATE':
371
+ await this.users?.set(event.d.id, event.d);
372
+ break;
373
+ case 'VOICE_STATE_UPDATE':
374
+ if (!event.d.guild_id) {
375
+ return;
376
+ }
377
+ if (event.d.channel_id != null) {
378
+ await this.voiceStates?.set(event.d.user_id, event.d.guild_id, event.d);
379
+ }
380
+ else {
381
+ await this.voiceStates?.remove(event.d.user_id, event.d.guild_id);
382
+ }
383
+ break;
384
+ case 'STAGE_INSTANCE_CREATE':
385
+ case 'STAGE_INSTANCE_UPDATE':
386
+ await this.stageInstances?.set(event.d.id, event.d.guild_id, event.d);
387
+ break;
388
+ case 'STAGE_INSTANCE_DELETE':
389
+ await this.stageInstances?.remove(event.d.id, event.d.guild_id);
390
+ break;
391
+ }
392
+ }
393
+ }
394
+ exports.Cache = Cache;
@@ -0,0 +1,7 @@
1
+ import type { AllChannels } from '../../structures';
2
+ import { GuildRelatedResource } from './default/guild-related';
3
+ export declare class Channels extends GuildRelatedResource {
4
+ namespace: string;
5
+ get(id: string): Promise<AllChannels | undefined>;
6
+ values(guild: string): Promise<AllChannels[]>;
7
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Channels = void 0;
7
+ const channels_1 = __importDefault(require("../../structures/channels"));
8
+ const guild_related_1 = require("./default/guild-related");
9
+ class Channels extends guild_related_1.GuildRelatedResource {
10
+ namespace = 'channel';
11
+ async get(id) {
12
+ const rawChannel = await super.get(id);
13
+ return rawChannel ? (0, channels_1.default)(rawChannel, this.client) : undefined;
14
+ }
15
+ async values(guild) {
16
+ const channels = await super.values(guild);
17
+ return channels.map(rawChannel => (0, channels_1.default)(rawChannel, this.client));
18
+ }
19
+ }
20
+ exports.Channels = Channels;
@@ -0,0 +1,25 @@
1
+ import type { BaseClient } from '../../../client/base';
2
+ import type { GatewayIntentBits } from '../../../common';
3
+ import type { Cache } from '../../index';
4
+ export declare class BaseResource<T = any> {
5
+ protected cache: Cache;
6
+ client: BaseClient;
7
+ namespace: string;
8
+ constructor(cache: Cache, client?: BaseClient);
9
+ get rest(): import("../../..").REST;
10
+ get adapter(): import("../../index").Adapter;
11
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): Promise<void>;
12
+ setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any): Promise<any>;
13
+ get(id: string): Promise<T | undefined>;
14
+ set(id: string, data: any): Promise<void>;
15
+ patch<T extends Record<any, any> = Record<any, any>>(id: string, data: T): Promise<void>;
16
+ remove(id: string): Promise<void>;
17
+ keys(): Promise<string[]>;
18
+ values(): Promise<T[]>;
19
+ count(): Promise<number>;
20
+ contains(id: string): Promise<boolean>;
21
+ getToRelationship(): Promise<string[]>;
22
+ addToRelationship(id: string | string[]): Promise<void>;
23
+ removeToRelationship(id: string | string[]): Promise<void>;
24
+ hashId(id: string): string;
25
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseResource = void 0;
4
+ class BaseResource {
5
+ cache;
6
+ client;
7
+ namespace = 'base';
8
+ constructor(cache, client) {
9
+ this.cache = cache;
10
+ if (client) {
11
+ this.client = client;
12
+ }
13
+ }
14
+ /** @internal */
15
+ __setClient(client) {
16
+ this.client = client;
17
+ }
18
+ get rest() {
19
+ return this.client.rest;
20
+ }
21
+ get adapter() {
22
+ return this.cache.adapter;
23
+ }
24
+ async removeIfNI(intent, id) {
25
+ if (!this.cache.hasIntent(intent)) {
26
+ await this.remove(id);
27
+ }
28
+ }
29
+ async setIfNI(intent, id, data) {
30
+ if (!this.cache.hasIntent(intent)) {
31
+ await this.set(id, data);
32
+ return data;
33
+ }
34
+ }
35
+ async get(id) {
36
+ return this.adapter.get(this.hashId(id));
37
+ }
38
+ async set(id, data) {
39
+ await this.addToRelationship(id);
40
+ await this.adapter.set(this.hashId(id), data);
41
+ }
42
+ async patch(id, data) {
43
+ await this.addToRelationship(id);
44
+ await this.adapter.patch(false, this.hashId(id), data);
45
+ }
46
+ async remove(id) {
47
+ await this.removeToRelationship(id);
48
+ await this.adapter.remove(this.hashId(id));
49
+ }
50
+ async keys() {
51
+ return this.adapter.keys(this.namespace);
52
+ }
53
+ async values() {
54
+ return this.adapter.values(this.namespace);
55
+ }
56
+ async count() {
57
+ return this.adapter.count(this.namespace);
58
+ }
59
+ async contains(id) {
60
+ return this.adapter.contains(this.namespace, id);
61
+ }
62
+ async getToRelationship() {
63
+ return this.adapter.getToRelationship(this.namespace);
64
+ }
65
+ async addToRelationship(id) {
66
+ await this.adapter.addToRelationship(this.namespace, id);
67
+ }
68
+ async removeToRelationship(id) {
69
+ await this.adapter.removeToRelationship(this.namespace, id);
70
+ }
71
+ hashId(id) {
72
+ return `${this.namespace}.${id}`;
73
+ }
74
+ }
75
+ exports.BaseResource = BaseResource;
@@ -0,0 +1,33 @@
1
+ import type { BaseClient } from '../../../client/base';
2
+ import type { GatewayIntentBits } from '../../../common';
3
+ import type { Cache } from '../../index';
4
+ export declare class GuildBasedResource<T = any> {
5
+ protected cache: Cache;
6
+ client: BaseClient;
7
+ namespace: string;
8
+ constructor(cache: Cache, client?: BaseClient);
9
+ parse(data: any, _id: string, guild_id: string): any;
10
+ get adapter(): import("../../index").Adapter;
11
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): Promise<void>;
12
+ setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): Promise<any>;
13
+ get(id: string, guild: string): Promise<(T & {
14
+ guild_id: string;
15
+ }) | undefined>;
16
+ set(__keys: string, guild: string, data: any): Promise<void>;
17
+ set(__keys: [string, any][], guild: string): Promise<void>;
18
+ patch(__keys: string, guild: string, data: any): Promise<void>;
19
+ patch(__keys: [string, any][], guild: string): Promise<void>;
20
+ remove(id: string | string[], guild: string): Promise<void>;
21
+ keys(guild: string): Promise<string[]>;
22
+ values(guild: string): Promise<(T & {
23
+ guild_id: string;
24
+ })[]>;
25
+ count(guild: string): Promise<number>;
26
+ contains(id: string, guild: string): Promise<boolean>;
27
+ getToRelationship(guild: string): Promise<string[]>;
28
+ addToRelationship(id: string | string[], guild: string): Promise<void>;
29
+ removeToRelationship(id: string | string[], guild: string): Promise<void>;
30
+ removeRelationship(id: string | string[]): Promise<void>;
31
+ hashId(id: string): string;
32
+ hashGuildId(guild: string, id: string): string;
33
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildBasedResource = void 0;
4
+ class GuildBasedResource {
5
+ cache;
6
+ client;
7
+ namespace = 'base';
8
+ constructor(cache, client) {
9
+ this.cache = cache;
10
+ if (client) {
11
+ this.client = client;
12
+ }
13
+ }
14
+ /** @internal */
15
+ __setClient(client) {
16
+ this.client = client;
17
+ }
18
+ parse(data, _id, guild_id) {
19
+ data.guild_id = guild_id;
20
+ return data;
21
+ }
22
+ get adapter() {
23
+ return this.cache.adapter;
24
+ }
25
+ async removeIfNI(intent, id, guildId) {
26
+ if (!this.cache.hasIntent(intent)) {
27
+ await this.remove(id, guildId);
28
+ }
29
+ }
30
+ async setIfNI(intent, id, guildId, data) {
31
+ if (!this.cache.hasIntent(intent)) {
32
+ await this.set(id, guildId, data);
33
+ return data;
34
+ }
35
+ }
36
+ async get(id, guild) {
37
+ return this.adapter.get(this.hashGuildId(id, guild));
38
+ }
39
+ async set(__keys, guild, data) {
40
+ const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
41
+ await this.addToRelationship(keys.map(x => x[0]), guild);
42
+ await this.adapter.set(keys.map(([key, value]) => {
43
+ return [this.hashGuildId(key, guild), this.parse(value, key, guild)];
44
+ }));
45
+ }
46
+ async patch(__keys, guild, data) {
47
+ const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
48
+ const oldDatas = await this.adapter.get(keys.map(([key]) => this.hashGuildId(key, guild)));
49
+ await this.addToRelationship(keys.map(x => x[0]), guild);
50
+ await this.adapter.set(keys.map(([key, value]) => {
51
+ const oldData = oldDatas.find(x => x.id === key) ?? {};
52
+ return [this.hashGuildId(key, guild), this.parse({ ...oldData, ...value }, key, guild)];
53
+ }));
54
+ }
55
+ async remove(id, guild) {
56
+ const ids = Array.isArray(id) ? id : [id];
57
+ await this.removeToRelationship(ids, guild);
58
+ await this.adapter.remove(ids.map(x => this.hashGuildId(x, guild)));
59
+ }
60
+ async keys(guild) {
61
+ return this.adapter.scan(this.hashGuildId(guild, '*'), true);
62
+ }
63
+ async values(guild) {
64
+ return this.adapter.scan(this.hashGuildId(guild, '*'));
65
+ }
66
+ async count(guild) {
67
+ return (await this.adapter.scan(this.hashGuildId(guild, '*'), true)).length;
68
+ }
69
+ async contains(id, guild) {
70
+ return this.adapter.contains(this.hashId(guild), id);
71
+ }
72
+ async getToRelationship(guild) {
73
+ return this.adapter.getToRelationship(this.hashId(guild));
74
+ }
75
+ async addToRelationship(id, guild) {
76
+ await this.adapter.addToRelationship(this.hashId(guild), id);
77
+ }
78
+ async removeToRelationship(id, guild) {
79
+ await this.adapter.removeToRelationship(this.hashId(guild), id);
80
+ }
81
+ async removeRelationship(id) {
82
+ await this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
83
+ }
84
+ hashId(id) {
85
+ return `${this.namespace}.${id}`;
86
+ }
87
+ hashGuildId(guild, id) {
88
+ return `${this.namespace}.${guild}.${id}`;
89
+ }
90
+ }
91
+ exports.GuildBasedResource = GuildBasedResource;
@@ -0,0 +1,32 @@
1
+ import type { BaseClient } from '../../../client/base';
2
+ import type { GatewayIntentBits } from '../../../common';
3
+ import type { Cache } from '../../index';
4
+ export declare class GuildRelatedResource<T = any> {
5
+ protected cache: Cache;
6
+ client: BaseClient;
7
+ namespace: string;
8
+ constructor(cache: Cache, client?: BaseClient);
9
+ parse(data: any, _id: string, guild_id: string): any;
10
+ get adapter(): import("../../index").Adapter;
11
+ removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): Promise<void>;
12
+ setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): Promise<any>;
13
+ get(id: string): Promise<(T & {
14
+ guild_id: string;
15
+ }) | undefined>;
16
+ set(__keys: string, guild: string, data: any): Promise<void>;
17
+ set(__keys: [string, any][], guild: string): Promise<void>;
18
+ patch(__keys: string, guild?: string, data?: any): Promise<void>;
19
+ patch(__keys: [string, any][], guild?: string): Promise<void>;
20
+ remove(id: string | string[], guild: string): Promise<void>;
21
+ keys(guild: string): Promise<string[]>;
22
+ values(guild: string): Promise<(T & {
23
+ guild_id: string;
24
+ })[]>;
25
+ count(to: string): Promise<number>;
26
+ contains(id: string, guild: string): Promise<boolean>;
27
+ getToRelationship(guild: string): Promise<string[]>;
28
+ addToRelationship(id: string | string[], guild: string): Promise<void>;
29
+ removeToRelationship(id: string | string[], guild: string): Promise<void>;
30
+ removeRelationship(id: string | string[]): Promise<void>;
31
+ hashId(id: string): string;
32
+ }