dfx 0.9.4 → 0.9.7
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/README.md +39 -1
- package/dist/DiscordGateway/WS/index.js +2 -2
- package/dist/DiscordGateway/WS/index.js.map +1 -1
- package/dist/Interactions/context.d.ts +3 -3
- package/dist/Interactions/context.d.ts.map +1 -1
- package/dist/Interactions/gateway.d.ts +1 -1
- package/dist/Interactions/gateway.d.ts.map +1 -1
- package/dist/Interactions/gateway.js +1 -1
- package/dist/Interactions/gateway.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/DiscordGateway/WS/index.ts +2 -2
- package/src/Interactions/context.ts +2 -2
- package/src/Interactions/gateway.ts +47 -46
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
1
|
# dfx
|
|
2
2
|
|
|
3
|
-
A Discord library
|
|
3
|
+
A Discord library built on top of @effect/io
|
|
4
|
+
|
|
5
|
+
- Supports both the gateway and webhooks
|
|
6
|
+
- Simple yet powerful abstractions to build Discord bots
|
|
7
|
+
|
|
8
|
+
## Example
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import * as Effect from "@effect/io/Effect"
|
|
12
|
+
import { pipe } from "@fp-ts/data/Function"
|
|
13
|
+
import { Ix, runIxGateway, makeLayer } from "dfx"
|
|
14
|
+
|
|
15
|
+
// Create the dependencies layer
|
|
16
|
+
const Dependencies = makeLayer({
|
|
17
|
+
token: "xxx",
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
// Create hello command that responds with "Hello!"
|
|
21
|
+
const hello = Ix.global(
|
|
22
|
+
{
|
|
23
|
+
name: "hello",
|
|
24
|
+
description: "A basic command",
|
|
25
|
+
},
|
|
26
|
+
Effect.succeedSome({
|
|
27
|
+
type: 4,
|
|
28
|
+
data: {
|
|
29
|
+
content: "Hello!",
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
// Run it
|
|
35
|
+
pipe(
|
|
36
|
+
Ix.builder.add(hello),
|
|
37
|
+
runIxGateway((error) => Effect.fail(error)),
|
|
38
|
+
Effect.providerLayer(Dependencies),
|
|
39
|
+
Effect.unsafeRunPromise,
|
|
40
|
+
)
|
|
41
|
+
```
|
|
@@ -33,13 +33,13 @@ export class WebSocketCloseError {
|
|
|
33
33
|
}
|
|
34
34
|
const recv = (ws) => tsplus_module_3.async((emit) => {
|
|
35
35
|
ws.on("message", (message) => {
|
|
36
|
-
|
|
36
|
+
emit.data(message);
|
|
37
37
|
});
|
|
38
38
|
ws.on("error", (cause) => {
|
|
39
39
|
emit.fail(new WebSocketError(cause));
|
|
40
40
|
});
|
|
41
41
|
ws.on("close", (code, reason) => {
|
|
42
|
-
|
|
42
|
+
emit.fail(new WebSocketCloseError(code, reason.toString("utf8")));
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
export class WebSocketWriteError {
|
|
@@ -1 +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;QAAf,W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 @@
|
|
|
1
|
-
import { Discord, Effect } from "dfx/common";
|
|
1
|
+
import { Discord, Effect, Maybe } from "dfx/common";
|
|
2
2
|
import { InteractionResponse } from "./definitions.js";
|
|
3
3
|
export declare const InteractionContext: import("../common.js").Tag<import("../types.js").Interaction>;
|
|
4
4
|
export declare const ApplicationCommandContext: import("../common.js").Tag<import("../types.js").ApplicationCommandDatum>;
|
|
@@ -22,7 +22,7 @@ export declare class ResolvedDataNotFound {
|
|
|
22
22
|
export declare const getResolved: <A>(name: string, f: (id: Discord.Snowflake, data: Discord.ResolvedDatum) => A | undefined) => import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, ResolvedDataNotFound, A>;
|
|
23
23
|
export declare const focusedOptionValue: import("../common.js").Effect<FocusedOptionContext, never, string>;
|
|
24
24
|
export declare const commandOptionsMap: import("../common.js").Effect<import("../types.js").ApplicationCommandDatum, never, Record<string, string | undefined>>;
|
|
25
|
-
export declare const handleSubCommands: <NER extends Record<string, import("../common.js").Effect<any, any, InteractionResponse
|
|
25
|
+
export declare const handleSubCommands: <NER extends Record<string, import("../common.js").Effect<any, any, import("../common.js").Maybe<InteractionResponse>>>>(commands: NER) => import("../common.js").Effect<import("../types.js").Interaction | import("../types.js").ApplicationCommandDatum | Exclude<[NER[keyof NER]] extends [{
|
|
26
26
|
[EffectTypeId]: {
|
|
27
27
|
_R: (_: never) => infer R;
|
|
28
28
|
};
|
|
@@ -30,7 +30,7 @@ export declare const handleSubCommands: <NER extends Record<string, import("../c
|
|
|
30
30
|
[EffectTypeId]: {
|
|
31
31
|
_E: (_: never) => infer E;
|
|
32
32
|
};
|
|
33
|
-
}] ? E : never, InteractionResponse
|
|
33
|
+
}] ? E : never, import("../common.js").Maybe<InteractionResponse>>;
|
|
34
34
|
export declare const getSubCommand: import("../common.js").Effect<SubCommandContext, never, import("../types.js").ApplicationCommandInteractionDataOption>;
|
|
35
35
|
export declare const subCommandOptionsMap: import("../common.js").Effect<SubCommandContext, never, Record<string, string | undefined>>;
|
|
36
36
|
export declare const modalValues: import("../common.js").Effect<import("../types.js").ModalSubmitDatum, never, Record<string, string | undefined>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/Interactions/context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAKtD,eAAO,MAAM,kBAAkB,+DAA6B,CAAA;AAC5D,eAAO,MAAM,yBAAyB,2EAAyC,CAAA;AAC/E,eAAO,MAAM,uBAAuB,yEAAuC,CAAA;AAC3E,eAAO,MAAM,kBAAkB,oEAAkC,CAAA;AAEjE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,uCAAuC,CAAA;CACxE;AACD,eAAO,MAAM,oBAAoB,kDAA8B,CAAA;AAE/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,uCAAuC,CAAA;CAClE;AACD,eAAO,MAAM,iBAAiB,+CAA2B,CAAA;AAEzD,eAAO,MAAM,UAAU,oIAA4C,CAAA;AAEnE,qBAAa,oBAAoB;IAG7B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,uBAAuB;IAC9C,QAAQ,CAAC,IAAI,EAAE,MAAM;IAHvB,QAAQ,CAAC,IAAI,0BAAyB;gBAE3B,IAAI,EAAE,OAAO,CAAC,uBAAuB,EACrC,IAAI,EAAE,MAAM;CAExB;AAED,eAAO,MAAM,WAAW,YAChB,MAAM,UACJ,QAAQ,SAAS,QAAQ,QAAQ,aAAa,4HAUrD,CAAA;AAEH,eAAO,MAAM,kBAAkB,oEAE9B,CAAA;AAED,eAAO,MAAM,iBAAiB,yHAE7B,CAAA;AAED,eAAO,MAAM,iBAAiB;;gBAOM,KAAK;;;;gBAQe,KAAK;;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/Interactions/context.ts"],"names":[],"mappings":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declare const run: <
|
|
6
|
+
export declare const run: <R2, E, E2>(catchAll: (e: import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError | E) => import("../common.js").Effect<R2, E2, any>, { sync }?: RunOpts) => <R>(ix: InteractionBuilder<R, E>) => import("../common.js").Effect<import("../index.js").DiscordREST | import("../DiscordGateway/index.js").DiscordGateway | R2 | R, import("../Http/index.js").FetchError | import("../Http/index.js").StatusCodeError | import("../Http/index.js").JsonParseError | E2, void>;
|
|
7
7
|
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAG/C,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAG/C,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,GAAG,0NAKK,OAAO,oTAyCtB,CAAA"}
|
|
@@ -4,7 +4,7 @@ import * as tsplus_module_3 from "@fp-ts/data/Option";
|
|
|
4
4
|
import * as tsplus_module_4 from "dfx/common-gateway";
|
|
5
5
|
import { handlers } from "./handlers.js";
|
|
6
6
|
import { splitDefinitions } from "./utils.js";
|
|
7
|
-
export const run = (
|
|
7
|
+
export const run = (catchAll, { sync = true } = {}) => (ix) => (() => {
|
|
8
8
|
const { GlobalApplicationCommand, GuildApplicationCommand } = splitDefinitions(ix.definitions);
|
|
9
9
|
return tsplus_module_1.flatMap(application => {
|
|
10
10
|
const globalSync = tsplus_module_2.Rest.rest.bulkOverwriteGlobalApplicationCommands(application.id, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAM7C,MAAM,CAAC,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/Interactions/gateway.ts"],"names":[],"mappings":";;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAM7C,MAAM,CAAC,MAAM,GAAG,GACd,CACE,QAEwB,EACxB,EAAE,IAAI,GAAG,IAAI,KAAc,EAAE,EAC7B,EAAE,CACJ,CAAI,EAA4B,EAAE,EAAE;IAEhC,MAAM,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,GACzD,gBAAgB,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;mCAE5B,WAAW;QAIjB,MAAM,UAAU,GAAG,gBAAA,IAAI,CAAC,IAAI,CAAC,sCAAsC,CACjE,WAAW,CAAC,EAAE,EACd;YACE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACrE,CACF,CAAA;QAED,MAAM,SAAS,GAAG,uBAAuB,CAAC,MAAM;YAC9C,CAAC,CAAC,gBAAA,OAAO,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC,CAAC,EAAE,EAAE,CAC3C,gBAAA,IAAI,CAAC,IAAI,CAAC,qCAAqC,CAC7C,WAAW,CAAC,EAAE,EACd,CAAC,CAAC,EAAE,EACJ,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAQ,CACrD,CACF;YACH,CAAC,CAAC,sBAAa,CAAA;QAEjB,MAAM,MAAM,GAAG,QAAQ,CAAC,EAAE,CAAC,WAAW,CAAC,CAAA;QAEvC,MAAM,GAAG,GAAG,gBAAA,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC7D,yBAMY,QAAQ,EANpB,oBACO,CAAC,CAAC,EAAE,EAAE,CACT,4CAAqB,CAAC,CAAC,EAAE,EAAE,CACzB,gBAAA,IAAI,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,EADvD,CAAC,CAEA,EAJL,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAKd,CACkB,CACtB,CAAA;iDAEC,IAAI,CAAC,CAAC,CAAC,uBAA8B,SAAS,EAAvC,uBAAW,UAAU,EAArB,GAAG,CAAmB,CAAkB,CAAC,CAAC,CAAC,GAAG;OAhCrD,wBAAwD,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAArE,gBAAA,IAAI,CAAC,IAAI,CAAC,mCAAmC,EAAE,CAAuB;IAiCxE,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * as DiscordWS from "./DiscordGateway/DiscordWS/index.js";
|
|
|
5
5
|
export * as Gateway from "./DiscordGateway/index.js";
|
|
6
6
|
export { DiscordREST, LiveDiscordREST, rest } from "./DiscordREST/index.js";
|
|
7
7
|
export * as Ix from "./Interactions/index.js";
|
|
8
|
-
export { run as
|
|
8
|
+
export { run as runIxGateway } from "./Interactions/gateway.js";
|
|
9
9
|
export * as Log from "./Log/index.js";
|
|
10
10
|
export * as RateLimitStore from "./RateLimitStore/index.js";
|
|
11
11
|
export * as Flags from "./Helpers/flags.js";
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export * as DiscordWS from "./DiscordGateway/DiscordWS/index.js";
|
|
|
7
7
|
export * as Gateway from "./DiscordGateway/index.js";
|
|
8
8
|
export { DiscordREST, LiveDiscordREST, rest } from "./DiscordREST/index.js";
|
|
9
9
|
export * as Ix from "./Interactions/index.js";
|
|
10
|
-
export { run as
|
|
10
|
+
export { run as runIxGateway } from "./Interactions/gateway.js";
|
|
11
11
|
export * as Log from "./Log/index.js";
|
|
12
12
|
export * as RateLimitStore from "./RateLimitStore/index.js";
|
|
13
13
|
export * as Flags from "./Helpers/flags.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dfx",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@fp-ts/data": "^0.0.20",
|
|
28
28
|
"@tim-smart/discord-api-docs-parser": "^0.4.1",
|
|
29
29
|
"@types/ws": "^8.5.3",
|
|
30
|
-
"lerna": "^
|
|
30
|
+
"lerna": "^6.1.0",
|
|
31
31
|
"typescript": "https://cdn.jsdelivr.net/npm/@tsplus/installer/compiler/typescript.tgz"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"@fp-ts/data": "^0.0.20"
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "077dee8878977e0cd33623858efa4314e668f022"
|
|
54
54
|
}
|
|
@@ -29,7 +29,7 @@ const recv = (ws: WebSocket) =>
|
|
|
29
29
|
EffectSource.async<WebSocketError | WebSocketCloseError, WebSocket.RawData>(
|
|
30
30
|
(emit) => {
|
|
31
31
|
ws.on("message", (message) => {
|
|
32
|
-
|
|
32
|
+
emit.data(message)
|
|
33
33
|
})
|
|
34
34
|
|
|
35
35
|
ws.on("error", (cause) => {
|
|
@@ -37,7 +37,7 @@ const recv = (ws: WebSocket) =>
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
ws.on("close", (code, reason) => {
|
|
40
|
-
|
|
40
|
+
emit.fail(new WebSocketCloseError(code, reason.toString("utf8")))
|
|
41
41
|
})
|
|
42
42
|
},
|
|
43
43
|
)
|
|
@@ -51,7 +51,7 @@ export const commandOptionsMap = Effect.serviceWith(ApplicationCommandContext)(
|
|
|
51
51
|
)
|
|
52
52
|
|
|
53
53
|
export const handleSubCommands = <
|
|
54
|
-
NER extends Record<string, Effect<any, any, InteractionResponse
|
|
54
|
+
NER extends Record<string, Effect<any, any, Maybe<InteractionResponse>>>,
|
|
55
55
|
>(
|
|
56
56
|
commands: NER,
|
|
57
57
|
): Effect<
|
|
@@ -68,7 +68,7 @@ export const handleSubCommands = <
|
|
|
68
68
|
[NER[keyof NER]] extends [{ [EffectTypeId]: { _E: (_: never) => infer E } }]
|
|
69
69
|
? E
|
|
70
70
|
: never,
|
|
71
|
-
InteractionResponse
|
|
71
|
+
Maybe<InteractionResponse>
|
|
72
72
|
> =>
|
|
73
73
|
Effect.struct({
|
|
74
74
|
interaction: Effect.service(InteractionContext),
|
|
@@ -6,49 +6,50 @@ export interface RunOpts {
|
|
|
6
6
|
sync?: boolean
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const run =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
9
|
+
export const run =
|
|
10
|
+
<R2, E, E2>(
|
|
11
|
+
catchAll: (
|
|
12
|
+
e: Http.FetchError | Http.StatusCodeError | Http.JsonParseError | E,
|
|
13
|
+
) => Effect<R2, E2, any>,
|
|
14
|
+
{ sync = true }: RunOpts = {},
|
|
15
|
+
) =>
|
|
16
|
+
<R>(ix: InteractionBuilder<R, E>) =>
|
|
17
|
+
Do(($) => {
|
|
18
|
+
const { GlobalApplicationCommand, GuildApplicationCommand } =
|
|
19
|
+
splitDefinitions(ix.definitions)
|
|
20
|
+
|
|
21
|
+
const application = $(
|
|
22
|
+
Rest.rest.getCurrentBotApplicationInformation().flatMap((a) => a.json),
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const globalSync = Rest.rest.bulkOverwriteGlobalApplicationCommands(
|
|
26
|
+
application.id,
|
|
27
|
+
{
|
|
28
|
+
body: JSON.stringify(GlobalApplicationCommand.map((a) => a.command)),
|
|
29
|
+
},
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
const guildSync = GuildApplicationCommand.length
|
|
33
|
+
? Gateway.handleDispatch("GUILD_CREATE", (a) =>
|
|
34
|
+
Rest.rest.bulkOverwriteGuildApplicationCommands(
|
|
35
|
+
application.id,
|
|
36
|
+
a.id,
|
|
37
|
+
GuildApplicationCommand.map((a) => a.command) as any,
|
|
38
|
+
),
|
|
39
|
+
)
|
|
40
|
+
: Effect.unit()
|
|
41
|
+
|
|
42
|
+
const handle = handlers(ix.definitions)
|
|
43
|
+
|
|
44
|
+
const run = Gateway.handleDispatch("INTERACTION_CREATE", (i) =>
|
|
45
|
+
handle[i.type](i)
|
|
46
|
+
.tap((r) =>
|
|
47
|
+
r.match(Effect.unit, (r) =>
|
|
48
|
+
Rest.rest.createInteractionResponse(i.id, i.token, r),
|
|
49
|
+
),
|
|
50
|
+
)
|
|
51
|
+
.catchAll(catchAll),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
$(sync ? run.zipPar(globalSync).zipPar(guildSync) : run)
|
|
55
|
+
})
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * as DiscordWS from "./DiscordGateway/DiscordWS/index.js"
|
|
|
5
5
|
export * as Gateway from "./DiscordGateway/index.js"
|
|
6
6
|
export { DiscordREST, LiveDiscordREST, rest } from "./DiscordREST/index.js"
|
|
7
7
|
export * as Ix from "./Interactions/index.js"
|
|
8
|
-
export { run as
|
|
8
|
+
export { run as runIxGateway } from "./Interactions/gateway.js"
|
|
9
9
|
export * as Log from "./Log/index.js"
|
|
10
10
|
export * as RateLimitStore from "./RateLimitStore/index.js"
|
|
11
11
|
|