dfx 0.60.0 → 0.61.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 (182) hide show
  1. package/Cache/driver.d.ts +1 -1
  2. package/Cache/driver.d.ts.map +1 -1
  3. package/Cache/memory.js +2 -2
  4. package/Cache/memory.js.map +1 -1
  5. package/Cache/memoryTTL.d.ts.map +1 -1
  6. package/Cache/memoryTTL.js.map +1 -1
  7. package/Cache/prelude.d.ts.map +1 -1
  8. package/Cache/prelude.js.map +1 -1
  9. package/Cache.d.ts +1 -1
  10. package/Cache.d.ts.map +1 -1
  11. package/Cache.js +1 -1
  12. package/Cache.js.map +1 -1
  13. package/DiscordGateway/DiscordWS.d.ts +4 -4
  14. package/DiscordGateway/DiscordWS.d.ts.map +1 -1
  15. package/DiscordGateway/DiscordWS.js +2 -2
  16. package/DiscordGateway/DiscordWS.js.map +1 -1
  17. package/DiscordGateway/Shard/heartbeats.js.map +1 -1
  18. package/DiscordGateway/Shard/utils.d.ts +1 -1
  19. package/DiscordGateway/Shard/utils.d.ts.map +1 -1
  20. package/DiscordGateway/Shard/utils.js.map +1 -1
  21. package/DiscordGateway/Shard.d.ts +6 -6
  22. package/DiscordGateway/Shard.d.ts.map +1 -1
  23. package/DiscordGateway/Shard.js +11 -11
  24. package/DiscordGateway/Shard.js.map +1 -1
  25. package/DiscordGateway/ShardStore.d.ts +2 -2
  26. package/DiscordGateway/ShardStore.d.ts.map +1 -1
  27. package/DiscordGateway/ShardStore.js +2 -2
  28. package/DiscordGateway/ShardStore.js.map +1 -1
  29. package/DiscordGateway/Sharder.js.map +1 -1
  30. package/DiscordGateway/WS.d.ts +4 -4
  31. package/DiscordGateway/WS.d.ts.map +1 -1
  32. package/DiscordGateway/WS.js +6 -6
  33. package/DiscordGateway/WS.js.map +1 -1
  34. package/DiscordGateway.d.ts.map +1 -1
  35. package/DiscordGateway.js.map +1 -1
  36. package/DiscordREST/types.d.ts +1 -1
  37. package/DiscordREST/types.d.ts.map +1 -1
  38. package/DiscordREST/utils.d.ts +1 -1
  39. package/DiscordREST/utils.d.ts.map +1 -1
  40. package/DiscordREST/utils.js +1 -1
  41. package/DiscordREST/utils.js.map +1 -1
  42. package/DiscordREST.d.ts.map +1 -1
  43. package/DiscordREST.js.map +1 -1
  44. package/Helpers/flags.d.ts.map +1 -1
  45. package/Helpers/flags.js.map +1 -1
  46. package/Helpers/intents.d.ts.map +1 -1
  47. package/Helpers/intents.js.map +1 -1
  48. package/Helpers/interactions.d.ts +1 -1
  49. package/Helpers/interactions.d.ts.map +1 -1
  50. package/Helpers/interactions.js +2 -2
  51. package/Helpers/interactions.js.map +1 -1
  52. package/Helpers/members.d.ts.map +1 -1
  53. package/Helpers/members.js.map +1 -1
  54. package/Helpers/permissions.js.map +1 -1
  55. package/Interactions/builder.d.ts +1 -1
  56. package/Interactions/builder.d.ts.map +1 -1
  57. package/Interactions/builder.js.map +1 -1
  58. package/Interactions/context.d.ts.map +1 -1
  59. package/Interactions/context.js.map +1 -1
  60. package/Interactions/definitions.d.ts.map +1 -1
  61. package/Interactions/definitions.js.map +1 -1
  62. package/Interactions/gateway.d.ts.map +1 -1
  63. package/Interactions/gateway.js.map +1 -1
  64. package/Interactions/handlers.d.ts.map +1 -1
  65. package/Interactions/handlers.js.map +1 -1
  66. package/Interactions/index.d.ts +1 -1
  67. package/Interactions/index.d.ts.map +1 -1
  68. package/Interactions/index.js.map +1 -1
  69. package/Interactions/utils.d.ts.map +1 -1
  70. package/Interactions/utils.js.map +1 -1
  71. package/Interactions/webhook.d.ts.map +1 -1
  72. package/Interactions/webhook.js.map +1 -1
  73. package/LICENSE +21 -0
  74. package/Log.d.ts +1 -1
  75. package/Log.d.ts.map +1 -1
  76. package/Log.js +1 -1
  77. package/Log.js.map +1 -1
  78. package/RateLimit.d.ts.map +1 -1
  79. package/RateLimit.js.map +1 -1
  80. package/gateway.d.ts +1 -1
  81. package/gateway.d.ts.map +1 -1
  82. package/gateway.js +1 -1
  83. package/gateway.js.map +1 -1
  84. package/index.d.ts +1 -1
  85. package/index.d.ts.map +1 -1
  86. package/mjs/Cache/memory.mjs +2 -2
  87. package/mjs/Cache/memory.mjs.map +1 -1
  88. package/mjs/Cache/memoryTTL.mjs.map +1 -1
  89. package/mjs/Cache/prelude.mjs.map +1 -1
  90. package/mjs/Cache.mjs +1 -1
  91. package/mjs/Cache.mjs.map +1 -1
  92. package/mjs/DiscordGateway/DiscordWS.mjs +2 -2
  93. package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
  94. package/mjs/DiscordGateway/Shard/heartbeats.mjs.map +1 -1
  95. package/mjs/DiscordGateway/Shard/utils.mjs.map +1 -1
  96. package/mjs/DiscordGateway/Shard.mjs +11 -11
  97. package/mjs/DiscordGateway/Shard.mjs.map +1 -1
  98. package/mjs/DiscordGateway/ShardStore.mjs +2 -2
  99. package/mjs/DiscordGateway/ShardStore.mjs.map +1 -1
  100. package/mjs/DiscordGateway/Sharder.mjs.map +1 -1
  101. package/mjs/DiscordGateway/WS.mjs +5 -5
  102. package/mjs/DiscordGateway/WS.mjs.map +1 -1
  103. package/mjs/DiscordGateway.mjs.map +1 -1
  104. package/mjs/DiscordREST/utils.mjs +1 -1
  105. package/mjs/DiscordREST/utils.mjs.map +1 -1
  106. package/mjs/DiscordREST.mjs +1 -1
  107. package/mjs/DiscordREST.mjs.map +1 -1
  108. package/mjs/Helpers/flags.mjs.map +1 -1
  109. package/mjs/Helpers/intents.mjs.map +1 -1
  110. package/mjs/Helpers/interactions.mjs +2 -2
  111. package/mjs/Helpers/interactions.mjs.map +1 -1
  112. package/mjs/Helpers/members.mjs.map +1 -1
  113. package/mjs/Helpers/permissions.mjs.map +1 -1
  114. package/mjs/Interactions/builder.mjs.map +1 -1
  115. package/mjs/Interactions/context.mjs.map +1 -1
  116. package/mjs/Interactions/definitions.mjs.map +1 -1
  117. package/mjs/Interactions/gateway.mjs +1 -1
  118. package/mjs/Interactions/gateway.mjs.map +1 -1
  119. package/mjs/Interactions/handlers.mjs.map +1 -1
  120. package/mjs/Interactions/index.mjs.map +1 -1
  121. package/mjs/Interactions/utils.mjs.map +1 -1
  122. package/mjs/Interactions/webhook.mjs.map +1 -1
  123. package/mjs/Log.mjs +1 -1
  124. package/mjs/Log.mjs.map +1 -1
  125. package/mjs/RateLimit.mjs.map +1 -1
  126. package/mjs/gateway.mjs +1 -1
  127. package/mjs/gateway.mjs.map +1 -1
  128. package/mjs/index.mjs +1 -1
  129. package/mjs/index.mjs.map +1 -1
  130. package/mjs/types.mjs.map +1 -1
  131. package/mjs/utils/Effect.mjs +4 -4
  132. package/mjs/utils/Effect.mjs.map +1 -1
  133. package/mjs/version.mjs +1 -1
  134. package/mjs/webhooks.mjs +1 -1
  135. package/mjs/webhooks.mjs.map +1 -1
  136. package/package.json +32 -26
  137. package/src/Cache/driver.ts +1 -1
  138. package/src/Cache/memory.ts +2 -2
  139. package/src/Cache/memoryTTL.ts +6 -4
  140. package/src/Cache/prelude.ts +15 -13
  141. package/src/Cache.ts +3 -3
  142. package/src/DiscordGateway/DiscordWS.ts +9 -10
  143. package/src/DiscordGateway/Shard/heartbeats.ts +1 -1
  144. package/src/DiscordGateway/Shard/utils.ts +10 -12
  145. package/src/DiscordGateway/Shard.ts +23 -24
  146. package/src/DiscordGateway/ShardStore.ts +2 -2
  147. package/src/DiscordGateway/Sharder.ts +7 -7
  148. package/src/DiscordGateway/WS.ts +10 -10
  149. package/src/DiscordGateway.ts +8 -9
  150. package/src/DiscordREST/types.ts +1 -1
  151. package/src/DiscordREST/utils.ts +5 -3
  152. package/src/DiscordREST.ts +27 -24
  153. package/src/Helpers/flags.ts +2 -4
  154. package/src/Helpers/intents.ts +3 -4
  155. package/src/Helpers/interactions.ts +53 -56
  156. package/src/Helpers/members.ts +2 -2
  157. package/src/Helpers/permissions.ts +2 -2
  158. package/src/Interactions/builder.ts +21 -19
  159. package/src/Interactions/context.ts +16 -23
  160. package/src/Interactions/definitions.ts +27 -34
  161. package/src/Interactions/gateway.ts +80 -83
  162. package/src/Interactions/handlers.ts +34 -35
  163. package/src/Interactions/index.ts +17 -21
  164. package/src/Interactions/utils.ts +13 -17
  165. package/src/Interactions/webhook.ts +19 -15
  166. package/src/Log.ts +3 -3
  167. package/src/RateLimit.ts +5 -4
  168. package/src/gateway.ts +2 -2
  169. package/src/index.ts +1 -1
  170. package/src/types.ts +50 -26
  171. package/src/utils/Effect.ts +16 -17
  172. package/src/version.ts +1 -1
  173. package/src/webhooks.ts +2 -2
  174. package/types.d.ts.map +1 -1
  175. package/types.js.map +1 -1
  176. package/utils/Effect.d.ts.map +1 -1
  177. package/utils/Effect.js +4 -4
  178. package/utils/Effect.js.map +1 -1
  179. package/version.d.ts +1 -1
  180. package/version.js +1 -1
  181. package/webhooks.d.ts +1 -1
  182. package/webhooks.d.ts.map +1 -1
@@ -61,28 +61,28 @@ export const handlers = <R, E, TE, A, B>(
61
61
  [Discord.InteractionType.MODAL_SUBMIT]: i => {
62
62
  const data = i.data as Discord.ModalSubmitDatum
63
63
 
64
- return Effect.findFirst(ModalSubmit, _ =>
65
- _.predicate(data.custom_id),
66
- ).pipe(
67
- Effect.flatMap(
68
- Option.match({
69
- onNone: () => Effect.fail(new DefinitionNotFound(i)),
70
- onSome: match =>
71
- Effect.provideService(
72
- match.handle(i),
73
- Ctx.ModalSubmitData,
74
- data,
75
- ) as Handler<R, E, B>,
76
- }),
77
- ),
78
- )
64
+ return Effect.findFirst(ModalSubmit, _ => _.predicate(data.custom_id))
65
+ .pipe(
66
+ Effect.flatMap(
67
+ Option.match({
68
+ onNone: () => Effect.fail(new DefinitionNotFound(i)),
69
+ onSome: match =>
70
+ Effect.provideService(
71
+ match.handle(i),
72
+ Ctx.ModalSubmitData,
73
+ data,
74
+ ) as Handler<R, E, B>,
75
+ }),
76
+ ),
77
+ )
79
78
  },
80
79
 
81
80
  [Discord.InteractionType.MESSAGE_COMPONENT]: i => {
82
81
  const data = i.data as Discord.MessageComponentDatum
83
82
 
84
- return Effect.findFirst(MessageComponent, _ =>
85
- _.predicate(data.custom_id),
83
+ return Effect.findFirst(
84
+ MessageComponent,
85
+ _ => _.predicate(data.custom_id),
86
86
  ).pipe(
87
87
  Effect.flatMap(
88
88
  Option.match({
@@ -104,25 +104,24 @@ export const handlers = <R, E, TE, A, B>(
104
104
  return Option.match(IxHelpers.focusedOption(data), {
105
105
  onNone: () => Effect.fail(new DefinitionNotFound(i)),
106
106
  onSome: focusedOption =>
107
- Effect.findFirst(Autocomplete, _ =>
108
- _.predicate(data, focusedOption),
109
- ).pipe(
110
- Effect.flatMap(
111
- Option.match({
112
- onNone: () => Effect.fail(new DefinitionNotFound(i)),
113
- onSome: match =>
114
- Effect.provideService(
115
- match.handle(i),
116
- Ctx.ApplicationCommand,
117
- data,
118
- ).pipe(
119
- Effect.provideService(Ctx.FocusedOptionContext, {
120
- focusedOption,
121
- }),
122
- ) as Handler<R, E, B>,
123
- }),
107
+ Effect.findFirst(Autocomplete, _ => _.predicate(data, focusedOption))
108
+ .pipe(
109
+ Effect.flatMap(
110
+ Option.match({
111
+ onNone: () => Effect.fail(new DefinitionNotFound(i)),
112
+ onSome: match =>
113
+ Effect.provideService(
114
+ match.handle(i),
115
+ Ctx.ApplicationCommand,
116
+ data,
117
+ ).pipe(
118
+ Effect.provideService(Ctx.FocusedOptionContext, {
119
+ focusedOption,
120
+ }),
121
+ ) as Handler<R, E, B>,
122
+ }),
123
+ ),
124
124
  ),
125
- ),
126
125
  })
127
126
  },
128
127
  }
@@ -5,10 +5,10 @@ export { response } from "dfx/Helpers/interactions"
5
5
  export * from "dfx/Interactions/builder"
6
6
  export * from "dfx/Interactions/context"
7
7
  export {
8
- InteractionDefinition,
9
8
  autocomplete,
10
9
  global,
11
10
  guild,
11
+ InteractionDefinition,
12
12
  messageComponent,
13
13
  modalSubmit,
14
14
  } from "dfx/Interactions/definitions"
@@ -23,24 +23,20 @@ export const idStartsWith = (query: string) => (customId: string) =>
23
23
  export const idRegex = (query: RegExp) => (customId: string) =>
24
24
  Effect.succeed(query.test(customId))
25
25
 
26
- export const option =
27
- (command: string, optionName: string) =>
28
- (
29
- data: Pick<Discord.ApplicationCommandDatum, "name">,
30
- focusedOption: Pick<
31
- Discord.ApplicationCommandInteractionDataOption,
32
- "name"
33
- >,
34
- ) =>
35
- Effect.succeed(data.name === command && focusedOption.name === optionName)
26
+ export const option = (command: string, optionName: string) =>
27
+ (
28
+ data: Pick<Discord.ApplicationCommandDatum, "name">,
29
+ focusedOption: Pick<
30
+ Discord.ApplicationCommandInteractionDataOption,
31
+ "name"
32
+ >,
33
+ ) => Effect.succeed(data.name === command && focusedOption.name === optionName)
36
34
 
37
- export const optionOnly =
38
- (optionName: string) =>
39
- (
40
- _: unknown,
41
- focusedOption: Pick<
42
- Discord.ApplicationCommandInteractionDataOption,
43
- "name"
44
- >,
45
- ) =>
46
- Effect.succeed(focusedOption.name === optionName)
35
+ export const optionOnly = (optionName: string) =>
36
+ (
37
+ _: unknown,
38
+ focusedOption: Pick<
39
+ Discord.ApplicationCommandInteractionDataOption,
40
+ "name"
41
+ >,
42
+ ) => Effect.succeed(focusedOption.name === optionName)
@@ -7,12 +7,11 @@ import type * as Discord from "dfx/types"
7
7
  export type DefinitionFlattened<R, E, TE, A> = D.InteractionDefinition<
8
8
  R,
9
9
  E
10
- > extends infer D
11
- ? {
12
- [K in keyof D]: K extends "handle"
13
- ? (_: Discord.Interaction) => Effect.Effect<R, TE, A>
14
- : D[K]
15
- }
10
+ > extends infer D ? {
11
+ [K in keyof D]: K extends "handle"
12
+ ? (_: Discord.Interaction) => Effect.Effect<R, TE, A>
13
+ : D[K]
14
+ }
16
15
  : never
17
16
 
18
17
  export type DefinitionFlattenedCommand<R, E, TE, A> = Extract<
@@ -45,13 +44,11 @@ export const flattenDefinitions = <R, E, TE, A, B>(
45
44
  handle: (i: Discord.Interaction) =>
46
45
  Effect.isEffect(definition.handle)
47
46
  ? transform(
48
- Effect.flatMap(definition.handle, _ => handleResponse(i, _)),
49
- )
47
+ Effect.flatMap(definition.handle, _ => handleResponse(i, _)),
48
+ )
50
49
  : transform(
51
- Effect.flatMap(definition.handle(context), _ =>
52
- handleResponse(i, _),
53
- ),
54
- ),
50
+ Effect.flatMap(definition.handle(context), _ => handleResponse(i, _)),
51
+ ),
55
52
  }))
56
53
 
57
54
  export const splitDefinitions = <R, E, TE, A>(
@@ -82,11 +79,10 @@ export const splitDefinitions = <R, E, TE, A>(
82
79
  ).pipe(
83
80
  Chunk.reduce(
84
81
  {} as Record<string, DefinitionFlattenedCommand<R, E, TE, A>>,
85
- (acc, d) =>
86
- ({
87
- ...acc,
88
- [d.command.name]: d,
89
- } as any),
82
+ (acc, d) => ({
83
+ ...acc,
84
+ [d.command.name]: d,
85
+ } as any),
90
86
  ),
91
87
  )
92
88
 
@@ -42,8 +42,8 @@ const checkSignature = (
42
42
  publicKey,
43
43
  crypto,
44
44
  algorithm,
45
- ),
46
- ),
45
+ )
46
+ )
47
47
  ),
48
48
  Effect.filterOrFail(identity, () => new BadWebhookSignature()),
49
49
  Effect.catchAllCause(() => Effect.fail(new BadWebhookSignature())),
@@ -86,14 +86,16 @@ export class WebhookParseError {
86
86
  }
87
87
 
88
88
  const fromHeadersAndBody = (headers: Headers, body: string) =>
89
- Effect.tap(WebhookConfig, ({ algorithm, crypto, publicKey }) =>
90
- checkSignature(publicKey, headers, body, crypto, algorithm),
89
+ Effect.tap(
90
+ WebhookConfig,
91
+ ({ algorithm, crypto, publicKey }) =>
92
+ checkSignature(publicKey, headers, body, crypto, algorithm),
91
93
  ).pipe(
92
94
  Effect.flatMap(() =>
93
95
  Effect.try({
94
96
  try: () => JSON.parse(body) as Discord.Interaction,
95
97
  catch: reason => new WebhookParseError(reason),
96
- }),
98
+ })
97
99
  ),
98
100
  )
99
101
 
@@ -113,12 +115,14 @@ const run = <R, E>(
113
115
  ) => {
114
116
  const handler = handlers(definitions, handleResponse)
115
117
  return (headers: Headers, body: string) =>
116
- Effect.flatMap(fromHeadersAndBody(headers, body), interaction =>
117
- Effect.provideService(
118
- handler[interaction.type](interaction),
119
- Interaction,
120
- interaction,
121
- ),
118
+ Effect.flatMap(
119
+ fromHeadersAndBody(headers, body),
120
+ interaction =>
121
+ Effect.provideService(
122
+ handler[interaction.type](interaction),
123
+ Interaction,
124
+ interaction,
125
+ ),
122
126
  )
123
127
  }
124
128
 
@@ -134,14 +138,14 @@ export interface HandleWebhookOpts<E> {
134
138
  */
135
139
  export const makeHandler = <R, E, TE>(
136
140
  ix: InteractionBuilder<R, E, TE>,
137
- ): (({
141
+ ): ({
138
142
  body,
139
143
  error,
140
144
  headers,
141
145
  success,
142
146
  }: HandleWebhookOpts<
143
147
  E | WebhookParseError | BadWebhookSignature | DefinitionNotFound
144
- >) => Effect.Effect<WebhookConfig, never, void>) => {
148
+ >) => Effect.Effect<WebhookConfig, never, void> => {
145
149
  const handle = run(
146
150
  Chunk.map(ix.definitions, ([d]) => [d, identity] as any),
147
151
  (_i, r) => Effect.succeed(r),
@@ -166,7 +170,7 @@ export const makeHandler = <R, E, TE>(
166
170
  */
167
171
  export const makeSimpleHandler = <R, E, TE>(
168
172
  ix: InteractionBuilder<R, E, TE>,
169
- ): (({
173
+ ): ({
170
174
  body,
171
175
  headers,
172
176
  }: {
@@ -176,7 +180,7 @@ export const makeSimpleHandler = <R, E, TE>(
176
180
  WebhookConfig,
177
181
  BadWebhookSignature | WebhookParseError | DefinitionNotFound,
178
182
  Discord.InteractionResponse
179
- >) => {
183
+ > => {
180
184
  const handle = run(
181
185
  Chunk.map(ix.definitions, ([d]) => [d, identity] as any),
182
186
  (_i, r) => Effect.succeed(r),
package/src/Log.ts CHANGED
@@ -1,6 +1,6 @@
1
+ import { Tag } from "@effect/data/Context"
1
2
  import * as Effect from "@effect/io/Effect"
2
3
  import * as Layer from "@effect/io/Layer"
3
- import { Tag } from "@effect/data/Context"
4
4
 
5
5
  const make = (debug = false) => ({
6
6
  info: (...args: Array<any>) =>
@@ -10,8 +10,8 @@ const make = (debug = false) => ({
10
10
  debug: (...args: Array<any>) =>
11
11
  debug
12
12
  ? Effect.sync(() => {
13
- console.error("DEBUG", ...args)
14
- })
13
+ console.error("DEBUG", ...args)
14
+ })
15
15
  : Effect.unit,
16
16
  })
17
17
 
package/src/RateLimit.ts CHANGED
@@ -43,7 +43,7 @@ export interface RateLimitStore {
43
43
  export const RateLimitStore = Tag<RateLimitStore>()
44
44
  export const LiveMemoryRateLimitStore = Layer.sync(RateLimitStore, Memory.make)
45
45
 
46
- const makeLimiter = Effect.gen(function* (_) {
46
+ const makeLimiter = Effect.gen(function*(_) {
47
47
  const store = yield* _(RateLimitStore)
48
48
  const log = yield* _(Log)
49
49
 
@@ -64,10 +64,10 @@ const makeLimiter = Effect.gen(function* (_) {
64
64
  windowMs,
65
65
  limit,
66
66
  delay: Duration.toMillis(d),
67
- }),
67
+ })
68
68
  ),
69
69
  Effect.tap(_ =>
70
- Duration.toMillis(_) === 0 ? Effect.unit : Effect.sleep(_),
70
+ Duration.toMillis(_) === 0 ? Effect.unit : Effect.sleep(_)
71
71
  ),
72
72
  Effect.asUnit,
73
73
  )
@@ -77,6 +77,7 @@ const makeLimiter = Effect.gen(function* (_) {
77
77
  })
78
78
 
79
79
  export interface RateLimiter
80
- extends Effect.Effect.Success<typeof makeLimiter> {}
80
+ extends Effect.Effect.Success<typeof makeLimiter>
81
+ {}
81
82
  export const RateLimiter = Tag<RateLimiter>()
82
83
  export const LiveRateLimiter = Layer.effect(RateLimiter, makeLimiter)
package/src/gateway.ts CHANGED
@@ -16,10 +16,10 @@ import * as SendEvent from "dfx/DiscordGateway/Shard/sendEvents"
16
16
  import * as ShardStore from "dfx/DiscordGateway/ShardStore"
17
17
  import { LiveMemoryShardStore } from "dfx/DiscordGateway/ShardStore"
18
18
  import * as WS from "dfx/DiscordGateway/WS"
19
- import type { RateLimiter } from "dfx/RateLimit"
20
- import { LiveMemoryRateLimitStore, LiveRateLimiter } from "dfx/RateLimit"
21
19
  import { InteractionsRegistryLive } from "dfx/gateway"
22
20
  import type { InteractionsRegistry } from "dfx/gateway"
21
+ import type { RateLimiter } from "dfx/RateLimit"
22
+ import { LiveMemoryRateLimitStore, LiveRateLimiter } from "dfx/RateLimit"
23
23
 
24
24
  export { DiscordGateway, LiveDiscordGateway } from "dfx/DiscordGateway"
25
25
 
package/src/index.ts CHANGED
@@ -17,8 +17,8 @@ export {
17
17
  BucketDetails,
18
18
  LiveMemoryRateLimitStore,
19
19
  LiveRateLimiter,
20
- RateLimitStore,
21
20
  RateLimiter,
21
+ RateLimitStore,
22
22
  } from "dfx/RateLimit"
23
23
 
24
24
  export {
package/src/types.ts CHANGED
@@ -1173,7 +1173,8 @@ export function createRoutes<O = any>(
1173
1173
  batchEditApplicationCommandPermissions: (applicationId, guildId, options) =>
1174
1174
  fetch({
1175
1175
  method: "PUT",
1176
- url: `/applications/${applicationId}/guilds/${guildId}/commands/permissions`,
1176
+ url:
1177
+ `/applications/${applicationId}/guilds/${guildId}/commands/permissions`,
1177
1178
  options,
1178
1179
  }),
1179
1180
  beginGuildPrune: (guildId, params, options) =>
@@ -1342,7 +1343,8 @@ export function createRoutes<O = any>(
1342
1343
  createReaction: (channelId, messageId, emoji, options) =>
1343
1344
  fetch({
1344
1345
  method: "PUT",
1345
- url: `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me`,
1346
+ url:
1347
+ `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me`,
1346
1348
  options,
1347
1349
  }),
1348
1350
  createStageInstance: (params, options) =>
@@ -1403,7 +1405,8 @@ export function createRoutes<O = any>(
1403
1405
  ) =>
1404
1406
  fetch({
1405
1407
  method: "DELETE",
1406
- url: `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
1408
+ url:
1409
+ `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
1407
1410
  options,
1408
1411
  }),
1409
1412
  deleteGlobalApplicationCommand: (applicationId, commandId, options) =>
@@ -1426,7 +1429,8 @@ export function createRoutes<O = any>(
1426
1429
  ) =>
1427
1430
  fetch({
1428
1431
  method: "DELETE",
1429
- url: `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
1432
+ url:
1433
+ `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
1430
1434
  options,
1431
1435
  }),
1432
1436
  deleteGuildEmoji: (guildId, emojiId, options) =>
@@ -1484,13 +1488,15 @@ export function createRoutes<O = any>(
1484
1488
  ) =>
1485
1489
  fetch({
1486
1490
  method: "DELETE",
1487
- url: `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
1491
+ url:
1492
+ `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
1488
1493
  options,
1489
1494
  }),
1490
1495
  deleteOwnReaction: (channelId, messageId, emoji, options) =>
1491
1496
  fetch({
1492
1497
  method: "DELETE",
1493
- url: `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me`,
1498
+ url:
1499
+ `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/@me`,
1494
1500
  options,
1495
1501
  }),
1496
1502
  deleteStageInstance: (channelId, options) =>
@@ -1502,7 +1508,8 @@ export function createRoutes<O = any>(
1502
1508
  deleteUserReaction: (channelId, messageId, emoji, userId, options) =>
1503
1509
  fetch({
1504
1510
  method: "DELETE",
1505
- url: `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/${userId}`,
1511
+ url:
1512
+ `/channels/${channelId}/messages/${messageId}/reactions/${emoji}/${userId}`,
1506
1513
  options,
1507
1514
  }),
1508
1515
  deleteWebhook: (webhookId, options) =>
@@ -1539,7 +1546,8 @@ export function createRoutes<O = any>(
1539
1546
  ) =>
1540
1547
  fetch({
1541
1548
  method: "PUT",
1542
- url: `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}/permissions`,
1549
+ url:
1550
+ `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}/permissions`,
1543
1551
  params,
1544
1552
  options,
1545
1553
  }),
@@ -1559,7 +1567,8 @@ export function createRoutes<O = any>(
1559
1567
  ) =>
1560
1568
  fetch({
1561
1569
  method: "PATCH",
1562
- url: `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
1570
+ url:
1571
+ `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
1563
1572
  params,
1564
1573
  options,
1565
1574
  }),
@@ -1579,7 +1588,8 @@ export function createRoutes<O = any>(
1579
1588
  ) =>
1580
1589
  fetch({
1581
1590
  method: "PATCH",
1582
- url: `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
1591
+ url:
1592
+ `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
1583
1593
  params,
1584
1594
  options,
1585
1595
  }),
@@ -1598,7 +1608,8 @@ export function createRoutes<O = any>(
1598
1608
  ) =>
1599
1609
  fetch({
1600
1610
  method: "PATCH",
1601
- url: `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
1611
+ url:
1612
+ `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
1602
1613
  params,
1603
1614
  options,
1604
1615
  }),
@@ -1643,7 +1654,8 @@ export function createRoutes<O = any>(
1643
1654
  ) =>
1644
1655
  fetch({
1645
1656
  method: "GET",
1646
- url: `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}/permissions`,
1657
+ url:
1658
+ `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}/permissions`,
1647
1659
  options,
1648
1660
  }),
1649
1661
  getApplicationRoleConnectionMetadataRecords: (applicationId, options) =>
@@ -1735,7 +1747,8 @@ export function createRoutes<O = any>(
1735
1747
  ) =>
1736
1748
  fetch({
1737
1749
  method: "GET",
1738
- url: `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
1750
+ url:
1751
+ `/webhooks/${applicationId}/${interactionToken}/messages/${messageId}`,
1739
1752
  params,
1740
1753
  options,
1741
1754
  }),
@@ -1774,13 +1787,15 @@ export function createRoutes<O = any>(
1774
1787
  getGuildApplicationCommand: (applicationId, guildId, commandId, options) =>
1775
1788
  fetch({
1776
1789
  method: "GET",
1777
- url: `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
1790
+ url:
1791
+ `/applications/${applicationId}/guilds/${guildId}/commands/${commandId}`,
1778
1792
  options,
1779
1793
  }),
1780
1794
  getGuildApplicationCommandPermissions: (applicationId, guildId, options) =>
1781
1795
  fetch({
1782
1796
  method: "GET",
1783
- url: `/applications/${applicationId}/guilds/${guildId}/commands/permissions`,
1797
+ url:
1798
+ `/applications/${applicationId}/guilds/${guildId}/commands/permissions`,
1784
1799
  options,
1785
1800
  }),
1786
1801
  getGuildApplicationCommands: (applicationId, guildId, params, options) =>
@@ -1880,7 +1895,8 @@ export function createRoutes<O = any>(
1880
1895
  ) =>
1881
1896
  fetch({
1882
1897
  method: "GET",
1883
- url: `/guilds/${guildId}/scheduled-events/${guildScheduledEventId}/users`,
1898
+ url:
1899
+ `/guilds/${guildId}/scheduled-events/${guildScheduledEventId}/users`,
1884
1900
  params,
1885
1901
  options,
1886
1902
  }),
@@ -1960,7 +1976,8 @@ export function createRoutes<O = any>(
1960
1976
  ) =>
1961
1977
  fetch({
1962
1978
  method: "GET",
1963
- url: `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
1979
+ url:
1980
+ `/webhooks/${applicationId}/${interactionToken}/messages/@original`,
1964
1981
  params,
1965
1982
  options,
1966
1983
  }),
@@ -3195,7 +3212,7 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
3195
3212
  guildId: string,
3196
3213
  options?: O,
3197
3214
  ) => RestResponse<GuildOnboarding>
3198
- /** Returns the guild preview object for the given id.
3215
+ /** Returns the guild preview object for the given id.
3199
3216
  If the user is not in the guild, then the guild must be discoverable. */
3200
3217
  getGuildPreview: (guildId: string, options?: O) => RestResponse<GuildPreview>
3201
3218
  /** Returns an object with one pruned key indicating the number of members that would be removed in a prune operation. Requires the KICK_MEMBERS permission. */
@@ -4087,7 +4104,8 @@ export const enum GuildFeature {
4087
4104
  /** guild is able to set role icons */
4088
4105
  ROLE_ICONS = "ROLE_ICONS",
4089
4106
  /** guild has role subscriptions that can be purchased */
4090
- ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE = "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE",
4107
+ ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE =
4108
+ "ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE",
4091
4109
  /** guild has enabled role subscriptions */
4092
4110
  ROLE_SUBSCRIPTIONS_ENABLED = "ROLE_SUBSCRIPTIONS_ENABLED",
4093
4111
  /** guild has enabled ticketed events */
@@ -4470,8 +4488,9 @@ export interface IntegrationApplication {
4470
4488
  /** the bot associated with this application */
4471
4489
  readonly bot?: User
4472
4490
  }
4473
- export type IntegrationCreateEvent = Integration &
4474
- IntegrationCreateEventAdditional
4491
+ export type IntegrationCreateEvent =
4492
+ & Integration
4493
+ & IntegrationCreateEventAdditional
4475
4494
  export interface IntegrationCreateEventAdditional {
4476
4495
  /** ID of the guild */
4477
4496
  readonly guild_id: Snowflake
@@ -4488,8 +4507,9 @@ export const enum IntegrationExpireBehavior {
4488
4507
  REMOVE_ROLE = 0,
4489
4508
  KICK = 1,
4490
4509
  }
4491
- export type IntegrationUpdateEvent = Integration &
4492
- IntegrationUpdateEventAdditional
4510
+ export type IntegrationUpdateEvent =
4511
+ & Integration
4512
+ & IntegrationUpdateEventAdditional
4493
4513
  export interface IntegrationUpdateEventAdditional {
4494
4514
  /** ID of the guild */
4495
4515
  readonly guild_id: Snowflake
@@ -5226,7 +5246,9 @@ export interface ModifyGuildParams {
5226
5246
  /** verification level */
5227
5247
  readonly verification_level?: VerificationLevel | null
5228
5248
  /** default message notification level */
5229
- readonly default_message_notifications?: DefaultMessageNotificationLevel | null
5249
+ readonly default_message_notifications?:
5250
+ | DefaultMessageNotificationLevel
5251
+ | null
5230
5252
  /** explicit content filter level */
5231
5253
  readonly explicit_content_filter?: ExplicitContentFilterLevel | null
5232
5254
  /** id for afk channel */
@@ -5368,7 +5390,8 @@ export const enum OAuth2Scope {
5368
5390
  /** allows your app to update its commands using a Bearer token - client credentials grant only */
5369
5391
  APPLICATIONS_COMMANDS_UPDATE = "applications.commands.update",
5370
5392
  /** allows your app to update permissions for its commands in a guild a user has permissions to */
5371
- APPLICATIONS_COMMANDS_PERMISSIONS_UPDATE = "applications.commands.permissions.update",
5393
+ APPLICATIONS_COMMANDS_PERMISSIONS_UPDATE =
5394
+ "applications.commands.permissions.update",
5372
5395
  /** allows your app to read entitlements for a user's applications */
5373
5396
  APPLICATIONS_ENTITLEMENTS = "applications.entitlements",
5374
5397
  /** allows your app to read and update store data (SKUs, store listings, achievements, etc.) for a user's applications */
@@ -5683,7 +5706,8 @@ export interface ReceiveEvents {
5683
5706
  RESUMED: ResumedEvent
5684
5707
  RECONNECT: ReconnectEvent
5685
5708
  INVALID_SESSION: InvalidSessionEvent
5686
- APPLICATION_COMMAND_PERMISSIONS_UPDATE: ApplicationCommandPermissionsUpdateEvent
5709
+ APPLICATION_COMMAND_PERMISSIONS_UPDATE:
5710
+ ApplicationCommandPermissionsUpdateEvent
5687
5711
  AUTO_MODERATION_RULE_CREATE: AutoModerationRuleCreateEvent
5688
5712
  AUTO_MODERATION_RULE_UPDATE: AutoModerationRuleUpdateEvent
5689
5713
  AUTO_MODERATION_RULE_DELETE: AutoModerationRuleDeleteEvent
@@ -1,10 +1,10 @@
1
- import * as Effect from "@effect/io/Effect"
2
1
  import * as Option from "@effect/data/Option"
3
- import * as Ref from "@effect/io/Ref"
4
- import * as Queue from "@effect/io/Queue"
5
- import * as Hub from "@effect/io/Hub"
6
2
  import * as Deferred from "@effect/io/Deferred"
3
+ import * as Effect from "@effect/io/Effect"
7
4
  import * as Fiber from "@effect/io/Fiber"
5
+ import * as Hub from "@effect/io/Hub"
6
+ import * as Queue from "@effect/io/Queue"
7
+ import * as Ref from "@effect/io/Ref"
8
8
 
9
9
  export const subscribeForEachPar = <R, E, A, X>(
10
10
  self: Hub.Hub<A>,
@@ -18,10 +18,10 @@ export const subscribeForEachPar = <R, E, A, X>(
18
18
  effect(_).pipe(
19
19
  Effect.catchAllCause(_ => Deferred.failCause(deferred, _)),
20
20
  Effect.fork,
21
- ),
21
+ )
22
22
  ),
23
23
  Effect.forever,
24
- ),
24
+ )
25
25
  ),
26
26
  Effect.scoped,
27
27
  )
@@ -49,17 +49,16 @@ export const foreverSwitch = <R, E, A, R1, E1, X>(
49
49
  f(_).pipe(
50
50
  Effect.tapErrorCause(_ => Deferred.failCause(causeDeferred, _)),
51
51
  Effect.fork,
52
- ),
53
- ).pipe(
54
- Effect.flatMap(fiber => Ref.getAndSet(fiberRef, Option.some(fiber))),
55
- Effect.tap(_ =>
56
- Option.match(_, {
57
- onNone: () => Effect.unit,
58
- onSome: fiber => Fiber.interrupt(fiber),
59
- }),
60
- ),
61
- Effect.forever,
62
- )
52
+ )).pipe(
53
+ Effect.flatMap(fiber => Ref.getAndSet(fiberRef, Option.some(fiber))),
54
+ Effect.tap(_ =>
55
+ Option.match(_, {
56
+ onNone: () => Effect.unit,
57
+ onSome: fiber => Fiber.interrupt(fiber),
58
+ })
59
+ ),
60
+ Effect.forever,
61
+ )
63
62
 
64
63
  return Effect.all([run, Deferred.await(causeDeferred)], {
65
64
  concurrency: "unbounded",
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.60.0";
1
+ export const LIB_VERSION = "0.61.0";
package/src/webhooks.ts CHANGED
@@ -15,11 +15,11 @@ import { LiveMemoryRateLimitStore, LiveRateLimiter } from "dfx/RateLimit"
15
15
 
16
16
  export {
17
17
  BadWebhookSignature,
18
- WebhookConfig,
19
- WebhookParseError,
20
18
  makeConfigLayer,
21
19
  makeHandler,
22
20
  makeSimpleHandler,
21
+ WebhookConfig,
22
+ WebhookParseError,
23
23
  } from "dfx/Interactions/webhook"
24
24
 
25
25
  export const MemoryRateLimit = Layer.provide(