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,146 @@
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.OptionResolver = void 0;
7
+ const common_1 = require("../common");
8
+ const structures_1 = require("../structures");
9
+ const channels_1 = __importDefault(require("../structures/channels"));
10
+ class OptionResolver {
11
+ client;
12
+ parent;
13
+ guildId;
14
+ resolved;
15
+ options;
16
+ hoistedOptions;
17
+ subCommand = null;
18
+ group = null;
19
+ constructor(client, options, parent, guildId, resolved) {
20
+ this.client = client;
21
+ this.parent = parent;
22
+ this.guildId = guildId;
23
+ this.resolved = resolved;
24
+ this.hoistedOptions = this.options = options.map(option => this.transformOption(option, resolved));
25
+ if (this.hoistedOptions[0]?.type === common_1.ApplicationCommandOptionType.Subcommand) {
26
+ this.subCommand = this.hoistedOptions[0].name;
27
+ this.hoistedOptions = this.hoistedOptions[0].options ?? [];
28
+ }
29
+ if (this.hoistedOptions[0]?.type === common_1.ApplicationCommandOptionType.SubcommandGroup) {
30
+ this.group = this.hoistedOptions[0].name;
31
+ this.subCommand = this.hoistedOptions[0].options[0].name;
32
+ this.hoistedOptions = this.hoistedOptions[0].options[0].options ?? [];
33
+ }
34
+ }
35
+ get fullCommandName() {
36
+ return `${this.parent?.name}${this.group ? ` ${this.group} ${this.subCommand}` : this.subCommand ? ` ${this.subCommand}` : ''}`;
37
+ }
38
+ getCommand() {
39
+ if (this.subCommand) {
40
+ return (this.parent?.options).find(x => (this.group ? x.group === this.group : true) && x.name === this.subCommand);
41
+ }
42
+ return this.parent;
43
+ }
44
+ getAutocompleteValue() {
45
+ return this.hoistedOptions.find(option => option.focused)?.value;
46
+ }
47
+ getAutocomplete() {
48
+ return (this.getCommand()?.options).find(option => option.name === this.hoistedOptions.find(x => x.focused)?.name);
49
+ }
50
+ getParent() {
51
+ return this.parent?.name;
52
+ }
53
+ getSubCommand() {
54
+ return this.subCommand;
55
+ }
56
+ getGroup() {
57
+ return this.group;
58
+ }
59
+ get(name) {
60
+ return this.options.find(opt => opt.name === name);
61
+ }
62
+ getHoisted(name) {
63
+ return this.hoistedOptions.find(x => x.name === name);
64
+ }
65
+ getValue(name) {
66
+ const option = this.getHoisted(name);
67
+ if (!option) {
68
+ return;
69
+ }
70
+ switch (option.type) {
71
+ case common_1.ApplicationCommandOptionType.Attachment:
72
+ return option.attachment;
73
+ case common_1.ApplicationCommandOptionType.Boolean:
74
+ return option.value;
75
+ case common_1.ApplicationCommandOptionType.Channel:
76
+ return option.channel;
77
+ case common_1.ApplicationCommandOptionType.Integer:
78
+ case common_1.ApplicationCommandOptionType.Number:
79
+ return option.value;
80
+ case common_1.ApplicationCommandOptionType.Role:
81
+ return option.role;
82
+ case common_1.ApplicationCommandOptionType.String:
83
+ return option.value;
84
+ case common_1.ApplicationCommandOptionType.User:
85
+ return option.member ?? option.user;
86
+ case common_1.ApplicationCommandOptionType.Mentionable:
87
+ return option.member ?? option.user ?? option.channel ?? option.role;
88
+ default:
89
+ return;
90
+ }
91
+ }
92
+ getTypedOption(name, allow) {
93
+ const option = this.getHoisted(name);
94
+ if (!option) {
95
+ throw new Error('Bad Option');
96
+ }
97
+ if (!allow.includes(option.type)) {
98
+ throw new Error('Bad Option');
99
+ }
100
+ return option;
101
+ }
102
+ getChannel(name) {
103
+ const option = this.getTypedOption(name, [common_1.ApplicationCommandOptionType.Channel]);
104
+ return option.channel;
105
+ }
106
+ getString(name) {
107
+ const option = this.getTypedOption(name, [common_1.ApplicationCommandOptionType.String]);
108
+ return option.value;
109
+ }
110
+ transformOption(option, resolved) {
111
+ const resolve = {
112
+ ...option,
113
+ };
114
+ if ('value' in option) {
115
+ resolve.value = option.value;
116
+ }
117
+ if ('options' in option) {
118
+ resolve.options = option.options?.map(x => this.transformOption(x, resolved));
119
+ }
120
+ if (resolved) {
121
+ const value = resolve.value;
122
+ const user = resolved.users?.[value];
123
+ if (user) {
124
+ resolve.user = new structures_1.User(this.client, user);
125
+ }
126
+ const member = resolved.members?.[value];
127
+ if (member) {
128
+ resolve.member = new structures_1.InteractionGuildMember(this.client, member, user, this.guildId);
129
+ }
130
+ const channel = resolved.channels?.[value];
131
+ if (channel) {
132
+ resolve.channel = (0, channels_1.default)(channel, this.client);
133
+ }
134
+ const role = resolved.roles?.[value];
135
+ if (role) {
136
+ resolve.role = new structures_1.GuildRole(this.client, role, this.guildId);
137
+ }
138
+ const attachment = resolved.attachments?.[value];
139
+ if (attachment) {
140
+ resolve.attachment = attachment;
141
+ }
142
+ }
143
+ return resolve;
144
+ }
145
+ }
146
+ exports.OptionResolver = OptionResolver;
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ import type { GatewayDispatchPayload, GatewaySendPayload } from 'discord-api-types/v10';
3
+ import { Worker } from 'node:worker_threads';
4
+ import { REST } from '../../api';
5
+ import { ShardManager, type ShardManagerOptions } from '../../websocket';
6
+ import { Logger } from '../it/logger';
7
+ import type { MakeRequired } from '../types/util';
8
+ /**
9
+ * Represents a watcher class that extends the ShardManager.
10
+ */
11
+ export declare class Watcher extends ShardManager {
12
+ worker?: Worker;
13
+ logger: Logger;
14
+ rest?: REST;
15
+ options: MakeRequired<WatcherOptions, 'intents' | 'token' | 'handlePayload' | 'info'>;
16
+ /**
17
+ * Initializes a new instance of the Watcher class.
18
+ * @param options The options for the watcher.
19
+ */
20
+ constructor(options: WatcherOptions);
21
+ /**
22
+ * Resets the worker instance.
23
+ */
24
+ resetWorker(): void;
25
+ /**
26
+ * Spawns shards for the watcher.
27
+ */
28
+ spawnShards(): Promise<void>;
29
+ /**
30
+ * Builds the watcher.
31
+ */
32
+ protected build(): void;
33
+ }
34
+ export interface WatcherOptions extends Omit<ShardManagerOptions, 'debug' | 'handlePayload' | 'info' | 'token' | 'intents'> {
35
+ filePath: string;
36
+ transpileCommand: string;
37
+ srcPath: string;
38
+ argv?: string[];
39
+ handlePayload?: ShardManagerOptions['handlePayload'];
40
+ info?: ShardManagerOptions['info'];
41
+ token?: ShardManagerOptions['token'];
42
+ intents?: ShardManagerOptions['intents'];
43
+ }
44
+ export interface WatcherPayload {
45
+ type: 'PAYLOAD';
46
+ shardId: number;
47
+ payload: GatewayDispatchPayload;
48
+ }
49
+ export interface WatcherSendToShard {
50
+ type: 'SEND_TO_SHARD';
51
+ shardId: number;
52
+ payload: GatewaySendPayload;
53
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Watcher = void 0;
4
+ const chokidar_1 = require("chokidar");
5
+ const node_child_process_1 = require("node:child_process");
6
+ const node_worker_threads_1 = require("node:worker_threads");
7
+ const api_1 = require("../../api");
8
+ const base_1 = require("../../client/base");
9
+ const websocket_1 = require("../../websocket");
10
+ const logger_1 = require("../it/logger");
11
+ /**
12
+ * Represents a watcher class that extends the ShardManager.
13
+ */
14
+ class Watcher extends websocket_1.ShardManager {
15
+ worker;
16
+ logger = new logger_1.Logger({
17
+ name: '[Watcher]',
18
+ });
19
+ rest;
20
+ /**
21
+ * Initializes a new instance of the Watcher class.
22
+ * @param options The options for the watcher.
23
+ */
24
+ constructor(options) {
25
+ super({
26
+ handlePayload() { },
27
+ token: '',
28
+ intents: 0,
29
+ info: {
30
+ url: 'wss://gateway.discord.gg',
31
+ session_start_limit: {
32
+ max_concurrency: -1,
33
+ remaining: -1,
34
+ reset_after: -1,
35
+ total: -1,
36
+ },
37
+ shards: -1,
38
+ },
39
+ ...options,
40
+ });
41
+ }
42
+ /**
43
+ * Resets the worker instance.
44
+ */
45
+ resetWorker() {
46
+ if (this.worker) {
47
+ this.worker.terminate();
48
+ }
49
+ this.build();
50
+ this.worker = new node_worker_threads_1.Worker(this.options.filePath, {
51
+ argv: this.options.argv,
52
+ workerData: {
53
+ __USING_WATCHER__: true,
54
+ },
55
+ });
56
+ this.worker.on('message', (data) => {
57
+ switch (data.type) {
58
+ case 'SEND_TO_SHARD':
59
+ this.send(data.shardId, data.payload);
60
+ break;
61
+ }
62
+ });
63
+ }
64
+ /**
65
+ * Spawns shards for the watcher.
66
+ */
67
+ async spawnShards() {
68
+ const RC = await base_1.BaseClient.prototype.getRC();
69
+ this.options.token = RC.token;
70
+ this.rest ??= new api_1.REST({
71
+ token: this.options.token,
72
+ });
73
+ this.options.intents = RC.intents;
74
+ this.options.info = await new api_1.Router(this.rest).createProxy().gateway.bot.get();
75
+ this.options.totalShards = this.options.info.shards;
76
+ this.resetWorker();
77
+ const oldFn = this.options.handlePayload;
78
+ this.options.handlePayload = (shardId, payload) => {
79
+ this.worker?.postMessage({
80
+ type: 'PAYLOAD',
81
+ shardId,
82
+ payload,
83
+ });
84
+ return oldFn?.(shardId, payload);
85
+ };
86
+ this.connectQueue.concurrency = this.options.info.session_start_limit.max_concurrency;
87
+ await super.spawnShards();
88
+ const watcher = (0, chokidar_1.watch)(this.options.srcPath).on('ready', () => {
89
+ this.logger.debug(`Watching ${this.options.srcPath}`);
90
+ watcher.on('all', event => {
91
+ this.logger.debug(`${event} event detected, building`);
92
+ this.resetWorker();
93
+ });
94
+ });
95
+ }
96
+ /**
97
+ * Builds the watcher.
98
+ */
99
+ build() {
100
+ (0, node_child_process_1.execSync)(`cd ${process.cwd()} && ${this.options.transpileCommand}`);
101
+ this.logger.info('Builded');
102
+ }
103
+ }
104
+ exports.Watcher = Watcher;
@@ -0,0 +1,13 @@
1
+ export * from './it/constants';
2
+ export * from './it/utils';
3
+ export * from 'discord-api-types/v10';
4
+ export * from './bot/watcher';
5
+ export * from './it/colors';
6
+ export * from './it/logger';
7
+ export * from './shorters/channels';
8
+ export * from './shorters/guilds';
9
+ export * from './shorters/users';
10
+ export * from './types/options';
11
+ export * from './types/resolvables';
12
+ export * from './types/util';
13
+ export * from './types/write';
@@ -0,0 +1,30 @@
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
+ __exportStar(require("./it/constants"), exports);
18
+ __exportStar(require("./it/utils"), exports);
19
+ //
20
+ __exportStar(require("discord-api-types/v10"), exports);
21
+ __exportStar(require("./bot/watcher"), exports);
22
+ __exportStar(require("./it/colors"), exports);
23
+ __exportStar(require("./it/logger"), exports);
24
+ __exportStar(require("./shorters/channels"), exports);
25
+ __exportStar(require("./shorters/guilds"), exports);
26
+ __exportStar(require("./shorters/users"), exports);
27
+ __exportStar(require("./types/options"), exports);
28
+ __exportStar(require("./types/resolvables"), exports);
29
+ __exportStar(require("./types/util"), exports);
30
+ __exportStar(require("./types/write"), exports);
@@ -0,0 +1,274 @@
1
+ export interface Code {
2
+ open: string;
3
+ close: string;
4
+ regexp: RegExp;
5
+ }
6
+ /** RGB 8-bits per channel. Each in range `0->255` or `0x00->0xff` */
7
+ export interface Rgb {
8
+ r: number;
9
+ g: number;
10
+ b: number;
11
+ }
12
+ /**
13
+ * Set changing text color to enabled or disabled
14
+ * @param value
15
+ */
16
+ export declare function setColorEnabled(value: boolean): void;
17
+ /** Get whether text color change is enabled or disabled. */
18
+ export declare function getColorEnabled(): boolean;
19
+ /**
20
+ * Reset the text modified
21
+ * @param str text to reset
22
+ */
23
+ export declare function reset(str: string): string;
24
+ /**
25
+ * Make the text bold.
26
+ * @param str text to make bold
27
+ */
28
+ export declare function bold(str: string): string;
29
+ /**
30
+ * The text emits only a small amount of light.
31
+ * @param str text to dim
32
+ */
33
+ export declare function dim(str: string): string;
34
+ /**
35
+ * Make the text italic.
36
+ * @param str text to make italic
37
+ */
38
+ export declare function italic(str: string): string;
39
+ /**
40
+ * Make the text underline.
41
+ * @param str text to underline
42
+ */
43
+ export declare function underline(str: string): string;
44
+ /**
45
+ * Invert background color and text color.
46
+ * @param str text to invert its color
47
+ */
48
+ export declare function inverse(str: string): string;
49
+ /**
50
+ * Make the text hidden.
51
+ * @param str text to hide
52
+ */
53
+ export declare function hidden(str: string): string;
54
+ /**
55
+ * Put horizontal line through the center of the text.
56
+ * @param str text to strike through
57
+ */
58
+ export declare function strikethrough(str: string): string;
59
+ /**
60
+ * Set text color to black.
61
+ * @param str text to make black
62
+ */
63
+ export declare function black(str: string): string;
64
+ /**
65
+ * Set text color to red.
66
+ * @param str text to make red
67
+ */
68
+ export declare function red(str: string): string;
69
+ /**
70
+ * Set text color to green.
71
+ * @param str text to make green
72
+ */
73
+ export declare function green(str: string): string;
74
+ /**
75
+ * Set text color to yellow.
76
+ * @param str text to make yellow
77
+ */
78
+ export declare function yellow(str: string): string;
79
+ /**
80
+ * Set text color to blue.
81
+ * @param str text to make blue
82
+ */
83
+ export declare function blue(str: string): string;
84
+ /**
85
+ * Set text color to magenta.
86
+ * @param str text to make magenta
87
+ */
88
+ export declare function magenta(str: string): string;
89
+ /**
90
+ * Set text color to cyan.
91
+ * @param str text to make cyan
92
+ */
93
+ export declare function cyan(str: string): string;
94
+ /**
95
+ * Set text color to white.
96
+ * @param str text to make white
97
+ */
98
+ export declare function white(str: string): string;
99
+ /**
100
+ * Set text color to gray.
101
+ * @param str text to make gray
102
+ */
103
+ export declare function gray(str: string): string;
104
+ /**
105
+ * Set text color to bright black.
106
+ * @param str text to make bright-black
107
+ */
108
+ export declare function brightBlack(str: string): string;
109
+ /**
110
+ * Set text color to bright red.
111
+ * @param str text to make bright-red
112
+ */
113
+ export declare function brightRed(str: string): string;
114
+ /**
115
+ * Set text color to bright green.
116
+ * @param str text to make bright-green
117
+ */
118
+ export declare function brightGreen(str: string): string;
119
+ /**
120
+ * Set text color to bright yellow.
121
+ * @param str text to make bright-yellow
122
+ */
123
+ export declare function brightYellow(str: string): string;
124
+ /**
125
+ * Set text color to bright blue.
126
+ * @param str text to make bright-blue
127
+ */
128
+ export declare function brightBlue(str: string): string;
129
+ /**
130
+ * Set text color to bright magenta.
131
+ * @param str text to make bright-magenta
132
+ */
133
+ export declare function brightMagenta(str: string): string;
134
+ /**
135
+ * Set text color to bright cyan.
136
+ * @param str text to make bright-cyan
137
+ */
138
+ export declare function brightCyan(str: string): string;
139
+ /**
140
+ * Set text color to bright white.
141
+ * @param str text to make bright-white
142
+ */
143
+ export declare function brightWhite(str: string): string;
144
+ /**
145
+ * Set background color to black.
146
+ * @param str text to make its background black
147
+ */
148
+ export declare function bgBlack(str: string): string;
149
+ /**
150
+ * Set background color to red.
151
+ * @param str text to make its background red
152
+ */
153
+ export declare function bgRed(str: string): string;
154
+ /**
155
+ * Set background color to green.
156
+ * @param str text to make its background green
157
+ */
158
+ export declare function bgGreen(str: string): string;
159
+ /**
160
+ * Set background color to yellow.
161
+ * @param str text to make its background yellow
162
+ */
163
+ export declare function bgYellow(str: string): string;
164
+ /**
165
+ * Set background color to blue.
166
+ * @param str text to make its background blue
167
+ */
168
+ export declare function bgBlue(str: string): string;
169
+ /**
170
+ * Set background color to magenta.
171
+ * @param str text to make its background magenta
172
+ */
173
+ export declare function bgMagenta(str: string): string;
174
+ /**
175
+ * Set background color to cyan.
176
+ * @param str text to make its background cyan
177
+ */
178
+ export declare function bgCyan(str: string): string;
179
+ /**
180
+ * Set background color to white.
181
+ * @param str text to make its background white
182
+ */
183
+ export declare function bgWhite(str: string): string;
184
+ /**
185
+ * Set background color to bright black.
186
+ * @param str text to make its background bright-black
187
+ */
188
+ export declare function bgBrightBlack(str: string): string;
189
+ /**
190
+ * Set background color to bright red.
191
+ * @param str text to make its background bright-red
192
+ */
193
+ export declare function bgBrightRed(str: string): string;
194
+ /**
195
+ * Set background color to bright green.
196
+ * @param str text to make its background bright-green
197
+ */
198
+ export declare function bgBrightGreen(str: string): string;
199
+ /**
200
+ * Set background color to bright yellow.
201
+ * @param str text to make its background bright-yellow
202
+ */
203
+ export declare function bgBrightYellow(str: string): string;
204
+ /**
205
+ * Set background color to bright blue.
206
+ * @param str text to make its background bright-blue
207
+ */
208
+ export declare function bgBrightBlue(str: string): string;
209
+ /**
210
+ * Set background color to bright magenta.
211
+ * @param str text to make its background bright-magenta
212
+ */
213
+ export declare function bgBrightMagenta(str: string): string;
214
+ /**
215
+ * Set background color to bright cyan.
216
+ * @param str text to make its background bright-cyan
217
+ */
218
+ export declare function bgBrightCyan(str: string): string;
219
+ /**
220
+ * Set background color to bright white.
221
+ * @param str text to make its background bright-white
222
+ */
223
+ export declare function bgBrightWhite(str: string): string;
224
+ /**
225
+ * Set text color using paletted 8bit colors.
226
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
227
+ * @param str text color to apply paletted 8bit colors to
228
+ * @param color code
229
+ */
230
+ export declare function rgb8(str: string, color: number): string;
231
+ /**
232
+ * Set background color using paletted 8bit colors.
233
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
234
+ * @param str text color to apply paletted 8bit background colors to
235
+ * @param color code
236
+ */
237
+ export declare function bgRgb8(str: string, color: number): string;
238
+ /**
239
+ * Set text color using 24bit rgb.
240
+ * `color` can be a number in range `0x000000` to `0xffffff` or
241
+ * an `Rgb`.
242
+ *
243
+ * To produce the color magenta:
244
+ *
245
+ * ```ts
246
+ * import { rgb24 } from "./colors.ts";
247
+ * rgb24("foo", 0xff00ff);
248
+ * rgb24("foo", {r: 255, g: 0, b: 255});
249
+ * ```
250
+ * @param str text color to apply 24bit rgb to
251
+ * @param color code
252
+ */
253
+ export declare function rgb24(str: string, color: number | Rgb): string;
254
+ /**
255
+ * Set background color using 24bit rgb.
256
+ * `color` can be a number in range `0x000000` to `0xffffff` or
257
+ * an `Rgb`.
258
+ *
259
+ * To produce the color magenta:
260
+ *
261
+ * ```ts
262
+ * import { bgRgb24 } from "./colors.ts";
263
+ * bgRgb24("foo", 0xff00ff);
264
+ * bgRgb24("foo", {r: 255, g: 0, b: 255});
265
+ * ```
266
+ * @param str text color to apply 24bit rgb to
267
+ * @param color code
268
+ */
269
+ export declare function bgRgb24(str: string, color: number | Rgb): string;
270
+ /**
271
+ * Remove ANSI escape codes from the string.
272
+ * @param string to remove ANSI escape codes from
273
+ */
274
+ export declare function stripColor(string: string): string;