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,189 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = exports.LogLevels = void 0;
4
+ const colors_1 = require("./colors");
5
+ const utils_1 = require("./utils");
6
+ var LogLevels;
7
+ (function (LogLevels) {
8
+ LogLevels[LogLevels["Debug"] = 0] = "Debug";
9
+ LogLevels[LogLevels["Info"] = 1] = "Info";
10
+ LogLevels[LogLevels["Warn"] = 2] = "Warn";
11
+ LogLevels[LogLevels["Error"] = 3] = "Error";
12
+ LogLevels[LogLevels["Fatal"] = 4] = "Fatal";
13
+ })(LogLevels || (exports.LogLevels = LogLevels = {}));
14
+ /**
15
+ * Represents a logger utility for logging messages with various log levels.
16
+ */
17
+ class Logger {
18
+ /**
19
+ * The options for configuring the logger.
20
+ */
21
+ options;
22
+ /**
23
+ * The custom callback function for logging.
24
+ */
25
+ static __callback;
26
+ /**
27
+ * Allows customization of the logging behavior by providing a custom callback function.
28
+ * @param cb The custom callback function for logging.
29
+ * @example
30
+ * Logger.customize((logger, level, args) => {
31
+ * // Custom logging implementation
32
+ * });
33
+ */
34
+ static customize(cb) {
35
+ Logger.__callback = cb;
36
+ }
37
+ /**
38
+ * Constructs a new Logger instance with the provided options.
39
+ * @param options The options for configuring the logger.
40
+ */
41
+ constructor(options) {
42
+ this.options = (0, utils_1.MergeOptions)(Logger.DEFAULT_OPTIONS, options);
43
+ }
44
+ /**
45
+ * Sets the log level of the logger.
46
+ */
47
+ set level(level) {
48
+ this.options.logLevel = level;
49
+ }
50
+ /**
51
+ * Gets the log level of the logger.
52
+ */
53
+ get level() {
54
+ return this.options.logLevel;
55
+ }
56
+ /**
57
+ * Sets whether the logger is active or not.
58
+ */
59
+ set active(active) {
60
+ this.options.active = active;
61
+ }
62
+ /**
63
+ * Gets whether the logger is active or not.
64
+ */
65
+ get active() {
66
+ return this.options.active;
67
+ }
68
+ /**
69
+ * Sets the name of the logger.
70
+ */
71
+ set name(name) {
72
+ this.options.name = name;
73
+ }
74
+ /**
75
+ * Gets the name of the logger.
76
+ */
77
+ get name() {
78
+ return this.options.name;
79
+ }
80
+ /**
81
+ * Logs a message with the specified log level.
82
+ * @param level The log level.
83
+ * @param args The arguments to log.
84
+ * @returns The logged message.
85
+ */
86
+ rawLog(level, ...args) {
87
+ if (!this.active)
88
+ return;
89
+ if (level < this.level)
90
+ return;
91
+ let log;
92
+ if (!Logger.__callback) {
93
+ const color = Logger.colorFunctions.get(level) ?? Logger.noColor;
94
+ const memoryData = process.memoryUsage();
95
+ const date = new Date();
96
+ log = [
97
+ (0, colors_1.brightBlack)(formatMemoryUsage(memoryData.rss)),
98
+ (0, colors_1.bgBrightWhite)((0, colors_1.black)(`[${date.toLocaleDateString()} ${date.toLocaleTimeString()}]`)),
99
+ color(Logger.prefixes.get(level) ?? 'DEBUG'),
100
+ this.name ? `${this.name} >` : '>',
101
+ ...args,
102
+ ];
103
+ }
104
+ else {
105
+ log = Logger.__callback(this, level, args);
106
+ }
107
+ return console.log(...log);
108
+ }
109
+ /**
110
+ * Logs a debug message.
111
+ * @param args The arguments to log.
112
+ */
113
+ debug(...args) {
114
+ this.rawLog(LogLevels.Debug, ...args);
115
+ }
116
+ /**
117
+ * Logs an info message.
118
+ * @param args The arguments to log.
119
+ */
120
+ info(...args) {
121
+ this.rawLog(LogLevels.Info, ...args);
122
+ }
123
+ /**
124
+ * Logs a warning message.
125
+ * @param args The arguments to log.
126
+ */
127
+ warn(...args) {
128
+ this.rawLog(LogLevels.Warn, ...args);
129
+ }
130
+ /**
131
+ * Logs an error message.
132
+ * @param args The arguments to log.
133
+ */
134
+ error(...args) {
135
+ this.rawLog(LogLevels.Error, ...args);
136
+ }
137
+ /**
138
+ * Logs a fatal error message.
139
+ * @param args The arguments to log.
140
+ */
141
+ fatal(...args) {
142
+ this.rawLog(LogLevels.Fatal, ...args);
143
+ }
144
+ /**
145
+ * The default options for the logger.
146
+ */
147
+ static DEFAULT_OPTIONS = {
148
+ logLevel: LogLevels.Debug,
149
+ name: 'seyfert',
150
+ active: true,
151
+ };
152
+ /**
153
+ * A function that returns the input string as is, without any color modification.
154
+ * @param msg The message to log.
155
+ * @returns The input message as is.
156
+ */
157
+ static noColor(msg) {
158
+ return msg;
159
+ }
160
+ /**
161
+ * A map containing color functions for different log levels.
162
+ */
163
+ static colorFunctions = new Map([
164
+ [LogLevels.Debug, colors_1.gray],
165
+ [LogLevels.Info, colors_1.cyan],
166
+ [LogLevels.Warn, colors_1.yellow],
167
+ [LogLevels.Error, colors_1.red],
168
+ [LogLevels.Fatal, (str) => (0, colors_1.red)((0, colors_1.bold)((0, colors_1.italic)(str)))],
169
+ ]);
170
+ /**
171
+ * A map containing prefixes for different log levels.
172
+ */
173
+ static prefixes = new Map([
174
+ [LogLevels.Debug, 'DEBUG'],
175
+ [LogLevels.Info, 'INFO'],
176
+ [LogLevels.Warn, 'WARN'],
177
+ [LogLevels.Error, 'ERROR'],
178
+ [LogLevels.Fatal, 'FATAL'],
179
+ ]);
180
+ }
181
+ exports.Logger = Logger;
182
+ /**
183
+ * Formats memory usage data into a string.
184
+ * @param data The memory usage data.
185
+ * @returns The formatted string representing memory usage.
186
+ */
187
+ function formatMemoryUsage(data) {
188
+ return `[RAM Usage ${Math.round((data / 1024 / 1024) * 100) / 100} MB]`;
189
+ }
@@ -0,0 +1,107 @@
1
+ import { type ColorResolvable, type Logger, type ObjectToLower, type ObjectToSnake } from '..';
2
+ /**
3
+ * Resolves the color to a numeric representation.
4
+ * @param color The color to resolve.
5
+ * @returns The numeric representation of the color.
6
+ */
7
+ export declare function resolveColor(color: ColorResolvable): number;
8
+ /**
9
+ * Flattens an array to a certain depth.
10
+ * @param arr The array to flatten.
11
+ * @returns The flattened array.
12
+ */
13
+ export declare function fastFlat<A extends any[]>(arr: A): FlatArray<A, 1>[];
14
+ /**
15
+ * Creates a new array with the results of calling a provided function on every element in the array.
16
+ * @param arr The array to iterate over.
17
+ * @param fn The function that produces an element of the new array.
18
+ * @returns A new array with the results of calling the provided function on every element in the array.
19
+ */
20
+ export declare function fastMap<U, T extends any[]>(arr: T, fn: (value: T[number], index: number, array: T) => U): U[];
21
+ /**
22
+ * Delays the resolution of a Promise by the specified time.
23
+ * @param time The time in milliseconds to delay the resolution.
24
+ * @param result The value to resolve with after the delay.
25
+ * @returns A Promise that resolves after the specified time with the provided result.
26
+ */
27
+ export declare function delay<T>(time: number, result?: T): Promise<T>;
28
+ /**
29
+ * Checks if a given value is an object.
30
+ * @param o The value to check.
31
+ * @returns `true` if the value is an object, otherwise `false`.
32
+ */
33
+ export declare function isObject(o: any): boolean;
34
+ /**
35
+ * Merges multiple options objects together, deeply extending objects.
36
+ * @param defaults The default options object.
37
+ * @param options Additional options objects to merge.
38
+ * @returns The merged options object.
39
+ */
40
+ export declare function MergeOptions<T>(defaults: any, ...options: any[]): T;
41
+ /**
42
+ * Splits an array into two arrays based on the result of a predicate function.
43
+ * @param arr The array to split.
44
+ * @param func The predicate function used to test elements of the array.
45
+ * @returns An object containing two arrays: one with elements that passed the test and one with elements that did not.
46
+ */
47
+ export declare function filterSplit<Element, Predicate extends (value: Element) => boolean>(arr: Element[], func: Predicate): {
48
+ expect: Element[];
49
+ never: Element[];
50
+ };
51
+ /**
52
+ * Represents a base handler class.
53
+ */
54
+ export declare class BaseHandler {
55
+ protected logger: Logger;
56
+ /**
57
+ * Initializes a new instance of the BaseHandler class.
58
+ * @param logger The logger instance.
59
+ */
60
+ constructor(logger: Logger);
61
+ /**
62
+ * Filters a file path.
63
+ * @param path The path to filter.
64
+ * @returns `true` if the path passes the filter, otherwise `false`.
65
+ */
66
+ protected filter: (path: string) => boolean;
67
+ /**
68
+ * Recursively retrieves all files in a directory.
69
+ * @param dir The directory path.
70
+ * @returns A Promise that resolves to an array of file paths.
71
+ */
72
+ protected getFiles(dir: string): Promise<string[]>;
73
+ /**
74
+ * Loads files from given paths.
75
+ * @param paths The paths of the files to load.
76
+ * @returns A Promise that resolves to an array of loaded files.
77
+ */
78
+ protected loadFiles<T extends NonNullable<unknown>>(paths: string[]): Promise<T[]>;
79
+ /**
80
+ * Loads files from given paths along with additional information.
81
+ * @param paths The paths of the files to load.
82
+ * @returns A Promise that resolves to an array of objects containing name, file, and path.
83
+ */
84
+ protected loadFilesK<T>(paths: string[]): Promise<{
85
+ name: string;
86
+ file: T;
87
+ path: string;
88
+ }[]>;
89
+ }
90
+ /**
91
+ * Convert a camelCase object to snake_case.
92
+ * @param target The object to convert.
93
+ * @returns The converted object.
94
+ */
95
+ export declare function toSnakeCase<Obj extends Record<string, any>>(target: Obj): ObjectToSnake<Obj>;
96
+ /**
97
+ * Convert a snake_case object to camelCase.
98
+ * @param target The object to convert.
99
+ * @returns The converted object.
100
+ */
101
+ export declare function toCamelCase<Obj extends Record<string, any>>(target: Obj): ObjectToLower<Obj>;
102
+ export declare const ReplaceRegex: {
103
+ camel: (s: string) => string;
104
+ snake: (s: string) => string;
105
+ };
106
+ export declare function magicImport(path: string): Promise<any>;
107
+ export type OnFailCallback = (error: unknown) => any;
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.magicImport = exports.ReplaceRegex = exports.toCamelCase = exports.toSnakeCase = exports.BaseHandler = exports.filterSplit = exports.MergeOptions = exports.isObject = exports.delay = exports.fastMap = exports.fastFlat = exports.resolveColor = void 0;
4
+ const promises_1 = require("node:fs/promises");
5
+ const node_path_1 = require("node:path");
6
+ const promises_2 = require("node:timers/promises");
7
+ const __1 = require("..");
8
+ /**
9
+ * Resolves the color to a numeric representation.
10
+ * @param color The color to resolve.
11
+ * @returns The numeric representation of the color.
12
+ */
13
+ function resolveColor(color) {
14
+ switch (typeof color) {
15
+ case 'string':
16
+ if (color === 'Random')
17
+ return Math.floor(Math.random() * (0xffffff + 1));
18
+ if (color.startsWith('#'))
19
+ return Number.parseInt(color.slice(1), 16);
20
+ if (color in __1.EmbedColors)
21
+ return __1.EmbedColors[color];
22
+ return __1.EmbedColors.Default;
23
+ case 'number':
24
+ return color;
25
+ case 'object':
26
+ if (Array.isArray(color))
27
+ return (color[0] << 16) + (color[1] << 8) + color[2];
28
+ break;
29
+ default:
30
+ return color;
31
+ }
32
+ return color;
33
+ }
34
+ exports.resolveColor = resolveColor;
35
+ /**
36
+ * Flattens an array to a certain depth.
37
+ * @param arr The array to flatten.
38
+ * @returns The flattened array.
39
+ */
40
+ function fastFlat(arr) {
41
+ let newArr = [];
42
+ for (const element of arr) {
43
+ newArr = newArr.concat(element);
44
+ }
45
+ return newArr;
46
+ }
47
+ exports.fastFlat = fastFlat;
48
+ /**
49
+ * Creates a new array with the results of calling a provided function on every element in the array.
50
+ * @param arr The array to iterate over.
51
+ * @param fn The function that produces an element of the new array.
52
+ * @returns A new array with the results of calling the provided function on every element in the array.
53
+ */
54
+ function fastMap(arr, fn) {
55
+ const newArr = [];
56
+ let key = 0;
57
+ for (const value of arr) {
58
+ newArr.push(fn(value, key, arr));
59
+ key++;
60
+ }
61
+ return newArr;
62
+ }
63
+ exports.fastMap = fastMap;
64
+ /**
65
+ * Delays the resolution of a Promise by the specified time.
66
+ * @param time The time in milliseconds to delay the resolution.
67
+ * @param result The value to resolve with after the delay.
68
+ * @returns A Promise that resolves after the specified time with the provided result.
69
+ */
70
+ function delay(time, result) {
71
+ return (0, promises_2.setTimeout)(time, result);
72
+ }
73
+ exports.delay = delay;
74
+ /**
75
+ * Checks if a given value is an object.
76
+ * @param o The value to check.
77
+ * @returns `true` if the value is an object, otherwise `false`.
78
+ */
79
+ function isObject(o) {
80
+ return o && typeof o === 'object' && !Array.isArray(o);
81
+ }
82
+ exports.isObject = isObject;
83
+ /**
84
+ * Merges multiple options objects together, deeply extending objects.
85
+ * @param defaults The default options object.
86
+ * @param options Additional options objects to merge.
87
+ * @returns The merged options object.
88
+ */
89
+ function MergeOptions(defaults, ...options) {
90
+ const option = options.shift();
91
+ if (!option) {
92
+ return defaults;
93
+ }
94
+ return MergeOptions({
95
+ ...option,
96
+ ...Object.fromEntries(Object.entries(defaults).map(([key, value]) => [
97
+ key,
98
+ isObject(value) ? MergeOptions(value, option?.[key] || {}) : option?.[key] ?? value,
99
+ ])),
100
+ }, ...options);
101
+ }
102
+ exports.MergeOptions = MergeOptions;
103
+ /**
104
+ * Splits an array into two arrays based on the result of a predicate function.
105
+ * @param arr The array to split.
106
+ * @param func The predicate function used to test elements of the array.
107
+ * @returns An object containing two arrays: one with elements that passed the test and one with elements that did not.
108
+ */
109
+ function filterSplit(arr, func) {
110
+ const expect = [];
111
+ const never = [];
112
+ for (const element of arr) {
113
+ const test = func(element);
114
+ if (test)
115
+ expect.push(element);
116
+ else
117
+ never.push(element);
118
+ }
119
+ return { expect, never };
120
+ }
121
+ exports.filterSplit = filterSplit;
122
+ /**
123
+ * Represents a base handler class.
124
+ */
125
+ class BaseHandler {
126
+ logger;
127
+ /**
128
+ * Initializes a new instance of the BaseHandler class.
129
+ * @param logger The logger instance.
130
+ */
131
+ constructor(logger) {
132
+ this.logger = logger;
133
+ }
134
+ /**
135
+ * Filters a file path.
136
+ * @param path The path to filter.
137
+ * @returns `true` if the path passes the filter, otherwise `false`.
138
+ */
139
+ filter = (path) => !!path;
140
+ /**
141
+ * Recursively retrieves all files in a directory.
142
+ * @param dir The directory path.
143
+ * @returns A Promise that resolves to an array of file paths.
144
+ */
145
+ async getFiles(dir) {
146
+ const files = [];
147
+ for (const i of await (0, promises_1.readdir)(dir, { withFileTypes: true })) {
148
+ if (i.isDirectory()) {
149
+ files.push(...(await this.getFiles((0, node_path_1.join)(dir, i.name))));
150
+ }
151
+ else {
152
+ if (this.filter((0, node_path_1.join)(dir, i.name))) {
153
+ files.push((0, node_path_1.join)(dir, i.name));
154
+ }
155
+ }
156
+ }
157
+ return files;
158
+ }
159
+ /**
160
+ * Loads files from given paths.
161
+ * @param paths The paths of the files to load.
162
+ * @returns A Promise that resolves to an array of loaded files.
163
+ */
164
+ async loadFiles(paths) {
165
+ return Promise.all(paths.map(path => magicImport(path).then(file => file.default ?? file)));
166
+ }
167
+ /**
168
+ * Loads files from given paths along with additional information.
169
+ * @param paths The paths of the files to load.
170
+ * @returns A Promise that resolves to an array of objects containing name, file, and path.
171
+ */
172
+ async loadFilesK(paths) {
173
+ return Promise.all(paths.map(path => magicImport(path).then(file => {
174
+ return {
175
+ name: (0, node_path_1.basename)(path),
176
+ file: file.default ?? file,
177
+ path,
178
+ };
179
+ })));
180
+ }
181
+ }
182
+ exports.BaseHandler = BaseHandler;
183
+ /**
184
+ * Convert a camelCase object to snake_case.
185
+ * @param target The object to convert.
186
+ * @returns The converted object.
187
+ */
188
+ function toSnakeCase(target) {
189
+ const result = {};
190
+ for (const [key, value] of Object.entries(target)) {
191
+ switch (typeof value) {
192
+ case 'string':
193
+ case 'bigint':
194
+ case 'boolean':
195
+ case 'function':
196
+ case 'number':
197
+ case 'symbol':
198
+ case 'undefined':
199
+ result[exports.ReplaceRegex.snake(key)] = value;
200
+ break;
201
+ case 'object':
202
+ if (Array.isArray(value)) {
203
+ result[exports.ReplaceRegex.snake(key)] = value.map(prop => typeof prop === 'object' && prop ? toSnakeCase(prop) : prop);
204
+ break;
205
+ }
206
+ if (isObject(value)) {
207
+ result[exports.ReplaceRegex.snake(key)] = toSnakeCase(value);
208
+ break;
209
+ }
210
+ if (!Number.isNaN(value)) {
211
+ result[exports.ReplaceRegex.snake(key)] = null;
212
+ break;
213
+ }
214
+ result[exports.ReplaceRegex.snake(key)] = toSnakeCase(value);
215
+ break;
216
+ }
217
+ }
218
+ return result;
219
+ }
220
+ exports.toSnakeCase = toSnakeCase;
221
+ /**
222
+ * Convert a snake_case object to camelCase.
223
+ * @param target The object to convert.
224
+ * @returns The converted object.
225
+ */
226
+ function toCamelCase(target) {
227
+ const result = {};
228
+ for (const [key, value] of Object.entries(target)) {
229
+ switch (typeof value) {
230
+ case 'string':
231
+ case 'bigint':
232
+ case 'boolean':
233
+ case 'function':
234
+ case 'symbol':
235
+ case 'number':
236
+ case 'undefined':
237
+ result[exports.ReplaceRegex.camel(key)] = value;
238
+ break;
239
+ case 'object':
240
+ if (Array.isArray(value)) {
241
+ result[exports.ReplaceRegex.camel(key)] = value.map(prop => typeof prop === 'object' && prop ? toCamelCase(prop) : prop);
242
+ break;
243
+ }
244
+ if (isObject(value)) {
245
+ result[exports.ReplaceRegex.camel(key)] = toCamelCase(value);
246
+ break;
247
+ }
248
+ if (!Number.isNaN(value)) {
249
+ result[exports.ReplaceRegex.camel(key)] = null;
250
+ break;
251
+ }
252
+ result[exports.ReplaceRegex.camel(key)] = toCamelCase(value);
253
+ break;
254
+ }
255
+ }
256
+ return result;
257
+ }
258
+ exports.toCamelCase = toCamelCase;
259
+ exports.ReplaceRegex = {
260
+ camel: (s) => {
261
+ return s.toLowerCase().replace(/(_\S)/gi, a => a[1].toUpperCase());
262
+ },
263
+ snake: (s) => {
264
+ return s.replace(/[A-Z]/g, a => `_${a.toLowerCase()}`);
265
+ },
266
+ };
267
+ async function magicImport(path) {
268
+ try {
269
+ return require(path);
270
+ }
271
+ catch {
272
+ return eval('((path) => import(`file:///${path}`))')(path.split('\\').join('\\\\'));
273
+ }
274
+ }
275
+ exports.magicImport = magicImport;
@@ -0,0 +1,5 @@
1
+ import type { UsingClient } from '../../commands';
2
+ export declare class BaseShorter {
3
+ readonly client: UsingClient;
4
+ constructor(client: UsingClient);
5
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseShorter = void 0;
4
+ class BaseShorter {
5
+ client;
6
+ constructor(client) {
7
+ this.client = client;
8
+ }
9
+ }
10
+ exports.BaseShorter = BaseShorter;
@@ -0,0 +1,90 @@
1
+ import type { RESTPatchAPIChannelJSONBody } from '..';
2
+ import { Message } from '../../structures';
3
+ import { BaseShorter } from './base';
4
+ export declare class ChannelShorter extends BaseShorter {
5
+ get channels(): {
6
+ /**
7
+ * Fetches a channel by its ID.
8
+ * @param id The ID of the channel to fetch.
9
+ * @param force Whether to force fetching the channel from the API even if it exists in the cache.
10
+ * @returns A Promise that resolves to the fetched channel.
11
+ */
12
+ fetch: (id: string, force?: boolean) => Promise<import("../../structures").AllChannels>;
13
+ /**
14
+ * Deletes a channel by its ID.
15
+ * @param id The ID of the channel to delete.
16
+ * @param optional Optional parameters for the deletion.
17
+ * @returns A Promise that resolves to the deleted channel.
18
+ */
19
+ delete: (id: string, optional?: ChannelShorterOptionalParams) => Promise<import("../../structures").AllChannels>;
20
+ /**
21
+ * Edits a channel by its ID.
22
+ * @param id The ID of the channel to edit.
23
+ * @param body The updated channel data.
24
+ * @param optional Optional parameters for the editing.
25
+ * @returns A Promise that resolves to the edited channel.
26
+ */
27
+ edit: (id: string, body: RESTPatchAPIChannelJSONBody, optional?: ChannelShorterOptionalParams) => Promise<import("../../structures").AllChannels>;
28
+ /**
29
+ * Sends a typing indicator to the channel.
30
+ * @param id The ID of the channel.
31
+ * @returns A Promise that resolves when the typing indicator is successfully sent.
32
+ */
33
+ typing: (id: string) => Promise<never>;
34
+ /**
35
+ * Provides access to pinned messages in the channel.
36
+ */
37
+ pins: {
38
+ /**
39
+ * Fetches pinned messages in the channel.
40
+ * @param channelId The ID of the channel.
41
+ * @returns A Promise that resolves to an array of pinned messages.
42
+ */
43
+ fetch: (channelId: string) => Promise<Message[]>;
44
+ /**
45
+ * Pins a message in the channel.
46
+ * @param messageId The ID of the message to pin.
47
+ * @param channelId The ID of the channel.
48
+ * @param reason The reason for pinning the message.
49
+ * @returns A Promise that resolves when the message is successfully pinned.
50
+ */
51
+ set: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
52
+ /**
53
+ * Unpins a message in the channel.
54
+ * @param messageId The ID of the message to unpin.
55
+ * @param channelId The ID of the channel.
56
+ * @param reason The reason for unpinning the message.
57
+ * @returns A Promise that resolves when the message is successfully unpinned.
58
+ */
59
+ delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
60
+ };
61
+ };
62
+ get pins(): {
63
+ /**
64
+ * Fetches pinned messages in the channel.
65
+ * @param channelId The ID of the channel.
66
+ * @returns A Promise that resolves to an array of pinned messages.
67
+ */
68
+ fetch: (channelId: string) => Promise<Message[]>;
69
+ /**
70
+ * Pins a message in the channel.
71
+ * @param messageId The ID of the message to pin.
72
+ * @param channelId The ID of the channel.
73
+ * @param reason The reason for pinning the message.
74
+ * @returns A Promise that resolves when the message is successfully pinned.
75
+ */
76
+ set: (messageId: string, channelId: string, reason?: string) => Promise<never>;
77
+ /**
78
+ * Unpins a message in the channel.
79
+ * @param messageId The ID of the message to unpin.
80
+ * @param channelId The ID of the channel.
81
+ * @param reason The reason for unpinning the message.
82
+ * @returns A Promise that resolves when the message is successfully unpinned.
83
+ */
84
+ delete: (messageId: string, channelId: string, reason?: string) => Promise<never>;
85
+ };
86
+ }
87
+ export type ChannelShorterOptionalParams = Partial<{
88
+ guildId: string;
89
+ reason: string;
90
+ }>;