dfx 0.59.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.
- package/Cache/driver.d.ts +1 -1
- package/Cache/driver.d.ts.map +1 -1
- package/Cache/memory.js +2 -2
- package/Cache/memory.js.map +1 -1
- package/Cache/memoryTTL.d.ts.map +1 -1
- package/Cache/memoryTTL.js.map +1 -1
- package/Cache/prelude.d.ts.map +1 -1
- package/Cache/prelude.js.map +1 -1
- package/Cache.d.ts +1 -1
- package/Cache.d.ts.map +1 -1
- package/Cache.js +1 -1
- package/Cache.js.map +1 -1
- package/DiscordGateway/DiscordWS.d.ts +5 -5
- package/DiscordGateway/DiscordWS.d.ts.map +1 -1
- package/DiscordGateway/DiscordWS.js +2 -2
- package/DiscordGateway/DiscordWS.js.map +1 -1
- package/DiscordGateway/Shard/heartbeats.js.map +1 -1
- package/DiscordGateway/Shard/utils.d.ts +1 -1
- package/DiscordGateway/Shard/utils.d.ts.map +1 -1
- package/DiscordGateway/Shard/utils.js.map +1 -1
- package/DiscordGateway/Shard.d.ts +8 -8
- package/DiscordGateway/Shard.d.ts.map +1 -1
- package/DiscordGateway/Shard.js +11 -11
- package/DiscordGateway/Shard.js.map +1 -1
- package/DiscordGateway/ShardStore.d.ts +2 -2
- package/DiscordGateway/ShardStore.d.ts.map +1 -1
- package/DiscordGateway/ShardStore.js +2 -2
- package/DiscordGateway/ShardStore.js.map +1 -1
- package/DiscordGateway/Sharder.js.map +1 -1
- package/DiscordGateway/WS.d.ts +4 -4
- package/DiscordGateway/WS.d.ts.map +1 -1
- package/DiscordGateway/WS.js +6 -6
- package/DiscordGateway/WS.js.map +1 -1
- package/DiscordGateway.d.ts.map +1 -1
- package/DiscordGateway.js.map +1 -1
- package/DiscordREST/types.d.ts +1 -1
- package/DiscordREST/types.d.ts.map +1 -1
- package/DiscordREST/utils.d.ts +1 -1
- package/DiscordREST/utils.d.ts.map +1 -1
- package/DiscordREST/utils.js +1 -1
- package/DiscordREST/utils.js.map +1 -1
- package/DiscordREST.d.ts.map +1 -1
- package/DiscordREST.js.map +1 -1
- package/Helpers/flags.d.ts.map +1 -1
- package/Helpers/flags.js.map +1 -1
- package/Helpers/intents.d.ts.map +1 -1
- package/Helpers/intents.js.map +1 -1
- package/Helpers/interactions.d.ts +1 -1
- package/Helpers/interactions.d.ts.map +1 -1
- package/Helpers/interactions.js +2 -2
- package/Helpers/interactions.js.map +1 -1
- package/Helpers/members.d.ts.map +1 -1
- package/Helpers/members.js.map +1 -1
- package/Helpers/permissions.js.map +1 -1
- package/Interactions/builder.d.ts +1 -1
- package/Interactions/builder.d.ts.map +1 -1
- package/Interactions/builder.js.map +1 -1
- package/Interactions/context.d.ts.map +1 -1
- package/Interactions/context.js.map +1 -1
- package/Interactions/definitions.d.ts.map +1 -1
- package/Interactions/definitions.js.map +1 -1
- package/Interactions/gateway.d.ts.map +1 -1
- package/Interactions/gateway.js.map +1 -1
- package/Interactions/handlers.d.ts.map +1 -1
- package/Interactions/handlers.js.map +1 -1
- package/Interactions/index.d.ts +1 -1
- package/Interactions/index.d.ts.map +1 -1
- package/Interactions/index.js.map +1 -1
- package/Interactions/utils.d.ts.map +1 -1
- package/Interactions/utils.js.map +1 -1
- package/Interactions/webhook.d.ts.map +1 -1
- package/Interactions/webhook.js.map +1 -1
- package/LICENSE +21 -0
- package/Log.d.ts +1 -1
- package/Log.d.ts.map +1 -1
- package/Log.js +1 -1
- package/Log.js.map +1 -1
- package/RateLimit.d.ts +2 -2
- package/RateLimit.d.ts.map +1 -1
- package/RateLimit.js.map +1 -1
- package/gateway.d.ts +1 -1
- package/gateway.d.ts.map +1 -1
- package/gateway.js +1 -1
- package/gateway.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.d.ts.map +1 -1
- package/mjs/Cache/memory.mjs +2 -2
- package/mjs/Cache/memory.mjs.map +1 -1
- package/mjs/Cache/memoryTTL.mjs.map +1 -1
- package/mjs/Cache/prelude.mjs.map +1 -1
- package/mjs/Cache.mjs +1 -1
- package/mjs/Cache.mjs.map +1 -1
- package/mjs/DiscordGateway/DiscordWS.mjs +2 -2
- package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
- package/mjs/DiscordGateway/Shard/heartbeats.mjs.map +1 -1
- package/mjs/DiscordGateway/Shard/utils.mjs.map +1 -1
- package/mjs/DiscordGateway/Shard.mjs +11 -11
- package/mjs/DiscordGateway/Shard.mjs.map +1 -1
- package/mjs/DiscordGateway/ShardStore.mjs +2 -2
- package/mjs/DiscordGateway/ShardStore.mjs.map +1 -1
- package/mjs/DiscordGateway/Sharder.mjs.map +1 -1
- package/mjs/DiscordGateway/WS.mjs +5 -5
- package/mjs/DiscordGateway/WS.mjs.map +1 -1
- package/mjs/DiscordGateway.mjs.map +1 -1
- package/mjs/DiscordREST/utils.mjs +1 -1
- package/mjs/DiscordREST/utils.mjs.map +1 -1
- package/mjs/DiscordREST.mjs +1 -1
- package/mjs/DiscordREST.mjs.map +1 -1
- package/mjs/Helpers/flags.mjs.map +1 -1
- package/mjs/Helpers/intents.mjs.map +1 -1
- package/mjs/Helpers/interactions.mjs +2 -2
- package/mjs/Helpers/interactions.mjs.map +1 -1
- package/mjs/Helpers/members.mjs.map +1 -1
- package/mjs/Helpers/permissions.mjs.map +1 -1
- package/mjs/Interactions/builder.mjs.map +1 -1
- package/mjs/Interactions/context.mjs.map +1 -1
- package/mjs/Interactions/definitions.mjs.map +1 -1
- package/mjs/Interactions/gateway.mjs +1 -1
- package/mjs/Interactions/gateway.mjs.map +1 -1
- package/mjs/Interactions/handlers.mjs.map +1 -1
- package/mjs/Interactions/index.mjs.map +1 -1
- package/mjs/Interactions/utils.mjs.map +1 -1
- package/mjs/Interactions/webhook.mjs.map +1 -1
- package/mjs/Log.mjs +1 -1
- package/mjs/Log.mjs.map +1 -1
- package/mjs/RateLimit.mjs.map +1 -1
- package/mjs/gateway.mjs +1 -1
- package/mjs/gateway.mjs.map +1 -1
- package/mjs/index.mjs +1 -1
- package/mjs/index.mjs.map +1 -1
- package/mjs/types.mjs.map +1 -1
- package/mjs/utils/Effect.mjs +4 -4
- package/mjs/utils/Effect.mjs.map +1 -1
- package/mjs/version.mjs +1 -1
- package/mjs/webhooks.mjs +1 -1
- package/mjs/webhooks.mjs.map +1 -1
- package/package.json +32 -26
- package/src/Cache/driver.ts +1 -1
- package/src/Cache/memory.ts +2 -2
- package/src/Cache/memoryTTL.ts +6 -4
- package/src/Cache/prelude.ts +15 -13
- package/src/Cache.ts +3 -3
- package/src/DiscordGateway/DiscordWS.ts +9 -10
- package/src/DiscordGateway/Shard/heartbeats.ts +1 -1
- package/src/DiscordGateway/Shard/utils.ts +10 -12
- package/src/DiscordGateway/Shard.ts +23 -24
- package/src/DiscordGateway/ShardStore.ts +2 -2
- package/src/DiscordGateway/Sharder.ts +7 -7
- package/src/DiscordGateway/WS.ts +10 -10
- package/src/DiscordGateway.ts +8 -9
- package/src/DiscordREST/types.ts +1 -1
- package/src/DiscordREST/utils.ts +5 -3
- package/src/DiscordREST.ts +27 -24
- package/src/Helpers/flags.ts +2 -4
- package/src/Helpers/intents.ts +3 -4
- package/src/Helpers/interactions.ts +53 -56
- package/src/Helpers/members.ts +2 -2
- package/src/Helpers/permissions.ts +2 -2
- package/src/Interactions/builder.ts +21 -19
- package/src/Interactions/context.ts +16 -23
- package/src/Interactions/definitions.ts +27 -34
- package/src/Interactions/gateway.ts +80 -83
- package/src/Interactions/handlers.ts +34 -35
- package/src/Interactions/index.ts +17 -21
- package/src/Interactions/utils.ts +13 -17
- package/src/Interactions/webhook.ts +19 -15
- package/src/Log.ts +3 -3
- package/src/RateLimit.ts +5 -4
- package/src/gateway.ts +2 -2
- package/src/index.ts +1 -1
- package/src/types.ts +50 -26
- package/src/utils/Effect.ts +16 -17
- package/src/version.ts +1 -1
- package/src/webhooks.ts +2 -2
- package/types.d.ts.map +1 -1
- package/types.js.map +1 -1
- package/utils/Effect.d.ts.map +1 -1
- package/utils/Effect.js +4 -4
- package/utils/Effect.js.map +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/webhooks.d.ts +1 -1
- 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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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(
|
|
85
|
-
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
49
|
-
|
|
47
|
+
Effect.flatMap(definition.handle, _ => handleResponse(i, _)),
|
|
48
|
+
)
|
|
50
49
|
: transform(
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
88
|
-
|
|
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(
|
|
90
|
-
|
|
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(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
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
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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 =
|
|
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 =
|
|
4474
|
-
|
|
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 =
|
|
4492
|
-
|
|
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?:
|
|
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 =
|
|
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:
|
|
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
|
package/src/utils/Effect.ts
CHANGED
|
@@ -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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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.
|
|
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(
|