dfx 0.3.1 → 0.5.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 (312) hide show
  1. package/dist/DiscordConfig/index.d.ts +40 -0
  2. package/dist/DiscordConfig/index.d.ts.map +1 -0
  3. package/dist/DiscordConfig/index.js +29 -0
  4. package/dist/DiscordConfig/index.js.map +1 -0
  5. package/dist/DiscordGateway/DiscordWS/index.d.ts +23 -0
  6. package/dist/DiscordGateway/DiscordWS/index.d.ts.map +1 -0
  7. package/dist/DiscordGateway/DiscordWS/index.js +25 -0
  8. package/dist/DiscordGateway/DiscordWS/index.js.map +1 -0
  9. package/dist/DiscordGateway/Shard/heartbeats.d.ts +3 -0
  10. package/dist/DiscordGateway/Shard/heartbeats.d.ts.map +1 -0
  11. package/dist/DiscordGateway/Shard/heartbeats.js +23 -0
  12. package/dist/DiscordGateway/Shard/heartbeats.js.map +1 -0
  13. package/dist/DiscordGateway/Shard/identify.d.ts +13 -0
  14. package/dist/DiscordGateway/Shard/identify.d.ts.map +1 -0
  15. package/dist/DiscordGateway/Shard/identify.js +30 -0
  16. package/dist/DiscordGateway/Shard/identify.js.map +1 -0
  17. package/dist/DiscordGateway/Shard/index.d.ts +9 -0
  18. package/dist/DiscordGateway/Shard/index.d.ts.map +1 -0
  19. package/dist/DiscordGateway/Shard/index.js +51 -0
  20. package/dist/DiscordGateway/Shard/index.js.map +1 -0
  21. package/dist/DiscordGateway/Shard/invalidSession.d.ts +3 -0
  22. package/dist/DiscordGateway/Shard/invalidSession.d.ts.map +1 -0
  23. package/dist/DiscordGateway/Shard/invalidSession.js +9 -0
  24. package/dist/DiscordGateway/Shard/invalidSession.js.map +1 -0
  25. package/dist/DiscordGateway/Shard/sendEvents.d.ts +8 -0
  26. package/dist/DiscordGateway/Shard/sendEvents.d.ts.map +1 -0
  27. package/dist/DiscordGateway/Shard/sendEvents.js +26 -0
  28. package/dist/DiscordGateway/Shard/sendEvents.js.map +1 -0
  29. package/dist/DiscordGateway/Shard/utils.d.ts +4 -0
  30. package/dist/DiscordGateway/Shard/utils.d.ts.map +1 -0
  31. package/dist/DiscordGateway/Shard/utils.js +9 -0
  32. package/dist/DiscordGateway/Shard/utils.js.map +1 -0
  33. package/dist/DiscordGateway/ShardStore/index.d.ts +13 -0
  34. package/dist/DiscordGateway/ShardStore/index.d.ts.map +1 -0
  35. package/dist/DiscordGateway/ShardStore/index.js +22 -0
  36. package/dist/DiscordGateway/ShardStore/index.js.map +1 -0
  37. package/dist/DiscordGateway/Sharder/index.d.ts +10 -0
  38. package/dist/DiscordGateway/Sharder/index.d.ts.map +1 -0
  39. package/dist/DiscordGateway/Sharder/index.js +60 -0
  40. package/dist/DiscordGateway/Sharder/index.js.map +1 -0
  41. package/dist/DiscordGateway/WS/index.d.ts +28 -0
  42. package/dist/DiscordGateway/WS/index.d.ts.map +1 -0
  43. package/dist/DiscordGateway/WS/index.js +82 -0
  44. package/dist/DiscordGateway/WS/index.js.map +1 -0
  45. package/dist/DiscordGateway/index.d.ts +21 -0
  46. package/dist/DiscordGateway/index.d.ts.map +1 -0
  47. package/dist/DiscordGateway/index.js +27 -0
  48. package/dist/DiscordGateway/index.js.map +1 -0
  49. package/dist/DiscordREST/index.d.ts +13 -0
  50. package/dist/DiscordREST/index.d.ts.map +1 -0
  51. package/dist/DiscordREST/index.js +85 -0
  52. package/dist/DiscordREST/index.js.map +1 -0
  53. package/dist/DiscordREST/types.d.ts +10 -0
  54. package/dist/DiscordREST/types.d.ts.map +1 -0
  55. package/dist/DiscordREST/types.js +2 -0
  56. package/{esm → dist}/DiscordREST/types.js.map +1 -1
  57. package/dist/DiscordREST/utils.d.ts +11 -0
  58. package/dist/DiscordREST/utils.d.ts.map +1 -0
  59. package/dist/DiscordREST/utils.js +22 -0
  60. package/dist/DiscordREST/utils.js.map +1 -0
  61. package/dist/Helpers/flags.d.ts +28 -0
  62. package/dist/Helpers/flags.d.ts.map +1 -0
  63. package/dist/Helpers/flags.js +36 -0
  64. package/dist/Helpers/flags.js.map +1 -0
  65. package/dist/Helpers/intents.d.ts +25 -0
  66. package/dist/Helpers/intents.d.ts.map +1 -0
  67. package/dist/Helpers/intents.js +28 -0
  68. package/dist/Helpers/intents.js.map +1 -0
  69. package/dist/Helpers/interactions.d.ts +74 -0
  70. package/dist/Helpers/interactions.d.ts.map +1 -0
  71. package/dist/Helpers/interactions.js +93 -0
  72. package/dist/Helpers/interactions.js.map +1 -0
  73. package/dist/Helpers/members.d.ts +10 -0
  74. package/dist/Helpers/members.d.ts.map +1 -0
  75. package/dist/Helpers/members.js +10 -0
  76. package/dist/Helpers/members.js.map +1 -0
  77. package/dist/Helpers/permissions.d.ts +35 -0
  78. package/dist/Helpers/permissions.d.ts.map +1 -0
  79. package/dist/Helpers/permissions.js +69 -0
  80. package/dist/Helpers/permissions.js.map +1 -0
  81. package/dist/Helpers/ui.d.ts +48 -0
  82. package/dist/Helpers/ui.d.ts.map +1 -0
  83. package/dist/Helpers/ui.js +67 -0
  84. package/dist/Helpers/ui.js.map +1 -0
  85. package/dist/Http/index.d.ts +31 -0
  86. package/dist/Http/index.d.ts.map +1 -0
  87. package/dist/Http/index.js +54 -0
  88. package/dist/Http/index.js.map +1 -0
  89. package/dist/Interactions/context.d.ts +29 -0
  90. package/dist/Interactions/context.d.ts.map +1 -0
  91. package/dist/Interactions/context.js +23 -0
  92. package/dist/Interactions/context.js.map +1 -0
  93. package/dist/Interactions/definitions.d.ts +55 -0
  94. package/dist/Interactions/definitions.d.ts.map +1 -0
  95. package/dist/Interactions/definitions.js +52 -0
  96. package/dist/Interactions/definitions.js.map +1 -0
  97. package/dist/Interactions/gateway.d.ts +6 -0
  98. package/dist/Interactions/gateway.d.ts.map +1 -0
  99. package/dist/Interactions/gateway.js +17 -0
  100. package/dist/Interactions/gateway.js.map +1 -0
  101. package/dist/Interactions/handlers.d.ts +9 -0
  102. package/dist/Interactions/handlers.d.ts.map +1 -0
  103. package/dist/Interactions/handlers.js +49 -0
  104. package/dist/Interactions/handlers.js.map +1 -0
  105. package/dist/Interactions/index.d.ts +20 -0
  106. package/dist/Interactions/index.d.ts.map +1 -0
  107. package/dist/Interactions/index.js +31 -0
  108. package/dist/Interactions/index.js.map +1 -0
  109. package/dist/Interactions/utils.d.ts +10 -0
  110. package/dist/Interactions/utils.d.ts.map +1 -0
  111. package/dist/Interactions/utils.js +20 -0
  112. package/dist/Interactions/utils.js.map +1 -0
  113. package/dist/Interactions/webhook.d.ts +18 -0
  114. package/dist/Interactions/webhook.d.ts.map +1 -0
  115. package/dist/Interactions/webhook.js +26 -0
  116. package/dist/Interactions/webhook.js.map +1 -0
  117. package/dist/Log/index.d.ts +13 -0
  118. package/dist/Log/index.d.ts.map +1 -0
  119. package/dist/Log/index.js +19 -0
  120. package/dist/Log/index.js.map +1 -0
  121. package/dist/RateLimitStore/index.d.ts +25 -0
  122. package/dist/RateLimitStore/index.d.ts.map +1 -0
  123. package/dist/RateLimitStore/index.js +24 -0
  124. package/dist/RateLimitStore/index.js.map +1 -0
  125. package/dist/RateLimitStore/memory.d.ts +3 -0
  126. package/dist/RateLimitStore/memory.d.ts.map +1 -0
  127. package/dist/RateLimitStore/memory.js +31 -0
  128. package/dist/RateLimitStore/memory.js.map +1 -0
  129. package/dist/RateLimitStore/utils.d.ts +3 -0
  130. package/dist/RateLimitStore/utils.d.ts.map +1 -0
  131. package/dist/RateLimitStore/utils.js +18 -0
  132. package/dist/RateLimitStore/utils.js.map +1 -0
  133. package/dist/common.d.ts +34 -0
  134. package/dist/common.d.ts.map +1 -0
  135. package/dist/common.js +21 -0
  136. package/dist/common.js.map +1 -0
  137. package/dist/example.d.ts +2 -0
  138. package/dist/example.d.ts.map +1 -0
  139. package/dist/example.js +47 -0
  140. package/dist/example.js.map +1 -0
  141. package/dist/global.d.ts +14 -0
  142. package/dist/global.d.ts.map +1 -0
  143. package/dist/global.js +2 -0
  144. package/dist/global.js.map +1 -0
  145. package/dist/index.d.ts +21 -0
  146. package/dist/index.d.ts.map +1 -0
  147. package/dist/index.js +33 -0
  148. package/dist/index.js.map +1 -0
  149. package/{types.d.ts → dist/types.d.ts} +1455 -824
  150. package/dist/types.d.ts.map +1 -0
  151. package/{esm → dist}/types.js +283 -46
  152. package/dist/types.js.map +1 -0
  153. package/dist/utils/effect.d.ts +3 -0
  154. package/dist/utils/effect.d.ts.map +1 -0
  155. package/dist/utils/effect.js +2 -0
  156. package/dist/utils/effect.js.map +1 -0
  157. package/dist/utils/tsplus.d.ts +14 -0
  158. package/dist/utils/tsplus.d.ts.map +1 -0
  159. package/dist/utils/tsplus.js +2 -0
  160. package/dist/utils/tsplus.js.map +1 -0
  161. package/package.json +36 -51
  162. package/src/DiscordConfig/index.ts +52 -0
  163. package/src/DiscordGateway/DiscordWS/index.ts +50 -0
  164. package/src/DiscordGateway/Shard/heartbeats.ts +39 -0
  165. package/src/DiscordGateway/Shard/identify.ts +61 -0
  166. package/src/DiscordGateway/Shard/index.ts +90 -0
  167. package/src/DiscordGateway/Shard/invalidSession.ts +11 -0
  168. package/src/DiscordGateway/Shard/sendEvents.ts +35 -0
  169. package/src/DiscordGateway/Shard/utils.ts +14 -0
  170. package/src/DiscordGateway/ShardStore/index.ts +33 -0
  171. package/src/DiscordGateway/Sharder/index.ts +95 -0
  172. package/src/DiscordGateway/WS/index.ts +99 -0
  173. package/src/DiscordGateway/index.ts +55 -0
  174. package/src/DiscordREST/index.ts +132 -0
  175. package/src/DiscordREST/types.ts +14 -0
  176. package/src/DiscordREST/utils.ts +35 -0
  177. package/src/Helpers/flags.ts +68 -0
  178. package/src/Helpers/intents.ts +32 -0
  179. package/src/Helpers/interactions.ts +180 -0
  180. package/src/Helpers/members.ts +14 -0
  181. package/src/Helpers/permissions.ts +102 -0
  182. package/src/Helpers/ui.ts +103 -0
  183. package/src/Http/index.ts +65 -0
  184. package/src/Interactions/context.ts +76 -0
  185. package/src/Interactions/definitions.ts +124 -0
  186. package/src/Interactions/gateway.ts +44 -0
  187. package/src/Interactions/handlers.ts +139 -0
  188. package/src/Interactions/index.ts +57 -0
  189. package/src/Interactions/utils.ts +47 -0
  190. package/src/Interactions/webhook.ts +59 -0
  191. package/src/Log/index.ts +23 -0
  192. package/src/RateLimitStore/index.ts +65 -0
  193. package/src/RateLimitStore/memory.ts +48 -0
  194. package/src/RateLimitStore/utils.ts +27 -0
  195. package/src/common.ts +35 -0
  196. package/src/example.ts +52 -0
  197. package/src/global.ts +50 -0
  198. package/src/index.ts +45 -0
  199. package/src/json.d.ts +1 -0
  200. package/{types.ts → src/types.ts} +1615 -875
  201. package/src/utils/effect.ts +7 -0
  202. package/src/utils/tsplus.ts +11 -0
  203. package/DiscordConfig/index.d.ts +0 -29
  204. package/DiscordConfig/index.js +0 -31
  205. package/DiscordConfig/index.js.map +0 -1
  206. package/DiscordConfig/index.ts +0 -45
  207. package/DiscordGateway/index.d.ts +0 -23
  208. package/DiscordGateway/index.js +0 -25
  209. package/DiscordGateway/index.js.map +0 -1
  210. package/DiscordGateway/index.ts +0 -34
  211. package/DiscordGateway/utils.d.ts +0 -3
  212. package/DiscordGateway/utils.js +0 -12
  213. package/DiscordGateway/utils.js.map +0 -1
  214. package/DiscordGateway/utils.ts +0 -17
  215. package/DiscordREST/http.d.ts +0 -3
  216. package/DiscordREST/http.js +0 -20
  217. package/DiscordREST/http.js.map +0 -1
  218. package/DiscordREST/http.ts +0 -21
  219. package/DiscordREST/index.d.ts +0 -15
  220. package/DiscordREST/index.js +0 -63
  221. package/DiscordREST/index.js.map +0 -1
  222. package/DiscordREST/index.ts +0 -79
  223. package/DiscordREST/types.d.ts +0 -14
  224. package/DiscordREST/types.js +0 -6
  225. package/DiscordREST/types.js.map +0 -1
  226. package/DiscordREST/types.ts +0 -15
  227. package/DiscordShard/commands.d.ts +0 -7
  228. package/DiscordShard/commands.js +0 -38
  229. package/DiscordShard/commands.js.map +0 -1
  230. package/DiscordShard/commands.ts +0 -40
  231. package/DiscordShard/heartbeats.d.ts +0 -6
  232. package/DiscordShard/heartbeats.js +0 -29
  233. package/DiscordShard/heartbeats.js.map +0 -1
  234. package/DiscordShard/heartbeats.ts +0 -65
  235. package/DiscordShard/identify.d.ts +0 -15
  236. package/DiscordShard/identify.js +0 -35
  237. package/DiscordShard/identify.js.map +0 -1
  238. package/DiscordShard/identify.ts +0 -75
  239. package/DiscordShard/index.d.ts +0 -32
  240. package/DiscordShard/index.js +0 -65
  241. package/DiscordShard/index.js.map +0 -1
  242. package/DiscordShard/index.ts +0 -124
  243. package/DiscordShard/invalidSession.d.ts +0 -6
  244. package/DiscordShard/invalidSession.js +0 -17
  245. package/DiscordShard/invalidSession.js.map +0 -1
  246. package/DiscordShard/invalidSession.ts +0 -24
  247. package/DiscordShard/utils.d.ts +0 -7
  248. package/DiscordShard/utils.js +0 -17
  249. package/DiscordShard/utils.js.map +0 -1
  250. package/DiscordShard/utils.ts +0 -32
  251. package/DiscordWS/index.d.ts +0 -36
  252. package/DiscordWS/index.js +0 -33
  253. package/DiscordWS/index.js.map +0 -1
  254. package/DiscordWS/index.ts +0 -78
  255. package/Log/index.d.ts +0 -15
  256. package/Log/index.js +0 -28
  257. package/Log/index.js.map +0 -1
  258. package/Log/index.ts +0 -30
  259. package/Utils/memoize.d.ts +0 -3
  260. package/Utils/memoize.js +0 -16
  261. package/Utils/memoize.js.map +0 -1
  262. package/Utils/memoize.ts +0 -15
  263. package/WS/index.d.ts +0 -30
  264. package/WS/index.js +0 -70
  265. package/WS/index.js.map +0 -1
  266. package/WS/index.ts +0 -106
  267. package/bot.d.ts +0 -1
  268. package/bot.js +0 -28
  269. package/bot.js.map +0 -1
  270. package/bot.ts +0 -48
  271. package/esm/DiscordConfig/index.js +0 -26
  272. package/esm/DiscordConfig/index.js.map +0 -1
  273. package/esm/DiscordGateway/index.js +0 -20
  274. package/esm/DiscordGateway/index.js.map +0 -1
  275. package/esm/DiscordGateway/utils.js +0 -7
  276. package/esm/DiscordGateway/utils.js.map +0 -1
  277. package/esm/DiscordREST/http.js +0 -15
  278. package/esm/DiscordREST/http.js.map +0 -1
  279. package/esm/DiscordREST/index.js +0 -59
  280. package/esm/DiscordREST/index.js.map +0 -1
  281. package/esm/DiscordREST/types.js +0 -3
  282. package/esm/DiscordShard/commands.js +0 -28
  283. package/esm/DiscordShard/commands.js.map +0 -1
  284. package/esm/DiscordShard/heartbeats.js +0 -24
  285. package/esm/DiscordShard/heartbeats.js.map +0 -1
  286. package/esm/DiscordShard/identify.js +0 -30
  287. package/esm/DiscordShard/identify.js.map +0 -1
  288. package/esm/DiscordShard/index.js +0 -60
  289. package/esm/DiscordShard/index.js.map +0 -1
  290. package/esm/DiscordShard/invalidSession.js +0 -12
  291. package/esm/DiscordShard/invalidSession.js.map +0 -1
  292. package/esm/DiscordShard/utils.js +0 -11
  293. package/esm/DiscordShard/utils.js.map +0 -1
  294. package/esm/DiscordWS/index.js +0 -28
  295. package/esm/DiscordWS/index.js.map +0 -1
  296. package/esm/Log/index.js +0 -22
  297. package/esm/Log/index.js.map +0 -1
  298. package/esm/Utils/memoize.js +0 -12
  299. package/esm/Utils/memoize.js.map +0 -1
  300. package/esm/WS/index.js +0 -65
  301. package/esm/WS/index.js.map +0 -1
  302. package/esm/bot.js +0 -25
  303. package/esm/bot.js.map +0 -1
  304. package/esm/mod.js +0 -16
  305. package/esm/mod.js.map +0 -1
  306. package/esm/types.js.map +0 -1
  307. package/mod.d.ts +0 -7
  308. package/mod.js +0 -25
  309. package/mod.js.map +0 -1
  310. package/mod.ts +0 -19
  311. package/types.js +0 -1564
  312. package/types.js.map +0 -1
@@ -0,0 +1,82 @@
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
2
+ import * as tsplus_module_2 from "@effect/io/Ref";
3
+ import * as tsplus_module_3 from "callbag-effect-ts/Source/async";
4
+ import * as tsplus_module_4 from "callbag-effect-ts/Source/unwrap";
5
+ import * as tsplus_module_5 from "callbag-effect-ts/Source/tap";
6
+ import * as tsplus_module_6 from "callbag-effect-ts/Source/drain";
7
+ import * as tsplus_module_7 from "dfx/common";
8
+ import * as tsplus_module_8 from "@effect/io/Schedule";
9
+ import * as tsplus_module_9 from "callbag-effect-ts/Source/merge";
10
+ import * as tsplus_module_10 from "callbag-effect-ts/Source/unwrapScope";
11
+ import * as tsplus_module_11 from "callbag-effect-ts/Source/retry";
12
+ import WebSocket from "isomorphic-ws";
13
+ export const Reconnect = Symbol();
14
+ const socket = (urlRef, options) => tsplus_module_1.acquireRelease(tsplus_module_1.map(url => new WebSocket(url, options))(tsplus_module_2.get(urlRef)), (ws) => tsplus_module_1.sync(() => {
15
+ ws.close();
16
+ ws.removeAllListeners();
17
+ }));
18
+ export class WebSocketError {
19
+ reason;
20
+ _tag = "WebSocketError";
21
+ constructor(reason) {
22
+ this.reason = reason;
23
+ }
24
+ }
25
+ export class WebSocketCloseError {
26
+ code;
27
+ reason;
28
+ _tag = "WebSocketCloseError";
29
+ constructor(code, reason) {
30
+ this.code = code;
31
+ this.reason = reason;
32
+ }
33
+ }
34
+ const recv = (ws) => tsplus_module_3.async((emit) => {
35
+ ws.on("message", (message) => {
36
+ return emit.data(message);
37
+ });
38
+ ws.on("error", (cause) => {
39
+ emit.fail(new WebSocketError(cause));
40
+ });
41
+ ws.on("close", (code, reason) => {
42
+ return emit.fail(new WebSocketCloseError(code, reason.toString("utf8")));
43
+ });
44
+ });
45
+ export class WebSocketWriteError {
46
+ reason;
47
+ _tag = "WebSocketWriteError";
48
+ constructor(reason) {
49
+ this.reason = reason;
50
+ }
51
+ }
52
+ const send = (ws, out) => tsplus_module_1.map(log => tsplus_module_6.drain(tsplus_module_5.tap((data) => tsplus_module_1.async((resume) => {
53
+ if (data === Reconnect) {
54
+ ws.close(1012, "reconnecting");
55
+ resume(tsplus_module_1.unit());
56
+ }
57
+ else {
58
+ ws.send(data, (err) => {
59
+ resume(err
60
+ ? tsplus_module_1.fail(new WebSocketWriteError(err))
61
+ : tsplus_module_1.unit());
62
+ });
63
+ }
64
+ }))(tsplus_module_5.tap((p) => log.debug("WS", "send", p))(tsplus_module_4.unwrap(tsplus_module_1.map(() => out)(tsplus_module_1.async((resume) => {
65
+ if (ws.readyState & ws.OPEN) {
66
+ resume(tsplus_module_1.unit());
67
+ }
68
+ else {
69
+ ws.once("open", () => {
70
+ resume(tsplus_module_1.unit());
71
+ });
72
+ }
73
+ })))))))(tsplus_module_1.service(tsplus_module_7.Log.Log));
74
+ export const make = (url, options) => (() => {
75
+ const [sink, outbound] = tsplus_module_3.asyncSink();
76
+ return tsplus_module_1.map(log => {
77
+ const withLog = tsplus_module_1.provideService(tsplus_module_7.Log.Log)(log);
78
+ const source = tsplus_module_11.retry(tsplus_module_8.recurWhile((e) => e._tag === "WebSocketCloseError" && e.code === 1012))(tsplus_module_10.unwrapScope(tsplus_module_1.flatMap(ws => tsplus_module_1.map(sendEffect => tsplus_module_9.merge(sendEffect)(recv(ws)))(withLog(send(ws, outbound))))(socket(url, options))));
79
+ return { source, sink };
80
+ })(tsplus_module_1.service(tsplus_module_7.Log.Log));
81
+ })();
82
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/DiscordGateway/WS/index.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,SAAS,MAAM,eAAe,CAAA;AAErC,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,EAAE,CAAA;AAIjC,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAE,OAAiC,EAAE,EAAE,CACxE,mDACQ,GAAG,IACF,IAAI,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,sBADpB,MAAM,IAEJ,CAAC,EAAE,EAAE,EAAE,CACvB,qBAAY,GAAG,EAAE;IACf,EAAE,CAAC,KAAK,EAAE,CAAA;IACV,EAAE,CAAC,kBAAkB,EAAE,CAAA;AACzB,CAAC,CAAC,CACH,CAAA;AAEH,MAAM,OAAO,cAAc;IAEJ;IADZ,IAAI,GAAG,gBAAgB,CAAA;IAChC,YAAqB,MAAe;QAA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e,UAAU,EAAzB,IAAI,CAAC,EAAE,CAAC,CAAkB,EADZ,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,GADnC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAOlC,CAAA;QAED,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;OAbT,wBAAe,gBAAA,GAAG,CAAC,GAAG,CAAC;IAcrC,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { EffectSource, Discord, Effect } from "dfx/common";
2
+ import { Success } from "dfx/utils/effect";
3
+ export declare const make: import("../common.js").Effect<import("../DiscordConfig/index.js").DiscordConfig | import("../Log/index.js").Log | import("../RateLimitStore/index.js").RateLimiter | import("../index.js").DiscordREST | import("./ShardStore/index.js").ShardStore | import("./DiscordWS/index.js").DiscordWSCodec, never, {
4
+ shards: import("callbag-effect-ts/Source").EffectSource<never, never, {
5
+ run: import("../common.js").Effect<never, never, readonly [readonly [readonly [readonly [void, void], void], void], void]>;
6
+ raw: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<any>>;
7
+ dispatch: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<import("../types.js").ReceiveEvent>>;
8
+ send: (p: import("../types.js").GatewayPayload<any>) => void;
9
+ reconnect: () => void;
10
+ }>;
11
+ raw: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<any>>;
12
+ dispatch: import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").GatewayPayload<import("../types.js").ReceiveEvent>>;
13
+ fromDispatch: <K extends keyof import("../types.js").ReceiveEvents>(event: K) => import("callbag-effect-ts/Source").EffectSource<never, never, import("../types.js").ReceiveEvents[K]>;
14
+ handleDispatch: <K_1 extends keyof import("../types.js").ReceiveEvents, R1, E1, A>(event: K_1, handle: (event: import("../types.js").ReceiveEvents[K_1]) => import("../common.js").Effect<R1, E1, A>) => import("../common.js").Effect<R1, E1, void>;
15
+ }>;
16
+ export interface DiscordGateway extends Success<typeof make> {
17
+ }
18
+ export declare const DiscordGateway: import("../common.js").Tag<DiscordGateway>;
19
+ export declare const LiveDiscordGateway: import("../common.js").Layer<import("../DiscordConfig/index.js").DiscordConfig | import("../Log/index.js").Log | import("../RateLimitStore/index.js").RateLimiter | import("../index.js").DiscordREST | import("./ShardStore/index.js").ShardStore | import("./DiscordWS/index.js").DiscordWSCodec, never, DiscordGateway>;
20
+ export declare const handleDispatch: <K extends keyof import("../types.js").ReceiveEvents, R1, E1, A>(event: K, handle: (event: import("../types.js").ReceiveEvents[K]) => import("../common.js").Effect<R1, E1, A>) => import("../common.js").Effect<DiscordGateway | R1, E1, void>;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":";;AAuBA,eAAO,MAAM,IAAI;;;;;;;;;;;;EAcf,CAAA;AAEF,MAAM,WAAW,cAAe,SAAQ,OAAO,CAAC,OAAO,IAAI,CAAC;CAAG;AAC/D,eAAO,MAAM,cAAc,4CAAwB,CAAA;AACnD,eAAO,MAAM,kBAAkB,4TAAyC,CAAA;AAExE,eAAO,MAAM,cAAc,iPAWxB,CAAA"}
@@ -0,0 +1,27 @@
1
+ import * as tsplus_module_1 from "callbag-effect-ts/Source/filter";
2
+ import * as tsplus_module_2 from "callbag-effect-ts/Source/map";
3
+ import * as tsplus_module_3 from "callbag-effect-ts/Source/fromEffect";
4
+ import * as tsplus_module_4 from "callbag-effect-ts/Source/chainPar";
5
+ import * as tsplus_module_5 from "callbag-effect-ts/Source/run";
6
+ import * as tsplus_module_6 from "callbag-effect-ts/Source/share";
7
+ import * as tsplus_module_7 from "@effect/io/Effect";
8
+ import * as tsplus_module_8 from "dfx/common";
9
+ import * as tsplus_module_9 from "@effect/io/Layer";
10
+ import { spawn } from "./Sharder/index.js";
11
+ const fromDispatchFactory = (source) => (event) => tsplus_module_2.map((p) => p.d)(tsplus_module_1.filter((p) => p.t === event)(source));
12
+ const handleDispatchFactory = (source) => (event, handle) => tsplus_module_5.runDrain(tsplus_module_4.chainPar((a) => tsplus_module_3.fromEffect(handle(a.d)))(tsplus_module_1.filter((p) => p.t === event)(source)));
13
+ export const make = tsplus_module_7.flatMap(shards => tsplus_module_7.flatMap(raw => tsplus_module_7.map(dispatch => {
14
+ const fromDispatch = fromDispatchFactory(dispatch);
15
+ const handleDispatch = handleDispatchFactory(dispatch);
16
+ return {
17
+ shards,
18
+ raw,
19
+ dispatch,
20
+ fromDispatch,
21
+ handleDispatch,
22
+ };
23
+ })(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.dispatch)(shards))))(tsplus_module_6.share(tsplus_module_4.chainPar((s) => s.raw)(shards))))(tsplus_module_6.share(spawn));
24
+ export const DiscordGateway = tsplus_module_8.Tag();
25
+ export const LiveDiscordGateway = tsplus_module_9.fromEffect(DiscordGateway)(make);
26
+ export const handleDispatch = (event, handle) => tsplus_module_7.serviceWithEffect(DiscordGateway)((a) => a.handleDispatch(event, handle));
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordGateway/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE1C,MAAM,mBAAmB,GACvB,CACE,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACsC,EAAE,CAChD,oBAAwC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAS,EAA1D,uBAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAAlC,MAAM,CAA6B,CAAwB,CAAA;AAE/D,MAAM,qBAAqB,GACzB,CACE,MAAwE,EACxE,EAAE,CACJ,CACE,KAAQ,EACR,MAA8D,EAChC,EAAE,0BAChC,yBAEY,CAAC,CAAC,EAAE,EAAE,CAAC,2BAAwB,MAAM,CAAC,CAAC,CAAC,CAAQ,CAAC,CAAC,EAF9D,uBACU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,EAD9B,MAAM,CACyB,CACgC,CAAS,CAAA;AAE5E,MAAM,CAAC,MAAM,IAAI,2BACT,MAAM,4BACN,GAAG,wBACH,QAAQ;IACd,MAAM,YAAY,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAA;IAClD,MAAM,cAAc,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAA;IAEtD,OAAO;QACL,MAAM;QACN,GAAG;QACH,QAAQ;QACR,YAAY;QACZ,cAAc;KACf,CAAA;yBAVkB,yBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAjC,MAAM,CAA4B,0BADvC,yBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,EAA5B,MAAM,CAAuB,0BAD1B,KAAK,EAatB,CAAA;AAGF,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAA,GAAG,EAAkB,CAAA;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,2BAAiB,cAAc,CAAC,CAAC,IAAI,CAAC,CAAA;AAExE,MAAM,CAAC,MAAM,cAAc,GAAG,CAM5B,KAAQ,EACR,MAA8D,EAC9D,EAAE,CACF,kCAAyB,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAC7C,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,CAChC,CAAA"}
@@ -0,0 +1,13 @@
1
+ import { Effect, Http } from "dfx/common";
2
+ import { Success } from "dfx/utils/effect";
3
+ import { ResponseWithData } from "./types.js";
4
+ declare const make: import("../common.js").Effect<import("../DiscordConfig/index.js").DiscordConfig | import("dfx/RateLimitStore/index").RateLimitStore | import("../Log/index.js").Log | import("dfx/RateLimitStore/index").RateLimiter, never, {
5
+ request: <A = unknown>(path: string, init?: RequestInit) => import("../common.js").Effect<never, import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError, ResponseWithData<A>>;
6
+ }>;
7
+ export interface DiscordREST extends Success<typeof make> {
8
+ }
9
+ export declare const DiscordREST: import("../common.js").Tag<DiscordREST>;
10
+ export declare const LiveDiscordREST: import("../common.js").Layer<import("../DiscordConfig/index.js").DiscordConfig | import("dfx/RateLimitStore/index").RateLimitStore | import("../Log/index.js").Log | import("dfx/RateLimitStore/index").RateLimiter, never, DiscordREST>;
11
+ export declare const rest: import("../types.js").Endpoints<RequestInit>;
12
+ export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DiscordREST/index.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAI7C,QAAA,MAAM,IAAI;iCAoDA,MAAM,SACN,WAAW;EA8BnB,CAAA;AAEF,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,OAAO,IAAI,CAAC;CAAG;AAC5D,eAAO,MAAM,WAAW,yCAAqB,CAAA;AAC7C,eAAO,MAAM,eAAe,0OAAsC,CAAA;AAElE,eAAO,MAAM,IAAI,8CAoChB,CAAA"}
@@ -0,0 +1,85 @@
1
+ import * as tsplus_module_1 from "@effect/io/Effect";
2
+ import * as tsplus_module_2 from "dfx/common";
3
+ import * as tsplus_module_3 from "@fp-ts/data/Equal";
4
+ import * as tsplus_module_4 from "@fp-ts/data/Option";
5
+ import * as tsplus_module_5 from "@effect/io/Layer";
6
+ import { millis } from "@fp-ts/data/Duration";
7
+ import { rateLimitFromHeaders, routeFromConfig } from "./utils.js";
8
+ import Pkg from "../../package.json" assert { type: "json" };
9
+ const make = tsplus_module_1.flatMap(({ token, rest }) => tsplus_module_1.flatMap(log => tsplus_module_1.flatMap(store => tsplus_module_1.map(({ maybeWait }) => {
10
+ const globalRateLimit = maybeWait("rest.global", rest.globalRateLimit.window, rest.globalRateLimit.limit);
11
+ const requestRateLimit = (path, init) => (() => {
12
+ const route = routeFromConfig(path, init);
13
+ return tsplus_module_1.flatMap(maybeBucket => {
14
+ const bucket = tsplus_module_4.getOrElse(() => ({
15
+ key: `?.${tsplus_module_3.hash(route)}`,
16
+ resetAfter: 5000,
17
+ limit: 1,
18
+ }))(maybeBucket);
19
+ const resetAfter = millis(bucket.resetAfter);
20
+ return tsplus_module_1.map(() => void 0)(maybeWait(`rest.bucket.${bucket.key}`, resetAfter, bucket.limit));
21
+ })(store.getBucketForRoute(route));
22
+ })();
23
+ const updateBuckets = (path, init, response) => tsplus_module_1.ignore((() => {
24
+ const route = routeFromConfig(path, init);
25
+ return tsplus_module_1.flatMap(({ bucket, retryAfter, limit, remaining }) => {
26
+ const effectsToRun = [store.putBucketRoute(route, bucket)];
27
+ return tsplus_module_1.flatMap(hasBucket => {
28
+ if (!hasBucket || limit - 1 === remaining) {
29
+ effectsToRun.push(store.putBucket({
30
+ key: bucket,
31
+ resetAfter: retryAfter.millis,
32
+ limit: !hasBucket && remaining > 0 ? remaining : limit,
33
+ }));
34
+ }
35
+ return tsplus_module_1.map(() => void 0)(tsplus_module_1.collectAllParDiscard(effectsToRun));
36
+ })(store.hasBucket(bucket));
37
+ })(tsplus_module_1.fromOption(rateLimitFromHeaders(response.headers)));
38
+ })());
39
+ const request = (path, init = {}) => tsplus_module_1.tap(({ response }) => updateBuckets(path, init, response))(tsplus_module_1.catchTag("StatusCodeError", (e) => e.code === 429
40
+ ? tsplus_module_1.flatMap(() => tsplus_module_1.flatMap(() => request(path, init))(updateBuckets(path, init, e.response)))(log.debug("DiscordREST", "429", path)) : tsplus_module_1.fail(e))(tsplus_module_1.flatMap(() => tsplus_module_2.Http.requestWithJson(`${rest.baseUrl}${path}`, {
41
+ ...init,
42
+ headers: {
43
+ ...(init?.headers ?? {}),
44
+ Authorization: `Bot ${token}`,
45
+ "User-Agent": `DiscordBot (https://github.com/tim-smart/dfx, ${Pkg.version})`,
46
+ },
47
+ }))(tsplus_module_1.tap(() => globalRateLimit)(requestRateLimit(path, init)))));
48
+ return { request };
49
+ })(tsplus_module_1.service(tsplus_module_2.RateLimitStore.RateLimiter)))(tsplus_module_1.service(tsplus_module_2.RateLimitStore.RateLimitStore)))(tsplus_module_1.service(tsplus_module_2.Log.Log)))(tsplus_module_1.service(tsplus_module_2.Config.DiscordConfig));
50
+ export const DiscordREST = tsplus_module_2.Tag();
51
+ export const LiveDiscordREST = tsplus_module_5.fromEffect(DiscordREST)(make);
52
+ export const rest = tsplus_module_2.Discord.createRoutes(({ method, url, params, options = {} }) => tsplus_module_1.serviceWithEffect(DiscordREST)(({ request }) => {
53
+ const hasBody = method !== "GET" && method !== "DELETE";
54
+ let hasFormData = typeof options?.body?.append === "function";
55
+ let body = undefined;
56
+ const headers = {};
57
+ if (hasBody && !hasFormData) {
58
+ headers["content-type"] = "application/json";
59
+ }
60
+ const qs = new URLSearchParams();
61
+ if (!hasBody) {
62
+ Object.entries((params ?? {})).forEach(([key, value]) => {
63
+ qs.append(key, value);
64
+ });
65
+ }
66
+ else if (hasFormData) {
67
+ body = options.body;
68
+ if (params) {
69
+ ;
70
+ body.append("payload_json", JSON.stringify(params));
71
+ }
72
+ }
73
+ else if (params) {
74
+ body = JSON.stringify(params);
75
+ }
76
+ else {
77
+ body = options.body;
78
+ }
79
+ return request(`${url}?${qs.toString()}`, {
80
+ method,
81
+ headers,
82
+ body,
83
+ });
84
+ }));
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/DiscordREST/index.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAG7C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,GAAG,MAAM,oBAAoB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;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AAE;QACtB,IAAI,GAAG,OAAO,CAAC,IAAK,CAAA;QACpB,IAAI,MAAM,EAAE;YACV,CAAC;YAAC,IAAiB,CAAC,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;SACnE;KACF;SAAM,IAAI,MAAM,EAAE;QACjB,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;KAC9B;SAAM;QACL,IAAI,GAAG,OAAO,CAAC,IAAK,CAAA;KACrB;IAED,OAAO,OAAO,CAAC,GAAG,GAAG,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,EAAE;QACxC,MAAM;QACN,OAAO;QACP,IAAI;KACL,CAAC,CAAA;AACJ,CAAC,CAAC,CACL,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Effect, Http } from "dfx/common";
2
+ import { DiscordREST } from "./index.js";
3
+ export interface ResponseWithData<A> {
4
+ response: Response;
5
+ json: Effect<never, Http.JsonParseError, A>;
6
+ text: Effect<never, never, string>;
7
+ blob: Effect<never, Http.BlobError, Blob>;
8
+ }
9
+ export type RestResponse<T> = Effect<DiscordREST, Http.FetchError | Http.StatusCodeError | Http.JsonParseError, ResponseWithData<T>>;
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/DiscordREST/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,MAAM,WAAW,gBAAgB,CAAC,CAAC;IACjC,QAAQ,EAAE,QAAQ,CAAA;IAClB,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAA;IAC3C,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAClC,IAAI,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;CAC1C;AAED,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,MAAM,CAClC,WAAW,EACX,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,cAAc,EAC5D,gBAAgB,CAAC,CAAC,CAAC,CACpB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../DiscordREST/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/DiscordREST/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ export declare const routeFromConfig: (path: string, init: RequestInit) => string;
2
+ export declare const numberHeader: (headers: Headers) => (key: string) => import("../common.js").Maybe<number>;
3
+ export declare const retryAfter: (headers: Headers) => import("../common.js").Maybe<import("../common.js").Duration>;
4
+ export declare const rateLimitFromHeaders: (headers: Headers) => import("../common.js").Maybe<{
5
+ readonly bucket: string;
6
+ readonly retryAfter: import("../common.js").Duration;
7
+ readonly limit: number;
8
+ readonly remaining: number;
9
+ }>;
10
+ export type RateLimitDetails = ReturnType<typeof rateLimitFromHeaders>;
11
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/DiscordREST/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe,SAAU,MAAM,QAAQ,WAAW,WAa9D,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,OAAO,WAAW,MAAM,yCAGjC,CAAA;AAE7B,eAAO,MAAM,UAAU,YAAa,OAAO,kEAGjB,CAAA;AAE1B,eAAO,MAAM,oBAAoB,YAAa,OAAO;;;;;EAMjD,CAAA;AACJ,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import * as tsplus_module_1 from "@fp-ts/data/Option";
2
+ import * as tsplus_module_2 from "@fp-ts/data/Duration";
3
+ const majorResources = ["channels", "guilds", "webhooks"];
4
+ export const routeFromConfig = (path, init) => {
5
+ const method = (init?.method ?? "get").toLowerCase();
6
+ // Only keep major ID's
7
+ const routeURL = path
8
+ .split("?")[0]
9
+ .replace(/\/([A-Za-z]+)\/(\d{16,21}|@me)/g, (match, resource) => majorResources.includes(resource) ? match : `/${resource}`)
10
+ // Strip reactions
11
+ .replace(/\/reactions\/(.*)/, "/reactions");
12
+ return `${method}-${routeURL}`;
13
+ };
14
+ export const numberHeader = (headers) => (key) => tsplus_module_1.filter((n) => !isNaN(n))(tsplus_module_1.map(parseFloat)(tsplus_module_1.fromNullable(headers.get(key))));
15
+ export const retryAfter = (headers) => tsplus_module_1.map(tsplus_module_2.seconds)(tsplus_module_1.catchAll(() => numberHeader(headers)("retry-after"))(numberHeader(headers)("x-ratelimit-reset-after")));
16
+ export const rateLimitFromHeaders = (headers) => tsplus_module_1.struct({
17
+ bucket: tsplus_module_1.fromNullable(headers.get("x-ratelimit-bucket")),
18
+ retryAfter: retryAfter(headers),
19
+ limit: numberHeader(headers)("x-ratelimit-limit"),
20
+ remaining: numberHeader(headers)("x-ratelimit-remaining"),
21
+ });
22
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/DiscordREST/utils.ts"],"names":[],"mappings":";;AAAA,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAA;AAElE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,IAAiB,EAAE,EAAE;IACjE,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;IAEpD,uBAAuB;IACvB,MAAM,QAAQ,GAAG,IAAI;SAClB,KAAK,CAAC,GAAG,CAAC,CAAC,CA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declare function all(flags: Flags<number>): number;
6
+ export declare function all(flags: Flags<bigint>): bigint;
7
+ /**
8
+ * Returns a function that converts a bitfield to a list of flag names.
9
+ */
10
+ export declare function toList<T extends Flags<number>>(flags: T): (bitfield: number) => (keyof T)[];
11
+ export declare function toList<T extends Flags<bigint>>(flags: T): (bitfield: bigint) => (keyof T)[];
12
+ /**
13
+ * Returns a function that converts a list of flags names to a bigint bitfield.
14
+ */
15
+ export declare const fromListBigint: <T extends Flags<bigint>>(flags: T) => (list: (keyof T)[]) => bigint;
16
+ /**
17
+ * Returns a function that converts a list of flags names to a bitfield.
18
+ */
19
+ export declare const fromList: <T extends Flags<number>>(flags: T) => (list: (keyof T)[]) => number;
20
+ /**
21
+ * Checks if a bigint bitfield contains and a flag value.
22
+ */
23
+ export declare const hasBigInt: (flag: bigint | string) => (bits: bigint | string) => boolean;
24
+ /**
25
+ * Checks if a bitfield contains and a flag value.
26
+ */
27
+ export declare const has: (flag: number | string) => (bits: number | string) => boolean;
28
+ //# sourceMappingURL=flags.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../../src/Helpers/flags.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;AAEhE;;GAEG;AACH,wBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;AACjD,wBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;AAKjD;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,EAC5C,KAAK,EAAE,CAAC,GACP,CAAC,QAAQ,EAAE,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;AACpC,wBAAgB,MAAM,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,EAC5C,KAAK,EAAE,CAAC,GACP,CAAC,QAAQ,EAAE,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAA;AAYpC;;GAEG;AACH,eAAO,MAAM,cAAc,sEAG+B,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,sEAG6B,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,SAAS,SAAU,MAAM,GAAG,MAAM,YAE/B,MAAM,GAAG,MAAM,YAI9B,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,GAAG,SAAU,MAAM,GAAG,MAAM,YAEzB,MAAM,GAAG,MAAM,YAI9B,CAAA"}
@@ -0,0 +1,36 @@
1
+ export function all(flags) {
2
+ return Object.values(flags).reduce((acc, flag) => acc | flag);
3
+ }
4
+ export function toList(flags) {
5
+ const entries = Object.entries(flags);
6
+ return (val) => entries.reduce((acc, [key, flag]) => ((val & flag) === flag ? [...acc, key] : acc), []);
7
+ }
8
+ /**
9
+ * Returns a function that converts a list of flags names to a bigint bitfield.
10
+ */
11
+ export const fromListBigint = (flags) => (list) => list.reduce((acc, key) => acc | flags[key], BigInt(0));
12
+ /**
13
+ * Returns a function that converts a list of flags names to a bitfield.
14
+ */
15
+ export const fromList = (flags) => (list) => list.reduce((acc, key) => acc | flags[key], 0);
16
+ /**
17
+ * Checks if a bigint bitfield contains and a flag value.
18
+ */
19
+ export const hasBigInt = (flag) => {
20
+ const flagBigInt = BigInt(flag);
21
+ return (bits) => {
22
+ const bitsBigInt = BigInt(bits);
23
+ return (bitsBigInt & flagBigInt) === flagBigInt;
24
+ };
25
+ };
26
+ /**
27
+ * Checks if a bitfield contains and a flag value.
28
+ */
29
+ export const has = (flag) => {
30
+ const flagNumber = +flag;
31
+ return (bits) => {
32
+ const bitsNumber = +bits;
33
+ return (bitsNumber & flagNumber) === flagNumber;
34
+ };
35
+ };
36
+ //# sourceMappingURL=flags.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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U,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/B,OAAO,CAAC,IAAqB,EAAE,EAAE;QAC/B,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAC/B,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,UAAU,CAAA;IACjD,CAAC,CAAA;AACH,CAAC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,IAAqB,EAAE,EAAE;IAC3C,MAAM,UAAU,GAAG,CAAC,IAAI,CAAA;IACxB,OAAO,CAAC,IAAqB,EAAE,EAAE;QAC/B,MAAM,UAAU,GAAG,CAAC,IAAI,CAAA;QACxB,OAAO,CAAC,UAAU,GAAG,UAAU,CAAC,KAAK,UAAU,CAAA;IACjD,CAAC,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * All the intents
3
+ */
4
+ export declare const ALL: number;
5
+ /**
6
+ * Privileged intents
7
+ */
8
+ export declare const PRIVILEGED: number;
9
+ /**
10
+ * Un-privileged intents
11
+ */
12
+ export declare const UNPRIVILEGED: number;
13
+ /**
14
+ * Function that converts a intents bitfield value to a list of intent names.
15
+ */
16
+ export declare const toList: (bitfield: number) => ("GUILDS" | "GUILD_MEMBERS" | "GUILD_BANS" | "GUILD_EMOJIS_AND_STICKERS" | "GUILD_INTEGRATIONS" | "GUILD_WEBHOOKS" | "GUILD_INVITES" | "GUILD_VOICE_STATES" | "GUILD_PRESENCES" | "GUILD_MESSAGES" | "GUILD_MESSAGE_REACTIONS" | "GUILD_MESSAGE_TYPING" | "DIRECT_MESSAGES" | "DIRECT_MESSAGE_REACTIONS" | "DIRECT_MESSAGE_TYPING" | "MESSAGE_CONTENT" | "GUILD_SCHEDULED_EVENTS" | "AUTO_MODERATION_CONFIGURATION" | "AUTO_MODERATION_EXECUTION")[];
17
+ /**
18
+ * Function that converts a list of intent names to a bitfield value.
19
+ */
20
+ export declare const fromList: (list: ("GUILDS" | "GUILD_MEMBERS" | "GUILD_BANS" | "GUILD_EMOJIS_AND_STICKERS" | "GUILD_INTEGRATIONS" | "GUILD_WEBHOOKS" | "GUILD_INVITES" | "GUILD_VOICE_STATES" | "GUILD_PRESENCES" | "GUILD_MESSAGES" | "GUILD_MESSAGE_REACTIONS" | "GUILD_MESSAGE_TYPING" | "DIRECT_MESSAGES" | "DIRECT_MESSAGE_REACTIONS" | "DIRECT_MESSAGE_TYPING" | "MESSAGE_CONTENT" | "GUILD_SCHEDULED_EVENTS" | "AUTO_MODERATION_CONFIGURATION" | "AUTO_MODERATION_EXECUTION")[]) => number;
21
+ /**
22
+ * Check if an intent flag exists in the permissions.
23
+ */
24
+ export declare const has: (flag: string | number) => (bits: string | number) => boolean;
25
+ //# sourceMappingURL=intents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intents.d.ts","sourceRoot":"","sources":["../../src/Helpers/intents.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,GAAG,QAAoC,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,UAAU,QAGiB,CAAA;AAExC;;GAEG;AACH,eAAO,MAAM,YAAY,QAAmB,CAAA;AAE5C;;GAEG;AACH,eAAO,MAAM,MAAM,4cAAuC,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,QAAQ,wcAAyC,CAAA;AAE9D;;GAEG;AACH,eAAO,MAAM,GAAG,+DAAY,CAAA"}
@@ -0,0 +1,28 @@
1
+ import * as tsplus_module_1 from "dfx/common";
2
+ /**
3
+ * All the intents
4
+ */
5
+ export const ALL = tsplus_module_1.Flags.all(tsplus_module_1.Discord.GatewayIntents);
6
+ /**
7
+ * Privileged intents
8
+ */
9
+ export const PRIVILEGED = tsplus_module_1.Discord.GatewayIntents.GUILD_PRESENCES |
10
+ tsplus_module_1.Discord.GatewayIntents.GUILD_MEMBERS |
11
+ tsplus_module_1.Discord.GatewayIntents.MESSAGE_CONTENT;
12
+ /**
13
+ * Un-privileged intents
14
+ */
15
+ export const UNPRIVILEGED = ALL ^ PRIVILEGED;
16
+ /**
17
+ * Function that converts a intents bitfield value to a list of intent names.
18
+ */
19
+ export const toList = tsplus_module_1.Flags.toList(tsplus_module_1.Discord.GatewayIntents);
20
+ /**
21
+ * Function that converts a list of intent names to a bitfield value.
22
+ */
23
+ export const fromList = tsplus_module_1.Flags.fromList(tsplus_module_1.Discord.GatewayIntents);
24
+ /**
25
+ * Check if an intent flag exists in the permissions.
26
+ */
27
+ export const has = tsplus_module_1.Flags.has;
28
+ //# sourceMappingURL=intents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intents.js","sourceRoot":"","sources":["../../src/Helpers/intents.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,KAAK,CAAC,GAAG,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,gBAAA,OAAO,CAAC,cAAc,CAAC,eAAe;IACtC,gBAAA,OAAO,CAAC,cAAc,CAAC,aAAa;IACpC,gBAAA,OAAO,CAAC,cAAc,CAAC,eAAe,CAAA;AAExC;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,GAAG,UAAU,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,gBAAA,KAAK,CAAC,MAAM,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,gBAAA,KAAK,CAAC,QAAQ,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,CAAA;AAE9D;;GAEG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,gBAAA,KAAK,CAAC,GAAG,CAAA"}
@@ -0,0 +1,74 @@
1
+ import { Discord, Maybe } from "dfx/common";
2
+ /**
3
+ * Maybe find a sub-command within the interaction options.
4
+ */
5
+ export declare const allSubCommands: (interaction: Discord.ApplicationCommandDatum) => readonly import("../types.js").ApplicationCommandInteractionDataOption[];
6
+ /**
7
+ * Maybe find a sub-command within the interaction options.
8
+ */
9
+ export declare const findSubCommand: (name: string) => (interaction: Discord.ApplicationCommandDatum) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
10
+ /**
11
+ * If the sub-command exists return `true`, else `false`.
12
+ */
13
+ export declare const isSubCommand: (name: string) => (interaction: import("../types.js").ApplicationCommandDatum) => boolean;
14
+ /**
15
+ * Maybe get the options for a sub-command
16
+ */
17
+ export declare const subCommandOptions: (name: string) => (interaction: import("../types.js").ApplicationCommandDatum) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption[]>;
18
+ /**
19
+ * A lens for accessing nested options in a interaction.
20
+ */
21
+ export declare const optionsWithNested: (data: Pick<Discord.ApplicationCommandDatum, "options">) => Discord.ApplicationCommandInteractionDataOption[];
22
+ /**
23
+ * Return the interaction options as a name / value map.
24
+ */
25
+ export declare const transformOptions: (options: Discord.ApplicationCommandInteractionDataOption[]) => Record<string, string | undefined>;
26
+ /**
27
+ * Return the interaction options as a name / value map.
28
+ */
29
+ export declare const optionsMap: (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => Record<string, string | undefined>;
30
+ /**
31
+ * Try find a matching option from the interaction.
32
+ */
33
+ export declare const getOption: (name: string) => (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
34
+ /**
35
+ * Try find a matching option from the interaction.
36
+ */
37
+ export declare const focusedOption: (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => import("../common.js").Maybe<import("../types.js").ApplicationCommandInteractionDataOption>;
38
+ /**
39
+ * Try find a matching option value from the interaction.
40
+ */
41
+ export declare const optionValue: (name: string) => (data: Pick<import("../types.js").ApplicationCommandDatum, "options">) => import("../common.js").Maybe<string>;
42
+ /**
43
+ * Try extract resolved data
44
+ */
45
+ export declare const resolved: (data: Discord.ApplicationCommandDatum) => import("../common.js").Maybe<import("../types.js").ResolvedDatum>;
46
+ /**
47
+ * Try find a matching option value from the interaction.
48
+ */
49
+ export declare const resolveOptionValue: <T>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => T | undefined) => (a: Discord.ApplicationCommandDatum) => import("../common.js").Maybe<T>;
50
+ /**
51
+ * A lens for accessing the components in a interaction.
52
+ */
53
+ export declare const components: (a: Discord.ModalSubmitDatum) => Discord.Component[];
54
+ /**
55
+ * A lens for accessing the components in a interaction.
56
+ */
57
+ export declare const componentsWithValue: (a: import("../types.js").ModalSubmitDatum) => readonly import("../types.js").Component[];
58
+ /**
59
+ * Return the interaction components as an id / value map.
60
+ */
61
+ export declare const transformComponents: (options: Discord.Component[]) => Record<string, string | undefined>;
62
+ /**
63
+ * Return the interaction components as an id / value map.
64
+ */
65
+ export declare const componentsMap: (a: import("../types.js").ModalSubmitDatum) => Record<string, string | undefined>;
66
+ /**
67
+ * Try find a matching component from the interaction.
68
+ */
69
+ export declare const getComponent: (id: string) => (a: import("../types.js").ModalSubmitDatum) => import("../common.js").Maybe<import("../types.js").Component>;
70
+ /**
71
+ * Try find a matching component value from the interaction.
72
+ */
73
+ export declare const componentValue: (id: string) => (a: import("../types.js").ModalSubmitDatum) => import("../common.js").Maybe<string>;
74
+ //# sourceMappingURL=interactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../../src/Helpers/interactions.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAiB,QAAQ,uBAAuB,6EAMxE,CAAA;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,SAClB,MAAM,mBAAmB,QAAQ,uBAAuB,gGAQ5D,CAAA;AAEL;;GAEG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,4EACI,CAAA;AAE7C;;GAEG;AACH,eAAO,MAAM,iBAAiB,SAAU,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