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,244 @@
1
+ import { REST } from '../api';
2
+ import type { Adapter } from '../cache';
3
+ import { Cache } from '../cache';
4
+ import type { RegisteredMiddlewares } from '../commands';
5
+ import type { DefaultLocale, MiddlewareContext } from '../commands/applications/shared';
6
+ import { CommandHandler } from '../commands/handler';
7
+ import { Logger, type MakeRequired } from '../common';
8
+ import type { DeepPartial, IntentStrings, OmitInsert } from '../common/types/util';
9
+ import { ComponentHandler } from '../components/handler';
10
+ import { LangsHandler } from '../langs/handler';
11
+ import type { ChatInputCommandInteraction, MessageCommandInteraction, UserCommandInteraction } from '../structures';
12
+ export declare class BaseClient {
13
+ rest: REST;
14
+ cache: Cache;
15
+ users: {
16
+ createDM: (userId: string, force?: boolean) => Promise<import("../structures").DMChannel>;
17
+ deleteDM: (userId: string, reason?: string | undefined) => Promise<import("../structures").DMChannel>;
18
+ fetch: (userId: string, force?: boolean) => Promise<import("../structures").User>;
19
+ write: (userId: string, body: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
20
+ };
21
+ channels: {
22
+ fetch: (id: string, force?: boolean | undefined) => Promise<import("../structures").AllChannels>;
23
+ delete: (id: string, optional?: Partial<{
24
+ guildId: string;
25
+ reason: string;
26
+ }>) => Promise<import("../structures").AllChannels>;
27
+ edit: (id: string, body: import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelJSONBody, optional?: Partial<{
28
+ guildId: string;
29
+ reason: string;
30
+ }>) => Promise<import("../structures").AllChannels>;
31
+ typing: (id: string) => Promise<never>;
32
+ pins: {
33
+ fetch: (channelId: string) => Promise<import("../structures").Message[]>;
34
+ set: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
35
+ delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
36
+ };
37
+ };
38
+ guilds: {
39
+ create: (body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildsJSONBody) => Promise<import("../structures").Guild<"api">>;
40
+ fetch: (id: string, force?: boolean) => Promise<import("../structures").Guild<"cached"> | import("../structures").Guild<"api">>;
41
+ widgetURL: (id: string, style?: import("discord-api-types/payloads/v10/guild").GuildWidgetStyle | undefined) => Promise<import("discord-api-types/payloads/v10/guild").APIGuildWidgetSettings>;
42
+ channels: {
43
+ list: (guildId: string, force?: boolean) => Promise<import("../structures").AllChannels[]>;
44
+ fetch: (guildId: string, channelId: string, force?: boolean | undefined) => Promise<import("../structures").AllChannels>;
45
+ create: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildChannelJSONBody) => Promise<import("../structures").AllChannels>;
46
+ delete: (guildId: string, channelId: string, reason?: string | undefined) => Promise<import("../structures").AllChannels>;
47
+ edit: (guildchannelId: string, channelId: string, body: import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelJSONBody, reason?: string | undefined) => Promise<import("../structures").AllChannels>;
48
+ editPositions: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildChannelPositionsJSONBody) => Promise<never>;
49
+ };
50
+ moderation: {
51
+ list: (guildId: string) => Promise<import("discord-api-types/rest/v10/autoModeration").RESTGetAPIAutoModerationRulesResult>;
52
+ create: (guildId: string, body: import("discord-api-types/rest/v10/autoModeration").RESTPostAPIAutoModerationRuleJSONBody) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
53
+ delete: (guildId: string, ruleId: string, reason?: string | undefined) => Promise<never>;
54
+ fetch: (guildId: string, ruleId: string) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
55
+ edit: (guildId: string, ruleId: string, body: {
56
+ name?: string | undefined;
57
+ eventType?: import("discord-api-types/payloads/v10/autoModeration").AutoModerationRuleEventType | undefined;
58
+ triggerMetadata?: import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRuleTriggerMetadata | undefined;
59
+ actions?: import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationAction[] | undefined;
60
+ enabled?: boolean | undefined;
61
+ exemptRoles?: string[] | undefined;
62
+ exemptChannels?: string[] | undefined;
63
+ }, reason?: string | undefined) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
64
+ };
65
+ stickers: {
66
+ list: (guildId: string) => Promise<import("../structures").Sticker[]>;
67
+ create: (guildId: string, { file, ...json }: import("../structures").CreateStickerBodyRequest, reason?: string | undefined) => Promise<import("../structures").Sticker>;
68
+ edit: (guildId: string, stickerId: string, body: import("discord-api-types/rest/v10/sticker").RESTPatchAPIGuildStickerJSONBody, reason?: string | undefined) => Promise<import("../structures").Sticker>;
69
+ fetch: (guildId: string, stickerId: string, force?: boolean) => Promise<import("../structures").Sticker>;
70
+ delete: (guildId: string, stickerId: string, reason?: string | undefined) => Promise<void>;
71
+ };
72
+ emojis: {
73
+ list: (guildId: string, force?: boolean) => Promise<import("../structures").GuildEmoji[]>;
74
+ create: (guildId: string, body: Omit<import("discord-api-types/rest/v10/emoji").RESTPostAPIGuildEmojiJSONBody, "image"> & {
75
+ image: import("../common").ImageResolvable;
76
+ }) => Promise<void>;
77
+ fetch: (guildId: string, emojiId: string, force?: boolean) => Promise<import("../structures").GuildEmoji>;
78
+ delete: (guildId: string, emojiId: string, reason?: string | undefined) => Promise<void>;
79
+ edit: (guildId: string, emojiId: string, body: import("discord-api-types/rest/v10/emoji").RESTPatchAPIGuildEmojiJSONBody, reason?: string | undefined) => Promise<import("../structures").GuildEmoji>;
80
+ };
81
+ };
82
+ messages: {
83
+ write: (channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
84
+ edit: (messageId: string, channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
85
+ crosspost: (messageId: string, channelId: string, reason?: string | undefined) => Promise<import("../structures").Message>;
86
+ delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<void>;
87
+ fetch: (messageId: string, channelId: string) => Promise<import("../structures").Message>;
88
+ purge: (messages: string[], channelId: string, reason?: string | undefined) => Promise<never>;
89
+ reactions: {
90
+ add: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable) => Promise<never>;
91
+ delete: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable, userId?: string) => Promise<never>;
92
+ fetch: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable, query?: import("discord-api-types/rest/v10/channel").RESTGetAPIChannelMessageReactionUsersQuery | undefined) => Promise<import("../structures").User[]>;
93
+ purge: (messageId: string, channelId: string, emoji?: import("../common").EmojiResolvable | undefined) => Promise<never>;
94
+ };
95
+ };
96
+ members: {
97
+ resolve: (guildId: string, resolve: import("../common").GuildMemberResolvable) => Promise<import("../structures").GuildMember | undefined>;
98
+ search: (guildId: string, query?: import("discord-api-types/rest/v10/guild").RESTGetAPIGuildMembersSearchQuery | undefined) => Promise<import("../structures").GuildMember[]>;
99
+ unban: (guildId: string, memberId: string, body?: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildBanJSONBody | undefined, reason?: string | undefined) => Promise<void>;
100
+ ban: (guildId: string, memberId: string, body?: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildBanJSONBody | undefined, reason?: string | undefined) => Promise<void>;
101
+ kick: (guildId: string, memberId: string, reason?: string | undefined) => Promise<void>;
102
+ edit: (guildId: string, memberId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildMemberJSONBody, reason?: string | undefined) => Promise<import("../structures").GuildMember>;
103
+ add: (guildId: string, memberId: string, body: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildMemberJSONBody) => Promise<import("../structures").GuildMember | undefined>;
104
+ fetch: (guildId: string, memberId: string, force?: boolean) => Promise<import("../structures").GuildMember>;
105
+ list: (guildId: string, query?: import("discord-api-types/rest/v10/guild").RESTGetAPIGuildMembersQuery | undefined, force?: boolean) => Promise<import("../structures").GuildMember[]>;
106
+ roles: {
107
+ add: (guildId: string, memberId: string, id: string) => Promise<void>;
108
+ remove: (guildId: string, memberId: string, id: string) => Promise<void>;
109
+ };
110
+ };
111
+ webhooks: {
112
+ delete: (webhookId: string, { token, reason }: Partial<{
113
+ token: string;
114
+ reason: string;
115
+ }>) => Promise<never>;
116
+ edit: (webhookId: string, body: import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookJSONBody | import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenJSONBody, { token, reason }: Partial<{
117
+ token: string;
118
+ reason: string;
119
+ }>) => Promise<import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenResult>;
120
+ fetch: (webhookId: string, token?: string | undefined) => Promise<import("../structures").Webhook>;
121
+ messages: {
122
+ write: (webhookId: string, token: string, { body: data, ...payload }: {
123
+ body: Omit<import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenJSONBody, "embeds" | "components"> & import("../common").ResolverProps;
124
+ query?: import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenQuery | undefined;
125
+ }) => Promise<import("../structures").WebhookMessage | null>;
126
+ edit: (webhookId: string, token: string, { messageId, body: data, ...json }: {
127
+ body: Omit<import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenMessageJSONBody, "embeds" | "components"> & import("../common").ResolverProps;
128
+ messageId: string;
129
+ query?: import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenMessageQuery | undefined;
130
+ }) => Promise<import("../structures").WebhookMessage>;
131
+ delete: (webhookId: string, token: string, messageId: string, reason?: string | undefined) => Promise<never>;
132
+ fetch: (webhookId: string, token: string, messageId: string, threadId?: string | undefined) => Promise<import("../structures").WebhookMessage | undefined>;
133
+ };
134
+ };
135
+ templates: {
136
+ fetch: (code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
137
+ list: (guildId: string) => Promise<import("discord-api-types/rest/v10/template").RESTGetAPIGuildTemplatesResult>;
138
+ create: (guildId: string, body: import("discord-api-types/rest/v10/template").RESTPostAPIGuildTemplatesJSONBody) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
139
+ sync: (guildId: string, code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
140
+ edit: (guildId: string, code: string, body: import("discord-api-types/utils/internals").AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Partial<import("discord-api-types/rest/v10/template").RESTPostAPIGuildTemplatesJSONBody>>) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
141
+ delete: (guildId: string, code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
142
+ };
143
+ roles: {
144
+ create: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<any>;
145
+ list: (guildId: string, force?: boolean) => Promise<import("../structures").GuildRole[]>;
146
+ edit: (guildId: string, roleId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<any>;
147
+ delete: (guildId: string, roleId: string, reason?: string | undefined) => Promise<void | undefined>;
148
+ editPositions: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildRolePositionsJSONBody) => Promise<import("../structures").GuildRole[]>;
149
+ };
150
+ debugger?: Logger;
151
+ logger: Logger;
152
+ commands: CommandHandler;
153
+ langs: LangsHandler;
154
+ components: ComponentHandler;
155
+ private _applicationId?;
156
+ private _botId?;
157
+ middlewares?: Record<string, MiddlewareContext>;
158
+ protected static assertString(value: unknown, message?: string): asserts value is string;
159
+ protected static getBotIdFromToken(token: string): string;
160
+ options: BaseClientOptions | undefined;
161
+ constructor(options?: BaseClientOptions);
162
+ set botId(id: string);
163
+ get botId(): string;
164
+ set applicationId(id: string);
165
+ get applicationId(): string;
166
+ get proxy(): import("../api").APIRoutes;
167
+ setServices({ rest, cache, defaultLang, middlewares }: ServicesOptions): void;
168
+ protected execute(..._options: unknown[]): Promise<void>;
169
+ start(options?: Pick<DeepPartial<StartOptions>, 'langsDir' | 'commandsDir' | 'connection' | 'token' | 'componentsDir'>): Promise<void>;
170
+ protected onPacket(..._packet: unknown[]): Promise<void>;
171
+ uploadCommands(applicationId?: string): Promise<void>;
172
+ loadCommands(dir?: string): Promise<void>;
173
+ loadComponents(dir?: string): Promise<void>;
174
+ t(locale: string): DefaultLocale;
175
+ loadLangs(dir?: string): Promise<void>;
176
+ getRC<T extends InternalRuntimeConfigHTTP | InternalRuntimeConfig = InternalRuntimeConfigHTTP | InternalRuntimeConfig>(): Promise<{
177
+ debug: boolean;
178
+ } & Omit<T, "debug" | "locations"> & {
179
+ templates: string | undefined;
180
+ langs: string | undefined;
181
+ events: string | undefined;
182
+ components: string | undefined;
183
+ base: string;
184
+ output: string;
185
+ commands: string;
186
+ }>;
187
+ }
188
+ export interface BaseClientOptions {
189
+ context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean>) => {};
190
+ globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
191
+ }
192
+ export interface StartOptions {
193
+ eventsDir: string;
194
+ langsDir: string;
195
+ commandsDir: string;
196
+ componentsDir: string;
197
+ connection: {
198
+ intents: number;
199
+ };
200
+ httpConnection: {
201
+ publicKey: string;
202
+ port: number;
203
+ };
204
+ token: string;
205
+ }
206
+ interface RC extends Variables {
207
+ debug?: boolean;
208
+ locations: {
209
+ base: string;
210
+ output: string;
211
+ commands: string;
212
+ langs?: string;
213
+ templates?: string;
214
+ events?: string;
215
+ components?: string;
216
+ };
217
+ }
218
+ export interface Variables {
219
+ token: string;
220
+ intents?: number;
221
+ applicationId?: string;
222
+ port?: number;
223
+ publicKey?: string;
224
+ }
225
+ export type InternalRuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'port' | 'applicationId'>, 'intents' | 'locations'> & {
226
+ locations: Omit<RC['locations'], 'events'>;
227
+ };
228
+ export type RuntimeConfigHTTP = Omit<MakeRequired<RC, 'publicKey' | 'applicationId'>, 'intents' | 'locations'> & {
229
+ locations: Omit<RC['locations'], 'events'>;
230
+ };
231
+ export type InternalRuntimeConfig = Omit<MakeRequired<RC, 'intents'>, 'publicKey' | 'port'>;
232
+ export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
233
+ intents?: IntentStrings | number;
234
+ }>;
235
+ export type ServicesOptions = {
236
+ rest?: REST;
237
+ cache?: {
238
+ adapter: Adapter;
239
+ disabledCache?: Cache['disabledCache'];
240
+ };
241
+ defaultLang?: string;
242
+ middlewares?: Record<string, MiddlewareContext>;
243
+ };
244
+ export {};
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseClient = void 0;
4
+ const node_path_1 = require("node:path");
5
+ const api_1 = require("../api");
6
+ const cache_1 = require("../cache");
7
+ const handler_1 = require("../commands/handler");
8
+ const common_1 = require("../common");
9
+ const members_1 = require("../common/shorters/members");
10
+ const messages_1 = require("../common/shorters/messages");
11
+ const roles_1 = require("../common/shorters/roles");
12
+ const templates_1 = require("../common/shorters/templates");
13
+ const webhook_1 = require("../common/shorters/webhook");
14
+ const handler_2 = require("../components/handler");
15
+ const handler_3 = require("../langs/handler");
16
+ class BaseClient {
17
+ /** @internal */
18
+ __handleGuilds = new Set();
19
+ rest;
20
+ cache;
21
+ users = new common_1.UsersShorter(this).users;
22
+ channels = new common_1.ChannelShorter(this).channels;
23
+ guilds = new common_1.GuildShorter(this).guilds;
24
+ messages = new messages_1.MessageShorter(this).messages;
25
+ members = new members_1.MemberShorter(this).members;
26
+ webhooks = new webhook_1.WebhookShorter(this).webhooks;
27
+ templates = new templates_1.TemplateShorter(this).templates;
28
+ roles = new roles_1.RoleShorter(this).roles;
29
+ debugger;
30
+ logger = new common_1.Logger({
31
+ name: '[Seyfert]',
32
+ });
33
+ commands = new handler_1.CommandHandler(this.logger);
34
+ langs = new handler_3.LangsHandler(this.logger);
35
+ components = new handler_2.ComponentHandler(this.logger, this);
36
+ _applicationId;
37
+ _botId;
38
+ middlewares;
39
+ static assertString(value, message) {
40
+ if (!(typeof value === 'string' && value !== '')) {
41
+ throw new Error(message ?? 'Value is not a string');
42
+ }
43
+ }
44
+ static getBotIdFromToken(token) {
45
+ return Buffer.from(token.split('.')[0], 'base64').toString('ascii');
46
+ }
47
+ options;
48
+ constructor(options) {
49
+ this.options = options;
50
+ }
51
+ set botId(id) {
52
+ this._botId = id;
53
+ }
54
+ get botId() {
55
+ return this._botId ?? BaseClient.getBotIdFromToken(this.rest.options.token);
56
+ }
57
+ set applicationId(id) {
58
+ this._applicationId = id;
59
+ }
60
+ get applicationId() {
61
+ return this._applicationId ?? this.botId;
62
+ }
63
+ get proxy() {
64
+ return new api_1.Router(this.rest).createProxy();
65
+ }
66
+ setServices({ rest, cache, defaultLang, middlewares }) {
67
+ if (rest) {
68
+ this.rest = rest;
69
+ }
70
+ if (cache) {
71
+ this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache.adapter, cache.disabledCache ?? this.cache?.disabledCache, this);
72
+ }
73
+ if (defaultLang) {
74
+ this.langs.defaultLang = defaultLang;
75
+ }
76
+ if (middlewares) {
77
+ this.middlewares = middlewares;
78
+ }
79
+ }
80
+ async execute(..._options) {
81
+ if ((await this.getRC()).debug) {
82
+ this.debugger = new common_1.Logger({
83
+ name: '[Debug]',
84
+ logLevel: common_1.LogLevels.Debug,
85
+ });
86
+ }
87
+ }
88
+ async start(options = {
89
+ token: undefined,
90
+ langsDir: undefined,
91
+ commandsDir: undefined,
92
+ connection: undefined,
93
+ componentsDir: undefined,
94
+ }) {
95
+ await this.loadLangs(options.langsDir);
96
+ await this.loadCommands(options.commandsDir);
97
+ await this.loadComponents(options.componentsDir);
98
+ const { token: tokenRC } = await this.getRC();
99
+ const token = options?.token ?? tokenRC;
100
+ if (!this.rest) {
101
+ BaseClient.assertString(token, 'token is not a string');
102
+ this.rest = new api_1.REST({
103
+ token,
104
+ debug: false, //(await this.getRC()).debug,
105
+ });
106
+ }
107
+ if (!this.cache) {
108
+ this.cache = new cache_1.Cache(0, new cache_1.MemoryAdapter(), [], this);
109
+ }
110
+ else {
111
+ this.cache.__setClient(this);
112
+ }
113
+ }
114
+ async onPacket(..._packet) {
115
+ throw new Error('Function not implemented');
116
+ }
117
+ async uploadCommands(applicationId) {
118
+ applicationId ??= await this.getRC().then(x => x.applicationId ?? this.applicationId);
119
+ BaseClient.assertString(applicationId, 'applicationId is not a string');
120
+ const commands = this.commands.values.map(x => x.toJSON());
121
+ const filter = (0, common_1.filterSplit)(commands, command => !command.guild_id);
122
+ await this.proxy.applications(applicationId).commands.put({
123
+ body: filter.expect,
124
+ });
125
+ const guilds = new Set();
126
+ for (const command of filter.never) {
127
+ for (const guild_id of command.guild_id) {
128
+ guilds.add(guild_id);
129
+ }
130
+ }
131
+ for (const guild of guilds) {
132
+ await this.proxy
133
+ .applications(applicationId)
134
+ .guilds(guild)
135
+ .commands.put({
136
+ body: filter.never.filter(x => x.guild_id?.includes(guild)),
137
+ });
138
+ }
139
+ }
140
+ async loadCommands(dir) {
141
+ dir ??= await this.getRC().then(x => x.commands);
142
+ BaseClient.assertString(dir);
143
+ await this.commands.load(dir, this);
144
+ this.logger.info('CommandHandler loaded');
145
+ }
146
+ async loadComponents(dir) {
147
+ dir ??= await this.getRC().then(x => x.components);
148
+ if (dir) {
149
+ await this.components.load(dir);
150
+ this.logger.info('ComponentHandler loaded');
151
+ }
152
+ }
153
+ t(locale) {
154
+ return this.langs.get(locale);
155
+ }
156
+ async loadLangs(dir) {
157
+ dir ??= await this.getRC().then(x => x.langs);
158
+ if (dir) {
159
+ await this.langs.load(dir);
160
+ this.logger.info('LangsHandler loaded');
161
+ }
162
+ }
163
+ async getRC() {
164
+ const { locations, debug, ...env } = (await (0, common_1.magicImport)((0, node_path_1.join)(process.cwd(), 'seyfert.config.js')).then(x => x.default ?? x));
165
+ return {
166
+ debug: !!debug,
167
+ ...env,
168
+ templates: locations.templates ? (0, node_path_1.join)(process.cwd(), locations.base, locations.templates) : undefined,
169
+ langs: locations.langs ? (0, node_path_1.join)(process.cwd(), locations.output, locations.langs) : undefined,
170
+ events: 'events' in locations && locations.events ? (0, node_path_1.join)(process.cwd(), locations.output, locations.events) : undefined,
171
+ components: locations.components ? (0, node_path_1.join)(process.cwd(), locations.output, locations.components) : undefined,
172
+ base: (0, node_path_1.join)(process.cwd(), locations.base),
173
+ output: (0, node_path_1.join)(process.cwd(), locations.output),
174
+ commands: (0, node_path_1.join)(process.cwd(), locations.output, locations.commands),
175
+ };
176
+ }
177
+ }
178
+ exports.BaseClient = BaseClient;
@@ -0,0 +1,32 @@
1
+ import type { DeepPartial, GatewayDispatchPayload, GatewayPresenceUpdateData, If } from '../common';
2
+ import { EventHandler } from '../events';
3
+ import { ClientUser } from '../structures';
4
+ import { ShardManager } from '../websocket';
5
+ import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
6
+ import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
7
+ import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
8
+ import { BaseClient } from './base';
9
+ export declare class Client<Ready extends boolean = boolean> extends BaseClient {
10
+ gateway: ShardManager;
11
+ events: EventHandler;
12
+ me: If<Ready, ClientUser>;
13
+ options: ClientOptions | undefined;
14
+ memberUpdateHandler: MemberUpdateHandler;
15
+ presenceUpdateHandler: PresenceUpdateHandler;
16
+ constructor(options?: ClientOptions);
17
+ setServices({ gateway, ...rest }: ServicesOptions & {
18
+ gateway?: ShardManager;
19
+ }): void;
20
+ loadEvents(dir?: string): Promise<void>;
21
+ protected execute(options?: {
22
+ token?: string;
23
+ intents?: number;
24
+ }): Promise<void>;
25
+ start(options?: Omit<DeepPartial<StartOptions>, 'httpConnection'>, execute?: boolean): Promise<void>;
26
+ protected onPacket(shardId: number, packet: GatewayDispatchPayload): Promise<void>;
27
+ }
28
+ export interface ClientOptions extends BaseClientOptions {
29
+ presence?: (shardId: number) => GatewayPresenceUpdateData;
30
+ shardStart?: number;
31
+ shardEnd?: number;
32
+ }
@@ -0,0 +1,156 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = void 0;
4
+ const node_worker_threads_1 = require("node:worker_threads");
5
+ const events_1 = require("../events");
6
+ const structures_1 = require("../structures");
7
+ const websocket_1 = require("../websocket");
8
+ const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
9
+ const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
10
+ const base_1 = require("./base");
11
+ const oninteraction_1 = require("./oninteraction");
12
+ class Client extends base_1.BaseClient {
13
+ gateway;
14
+ events = new events_1.EventHandler(this.logger);
15
+ me;
16
+ memberUpdateHandler = new memberUpdate_1.MemberUpdateHandler();
17
+ presenceUpdateHandler = new presenceUpdate_1.PresenceUpdateHandler();
18
+ constructor(options) {
19
+ super(options);
20
+ }
21
+ setServices({ gateway, ...rest }) {
22
+ super.setServices(rest);
23
+ if (gateway) {
24
+ const onPacket = this.onPacket.bind(this);
25
+ const oldFn = gateway.options.handlePayload;
26
+ gateway.options.handlePayload = async (shardId, packet) => {
27
+ await onPacket(shardId, packet);
28
+ return oldFn(shardId, packet);
29
+ };
30
+ this.gateway = gateway;
31
+ }
32
+ }
33
+ async loadEvents(dir) {
34
+ dir ??= await this.getRC().then(x => x.events);
35
+ if (dir) {
36
+ await this.events.load(dir);
37
+ this.logger.info('EventHandler loaded');
38
+ }
39
+ }
40
+ async execute(options = {}) {
41
+ await super.execute(options);
42
+ if (!node_worker_threads_1.workerData?.__USING_WATCHER__) {
43
+ await this.gateway.spawnShards();
44
+ }
45
+ else {
46
+ node_worker_threads_1.parentPort?.on('message', (data) => {
47
+ switch (data.type) {
48
+ case 'PAYLOAD':
49
+ this.gateway.options.handlePayload(data.shardId, data.payload);
50
+ break;
51
+ case 'SEND_TO_SHARD':
52
+ this.gateway.send(data.shardId, data.payload);
53
+ break;
54
+ }
55
+ });
56
+ }
57
+ }
58
+ async start(options = {}, execute = true) {
59
+ await super.start(options);
60
+ await this.loadEvents(options.eventsDir);
61
+ const { token: tokenRC, intents: intentsRC, debug: debugRC } = await this.getRC();
62
+ const token = options?.token ?? tokenRC;
63
+ const intents = options?.connection?.intents ?? intentsRC;
64
+ if (!this.gateway) {
65
+ base_1.BaseClient.assertString(token, 'token is not a string');
66
+ this.gateway = new websocket_1.ShardManager({
67
+ token,
68
+ info: await this.proxy.gateway.bot.get(),
69
+ intents,
70
+ handlePayload: (shardId, packet) => {
71
+ return this.onPacket(shardId, packet);
72
+ },
73
+ presence: this.options?.presence,
74
+ debug: debugRC,
75
+ shardStart: this.options?.shardStart,
76
+ shardEnd: this.options?.shardEnd,
77
+ });
78
+ }
79
+ this.cache.intents = this.gateway.options.intents;
80
+ if (execute) {
81
+ await this.execute(options.connection);
82
+ }
83
+ else {
84
+ await super.execute(options);
85
+ }
86
+ }
87
+ async onPacket(shardId, packet) {
88
+ switch (packet.t) {
89
+ //// Cases where we must obtain the old data before updating
90
+ case 'GUILD_MEMBER_UPDATE':
91
+ if (!this.memberUpdateHandler.check(packet.d)) {
92
+ return;
93
+ }
94
+ await this.events.execute(packet.t, packet, this, shardId);
95
+ await this.cache.onPacket(packet);
96
+ break;
97
+ case 'PRESENCE_UPDATE':
98
+ if (!this.presenceUpdateHandler.check(packet.d)) {
99
+ return;
100
+ }
101
+ await this.events.execute(packet.t, packet, this, shardId);
102
+ await this.cache.onPacket(packet);
103
+ break;
104
+ case 'GUILD_DELETE':
105
+ case 'CHANNEL_UPDATE': {
106
+ await this.events.execute(packet.t, packet, this, shardId);
107
+ await this.cache.onPacket(packet);
108
+ break;
109
+ }
110
+ //rest of the events
111
+ default: {
112
+ await this.cache.onPacket(packet);
113
+ switch (packet.t) {
114
+ case 'READY':
115
+ for (const g of packet.d.guilds) {
116
+ this.__handleGuilds.add(g.id);
117
+ }
118
+ this.botId = packet.d.user.id;
119
+ this.applicationId = packet.d.application.id;
120
+ this.me = new structures_1.ClientUser(this, packet.d.user, packet.d.application);
121
+ if (!this.__handleGuilds.size) {
122
+ if ([...this.gateway.values()].every(shard => shard.data.session_id) &&
123
+ this.events.values.BOT_READY &&
124
+ (this.events.values.BOT_READY.fired ? !this.events.values.BOT_READY.data.once : true)) {
125
+ this.events.values.BOT_READY.fired = true;
126
+ await this.events.values.BOT_READY.run(this.me, this, -1);
127
+ }
128
+ }
129
+ this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
130
+ break;
131
+ case 'INTERACTION_CREATE': {
132
+ await (0, oninteraction_1.onInteraction)(shardId, packet.d, this);
133
+ break;
134
+ }
135
+ case 'GUILD_CREATE': {
136
+ if (this.__handleGuilds.has(packet.d.id)) {
137
+ this.__handleGuilds.delete(packet.d.id);
138
+ if (!this.__handleGuilds.size &&
139
+ [...this.gateway.values()].every(shard => shard.data.session_id) &&
140
+ this.events.values.BOT_READY &&
141
+ (this.events.values.BOT_READY.fired ? !this.events.values.BOT_READY.data.once : true)) {
142
+ this.events.values.BOT_READY.fired = true;
143
+ await this.events.values.BOT_READY.run(this.me, this, -1);
144
+ }
145
+ return;
146
+ }
147
+ break;
148
+ }
149
+ }
150
+ await this.events.execute(packet.t, packet, this, shardId);
151
+ break;
152
+ }
153
+ }
154
+ }
155
+ }
156
+ exports.Client = Client;
@@ -0,0 +1,21 @@
1
+ /// <reference types="node" />
2
+ import type { HttpRequest, HttpResponse } from 'uWebSockets.js';
3
+ import type { APIInteraction, DeepPartial } from '../common';
4
+ import type { StartOptions } from './base';
5
+ import { BaseClient } from './base';
6
+ declare let UWS: typeof import('uWebSockets.js');
7
+ export declare class HttpClient extends BaseClient {
8
+ app: ReturnType<typeof UWS.App>;
9
+ publicKey: string;
10
+ publicKeyHex: Buffer;
11
+ constructor();
12
+ protected static readJson<T extends Record<string, any>>(res: HttpResponse): Promise<T>;
13
+ protected execute(options?: {
14
+ publicKey?: string;
15
+ port?: number;
16
+ }): Promise<void>;
17
+ start(options?: DeepPartial<Omit<StartOptions, 'connection'>>): Promise<void>;
18
+ protected verifySignature(res: HttpResponse, req: HttpRequest): Promise<APIInteraction | undefined>;
19
+ onPacket(res: HttpResponse, req: HttpRequest): Promise<void>;
20
+ }
21
+ export {};